@ngrok/mantle 0.73.5 → 0.74.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/accordion.d.ts +1 -1
- package/dist/agent.json +2 -1
- package/dist/alert-dialog.d.ts +6 -6
- package/dist/alert.d.ts +1 -1
- package/dist/alert.js.map +1 -1
- package/dist/anchor-CcTY5SIz.js.map +1 -1
- package/dist/badge.d.ts +1 -1
- package/dist/{button-BYZOBUgj.d.ts → button-BXZ_JTu_.d.ts} +4 -4
- package/dist/button.d.ts +1 -1
- package/dist/calendar.d.ts +1 -1
- package/dist/checkbox.d.ts +1 -1
- package/dist/code-block.d.ts +1 -1
- package/dist/code-block.js.map +1 -1
- package/dist/combobox.d.ts +1 -1
- package/dist/command.d.ts +5 -5
- package/dist/data-table.d.ts +9 -9
- package/dist/data-table.js.map +1 -1
- package/dist/dialog.d.ts +5 -5
- package/dist/{dropdown-menu-BgYk4L8o.d.ts → dropdown-menu-BqdyTFLu.d.ts} +2 -2
- package/dist/dropdown-menu.d.ts +1 -1
- package/dist/empty.d.ts +5 -5
- package/dist/field.js.map +1 -1
- package/dist/flag.d.ts +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/hover-card.d.ts +1 -1
- package/dist/icons.d.ts +6 -6
- package/dist/input.d.ts +3 -3
- package/dist/kbd.d.ts +1 -1
- package/dist/llms.txt +2 -1
- package/dist/main.d.ts +1 -1
- package/dist/multi-select.d.ts +2 -2
- package/dist/multi-select.js.map +1 -1
- package/dist/otp-input.js.map +1 -1
- package/dist/pagination.d.ts +1 -1
- package/dist/{primitive-D_-h74Kt.d.ts → primitive-FoWela9a.d.ts} +2 -2
- package/dist/progress.d.ts +4 -4
- package/dist/qr-code.d.ts +159 -0
- package/dist/qr-code.js +2 -0
- package/dist/qr-code.js.map +1 -0
- package/dist/radio-group.d.ts +3 -3
- package/dist/resolve-pre-rendered-props-C-vrNxH1.js.map +1 -1
- package/dist/separator-Bqjy77rG.js.map +1 -1
- package/dist/separator.d.ts +1 -1
- package/dist/sheet.d.ts +5 -5
- package/dist/skip-to-main-link.d.ts +1 -1
- package/dist/skip-to-main-link.js.map +1 -1
- package/dist/slider.d.ts +1 -1
- package/dist/split-button.d.ts +2 -2
- package/dist/tabs.d.ts +1 -1
- package/dist/theme-provider-MMwxHEfw.js.map +1 -1
- package/dist/theme.d.ts +4 -4
- package/dist/toast.d.ts +1 -1
- package/dist/tooltip.d.ts +3 -3
- package/dist/use-matches-media-query-CMSxHR9n.js.map +1 -1
- package/dist/use-prefers-reduced-motion-CWIoFA6W.js.map +1 -1
- package/package.json +30 -24
package/dist/code-block.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-block.js","names":["Root","RadixTabsRoot","MantleIcon","RadixTabsList","RadixTabsTrigger","RadixTabsContent"],"sources":["../src/components/code-block/escape-html.ts","../src/components/code-block/fold-runtime.ts","../src/components/code-block/code-block.tsx","../src/components/code-block/has-more-than-n-lines.ts"],"sourcesContent":["/**\n * Escapes special HTML characters in a string to their corresponding\n * HTML entities, preventing issues like unintended HTML rendering or\n * cross-site scripting (XSS) when injecting raw strings into the DOM\n * using `dangerouslySetInnerHTML`.\n *\n * Characters escaped:\n * - \\& => `&`;\n * - \\< => `<`;\n * - \\> => `>`;\n * - \\\" => `"`;\n * - \\' => `'`;\n *\n * @param {string} value The raw string to be escaped.\n *\n * @example\n * escapeHtml('<div>Hello & \"world\"</div>');\n * // Returns: '<div>Hello & "world"</div>'\n */\nfunction escapeHtml(value: string): string {\n\tlet firstSpecialCharIndex = -1;\n\tfor (let i = 0; i < value.length; i++) {\n\t\tconst character = value[i];\n\t\tif (\n\t\t\tcharacter === \"&\" ||\n\t\t\tcharacter === \"<\" ||\n\t\t\tcharacter === \">\" ||\n\t\t\tcharacter === '\"' ||\n\t\t\tcharacter === \"'\"\n\t\t) {\n\t\t\tfirstSpecialCharIndex = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (firstSpecialCharIndex === -1) {\n\t\treturn value;\n\t}\n\n\tlet escaped = value.slice(0, firstSpecialCharIndex);\n\tfor (let i = firstSpecialCharIndex; i < value.length; i++) {\n\t\tconst character = value[i];\n\t\tswitch (character) {\n\t\t\tcase \"&\":\n\t\t\t\tescaped += \"&\";\n\t\t\t\tbreak;\n\t\t\tcase \"<\":\n\t\t\t\tescaped += \"<\";\n\t\t\t\tbreak;\n\t\t\tcase \">\":\n\t\t\t\tescaped += \">\";\n\t\t\t\tbreak;\n\t\t\tcase '\"':\n\t\t\t\tescaped += \""\";\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\t\tescaped += \"'\";\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tescaped += character;\n\t\t}\n\t}\n\treturn escaped;\n}\n\nexport {\n\t//,\n\tescapeHtml,\n};\n","/**\n * Runtime fold/unfold behavior for `CodeBlock.Code` lives in this module so it\n * can be unit-tested independently of React. The implementation deliberately\n * keeps all interaction state in the DOM and uses a single delegated event\n * handler per `<pre>` — no per-line listeners, no React re-renders on toggle.\n *\n * Why event delegation: GitHub's diff-line performance work showed that\n * attaching listeners per line scales poorly past ~1000 rows. A single\n * top-level listener with attribute-based dispatch keeps memory overhead\n * constant and avoids React reconciliation entirely.\n *\n * @see https://github.blog/engineering/architecture-optimization/the-uphill-climb-of-making-diff-lines-performant/\n */\n\n/**\n * Cached per-`<code>` fold geometry. Built lazily on first interaction and\n * invalidated by `clearRegionLinesCache` whenever the inner HTML is replaced.\n */\ntype FoldGeometry = {\n\t/** Map from fold-region ID → the line elements that belong to that region. */\n\tregionToLines: Map<string, HTMLElement[]>;\n\t/**\n\t * Per-line cache of parent fold-region IDs as a `Set`. Pre-parsed at\n\t * map-build time so toggles can avoid re-splitting `data-fold-regions`\n\t * on every affected line every click — meaningful when 1000+ lines belong\n\t * to the toggled region.\n\t */\n\tlineToRegions: WeakMap<HTMLElement, Set<string>>;\n};\n\nconst FOLD_GEOMETRY_CACHE = new WeakMap<Element, FoldGeometry>();\n\n/**\n * Splits a space-separated string into a `Set`, dropping empty entries. Used\n * to parse `data-fold-regions` and `data-folded-regions` attribute values.\n */\nfunction parseSpaceSeparated(value: string | null | undefined): Set<string> {\n\tconst set = new Set<string>();\n\tif (value == null || value === \"\") {\n\t\treturn set;\n\t}\n\tfor (const part of value.split(\" \")) {\n\t\tif (part !== \"\") {\n\t\t\tset.add(part);\n\t\t}\n\t}\n\treturn set;\n}\n\n/**\n * Builds (and memoizes per `<code>` element) the {@link FoldGeometry} index.\n * Lazy on first interaction so initial render cost stays at zero.\n *\n * If a cached geometry exists but its first cached line element is no longer\n * connected to the DOM, the cache is treated as stale (typically because\n * something replaced the `<code>`'s `innerHTML` without going through the\n * `clearRegionLinesCache` path) and rebuilt from the current children.\n */\nfunction getFoldGeometry(codeElement: Element): FoldGeometry {\n\tconst cached = FOLD_GEOMETRY_CACHE.get(codeElement);\n\tif (cached != null && isGeometryConnected(cached)) {\n\t\treturn cached;\n\t}\n\tconst regionToLines = new Map<string, HTMLElement[]>();\n\tconst lineToRegions = new WeakMap<HTMLElement, Set<string>>();\n\tconst lineElements = codeElement.querySelectorAll(\"[data-fold-regions]\");\n\tfor (let index = 0; index < lineElements.length; index += 1) {\n\t\tconst lineElement = lineElements[index];\n\t\tif (!(lineElement instanceof HTMLElement)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst regions = parseSpaceSeparated(lineElement.dataset.foldRegions);\n\t\tif (regions.size === 0) {\n\t\t\tcontinue;\n\t\t}\n\t\tlineToRegions.set(lineElement, regions);\n\t\tfor (const region of regions) {\n\t\t\tlet lines = regionToLines.get(region);\n\t\t\tif (lines == null) {\n\t\t\t\tlines = [];\n\t\t\t\tregionToLines.set(region, lines);\n\t\t\t}\n\t\t\tlines.push(lineElement);\n\t\t}\n\t}\n\tconst geometry: FoldGeometry = { regionToLines, lineToRegions };\n\tFOLD_GEOMETRY_CACHE.set(codeElement, geometry);\n\treturn geometry;\n}\n\n/** Resets the per-element cache. Called when the code block re-renders new content. */\nfunction clearRegionLinesCache(codeElement: Element): void {\n\tFOLD_GEOMETRY_CACHE.delete(codeElement);\n}\n\n/** Clears per-code-element runtime state after the code element's HTML is replaced. */\nfunction resetFoldState(codeElement: Element): void {\n\tclearRegionLinesCache(codeElement);\n\tcodeElement.removeAttribute(\"data-folded-regions\");\n}\n\n/**\n * Cheap liveness probe: checks whether the first cached line is still\n * attached to the document. If `innerHTML` was replaced under us, the cached\n * line elements get detached and {@link Element.isConnected} flips to false.\n * Inspecting one entry is enough — they all detach together when the parent's\n * `innerHTML` is reset.\n */\nfunction isGeometryConnected(geometry: FoldGeometry): boolean {\n\tfor (const lines of geometry.regionToLines.values()) {\n\t\tif (lines.length === 0) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst sample = lines[0];\n\t\tif (sample == null) {\n\t\t\tcontinue;\n\t\t}\n\t\treturn sample.isConnected;\n\t}\n\t// Empty geometry — treat as still valid; rebuilding wouldn't add anything.\n\treturn true;\n}\n\n/**\n * Reconciles a single line's hidden state with the currently-folded region\n * set. A line is hidden if any of its parent regions are folded.\n */\nfunction syncLineHidden(\n\tline: HTMLElement,\n\tfoldedRegions: Set<string>,\n\tlineRegions: Set<string>,\n): void {\n\tlet isHidden = false;\n\tfor (const region of lineRegions) {\n\t\tif (foldedRegions.has(region)) {\n\t\t\tisHidden = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (isHidden) {\n\t\tline.dataset.foldHidden = \"true\";\n\t} else {\n\t\tdelete line.dataset.foldHidden;\n\t}\n}\n\n/**\n * Toggles the fold region addressed by `button` and synchronizes only the\n * affected lines. The set of folded regions is persisted on the `<code>`\n * element via `data-folded-regions`, keeping the source of truth in the DOM.\n *\n * Returns `true` if a toggle occurred (button was a valid fold toggle), so\n * callers can avoid follow-up work for unrelated clicks.\n */\nfunction toggleFoldFromButton(button: HTMLButtonElement): boolean {\n\tconst regionId = button.dataset.foldLine;\n\tif (regionId == null || regionId === \"\") {\n\t\treturn false;\n\t}\n\tconst codeElement = button.closest(\"[data-slot='code-block-code']\")?.querySelector(\"code\");\n\tif (codeElement == null) {\n\t\treturn false;\n\t}\n\n\tconst foldedRegions = parseSpaceSeparated(codeElement.getAttribute(\"data-folded-regions\"));\n\tconst isCollapsed = foldedRegions.has(regionId);\n\tconst willCollapse = !isCollapsed;\n\n\tif (willCollapse) {\n\t\tfoldedRegions.add(regionId);\n\t} else {\n\t\tfoldedRegions.delete(regionId);\n\t}\n\n\tif (foldedRegions.size === 0) {\n\t\tcodeElement.removeAttribute(\"data-folded-regions\");\n\t} else {\n\t\tcodeElement.setAttribute(\"data-folded-regions\", [...foldedRegions].join(\" \"));\n\t}\n\n\tbutton.setAttribute(\"aria-expanded\", willCollapse ? \"false\" : \"true\");\n\n\tconst { regionToLines, lineToRegions } = getFoldGeometry(codeElement);\n\tconst lines = regionToLines.get(regionId);\n\tif (lines != null) {\n\t\tfor (const line of lines) {\n\t\t\tconst lineRegions = lineToRegions.get(line);\n\t\t\tif (lineRegions != null) {\n\t\t\t\tsyncLineHidden(line, foldedRegions, lineRegions);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Attaches a single delegated `click` listener to the given `<pre>` element.\n * Returns a teardown function suitable for `useEffect` cleanup.\n *\n * The handler is a no-op when the click does not land on a fold toggle, so it\n * is safe to attach unconditionally (e.g. for non-foldable code blocks).\n */\nfunction attachFoldHandler(preElement: HTMLElement): () => void {\n\tconst handleClick = (event: Event) => {\n\t\tconst target = event.target;\n\t\tif (!(target instanceof Element)) {\n\t\t\treturn;\n\t\t}\n\t\tconst button = target.closest(\".mantle-code-fold-toggle\");\n\t\tif (!(button instanceof HTMLButtonElement)) {\n\t\t\treturn;\n\t\t}\n\t\ttoggleFoldFromButton(button);\n\t};\n\n\tpreElement.addEventListener(\"click\", handleClick);\n\treturn () => {\n\t\tpreElement.removeEventListener(\"click\", handleClick);\n\t};\n}\n\nexport {\n\tattachFoldHandler,\n\tclearRegionLinesCache,\n\tgetFoldGeometry,\n\tresetFoldState,\n\ttoggleFoldFromButton,\n};\n","\"use client\";\n\nimport { CaretDownIcon } from \"@phosphor-icons/react/CaretDown\";\nimport { CheckIcon } from \"@phosphor-icons/react/Check\";\nimport { CopyIcon } from \"@phosphor-icons/react/Copy\";\nimport { FileTextIcon } from \"@phosphor-icons/react/FileText\";\nimport { TerminalIcon } from \"@phosphor-icons/react/Terminal\";\nimport type {\n\tComponentProps,\n\tComponentRef,\n\tDispatch,\n\tHTMLAttributes,\n\tReactNode,\n\tSetStateAction,\n} from \"react\";\nimport {\n\tcreateContext,\n\tforwardRef,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseId,\n\tuseLayoutEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport {\n\tContent as RadixTabsContent,\n\tList as RadixTabsList,\n\tRoot as RadixTabsRoot,\n\tTrigger as RadixTabsTrigger,\n} from \"@radix-ui/react-tabs\";\nimport assert from \"tiny-invariant\";\nimport { useCopyToClipboard } from \"../../hooks/use-copy-to-clipboard.js\";\nimport type { SelfClosingWithAsChild, WithAsChild } from \"../../types/as-child.js\";\nimport { composeRefs } from \"../../utils/compose-refs/compose-refs.js\";\nimport { cx } from \"../../utils/cx/cx.js\";\nimport { Icon as MantleIcon } from \"../icon/icon.js\";\nimport type { SvgAttributes } from \"../icon/types.js\";\nimport { TrafficPolicyFileIcon } from \"../icons/traffic-policy-file.js\";\nimport { IconButton } from \"../button/icon-button.js\";\nimport { Slot } from \"../slot/index.js\";\nimport { escapeHtml } from \"./escape-html.js\";\nimport { attachFoldHandler, resetFoldState } from \"./fold-runtime.js\";\nimport type { Mode } from \"./resolve-pre-rendered-props.js\";\nimport type { MantleCodeBlockValue } from \"./mantle-code.js\";\n\ntype CodeBlockContextType = {\n\tcodeId: string | undefined;\n\tcopyTextRef: { current: string };\n\thasCodeExpander: boolean;\n\tisCodeExpanded: boolean;\n\tregisterCodeId: (id: string) => void;\n\tsetHasCodeExpander: (value: boolean) => void;\n\tsetIsCodeExpanded: Dispatch<SetStateAction<boolean>>;\n\tunregisterCodeId: (id: string) => void;\n};\n\nconst CodeBlockContext = createContext<CodeBlockContextType | null>(null);\n\n/** Returns the nearest `CodeBlock` context, throwing if called outside a `CodeBlock.Root`. */\nfunction useCodeBlockContext(): CodeBlockContextType {\n\tconst context = useContext(CodeBlockContext);\n\tassert(context != null, \"CodeBlock subcomponents must be rendered within a <CodeBlock.Root>.\");\n\treturn context;\n}\n\ntype CodeBlockRootProps = Omit<ComponentProps<\"div\">, \"align\"> &\n\tWithAsChild & {\n\t\t/**\n\t\t * The default active tab value (uncontrolled).\n\t\t * Only relevant when using `CodeBlock.TabList` / `CodeBlock.TabContent`.\n\t\t */\n\t\tdefaultTab?: string;\n\t\t/**\n\t\t * The controlled active tab value.\n\t\t * Only relevant when using `CodeBlock.TabList` / `CodeBlock.TabContent`.\n\t\t */\n\t\tactiveTab?: string;\n\t\t/**\n\t\t * Callback fired when the active tab changes.\n\t\t * Only relevant when using `CodeBlock.TabList` / `CodeBlock.TabContent`.\n\t\t */\n\t\tonActiveTabChange?: (value: string) => void;\n\t};\n\n/**\n * Shiki-powered code blocks with build-time syntax highlighting and zero browser bundle.\n * This is the root component for all CodeBlock components.\n *\n * For tabbed code blocks, pass `defaultTab` (uncontrolled) or `activeTab` / `onActiveTabChange`\n * (controlled) to enable tab switching with `CodeBlock.TabList` and `CodeBlock.TabContent`.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst Root = forwardRef<ComponentRef<\"div\">, CodeBlockRootProps>(\n\t({ asChild = false, className, defaultTab, activeTab, onActiveTabChange, ...props }, ref) => {\n\t\tconst copyTextRef = useRef(\"\");\n\t\tconst [hasCodeExpander, setHasCodeExpander] = useState(false);\n\t\tconst [isCodeExpanded, setIsCodeExpanded] = useState(false);\n\t\tconst [codeId, setCodeId] = useState<string | undefined>(undefined);\n\n\t\tconst registerCodeId = useCallback((id: string) => {\n\t\t\tsetCodeId((old) => {\n\t\t\t\tassert(old == null, \"You can only render a single CodeBlock.Code within a CodeBlock.\");\n\t\t\t\treturn id;\n\t\t\t});\n\t\t}, []);\n\n\t\tconst unregisterCodeId = useCallback((id: string) => {\n\t\t\tsetCodeId((old) => {\n\t\t\t\tassert(old === id, \"You can only render a single CodeBlock.Code within a CodeBlock.\");\n\t\t\t\treturn undefined;\n\t\t\t});\n\t\t}, []);\n\n\t\tconst context: CodeBlockContextType = useMemo(\n\t\t\t() =>\n\t\t\t\t({\n\t\t\t\t\tcodeId,\n\t\t\t\t\tcopyTextRef,\n\t\t\t\t\thasCodeExpander,\n\t\t\t\t\tisCodeExpanded,\n\t\t\t\t\tregisterCodeId,\n\t\t\t\t\tsetHasCodeExpander,\n\t\t\t\t\tsetIsCodeExpanded,\n\t\t\t\t\tunregisterCodeId,\n\t\t\t\t}) as const,\n\t\t\t[codeId, hasCodeExpander, isCodeExpanded, registerCodeId, unregisterCodeId],\n\t\t);\n\n\t\tconst hasTabs = defaultTab != null || activeTab != null;\n\t\tconst Component = asChild ? Slot : \"div\";\n\n\t\tconst tree = (\n\t\t\t<Component\n\t\t\t\tdata-slot=\"code-block\"\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"text-mono w-full overflow-hidden rounded-md border border-gray-300 bg-card font-mono\",\n\t\t\t\t\t\"[&_svg]:shrink-0\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\n\t\treturn (\n\t\t\t<CodeBlockContext.Provider value={context}>\n\t\t\t\t{hasTabs ? (\n\t\t\t\t\t<RadixTabsRoot\n\t\t\t\t\t\tasChild\n\t\t\t\t\t\tdefaultValue={defaultTab}\n\t\t\t\t\t\tvalue={activeTab}\n\t\t\t\t\t\tonValueChange={onActiveTabChange}\n\t\t\t\t\t>\n\t\t\t\t\t\t{tree}\n\t\t\t\t\t</RadixTabsRoot>\n\t\t\t\t) : (\n\t\t\t\t\ttree\n\t\t\t\t)}\n\t\t\t</CodeBlockContext.Provider>\n\t\t);\n\t},\n);\nRoot.displayName = \"CodeBlock\";\n\n/**\n * The body of the `CodeBlock`. This is where `CodeBlock.Code` and\n * the optional `CodeBlock.CopyButton` are rendered.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst Body = forwardRef<ComponentRef<\"div\">, ComponentProps<\"div\"> & WithAsChild>(\n\t({ asChild = false, className, ...props }, ref) => {\n\t\tconst Component = asChild ? Slot : \"div\";\n\t\treturn (\n\t\t\t<Component\n\t\t\t\tdata-slot=\"code-block-body\"\n\t\t\t\tclassName={cx(\"relative\", className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t},\n);\nBody.displayName = \"CodeBlockBody\";\n\n/**\n * Matches `SHIKI_VAL_<index>` placeholders injected by the Vite plugin for\n * interpolated template expressions. Hoisted to module scope to avoid\n * re-creating the regex on every substitution call.\n */\nconst LEGACY_SHIKI_VAL_PATTERN = /SHIKI_VAL_(\\d+)/g;\n\n/** Escapes special characters in a string for use in a `RegExp` constructor. */\nfunction escapeForRegExp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nconst maxPreValPatternCacheSize = 500;\nconst preValPatternCache = new Map<string, RegExp>();\n\n/**\n * Returns the cached `RegExp` for the given `preValToken`, falling back to the\n * legacy `SHIKI_VAL_<n>` pattern when no token is provided.\n */\nfunction getTemplateValPattern(preValToken: string | undefined): RegExp {\n\tif (preValToken == null || preValToken.length === 0) {\n\t\treturn LEGACY_SHIKI_VAL_PATTERN;\n\t}\n\n\tlet cached = preValPatternCache.get(preValToken);\n\tif (cached == null) {\n\t\tif (preValPatternCache.size >= maxPreValPatternCacheSize) {\n\t\t\tpreValPatternCache.clear();\n\t\t}\n\t\tcached = new RegExp(`${escapeForRegExp(preValToken)}(\\\\d+)__`, \"g\");\n\t\tpreValPatternCache.set(preValToken, cached);\n\t}\n\treturn cached;\n}\n\n/**\n * Replaces placeholder tokens in `input` with values from `vals`, applying\n * `mapValue` to each substituted value. Returns the input unchanged when\n * no placeholders are present.\n */\nfunction substituteTemplateVals(\n\tinput: string,\n\tvals: unknown[],\n\tpreValToken: string | undefined,\n\tmapValue: (value: unknown) => string,\n): string {\n\tif (preValToken == null) {\n\t\tif (!input.includes(\"SHIKI_VAL_\")) {\n\t\t\treturn input;\n\t\t}\n\t} else if (!input.includes(preValToken)) {\n\t\treturn input;\n\t}\n\n\treturn input.replaceAll(getTemplateValPattern(preValToken), (match, indexText: string) => {\n\t\tconst index = Number.parseInt(indexText, 10);\n\t\tif (Number.isNaN(index) || index < 0 || index >= vals.length) {\n\t\t\treturn match;\n\t\t}\n\t\treturn mapValue(vals[index]);\n\t});\n}\n\n/** Substitutes placeholder tokens in pre-rendered HTML, HTML-escaping each interpolated value. */\nfunction substitutePreVals(html: string, vals: unknown[], preValToken: string | undefined): string {\n\treturn substituteTemplateVals(html, vals, preValToken, (value) => escapeHtml(String(value)));\n}\n\n/** Substitutes placeholder tokens in plain text (for the copy button), without HTML escaping. */\nfunction substitutePreValsPlainText(\n\ttext: string,\n\tvals: unknown[],\n\tpreValToken: string | undefined,\n): string {\n\treturn substituteTemplateVals(text, vals, preValToken, (value) => String(value));\n}\n\ntype CodeBlockCodeProps = Omit<ComponentProps<\"pre\">, \"children\"> & {\n\t/**\n\t * The code value produced by `mantleCode(\"lang\")` tagged template.\n\t * Contains pre-rendered Shiki HTML (when the Vite plugin is active) and\n\t * the original code string for the copy button.\n\t */\n\tvalue: MantleCodeBlockValue;\n};\n\n/**\n * The `CodeBlock` content. Renders pre-highlighted code from `mantleCode()`.\n *\n * `value[\"~preHtml\"]` must be provided by Mantle's Vite plugin or server highlighter.\n * Runtime highlighting and runtime line decoration are intentionally unsupported.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst Code = forwardRef<ComponentRef<\"pre\">, CodeBlockCodeProps>(\n\t({ className, style, value, ...props }, ref) => {\n\t\tconst id = useId();\n\t\tconst preRef = useRef<HTMLPreElement>(null);\n\t\tconst { copyTextRef, hasCodeExpander, isCodeExpanded, registerCodeId, unregisterCodeId } =\n\t\t\tuseCodeBlockContext();\n\t\tconst {\n\t\t\tlanguage,\n\t\t\tcode,\n\t\t\t\"~preValToken\": __preValToken,\n\t\t\t\"~preVals\": __preVals,\n\t\t\t\"~highlightLines\": __highlightLines,\n\t\t\t\"~lineNumberStart\": __lineNumberStart,\n\t\t\t\"~preHtml\": __preHtml,\n\t\t\t\"~showLineNumbers\": __showLineNumbers,\n\t\t} = value;\n\n\t\tconst effectiveHighlightLines = __highlightLines;\n\t\tconst effectiveLineNumberStart = __lineNumberStart ?? 1;\n\t\tconst effectiveShowLineNumbers = __showLineNumbers ?? false;\n\t\tconst copyText = useMemo(\n\t\t\t() =>\n\t\t\t\t__preVals != null && __preVals.length > 0\n\t\t\t\t\t? substitutePreValsPlainText(code, __preVals, __preValToken)\n\t\t\t\t\t: code,\n\t\t\t[__preValToken, __preVals, code],\n\t\t);\n\n\t\tuseLayoutEffect(() => {\n\t\t\tcopyTextRef.current = copyText;\n\t\t}, [copyTextRef, copyText]);\n\n\t\tuseEffect(() => {\n\t\t\tregisterCodeId(id);\n\n\t\t\treturn () => {\n\t\t\t\tunregisterCodeId(id);\n\t\t\t};\n\t\t}, [id, registerCodeId, unregisterCodeId]);\n\n\t\tconst renderedHtml = useMemo(() => {\n\t\t\tif (__preHtml == null) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn __preVals != null && __preVals.length > 0\n\t\t\t\t? substitutePreVals(__preHtml, __preVals, __preValToken)\n\t\t\t\t: __preHtml;\n\t\t}, [__preHtml, __preValToken, __preVals]);\n\n\t\t// Attach a single delegated click handler per <pre> so fold toggles do\n\t\t// not pay the cost of N React re-renders or N event handlers — see the\n\t\t// performance rationale in `fold-runtime.ts`. Re-attaches when the\n\t\t// rendered HTML changes since `<code>` gets a new dangerouslySetInnerHTML.\n\t\tuseEffect(() => {\n\t\t\tconst pre = preRef.current;\n\t\t\tif (pre == null) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst codeElement = pre.querySelector(\"code\");\n\t\t\tif (codeElement != null) {\n\t\t\t\tresetFoldState(codeElement);\n\t\t\t}\n\t\t\treturn attachFoldHandler(pre);\n\t\t}, [renderedHtml]);\n\n\t\tconst isPreRendered = renderedHtml != null;\n\t\tconst displayHtml = renderedHtml ?? escapeHtml(copyText);\n\n\t\t// React diffs `dangerouslySetInnerHTML` by prop reference; a fresh\n\t\t// `{ __html }` literal each render re-applies `innerHTML`, wiping any\n\t\t// runtime-managed DOM state on the children (e.g. fold attributes).\n\t\tconst innerHtmlProp = useMemo(() => ({ __html: displayHtml }), [displayHtml]);\n\n\t\treturn (\n\t\t\t<pre\n\t\t\t\tdata-slot=\"code-block-code\"\n\t\t\t\taria-expanded={hasCodeExpander ? isCodeExpanded : undefined}\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"scrollbar overflow-x-auto overflow-y-hidden py-4\",\n\t\t\t\t\t!isPreRendered && \"pr-14\",\n\t\t\t\t\t\"data-[mantle-line-numbers~='false']:pl-4\",\n\t\t\t\t\t\"text-mono m-0 font-mono outline-hidden\",\n\t\t\t\t\t\"aria-collapsed:max-h-[13.6rem]\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tdata-highlighted={isPreRendered ? \"true\" : \"false\"}\n\t\t\t\tdata-lang={language}\n\t\t\t\tdata-mantle-highlight-lines={\n\t\t\t\t\tisPreRendered && effectiveHighlightLines != null && effectiveHighlightLines.length > 0\n\t\t\t\t\t\t? effectiveHighlightLines.join(\",\")\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tdata-mantle-line-number-start={\n\t\t\t\t\tisPreRendered && effectiveShowLineNumbers ? String(effectiveLineNumberStart) : \"1\"\n\t\t\t\t}\n\t\t\t\tdata-mantle-line-numbers={isPreRendered && effectiveShowLineNumbers ? \"true\" : \"false\"}\n\t\t\t\tid={id}\n\t\t\t\tref={composeRefs(preRef, ref)}\n\t\t\t\tstyle={\n\t\t\t\t\t{\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\"--mantle-line-number-start\": String(effectiveLineNumberStart),\n\t\t\t\t\t\ttabSize: 2,\n\t\t\t\t\t\tMozTabSize: 2,\n\t\t\t\t\t} as ComponentProps<\"pre\">[\"style\"]\n\t\t\t\t}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<code\n\t\t\t\t\tclassName=\"text-size-inherit block min-w-full w-max\"\n\t\t\t\t\tdangerouslySetInnerHTML={innerHtmlProp}\n\t\t\t\t/>\n\t\t\t</pre>\n\t\t);\n\t},\n);\nCode.displayName = \"CodeBlockCode\";\n\n/**\n * The (optional) header slot of the `CodeBlock`. This is where\n * `CodeBlock.Icon` and `CodeBlock.Title` are rendered.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst Header = forwardRef<ComponentRef<\"div\">, ComponentProps<\"div\"> & WithAsChild>(\n\t({ asChild = false, className, ...props }, ref) => {\n\t\tconst Component = asChild ? Slot : \"div\";\n\t\treturn (\n\t\t\t<Component\n\t\t\t\tdata-slot=\"code-block-header\"\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"flex items-center gap-1 border-b border-gray-300 bg-base px-4 py-2 text-gray-700\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t},\n);\nHeader.displayName = \"CodeBlockHeader\";\n\n/**\n * The (optional) title of the `CodeBlock`. Renders as `h3` by default;\n * use `asChild` to render a different element.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst Title = forwardRef<\n\tHTMLHeadingElement,\n\tHTMLAttributes<HTMLHeadingElement> & { asChild?: boolean }\n>(({ asChild = false, className, ...props }, ref) => {\n\tconst Component = asChild ? Slot : \"h3\";\n\treturn (\n\t\t<Component\n\t\t\tdata-slot=\"code-block-title\"\n\t\t\tref={ref}\n\t\t\tclassName={cx(\"text-mono m-0 font-mono font-normal\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n});\nTitle.displayName = \"CodeBlockTitle\";\n\ntype CodeBlockCopyButtonProps = Omit<ComponentProps<\"button\">, \"children\" | \"type\"> &\n\tSelfClosingWithAsChild & {\n\t\t/**\n\t\t * The accessible label for the copy button. This label will be visually hidden but announced to screen reader users, similar to alt text for img tags.\n\t\t *\n\t\t * @default \"Copy code\"\n\t\t */\n\t\tlabel?: string;\n\t\t/**\n\t\t * Callback fired when the copy button is clicked, passes the copied text as an argument.\n\t\t */\n\t\tonCopy?: (value: string) => void;\n\t\t/**\n\t\t * Callback fired when an error occurs during copying.\n\t\t */\n\t\tonCopyError?: (error: unknown) => void;\n\t};\n\n/**\n * The (optional) copy button of the `CodeBlock`. Copies the code content\n * to the clipboard when clicked.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst CopyButton = forwardRef<ComponentRef<\"button\">, CodeBlockCopyButtonProps>(\n\t({ className, label = \"Copy code\", onCopy, onCopyError, onClick, ...props }, ref) => {\n\t\tconst { copyTextRef } = useCodeBlockContext();\n\t\tconst copyToClipboard = useCopyToClipboard();\n\t\tconst [wasCopied, setWasCopied] = useState(false);\n\t\tconst timeoutHandle = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tif (timeoutHandle.current != null) {\n\t\t\t\t\tclearTimeout(timeoutHandle.current);\n\t\t\t\t}\n\t\t\t};\n\t\t}, []);\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"code-block-copy-button\"\n\t\t\t\tclassName=\"absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-[var(--icon-button-border-radius,0.375rem)] bg-card\"\n\t\t\t>\n\t\t\t\t<IconButton\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tappearance=\"ghost\"\n\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\tlabel={label}\n\t\t\t\t\ticon={wasCopied ? <CheckIcon /> : <CopyIcon />}\n\t\t\t\t\tclassName={className}\n\t\t\t\t\tref={ref}\n\t\t\t\t\tonClick={async (event) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tonClick?.(event);\n\t\t\t\t\t\t\tif (event.defaultPrevented) {\n\t\t\t\t\t\t\t\tif (timeoutHandle.current != null) {\n\t\t\t\t\t\t\t\t\tclearTimeout(timeoutHandle.current);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst text = copyTextRef.current;\n\t\t\t\t\t\t\tawait copyToClipboard(text);\n\t\t\t\t\t\t\tonCopy?.(text);\n\t\t\t\t\t\t\tsetWasCopied(true);\n\t\t\t\t\t\t\tif (timeoutHandle.current != null) {\n\t\t\t\t\t\t\t\tclearTimeout(timeoutHandle.current);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimeoutHandle.current = setTimeout(() => {\n\t\t\t\t\t\t\t\tsetWasCopied(false);\n\t\t\t\t\t\t\t}, 2000);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tonCopyError?.(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t\t{...props}\n\t\t\t\t/>\n\t\t\t</span>\n\t\t);\n\t},\n);\nCopyButton.displayName = \"CodeBlockCopyButton\";\n\ntype CodeBlockExpanderButtonProps = Omit<\n\tComponentProps<\"button\">,\n\t\"children\" | \"aria-controls\" | \"aria-expanded\"\n> &\n\tWithAsChild;\n\n/**\n * The (optional) expander button of the `CodeBlock`. Toggles the expanded\n * state of the code block. When present, the code block is collapsible.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst ExpanderButton = forwardRef<ComponentRef<\"button\">, CodeBlockExpanderButtonProps>(\n\t({ asChild = false, className, onClick, ...props }, ref) => {\n\t\tconst { codeId, isCodeExpanded, setIsCodeExpanded, setHasCodeExpander } = useCodeBlockContext();\n\n\t\tuseEffect(() => {\n\t\t\tsetHasCodeExpander(true);\n\t\t\treturn () => {\n\t\t\t\tsetHasCodeExpander(false);\n\t\t\t};\n\t\t}, [setHasCodeExpander]);\n\n\t\tconst Component = asChild ? Slot : \"button\";\n\n\t\treturn (\n\t\t\t<Component\n\t\t\t\t{...props}\n\t\t\t\tdata-slot=\"code-block-expander-button\"\n\t\t\t\taria-controls={codeId}\n\t\t\t\taria-expanded={isCodeExpanded}\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"flex w-full items-center justify-center gap-0.5 border-t border-gray-300 bg-card px-4 py-2 font-sans text-gray-700 hover:bg-gray-100\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={(event) => {\n\t\t\t\t\tsetIsCodeExpanded((prev) => !prev);\n\t\t\t\t\tonClick?.(event);\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{isCodeExpanded ? \"Show less\" : \"Show more\"}{\" \"}\n\t\t\t\t<MantleIcon\n\t\t\t\t\tsvg={<CaretDownIcon weight=\"bold\" />}\n\t\t\t\t\tclassName={cx(\"size-4\", isCodeExpanded && \"rotate-180\", \"transition-all duration-150\")}\n\t\t\t\t/>\n\t\t\t</Component>\n\t\t);\n\t},\n);\nExpanderButton.displayName = \"CodeBlockExpanderButton\";\n\ntype CodeBlockIconProps = Omit<SvgAttributes, \"children\"> &\n\t(\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * A custom icon SVG to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tsvg: ReactNode;\n\t\t\t\t/**\n\t\t\t\t * A preset icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tpreset?: undefined | never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * A custom icon SVG to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tsvg?: undefined | never;\n\t\t\t\t/**\n\t\t\t\t * A preset icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tpreset: Mode;\n\t\t }\n\t);\n\n/**\n * A small icon for the `CodeBlock` header. Pass either a custom `svg`\n * or a `preset` value (not both).\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nfunction CodeBlockIconComponent({\n\tclassName,\n\tpreset,\n\tsvg: _svgProp,\n\t...props\n}: CodeBlockIconProps) {\n\tlet svg = _svgProp;\n\tif (preset != null) {\n\t\tswitch (preset) {\n\t\t\tcase \"file\":\n\t\t\t\tsvg = <FileTextIcon weight=\"fill\" />;\n\t\t\t\tbreak;\n\t\t\tcase \"cli\":\n\t\t\t\tsvg = <TerminalIcon weight=\"fill\" />;\n\t\t\t\tbreak;\n\t\t\tcase \"traffic-policy\":\n\t\t\t\tsvg = <TrafficPolicyFileIcon />;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn <MantleIcon data-slot=\"code-block-icon\" className={className} svg={svg} {...props} />;\n}\nCodeBlockIconComponent.displayName = \"CodeBlockIcon\";\n\ntype CodeBlockTabListProps = Omit<ComponentProps<typeof RadixTabsList>, \"asChild\" | \"loop\">;\n\n/**\n * A tab list for the `CodeBlock` header. Renders pill-styled tab triggers\n * that switch which code is displayed. Built on Radix Tabs primitives.\n *\n * Place this inside `CodeBlock.Header` and pair with `CodeBlock.TabContent`\n * in `CodeBlock.Body` to conditionally render code based on the active tab.\n * Tab state is managed by `CodeBlock.Root` via `defaultTab` / `activeTab` / `onActiveTabChange`.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root defaultTab=\"yml\">\n * <CodeBlock.Header>\n * <CodeBlock.TabList>\n * <CodeBlock.TabTrigger value=\"yml\">policy.yml</CodeBlock.TabTrigger>\n * <CodeBlock.TabTrigger value=\"json\">policy.json</CodeBlock.TabTrigger>\n * </CodeBlock.TabList>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.TabContent value=\"yml\">\n * <CodeBlock.Code value={ymlValue} />\n * </CodeBlock.TabContent>\n * <CodeBlock.TabContent value=\"json\">\n * <CodeBlock.Code value={jsonValue} />\n * </CodeBlock.TabContent>\n * </CodeBlock.Body>\n * </CodeBlock.Root>\n * ```\n */\nconst TabList = forwardRef<ComponentRef<typeof RadixTabsList>, CodeBlockTabListProps>(\n\t({ className, ...props }, ref) => (\n\t\t<RadixTabsList\n\t\t\tdata-slot=\"code-block-tab-list\"\n\t\t\tclassName={cx(\"flex items-center gap-1\", className)}\n\t\t\tref={ref}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nTabList.displayName = \"CodeBlockTabList\";\n\ntype CodeBlockTabTriggerProps = Omit<ComponentProps<typeof RadixTabsTrigger>, \"asChild\">;\n\n/**\n * A pill-styled tab trigger for the `CodeBlock` header.\n * Must be rendered within a `CodeBlock.TabList`.\n *\n * @example\n * ```tsx\n * <CodeBlock.TabList>\n * <CodeBlock.TabTrigger value=\"yml\">policy.yml</CodeBlock.TabTrigger>\n * <CodeBlock.TabTrigger value=\"json\">policy.json</CodeBlock.TabTrigger>\n * </CodeBlock.TabList>\n * ```\n */\nconst TabTrigger = forwardRef<ComponentRef<typeof RadixTabsTrigger>, CodeBlockTabTriggerProps>(\n\t({ className, ...props }, ref) => (\n\t\t<RadixTabsTrigger\n\t\t\tdata-slot=\"code-block-tab-trigger\"\n\t\t\tclassName={cx(\n\t\t\t\t\"cursor-pointer rounded px-1.5 py-0.5 text-xs font-medium\",\n\t\t\t\t\"text-gray-600 outline-hidden\",\n\t\t\t\t\"hover:text-gray-900\",\n\t\t\t\t\"data-[state=active]:bg-neutral-500/15 data-[state=active]:text-strong\",\n\t\t\t\t\"focus-visible:ring-focus-accent focus-visible:ring-4\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tref={ref}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nTabTrigger.displayName = \"CodeBlockTabTrigger\";\n\ntype CodeBlockTabContentProps = Omit<\n\tComponentProps<typeof RadixTabsContent>,\n\t\"asChild\" | \"forceMount\"\n>;\n\n/**\n * Conditionally renders its children when the associated tab is active.\n * Pair with `CodeBlock.TabList` and `CodeBlock.TabTrigger` in the header,\n * and set `defaultTab` / `activeTab` on `CodeBlock.Root`.\n *\n * @example\n * ```tsx\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.TabContent value=\"yml\">\n * <CodeBlock.Code value={ymlValue} />\n * </CodeBlock.TabContent>\n * <CodeBlock.TabContent value=\"json\">\n * <CodeBlock.Code value={jsonValue} />\n * </CodeBlock.TabContent>\n * </CodeBlock.Body>\n * ```\n */\nconst TabContent = forwardRef<ComponentRef<typeof RadixTabsContent>, CodeBlockTabContentProps>(\n\t(props, ref) => <RadixTabsContent data-slot=\"code-block-tab-content\" ref={ref} {...props} />,\n);\nTabContent.displayName = \"CodeBlockTabContent\";\n\n/**\n * Shiki-powered code blocks with build-time syntax highlighting and zero browser bundle.\n *\n * Use `mantleCodeBlockPlugins()` to enable pre-rendering at build time.\n *\n * @example\n * Composition:\n * ```\n * # Standard\n * CodeBlock.Root\n * ├── CodeBlock.Header\n * │ ├── CodeBlock.Icon\n * │ └── CodeBlock.Title\n * ├── CodeBlock.Body\n * │ ├── CodeBlock.CopyButton\n * │ └── CodeBlock.Code\n * └── CodeBlock.ExpanderButton\n *\n * # Tabbed\n * CodeBlock.Root\n * ├── CodeBlock.Header\n * │ └── CodeBlock.TabList\n * │ └── CodeBlock.TabTrigger\n * ├── CodeBlock.Body\n * │ ├── CodeBlock.CopyButton\n * │ └── CodeBlock.TabContent\n * │ └── CodeBlock.Code\n * └── CodeBlock.ExpanderButton\n * ```\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n *\n * // Server-highlighted HTML fetched via an action route + React Query mutation\n * const highlightMutation = useMutation({\n * mutationFn: async () => {\n * const response = await fetch(\"/api/shiki-highlight\", {\n * method: \"POST\",\n * headers: { \"Content-Type\": \"application/json\" },\n * body: JSON.stringify({ code: source, language: \"typescript\" }),\n * });\n * return response.json();\n * },\n * });\n *\n * const serverValue = createMantleCodeBlockValue({\n * language: \"typescript\",\n * code: source,\n * preHtml: highlightMutation.data?.html,\n * });\n * ```\n */\nconst CodeBlock = {\n\t/**\n\t * The root component of the `CodeBlock`.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tRoot,\n\t/**\n\t * The body of the `CodeBlock`. Contains `Code` and optional `CopyButton`.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tBody,\n\t/**\n\t * The code content. Renders pre-highlighted Shiki HTML when the Vite plugin is active.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tCode,\n\t/**\n\t * The optional copy button.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tCopyButton,\n\t/**\n\t * The optional expander button for collapsible code blocks.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tExpanderButton,\n\t/**\n\t * The optional header slot for icon and title.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tHeader,\n\t/**\n\t * A small icon for the code block header. Use `preset` or `svg`.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tIcon: CodeBlockIconComponent,\n\t/**\n\t * Conditionally renders children when the associated tab is active.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root defaultTab=\"yml\">\n\t * <CodeBlock.Header>\n\t * <CodeBlock.TabList>\n\t * <CodeBlock.TabTrigger value=\"yml\">policy.yml</CodeBlock.TabTrigger>\n\t * <CodeBlock.TabTrigger value=\"json\">policy.json</CodeBlock.TabTrigger>\n\t * </CodeBlock.TabList>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.TabContent value=\"yml\">\n\t * <CodeBlock.Code value={ymlValue} />\n\t * </CodeBlock.TabContent>\n\t * <CodeBlock.TabContent value=\"json\">\n\t * <CodeBlock.Code value={jsonValue} />\n\t * </CodeBlock.TabContent>\n\t * </CodeBlock.Body>\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tTabContent,\n\t/**\n\t * A tab list for the code block header. Renders pill-styled tabs for switching code.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root defaultTab=\"yml\">\n\t * <CodeBlock.Header>\n\t * <CodeBlock.TabList>\n\t * <CodeBlock.TabTrigger value=\"yml\">policy.yml</CodeBlock.TabTrigger>\n\t * <CodeBlock.TabTrigger value=\"json\">policy.json</CodeBlock.TabTrigger>\n\t * </CodeBlock.TabList>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.TabContent value=\"yml\">\n\t * <CodeBlock.Code value={ymlValue} />\n\t * </CodeBlock.TabContent>\n\t * <CodeBlock.TabContent value=\"json\">\n\t * <CodeBlock.Code value={jsonValue} />\n\t * </CodeBlock.TabContent>\n\t * </CodeBlock.Body>\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tTabList,\n\t/**\n\t * A pill-styled tab trigger for the code block header. Must be inside `TabList`.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root defaultTab=\"yml\">\n\t * <CodeBlock.Header>\n\t * <CodeBlock.TabList>\n\t * <CodeBlock.TabTrigger value=\"yml\">policy.yml</CodeBlock.TabTrigger>\n\t * <CodeBlock.TabTrigger value=\"json\">policy.json</CodeBlock.TabTrigger>\n\t * </CodeBlock.TabList>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.TabContent value=\"yml\">\n\t * <CodeBlock.Code value={ymlValue} />\n\t * </CodeBlock.TabContent>\n\t * <CodeBlock.TabContent value=\"json\">\n\t * <CodeBlock.Code value={jsonValue} />\n\t * </CodeBlock.TabContent>\n\t * </CodeBlock.Body>\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tTabTrigger,\n\t/**\n\t * The optional title rendered in the header.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tTitle,\n} as const;\n\nexport {\n\t//,\n\tCodeBlock,\n};\n","/**\n * Returns `true` if `value` has more than `maxLines` newline-delimited lines.\n *\n * This is equivalent to `value.split(\"\\\\n\").length > maxLines`, but avoids\n * allocating an intermediate array and can early-return once the threshold is exceeded.\n */\nfunction hasMoreThanNLines(value: string, maxLines: number): boolean {\n\tlet lines = 1;\n\tif (lines > maxLines) {\n\t\treturn true;\n\t}\n\n\tfor (let i = 0; i < value.length; i++) {\n\t\tif (value[i] === \"\\n\") {\n\t\t\tlines += 1;\n\t\t\tif (lines > maxLines) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\nexport {\n\t//,\n\thasMoreThanNLines,\n};\n"],"mappings":"goCAmBA,SAAS,EAAW,EAAuB,CAC1C,IAAI,EAAwB,GAC5B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAAK,CACtC,IAAM,EAAY,EAAM,GACxB,GACC,IAAc,KACd,IAAc,KACd,IAAc,KACd,IAAc,KACd,IAAc,IACb,CACD,EAAwB,EACxB,KACD,CACD,CAEA,GAAI,IAA0B,GAC7B,OAAO,EAGR,IAAI,EAAU,EAAM,MAAM,EAAG,CAAqB,EAClD,IAAK,IAAI,EAAI,EAAuB,EAAI,EAAM,OAAQ,IAAK,CAC1D,IAAM,EAAY,EAAM,GACxB,OAAQ,EAAR,CACC,IAAK,IACJ,GAAW,QACX,MACD,IAAK,IACJ,GAAW,OACX,MACD,IAAK,IACJ,GAAW,OACX,MACD,IAAK,IACJ,GAAW,SACX,MACD,IAAK,IACJ,GAAW,QACX,MACD,QACC,GAAW,CACb,CACD,CACA,OAAO,CACR,CCjCA,MAAM,EAAsB,IAAI,QAMhC,SAAS,EAAoB,EAA+C,CAC3E,IAAM,EAAM,IAAI,IAChB,GAAI,GAAS,MAAQ,IAAU,GAC9B,OAAO,EAER,IAAK,IAAM,KAAQ,EAAM,MAAM,GAAG,EAC7B,IAAS,IACZ,EAAI,IAAI,CAAI,EAGd,OAAO,CACR,CAWA,SAAS,GAAgB,EAAoC,CAC5D,IAAM,EAAS,EAAoB,IAAI,CAAW,EAClD,GAAI,GAAU,MAAQ,GAAoB,CAAM,EAC/C,OAAO,EAER,IAAM,EAAgB,IAAI,IACpB,EAAgB,IAAI,QACpB,EAAe,EAAY,iBAAiB,qBAAqB,EACvE,IAAK,IAAI,EAA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mBA,KAAM,EAyBN,aAyBA,UAyBA,cAmBA,OACD,EC9mCA,SAAS,GAAkB,EAAe,EAA2B,CACpE,IAAI,EAAQ,EACZ,GAAI,EAAQ,EACX,MAAO,GAGR,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IACjC,GAAI,EAAM,KAAO;IAChB,GAAS,EACL,EAAQ,GACX,MAAO,GAIV,MAAO,EACR"}
|
|
1
|
+
{"version":3,"file":"code-block.js","names":["Root","RadixTabsRoot","MantleIcon","RadixTabsList","RadixTabsTrigger","RadixTabsContent"],"sources":["../src/components/code-block/escape-html.ts","../src/components/code-block/fold-runtime.ts","../src/components/code-block/code-block.tsx","../src/components/code-block/has-more-than-n-lines.ts"],"sourcesContent":["/**\n * Escapes special HTML characters in a string to their corresponding\n * HTML entities, preventing issues like unintended HTML rendering or\n * cross-site scripting (XSS) when injecting raw strings into the DOM\n * using `dangerouslySetInnerHTML`.\n *\n * Characters escaped:\n * - \\& => `&`;\n * - \\< => `<`;\n * - \\> => `>`;\n * - \\\" => `"`;\n * - \\' => `'`;\n *\n * @param {string} value The raw string to be escaped.\n *\n * @example\n * escapeHtml('<div>Hello & \"world\"</div>');\n * // Returns: '<div>Hello & "world"</div>'\n */\nfunction escapeHtml(value: string): string {\n\tlet firstSpecialCharIndex = -1;\n\tfor (let i = 0; i < value.length; i++) {\n\t\tconst character = value[i];\n\t\tif (\n\t\t\tcharacter === \"&\" ||\n\t\t\tcharacter === \"<\" ||\n\t\t\tcharacter === \">\" ||\n\t\t\tcharacter === '\"' ||\n\t\t\tcharacter === \"'\"\n\t\t) {\n\t\t\tfirstSpecialCharIndex = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (firstSpecialCharIndex === -1) {\n\t\treturn value;\n\t}\n\n\tlet escaped = value.slice(0, firstSpecialCharIndex);\n\tfor (let i = firstSpecialCharIndex; i < value.length; i++) {\n\t\tconst character = value[i];\n\t\tswitch (character) {\n\t\t\tcase \"&\":\n\t\t\t\tescaped += \"&\";\n\t\t\t\tbreak;\n\t\t\tcase \"<\":\n\t\t\t\tescaped += \"<\";\n\t\t\t\tbreak;\n\t\t\tcase \">\":\n\t\t\t\tescaped += \">\";\n\t\t\t\tbreak;\n\t\t\tcase '\"':\n\t\t\t\tescaped += \""\";\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\t\tescaped += \"'\";\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tescaped += character;\n\t\t}\n\t}\n\treturn escaped;\n}\n\nexport {\n\t//,\n\tescapeHtml,\n};\n","/**\n * Runtime fold/unfold behavior for `CodeBlock.Code` lives in this module so it\n * can be unit-tested independently of React. The implementation deliberately\n * keeps all interaction state in the DOM and uses a single delegated event\n * handler per `<pre>` — no per-line listeners, no React re-renders on toggle.\n *\n * Why event delegation: GitHub's diff-line performance work showed that\n * attaching listeners per line scales poorly past ~1000 rows. A single\n * top-level listener with attribute-based dispatch keeps memory overhead\n * constant and avoids React reconciliation entirely.\n *\n * @see https://github.blog/engineering/architecture-optimization/the-uphill-climb-of-making-diff-lines-performant/\n */\n\n/**\n * Cached per-`<code>` fold geometry. Built lazily on first interaction and\n * invalidated by `clearRegionLinesCache` whenever the inner HTML is replaced.\n */\ntype FoldGeometry = {\n\t/** Map from fold-region ID → the line elements that belong to that region. */\n\tregionToLines: Map<string, HTMLElement[]>;\n\t/**\n\t * Per-line cache of parent fold-region IDs as a `Set`. Pre-parsed at\n\t * map-build time so toggles can avoid re-splitting `data-fold-regions`\n\t * on every affected line every click — meaningful when 1000+ lines belong\n\t * to the toggled region.\n\t */\n\tlineToRegions: WeakMap<HTMLElement, Set<string>>;\n};\n\nconst FOLD_GEOMETRY_CACHE = new WeakMap<Element, FoldGeometry>();\n\n/**\n * Splits a space-separated string into a `Set`, dropping empty entries. Used\n * to parse `data-fold-regions` and `data-folded-regions` attribute values.\n */\nfunction parseSpaceSeparated(value: string | null | undefined): Set<string> {\n\tconst set = new Set<string>();\n\tif (value == null || value === \"\") {\n\t\treturn set;\n\t}\n\tfor (const part of value.split(\" \")) {\n\t\tif (part !== \"\") {\n\t\t\tset.add(part);\n\t\t}\n\t}\n\treturn set;\n}\n\n/**\n * Builds (and memoizes per `<code>` element) the {@link FoldGeometry} index.\n * Lazy on first interaction so initial render cost stays at zero.\n *\n * If a cached geometry exists but its first cached line element is no longer\n * connected to the DOM, the cache is treated as stale (typically because\n * something replaced the `<code>`'s `innerHTML` without going through the\n * `clearRegionLinesCache` path) and rebuilt from the current children.\n */\nfunction getFoldGeometry(codeElement: Element): FoldGeometry {\n\tconst cached = FOLD_GEOMETRY_CACHE.get(codeElement);\n\tif (cached != null && isGeometryConnected(cached)) {\n\t\treturn cached;\n\t}\n\tconst regionToLines = new Map<string, HTMLElement[]>();\n\tconst lineToRegions = new WeakMap<HTMLElement, Set<string>>();\n\tconst lineElements = codeElement.querySelectorAll(\"[data-fold-regions]\");\n\tfor (let index = 0; index < lineElements.length; index += 1) {\n\t\tconst lineElement = lineElements[index];\n\t\tif (!(lineElement instanceof HTMLElement)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst regions = parseSpaceSeparated(lineElement.dataset.foldRegions);\n\t\tif (regions.size === 0) {\n\t\t\tcontinue;\n\t\t}\n\t\tlineToRegions.set(lineElement, regions);\n\t\tfor (const region of regions) {\n\t\t\tlet lines = regionToLines.get(region);\n\t\t\tif (lines == null) {\n\t\t\t\tlines = [];\n\t\t\t\tregionToLines.set(region, lines);\n\t\t\t}\n\t\t\tlines.push(lineElement);\n\t\t}\n\t}\n\tconst geometry: FoldGeometry = { regionToLines, lineToRegions };\n\tFOLD_GEOMETRY_CACHE.set(codeElement, geometry);\n\treturn geometry;\n}\n\n/** Resets the per-element cache. Called when the code block re-renders new content. */\nfunction clearRegionLinesCache(codeElement: Element): void {\n\tFOLD_GEOMETRY_CACHE.delete(codeElement);\n}\n\n/** Clears per-code-element runtime state after the code element's HTML is replaced. */\nfunction resetFoldState(codeElement: Element): void {\n\tclearRegionLinesCache(codeElement);\n\tcodeElement.removeAttribute(\"data-folded-regions\");\n}\n\n/**\n * Cheap liveness probe: checks whether the first cached line is still\n * attached to the document. If `innerHTML` was replaced under us, the cached\n * line elements get detached and {@link Element.isConnected} flips to false.\n * Inspecting one entry is enough — they all detach together when the parent's\n * `innerHTML` is reset.\n */\nfunction isGeometryConnected(geometry: FoldGeometry): boolean {\n\tfor (const lines of geometry.regionToLines.values()) {\n\t\tif (lines.length === 0) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst sample = lines[0];\n\t\tif (sample == null) {\n\t\t\tcontinue;\n\t\t}\n\t\treturn sample.isConnected;\n\t}\n\t// Empty geometry — treat as still valid; rebuilding wouldn't add anything.\n\treturn true;\n}\n\n/**\n * Reconciles a single line's hidden state with the currently-folded region\n * set. A line is hidden if any of its parent regions are folded.\n */\nfunction syncLineHidden(\n\tline: HTMLElement,\n\tfoldedRegions: Set<string>,\n\tlineRegions: Set<string>,\n): void {\n\tlet isHidden = false;\n\tfor (const region of lineRegions) {\n\t\tif (foldedRegions.has(region)) {\n\t\t\tisHidden = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (isHidden) {\n\t\tline.dataset.foldHidden = \"true\";\n\t} else {\n\t\tdelete line.dataset.foldHidden;\n\t}\n}\n\n/**\n * Toggles the fold region addressed by `button` and synchronizes only the\n * affected lines. The set of folded regions is persisted on the `<code>`\n * element via `data-folded-regions`, keeping the source of truth in the DOM.\n *\n * Returns `true` if a toggle occurred (button was a valid fold toggle), so\n * callers can avoid follow-up work for unrelated clicks.\n */\nfunction toggleFoldFromButton(button: HTMLButtonElement): boolean {\n\tconst regionId = button.dataset.foldLine;\n\tif (regionId == null || regionId === \"\") {\n\t\treturn false;\n\t}\n\tconst codeElement = button.closest(\"[data-slot='code-block-code']\")?.querySelector(\"code\");\n\tif (codeElement == null) {\n\t\treturn false;\n\t}\n\n\tconst foldedRegions = parseSpaceSeparated(codeElement.getAttribute(\"data-folded-regions\"));\n\tconst isCollapsed = foldedRegions.has(regionId);\n\tconst willCollapse = !isCollapsed;\n\n\tif (willCollapse) {\n\t\tfoldedRegions.add(regionId);\n\t} else {\n\t\tfoldedRegions.delete(regionId);\n\t}\n\n\tif (foldedRegions.size === 0) {\n\t\tcodeElement.removeAttribute(\"data-folded-regions\");\n\t} else {\n\t\tcodeElement.setAttribute(\"data-folded-regions\", [...foldedRegions].join(\" \"));\n\t}\n\n\tbutton.setAttribute(\"aria-expanded\", willCollapse ? \"false\" : \"true\");\n\n\tconst { regionToLines, lineToRegions } = getFoldGeometry(codeElement);\n\tconst lines = regionToLines.get(regionId);\n\tif (lines != null) {\n\t\tfor (const line of lines) {\n\t\t\tconst lineRegions = lineToRegions.get(line);\n\t\t\tif (lineRegions != null) {\n\t\t\t\tsyncLineHidden(line, foldedRegions, lineRegions);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Attaches a single delegated `click` listener to the given `<pre>` element.\n * Returns a teardown function suitable for `useEffect` cleanup.\n *\n * The handler is a no-op when the click does not land on a fold toggle, so it\n * is safe to attach unconditionally (e.g. for non-foldable code blocks).\n */\nfunction attachFoldHandler(preElement: HTMLElement): () => void {\n\tconst handleClick = (event: Event) => {\n\t\tconst target = event.target;\n\t\tif (!(target instanceof Element)) {\n\t\t\treturn;\n\t\t}\n\t\tconst button = target.closest(\".mantle-code-fold-toggle\");\n\t\tif (!(button instanceof HTMLButtonElement)) {\n\t\t\treturn;\n\t\t}\n\t\ttoggleFoldFromButton(button);\n\t};\n\n\tpreElement.addEventListener(\"click\", handleClick);\n\treturn () => {\n\t\tpreElement.removeEventListener(\"click\", handleClick);\n\t};\n}\n\nexport {\n\tattachFoldHandler,\n\tclearRegionLinesCache,\n\tgetFoldGeometry,\n\tresetFoldState,\n\ttoggleFoldFromButton,\n};\n","\"use client\";\n\nimport { CaretDownIcon } from \"@phosphor-icons/react/CaretDown\";\nimport { CheckIcon } from \"@phosphor-icons/react/Check\";\nimport { CopyIcon } from \"@phosphor-icons/react/Copy\";\nimport { FileTextIcon } from \"@phosphor-icons/react/FileText\";\nimport { TerminalIcon } from \"@phosphor-icons/react/Terminal\";\nimport type {\n\tComponentProps,\n\tComponentRef,\n\tDispatch,\n\tHTMLAttributes,\n\tReactNode,\n\tSetStateAction,\n} from \"react\";\nimport {\n\tcreateContext,\n\tforwardRef,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseId,\n\tuseLayoutEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport {\n\tContent as RadixTabsContent,\n\tList as RadixTabsList,\n\tRoot as RadixTabsRoot,\n\tTrigger as RadixTabsTrigger,\n} from \"@radix-ui/react-tabs\";\nimport assert from \"tiny-invariant\";\nimport { useCopyToClipboard } from \"../../hooks/use-copy-to-clipboard.js\";\nimport type { SelfClosingWithAsChild, WithAsChild } from \"../../types/as-child.js\";\nimport { composeRefs } from \"../../utils/compose-refs/compose-refs.js\";\nimport { cx } from \"../../utils/cx/cx.js\";\nimport { Icon as MantleIcon } from \"../icon/icon.js\";\nimport type { SvgAttributes } from \"../icon/types.js\";\nimport { TrafficPolicyFileIcon } from \"../icons/traffic-policy-file.js\";\nimport { IconButton } from \"../button/icon-button.js\";\nimport { Slot } from \"../slot/index.js\";\nimport { escapeHtml } from \"./escape-html.js\";\nimport { attachFoldHandler, resetFoldState } from \"./fold-runtime.js\";\nimport type { Mode } from \"./resolve-pre-rendered-props.js\";\nimport type { MantleCodeBlockValue } from \"./mantle-code.js\";\n\ntype CodeBlockContextType = {\n\tcodeId: string | undefined;\n\tcopyTextRef: { current: string };\n\thasCodeExpander: boolean;\n\tisCodeExpanded: boolean;\n\tregisterCodeId: (id: string) => void;\n\tsetHasCodeExpander: (value: boolean) => void;\n\tsetIsCodeExpanded: Dispatch<SetStateAction<boolean>>;\n\tunregisterCodeId: (id: string) => void;\n};\n\nconst CodeBlockContext = createContext<CodeBlockContextType | null>(null);\n\n/** Returns the nearest `CodeBlock` context, throwing if called outside a `CodeBlock.Root`. */\nfunction useCodeBlockContext(): CodeBlockContextType {\n\tconst context = useContext(CodeBlockContext);\n\tassert(context != null, \"CodeBlock subcomponents must be rendered within a <CodeBlock.Root>.\");\n\treturn context;\n}\n\ntype CodeBlockRootProps = Omit<ComponentProps<\"div\">, \"align\"> &\n\tWithAsChild & {\n\t\t/**\n\t\t * The default active tab value (uncontrolled).\n\t\t * Only relevant when using `CodeBlock.TabList` / `CodeBlock.TabContent`.\n\t\t */\n\t\tdefaultTab?: string;\n\t\t/**\n\t\t * The controlled active tab value.\n\t\t * Only relevant when using `CodeBlock.TabList` / `CodeBlock.TabContent`.\n\t\t */\n\t\tactiveTab?: string;\n\t\t/**\n\t\t * Callback fired when the active tab changes.\n\t\t * Only relevant when using `CodeBlock.TabList` / `CodeBlock.TabContent`.\n\t\t */\n\t\tonActiveTabChange?: (value: string) => void;\n\t};\n\n/**\n * Shiki-powered code blocks with build-time syntax highlighting and zero browser bundle.\n * This is the root component for all CodeBlock components.\n *\n * For tabbed code blocks, pass `defaultTab` (uncontrolled) or `activeTab` / `onActiveTabChange`\n * (controlled) to enable tab switching with `CodeBlock.TabList` and `CodeBlock.TabContent`.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst Root = forwardRef<ComponentRef<\"div\">, CodeBlockRootProps>(\n\t({ asChild = false, className, defaultTab, activeTab, onActiveTabChange, ...props }, ref) => {\n\t\tconst copyTextRef = useRef(\"\");\n\t\tconst [hasCodeExpander, setHasCodeExpander] = useState(false);\n\t\tconst [isCodeExpanded, setIsCodeExpanded] = useState(false);\n\t\tconst [codeId, setCodeId] = useState<string | undefined>(undefined);\n\n\t\tconst registerCodeId = useCallback((id: string) => {\n\t\t\tsetCodeId((old) => {\n\t\t\t\tassert(old == null, \"You can only render a single CodeBlock.Code within a CodeBlock.\");\n\t\t\t\treturn id;\n\t\t\t});\n\t\t}, []);\n\n\t\tconst unregisterCodeId = useCallback((id: string) => {\n\t\t\tsetCodeId((old) => {\n\t\t\t\tassert(old === id, \"You can only render a single CodeBlock.Code within a CodeBlock.\");\n\t\t\t\treturn undefined;\n\t\t\t});\n\t\t}, []);\n\n\t\tconst context: CodeBlockContextType = useMemo(\n\t\t\t() =>\n\t\t\t\t({\n\t\t\t\t\tcodeId,\n\t\t\t\t\tcopyTextRef,\n\t\t\t\t\thasCodeExpander,\n\t\t\t\t\tisCodeExpanded,\n\t\t\t\t\tregisterCodeId,\n\t\t\t\t\tsetHasCodeExpander,\n\t\t\t\t\tsetIsCodeExpanded,\n\t\t\t\t\tunregisterCodeId,\n\t\t\t\t}) as const,\n\t\t\t[codeId, hasCodeExpander, isCodeExpanded, registerCodeId, unregisterCodeId],\n\t\t);\n\n\t\tconst hasTabs = defaultTab != null || activeTab != null;\n\t\tconst Component = asChild ? Slot : \"div\";\n\n\t\tconst tree = (\n\t\t\t<Component\n\t\t\t\tdata-slot=\"code-block\"\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"text-mono w-full overflow-hidden rounded-md border border-gray-300 bg-card font-mono\",\n\t\t\t\t\t\"[&_svg]:shrink-0\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\n\t\treturn (\n\t\t\t<CodeBlockContext.Provider value={context}>\n\t\t\t\t{hasTabs ? (\n\t\t\t\t\t<RadixTabsRoot\n\t\t\t\t\t\tasChild\n\t\t\t\t\t\tdefaultValue={defaultTab}\n\t\t\t\t\t\tvalue={activeTab}\n\t\t\t\t\t\tonValueChange={onActiveTabChange}\n\t\t\t\t\t>\n\t\t\t\t\t\t{tree}\n\t\t\t\t\t</RadixTabsRoot>\n\t\t\t\t) : (\n\t\t\t\t\ttree\n\t\t\t\t)}\n\t\t\t</CodeBlockContext.Provider>\n\t\t);\n\t},\n);\nRoot.displayName = \"CodeBlock\";\n\n/**\n * The body of the `CodeBlock`. This is where `CodeBlock.Code` and\n * the optional `CodeBlock.CopyButton` are rendered.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst Body = forwardRef<ComponentRef<\"div\">, ComponentProps<\"div\"> & WithAsChild>(\n\t({ asChild = false, className, ...props }, ref) => {\n\t\tconst Component = asChild ? Slot : \"div\";\n\t\treturn (\n\t\t\t<Component\n\t\t\t\tdata-slot=\"code-block-body\"\n\t\t\t\tclassName={cx(\"relative\", className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t},\n);\nBody.displayName = \"CodeBlockBody\";\n\n/**\n * Matches `SHIKI_VAL_<index>` placeholders injected by the Vite plugin for\n * interpolated template expressions. Hoisted to module scope to avoid\n * re-creating the regex on every substitution call.\n */\nconst LEGACY_SHIKI_VAL_PATTERN = /SHIKI_VAL_(\\d+)/g;\n\n/** Escapes special characters in a string for use in a `RegExp` constructor. */\nfunction escapeForRegExp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nconst maxPreValPatternCacheSize = 500;\nconst preValPatternCache = new Map<string, RegExp>();\n\n/**\n * Returns the cached `RegExp` for the given `preValToken`, falling back to the\n * legacy `SHIKI_VAL_<n>` pattern when no token is provided.\n */\nfunction getTemplateValPattern(preValToken: string | undefined): RegExp {\n\tif (preValToken == null || preValToken.length === 0) {\n\t\treturn LEGACY_SHIKI_VAL_PATTERN;\n\t}\n\n\tlet cached = preValPatternCache.get(preValToken);\n\tif (cached == null) {\n\t\tif (preValPatternCache.size >= maxPreValPatternCacheSize) {\n\t\t\tpreValPatternCache.clear();\n\t\t}\n\t\tcached = new RegExp(`${escapeForRegExp(preValToken)}(\\\\d+)__`, \"g\");\n\t\tpreValPatternCache.set(preValToken, cached);\n\t}\n\treturn cached;\n}\n\n/**\n * Replaces placeholder tokens in `input` with values from `vals`, applying\n * `mapValue` to each substituted value. Returns the input unchanged when\n * no placeholders are present.\n */\nfunction substituteTemplateVals(\n\tinput: string,\n\tvals: unknown[],\n\tpreValToken: string | undefined,\n\tmapValue: (value: unknown) => string,\n): string {\n\tif (preValToken == null) {\n\t\tif (!input.includes(\"SHIKI_VAL_\")) {\n\t\t\treturn input;\n\t\t}\n\t} else if (!input.includes(preValToken)) {\n\t\treturn input;\n\t}\n\n\treturn input.replaceAll(getTemplateValPattern(preValToken), (match, indexText: string) => {\n\t\tconst index = Number.parseInt(indexText, 10);\n\t\tif (Number.isNaN(index) || index < 0 || index >= vals.length) {\n\t\t\treturn match;\n\t\t}\n\t\treturn mapValue(vals[index]);\n\t});\n}\n\n/** Substitutes placeholder tokens in pre-rendered HTML, HTML-escaping each interpolated value. */\nfunction substitutePreVals(html: string, vals: unknown[], preValToken: string | undefined): string {\n\treturn substituteTemplateVals(html, vals, preValToken, (value) => escapeHtml(String(value)));\n}\n\n/** Substitutes placeholder tokens in plain text (for the copy button), without HTML escaping. */\nfunction substitutePreValsPlainText(\n\ttext: string,\n\tvals: unknown[],\n\tpreValToken: string | undefined,\n): string {\n\treturn substituteTemplateVals(text, vals, preValToken, (value) => String(value));\n}\n\ntype CodeBlockCodeProps = Omit<ComponentProps<\"pre\">, \"children\"> & {\n\t/**\n\t * The code value produced by `mantleCode(\"lang\")` tagged template.\n\t * Contains pre-rendered Shiki HTML (when the Vite plugin is active) and\n\t * the original code string for the copy button.\n\t */\n\tvalue: MantleCodeBlockValue;\n};\n\n/**\n * The `CodeBlock` content. Renders pre-highlighted code from `mantleCode()`.\n *\n * `value[\"~preHtml\"]` must be provided by Mantle's Vite plugin or server highlighter.\n * Runtime highlighting and runtime line decoration are intentionally unsupported.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst Code = forwardRef<ComponentRef<\"pre\">, CodeBlockCodeProps>(\n\t({ className, style, value, ...props }, ref) => {\n\t\tconst id = useId();\n\t\tconst preRef = useRef<HTMLPreElement>(null);\n\t\tconst { copyTextRef, hasCodeExpander, isCodeExpanded, registerCodeId, unregisterCodeId } =\n\t\t\tuseCodeBlockContext();\n\t\tconst {\n\t\t\tlanguage,\n\t\t\tcode,\n\t\t\t\"~preValToken\": __preValToken,\n\t\t\t\"~preVals\": __preVals,\n\t\t\t\"~highlightLines\": __highlightLines,\n\t\t\t\"~lineNumberStart\": __lineNumberStart,\n\t\t\t\"~preHtml\": __preHtml,\n\t\t\t\"~showLineNumbers\": __showLineNumbers,\n\t\t} = value;\n\n\t\tconst effectiveHighlightLines = __highlightLines;\n\t\tconst effectiveLineNumberStart = __lineNumberStart ?? 1;\n\t\tconst effectiveShowLineNumbers = __showLineNumbers ?? false;\n\t\tconst copyText = useMemo(\n\t\t\t() =>\n\t\t\t\t__preVals != null && __preVals.length > 0\n\t\t\t\t\t? substitutePreValsPlainText(code, __preVals, __preValToken)\n\t\t\t\t\t: code,\n\t\t\t[__preValToken, __preVals, code],\n\t\t);\n\n\t\tuseLayoutEffect(() => {\n\t\t\tcopyTextRef.current = copyText;\n\t\t}, [copyTextRef, copyText]);\n\n\t\tuseEffect(() => {\n\t\t\tregisterCodeId(id);\n\n\t\t\treturn () => {\n\t\t\t\tunregisterCodeId(id);\n\t\t\t};\n\t\t}, [id, registerCodeId, unregisterCodeId]);\n\n\t\tconst renderedHtml = useMemo(() => {\n\t\t\tif (__preHtml == null) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn __preVals != null && __preVals.length > 0\n\t\t\t\t? substitutePreVals(__preHtml, __preVals, __preValToken)\n\t\t\t\t: __preHtml;\n\t\t}, [__preHtml, __preValToken, __preVals]);\n\n\t\t// Attach a single delegated click handler per <pre> so fold toggles do\n\t\t// not pay the cost of N React re-renders or N event handlers — see the\n\t\t// performance rationale in `fold-runtime.ts`. Re-attaches when the\n\t\t// rendered HTML changes since `<code>` gets a new dangerouslySetInnerHTML.\n\t\tuseEffect(() => {\n\t\t\tconst pre = preRef.current;\n\t\t\tif (pre == null) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst codeElement = pre.querySelector(\"code\");\n\t\t\tif (codeElement != null) {\n\t\t\t\tresetFoldState(codeElement);\n\t\t\t}\n\t\t\treturn attachFoldHandler(pre);\n\t\t}, [renderedHtml]);\n\n\t\tconst isPreRendered = renderedHtml != null;\n\t\tconst displayHtml = renderedHtml ?? escapeHtml(copyText);\n\n\t\t// React diffs `dangerouslySetInnerHTML` by prop reference; a fresh\n\t\t// `{ __html }` literal each render re-applies `innerHTML`, wiping any\n\t\t// runtime-managed DOM state on the children (e.g. fold attributes).\n\t\tconst innerHtmlProp = useMemo(() => ({ __html: displayHtml }), [displayHtml]);\n\n\t\treturn (\n\t\t\t<pre\n\t\t\t\tdata-slot=\"code-block-code\"\n\t\t\t\taria-expanded={hasCodeExpander ? isCodeExpanded : undefined}\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"scrollbar overflow-x-auto overflow-y-hidden py-4\",\n\t\t\t\t\t!isPreRendered && \"pr-14\",\n\t\t\t\t\t\"data-[mantle-line-numbers~='false']:pl-4\",\n\t\t\t\t\t\"text-mono m-0 font-mono outline-hidden\",\n\t\t\t\t\t\"aria-collapsed:max-h-[13.6rem]\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tdata-highlighted={isPreRendered ? \"true\" : \"false\"}\n\t\t\t\tdata-lang={language}\n\t\t\t\tdata-mantle-highlight-lines={\n\t\t\t\t\tisPreRendered && effectiveHighlightLines != null && effectiveHighlightLines.length > 0\n\t\t\t\t\t\t? effectiveHighlightLines.join(\",\")\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tdata-mantle-line-number-start={\n\t\t\t\t\tisPreRendered && effectiveShowLineNumbers ? String(effectiveLineNumberStart) : \"1\"\n\t\t\t\t}\n\t\t\t\tdata-mantle-line-numbers={isPreRendered && effectiveShowLineNumbers ? \"true\" : \"false\"}\n\t\t\t\tid={id}\n\t\t\t\tref={composeRefs(preRef, ref)}\n\t\t\t\tstyle={\n\t\t\t\t\t{\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\"--mantle-line-number-start\": String(effectiveLineNumberStart),\n\t\t\t\t\t\ttabSize: 2,\n\t\t\t\t\t\tMozTabSize: 2,\n\t\t\t\t\t} as ComponentProps<\"pre\">[\"style\"]\n\t\t\t\t}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<code\n\t\t\t\t\tclassName=\"text-size-inherit block min-w-full w-max\"\n\t\t\t\t\tdangerouslySetInnerHTML={innerHtmlProp}\n\t\t\t\t/>\n\t\t\t</pre>\n\t\t);\n\t},\n);\nCode.displayName = \"CodeBlockCode\";\n\n/**\n * The (optional) header slot of the `CodeBlock`. This is where\n * `CodeBlock.Icon` and `CodeBlock.Title` are rendered.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst Header = forwardRef<ComponentRef<\"div\">, ComponentProps<\"div\"> & WithAsChild>(\n\t({ asChild = false, className, ...props }, ref) => {\n\t\tconst Component = asChild ? Slot : \"div\";\n\t\treturn (\n\t\t\t<Component\n\t\t\t\tdata-slot=\"code-block-header\"\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"flex items-center gap-1 border-b border-gray-300 bg-base px-4 py-2 text-gray-700\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t},\n);\nHeader.displayName = \"CodeBlockHeader\";\n\n/**\n * The (optional) title of the `CodeBlock`. Renders as `h3` by default;\n * use `asChild` to render a different element.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst Title = forwardRef<\n\tHTMLHeadingElement,\n\tHTMLAttributes<HTMLHeadingElement> & { asChild?: boolean }\n>(({ asChild = false, className, ...props }, ref) => {\n\tconst Component = asChild ? Slot : \"h3\";\n\treturn (\n\t\t<Component\n\t\t\tdata-slot=\"code-block-title\"\n\t\t\tref={ref}\n\t\t\tclassName={cx(\"text-mono m-0 font-mono font-normal\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n});\nTitle.displayName = \"CodeBlockTitle\";\n\ntype CodeBlockCopyButtonProps = Omit<ComponentProps<\"button\">, \"children\" | \"type\"> &\n\tSelfClosingWithAsChild & {\n\t\t/**\n\t\t * The accessible label for the copy button. This label will be visually hidden but announced to screen reader users, similar to alt text for img tags.\n\t\t *\n\t\t * @default \"Copy code\"\n\t\t */\n\t\tlabel?: string;\n\t\t/**\n\t\t * Callback fired when the copy button is clicked, passes the copied text as an argument.\n\t\t */\n\t\tonCopy?: (value: string) => void;\n\t\t/**\n\t\t * Callback fired when an error occurs during copying.\n\t\t */\n\t\tonCopyError?: (error: unknown) => void;\n\t};\n\n/**\n * The (optional) copy button of the `CodeBlock`. Copies the code content\n * to the clipboard when clicked.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst CopyButton = forwardRef<ComponentRef<\"button\">, CodeBlockCopyButtonProps>(\n\t({ className, label = \"Copy code\", onCopy, onCopyError, onClick, ...props }, ref) => {\n\t\tconst { copyTextRef } = useCodeBlockContext();\n\t\tconst copyToClipboard = useCopyToClipboard();\n\t\tconst [wasCopied, setWasCopied] = useState(false);\n\t\tconst timeoutHandle = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tif (timeoutHandle.current != null) {\n\t\t\t\t\tclearTimeout(timeoutHandle.current);\n\t\t\t\t}\n\t\t\t};\n\t\t}, []);\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"code-block-copy-button\"\n\t\t\t\tclassName=\"absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-[var(--icon-button-border-radius,0.375rem)] bg-card\"\n\t\t\t>\n\t\t\t\t<IconButton\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tappearance=\"ghost\"\n\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\tlabel={label}\n\t\t\t\t\ticon={wasCopied ? <CheckIcon /> : <CopyIcon />}\n\t\t\t\t\tclassName={className}\n\t\t\t\t\tref={ref}\n\t\t\t\t\tonClick={async (event) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tonClick?.(event);\n\t\t\t\t\t\t\tif (event.defaultPrevented) {\n\t\t\t\t\t\t\t\tif (timeoutHandle.current != null) {\n\t\t\t\t\t\t\t\t\tclearTimeout(timeoutHandle.current);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst text = copyTextRef.current;\n\t\t\t\t\t\t\tawait copyToClipboard(text);\n\t\t\t\t\t\t\tonCopy?.(text);\n\t\t\t\t\t\t\tsetWasCopied(true);\n\t\t\t\t\t\t\tif (timeoutHandle.current != null) {\n\t\t\t\t\t\t\t\tclearTimeout(timeoutHandle.current);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimeoutHandle.current = setTimeout(() => {\n\t\t\t\t\t\t\t\tsetWasCopied(false);\n\t\t\t\t\t\t\t}, 2000);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tonCopyError?.(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t\t{...props}\n\t\t\t\t/>\n\t\t\t</span>\n\t\t);\n\t},\n);\nCopyButton.displayName = \"CodeBlockCopyButton\";\n\ntype CodeBlockExpanderButtonProps = Omit<\n\tComponentProps<\"button\">,\n\t\"children\" | \"aria-controls\" | \"aria-expanded\"\n> &\n\tWithAsChild;\n\n/**\n * The (optional) expander button of the `CodeBlock`. Toggles the expanded\n * state of the code block. When present, the code block is collapsible.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nconst ExpanderButton = forwardRef<ComponentRef<\"button\">, CodeBlockExpanderButtonProps>(\n\t({ asChild = false, className, onClick, ...props }, ref) => {\n\t\tconst { codeId, isCodeExpanded, setIsCodeExpanded, setHasCodeExpander } = useCodeBlockContext();\n\n\t\tuseEffect(() => {\n\t\t\tsetHasCodeExpander(true);\n\t\t\treturn () => {\n\t\t\t\tsetHasCodeExpander(false);\n\t\t\t};\n\t\t}, [setHasCodeExpander]);\n\n\t\tconst Component = asChild ? Slot : \"button\";\n\n\t\treturn (\n\t\t\t<Component\n\t\t\t\t{...props}\n\t\t\t\tdata-slot=\"code-block-expander-button\"\n\t\t\t\taria-controls={codeId}\n\t\t\t\taria-expanded={isCodeExpanded}\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"flex w-full items-center justify-center gap-0.5 border-t border-gray-300 bg-card px-4 py-2 font-sans text-gray-700 hover:bg-gray-100\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={(event) => {\n\t\t\t\t\tsetIsCodeExpanded((prev) => !prev);\n\t\t\t\t\tonClick?.(event);\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{isCodeExpanded ? \"Show less\" : \"Show more\"}{\" \"}\n\t\t\t\t<MantleIcon\n\t\t\t\t\tsvg={<CaretDownIcon weight=\"bold\" />}\n\t\t\t\t\tclassName={cx(\"size-4\", isCodeExpanded && \"rotate-180\", \"transition-all duration-150\")}\n\t\t\t\t/>\n\t\t\t</Component>\n\t\t);\n\t},\n);\nExpanderButton.displayName = \"CodeBlockExpanderButton\";\n\ntype CodeBlockIconProps = Omit<SvgAttributes, \"children\"> &\n\t(\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * A custom icon SVG to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tsvg: ReactNode;\n\t\t\t\t/**\n\t\t\t\t * A preset icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tpreset?: undefined | never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * A custom icon SVG to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tsvg?: undefined | never;\n\t\t\t\t/**\n\t\t\t\t * A preset icon to display in the code block header.\n\t\t\t\t * (Pass only one of `svg` or `preset`.)\n\t\t\t\t */\n\t\t\t\tpreset: Mode;\n\t\t }\n\t);\n\n/**\n * A small icon for the `CodeBlock` header. Pass either a custom `svg`\n * or a `preset` value (not both).\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n * ```\n */\nfunction CodeBlockIconComponent({\n\tclassName,\n\tpreset,\n\tsvg: _svgProp,\n\t...props\n}: CodeBlockIconProps) {\n\tlet svg = _svgProp;\n\tif (preset != null) {\n\t\tswitch (preset) {\n\t\t\tcase \"file\":\n\t\t\t\tsvg = <FileTextIcon weight=\"fill\" />;\n\t\t\t\tbreak;\n\t\t\tcase \"cli\":\n\t\t\t\tsvg = <TerminalIcon weight=\"fill\" />;\n\t\t\t\tbreak;\n\t\t\tcase \"traffic-policy\":\n\t\t\t\tsvg = <TrafficPolicyFileIcon />;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn <MantleIcon data-slot=\"code-block-icon\" className={className} svg={svg} {...props} />;\n}\nCodeBlockIconComponent.displayName = \"CodeBlockIcon\";\n\ntype CodeBlockTabListProps = Omit<ComponentProps<typeof RadixTabsList>, \"asChild\" | \"loop\">;\n\n/**\n * A tab list for the `CodeBlock` header. Renders pill-styled tab triggers\n * that switch which code is displayed. Built on Radix Tabs primitives.\n *\n * Place this inside `CodeBlock.Header` and pair with `CodeBlock.TabContent`\n * in `CodeBlock.Body` to conditionally render code based on the active tab.\n * Tab state is managed by `CodeBlock.Root` via `defaultTab` / `activeTab` / `onActiveTabChange`.\n *\n * @example\n * ```tsx\n * <CodeBlock.Root defaultTab=\"yml\">\n * <CodeBlock.Header>\n * <CodeBlock.TabList>\n * <CodeBlock.TabTrigger value=\"yml\">policy.yml</CodeBlock.TabTrigger>\n * <CodeBlock.TabTrigger value=\"json\">policy.json</CodeBlock.TabTrigger>\n * </CodeBlock.TabList>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.TabContent value=\"yml\">\n * <CodeBlock.Code value={ymlValue} />\n * </CodeBlock.TabContent>\n * <CodeBlock.TabContent value=\"json\">\n * <CodeBlock.Code value={jsonValue} />\n * </CodeBlock.TabContent>\n * </CodeBlock.Body>\n * </CodeBlock.Root>\n * ```\n */\nconst TabList = forwardRef<ComponentRef<typeof RadixTabsList>, CodeBlockTabListProps>(\n\t({ className, ...props }, ref) => (\n\t\t<RadixTabsList\n\t\t\tdata-slot=\"code-block-tab-list\"\n\t\t\tclassName={cx(\"flex items-center gap-1\", className)}\n\t\t\tref={ref}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nTabList.displayName = \"CodeBlockTabList\";\n\ntype CodeBlockTabTriggerProps = Omit<ComponentProps<typeof RadixTabsTrigger>, \"asChild\">;\n\n/**\n * A pill-styled tab trigger for the `CodeBlock` header.\n * Must be rendered within a `CodeBlock.TabList`.\n *\n * @example\n * ```tsx\n * <CodeBlock.TabList>\n * <CodeBlock.TabTrigger value=\"yml\">policy.yml</CodeBlock.TabTrigger>\n * <CodeBlock.TabTrigger value=\"json\">policy.json</CodeBlock.TabTrigger>\n * </CodeBlock.TabList>\n * ```\n */\nconst TabTrigger = forwardRef<ComponentRef<typeof RadixTabsTrigger>, CodeBlockTabTriggerProps>(\n\t({ className, ...props }, ref) => (\n\t\t<RadixTabsTrigger\n\t\t\tdata-slot=\"code-block-tab-trigger\"\n\t\t\tclassName={cx(\n\t\t\t\t\"cursor-pointer rounded px-1.5 py-0.5 text-xs font-medium\",\n\t\t\t\t\"text-gray-600 outline-hidden\",\n\t\t\t\t\"hover:text-gray-900\",\n\t\t\t\t\"data-[state=active]:bg-neutral-500/15 data-[state=active]:text-strong\",\n\t\t\t\t\"focus-visible:ring-focus-accent focus-visible:ring-4\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tref={ref}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nTabTrigger.displayName = \"CodeBlockTabTrigger\";\n\ntype CodeBlockTabContentProps = Omit<\n\tComponentProps<typeof RadixTabsContent>,\n\t\"asChild\" | \"forceMount\"\n>;\n\n/**\n * Conditionally renders its children when the associated tab is active.\n * Pair with `CodeBlock.TabList` and `CodeBlock.TabTrigger` in the header,\n * and set `defaultTab` / `activeTab` on `CodeBlock.Root`.\n *\n * @example\n * ```tsx\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.TabContent value=\"yml\">\n * <CodeBlock.Code value={ymlValue} />\n * </CodeBlock.TabContent>\n * <CodeBlock.TabContent value=\"json\">\n * <CodeBlock.Code value={jsonValue} />\n * </CodeBlock.TabContent>\n * </CodeBlock.Body>\n * ```\n */\nconst TabContent = forwardRef<ComponentRef<typeof RadixTabsContent>, CodeBlockTabContentProps>(\n\t(props, ref) => <RadixTabsContent data-slot=\"code-block-tab-content\" ref={ref} {...props} />,\n);\nTabContent.displayName = \"CodeBlockTabContent\";\n\n/**\n * Shiki-powered code blocks with build-time syntax highlighting and zero browser bundle.\n *\n * Use `mantleCodeBlockPlugins()` to enable pre-rendering at build time.\n *\n * @example\n * Composition:\n * ```\n * # Standard\n * CodeBlock.Root\n * ├── CodeBlock.Header\n * │ ├── CodeBlock.Icon\n * │ └── CodeBlock.Title\n * ├── CodeBlock.Body\n * │ ├── CodeBlock.CopyButton\n * │ └── CodeBlock.Code\n * └── CodeBlock.ExpanderButton\n *\n * # Tabbed\n * CodeBlock.Root\n * ├── CodeBlock.Header\n * │ └── CodeBlock.TabList\n * │ └── CodeBlock.TabTrigger\n * ├── CodeBlock.Body\n * │ ├── CodeBlock.CopyButton\n * │ └── CodeBlock.TabContent\n * │ └── CodeBlock.Code\n * └── CodeBlock.ExpanderButton\n * ```\n *\n * @example\n * ```tsx\n * <CodeBlock.Root>\n * <CodeBlock.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\n * <CodeBlock.ExpanderButton />\n * </CodeBlock.Root>\n *\n * // Server-highlighted HTML fetched via an action route + React Query mutation\n * const highlightMutation = useMutation({\n * mutationFn: async () => {\n * const response = await fetch(\"/api/shiki-highlight\", {\n * method: \"POST\",\n * headers: { \"Content-Type\": \"application/json\" },\n * body: JSON.stringify({ code: source, language: \"typescript\" }),\n * });\n * return response.json();\n * },\n * });\n *\n * const serverValue = createMantleCodeBlockValue({\n * language: \"typescript\",\n * code: source,\n * preHtml: highlightMutation.data?.html,\n * });\n * ```\n */\nconst CodeBlock = {\n\t/**\n\t * The root component of the `CodeBlock`.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tRoot,\n\t/**\n\t * The body of the `CodeBlock`. Contains `Code` and optional `CopyButton`.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tBody,\n\t/**\n\t * The code content. Renders pre-highlighted Shiki HTML when the Vite plugin is active.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tCode,\n\t/**\n\t * The optional copy button.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tCopyButton,\n\t/**\n\t * The optional expander button for collapsible code blocks.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tExpanderButton,\n\t/**\n\t * The optional header slot for icon and title.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tHeader,\n\t/**\n\t * A small icon for the code block header. Use `preset` or `svg`.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tIcon: CodeBlockIconComponent,\n\t/**\n\t * Conditionally renders children when the associated tab is active.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root defaultTab=\"yml\">\n\t * <CodeBlock.Header>\n\t * <CodeBlock.TabList>\n\t * <CodeBlock.TabTrigger value=\"yml\">policy.yml</CodeBlock.TabTrigger>\n\t * <CodeBlock.TabTrigger value=\"json\">policy.json</CodeBlock.TabTrigger>\n\t * </CodeBlock.TabList>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.TabContent value=\"yml\">\n\t * <CodeBlock.Code value={ymlValue} />\n\t * </CodeBlock.TabContent>\n\t * <CodeBlock.TabContent value=\"json\">\n\t * <CodeBlock.Code value={jsonValue} />\n\t * </CodeBlock.TabContent>\n\t * </CodeBlock.Body>\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tTabContent,\n\t/**\n\t * A tab list for the code block header. Renders pill-styled tabs for switching code.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root defaultTab=\"yml\">\n\t * <CodeBlock.Header>\n\t * <CodeBlock.TabList>\n\t * <CodeBlock.TabTrigger value=\"yml\">policy.yml</CodeBlock.TabTrigger>\n\t * <CodeBlock.TabTrigger value=\"json\">policy.json</CodeBlock.TabTrigger>\n\t * </CodeBlock.TabList>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.TabContent value=\"yml\">\n\t * <CodeBlock.Code value={ymlValue} />\n\t * </CodeBlock.TabContent>\n\t * <CodeBlock.TabContent value=\"json\">\n\t * <CodeBlock.Code value={jsonValue} />\n\t * </CodeBlock.TabContent>\n\t * </CodeBlock.Body>\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tTabList,\n\t/**\n\t * A pill-styled tab trigger for the code block header. Must be inside `TabList`.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root defaultTab=\"yml\">\n\t * <CodeBlock.Header>\n\t * <CodeBlock.TabList>\n\t * <CodeBlock.TabTrigger value=\"yml\">policy.yml</CodeBlock.TabTrigger>\n\t * <CodeBlock.TabTrigger value=\"json\">policy.json</CodeBlock.TabTrigger>\n\t * </CodeBlock.TabList>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.TabContent value=\"yml\">\n\t * <CodeBlock.Code value={ymlValue} />\n\t * </CodeBlock.TabContent>\n\t * <CodeBlock.TabContent value=\"json\">\n\t * <CodeBlock.Code value={jsonValue} />\n\t * </CodeBlock.TabContent>\n\t * </CodeBlock.Body>\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tTabTrigger,\n\t/**\n\t * The optional title rendered in the header.\n\t *\n\t * @example\n\t * ```tsx\n\t * <CodeBlock.Root>\n\t * <CodeBlock.Header>\n\t * <CodeBlock.Icon preset=\"file\" />\n\t * <CodeBlock.Title>example.ts</CodeBlock.Title>\n\t * </CodeBlock.Header>\n\t * <CodeBlock.Body>\n\t * <CodeBlock.CopyButton />\n\t * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n\t * </CodeBlock.Body>\n\t * <CodeBlock.ExpanderButton />\n\t * </CodeBlock.Root>\n\t * ```\n\t */\n\tTitle,\n} as const;\n\nexport {\n\t//,\n\tCodeBlock,\n};\n","/**\n * Returns `true` if `value` has more than `maxLines` newline-delimited lines.\n *\n * This is equivalent to `value.split(\"\\\\n\").length > maxLines`, but avoids\n * allocating an intermediate array and can early-return once the threshold is exceeded.\n */\nfunction hasMoreThanNLines(value: string, maxLines: number): boolean {\n\tlet lines = 1;\n\tif (lines > maxLines) {\n\t\treturn true;\n\t}\n\n\tfor (let i = 0; i < value.length; i++) {\n\t\tif (value[i] === \"\\n\") {\n\t\t\tlines += 1;\n\t\t\tif (lines > maxLines) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\nexport {\n\t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OAAQ,IACjC,GAAI,EAAM,KAAO;IAChB,GAAS,EACL,EAAQ,GACX,MAAO,GAIV,MAAO,EACR"}
|
package/dist/combobox.d.ts
CHANGED
package/dist/command.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Root } from "./primitive-
|
|
1
|
+
import { t as Root } from "./primitive-FoWela9a.js";
|
|
2
2
|
import { ComponentProps, ComponentPropsWithoutRef, ReactNode } from "react";
|
|
3
3
|
import { Command as Command$1, useCommandState } from "cmdk";
|
|
4
4
|
|
|
@@ -204,7 +204,7 @@ declare const Command: {
|
|
|
204
204
|
shouldFilter,
|
|
205
205
|
showCloseButton,
|
|
206
206
|
title
|
|
207
|
-
}: CommandDialogContentProps): import("react
|
|
207
|
+
}: CommandDialogContentProps): import("react").JSX.Element;
|
|
208
208
|
displayName: string;
|
|
209
209
|
};
|
|
210
210
|
/**
|
|
@@ -243,7 +243,7 @@ declare const Command: {
|
|
|
243
243
|
ref?: React.Ref<HTMLInputElement>;
|
|
244
244
|
} & {
|
|
245
245
|
asChild?: boolean;
|
|
246
|
-
}, "key" |
|
|
246
|
+
}, "key" | keyof import("react").InputHTMLAttributes<HTMLInputElement> | "asChild">, "onChange" | "type" | "value"> & {
|
|
247
247
|
value?: string;
|
|
248
248
|
onValueChange?: (search: string) => void;
|
|
249
249
|
} & import("react").RefAttributes<HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -365,7 +365,7 @@ declare const Command: {
|
|
|
365
365
|
ref?: React.Ref<HTMLDivElement>;
|
|
366
366
|
} & {
|
|
367
367
|
asChild?: boolean;
|
|
368
|
-
}, "key" | keyof import("react").HTMLAttributes<HTMLDivElement> | "asChild">, "
|
|
368
|
+
}, "key" | keyof import("react").HTMLAttributes<HTMLDivElement> | "asChild">, "value" | "heading"> & {
|
|
369
369
|
heading?: React.ReactNode;
|
|
370
370
|
value?: string;
|
|
371
371
|
forceMount?: boolean;
|
|
@@ -500,7 +500,7 @@ type Props = Omit<ComponentProps<"kbd">, "children">;
|
|
|
500
500
|
declare function MetaKey({
|
|
501
501
|
className,
|
|
502
502
|
...props
|
|
503
|
-
}: Props): import("react
|
|
503
|
+
}: Props): import("react").JSX.Element;
|
|
504
504
|
//#endregion
|
|
505
505
|
export { Command, MetaKey, useCommandState };
|
|
506
506
|
//# sourceMappingURL=command.d.ts.map
|
package/dist/data-table.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Button } from "./button-
|
|
1
|
+
import { t as Button } from "./button-BXZ_JTu_.js";
|
|
2
2
|
import { s as SortingMode } from "./direction-CcTY0FmA.js";
|
|
3
3
|
import { t as Table$1 } from "./table-BWD9IlIN.js";
|
|
4
4
|
import { ComponentProps, ReactNode } from "react";
|
|
@@ -65,7 +65,7 @@ declare function Root<TData>({
|
|
|
65
65
|
children,
|
|
66
66
|
table,
|
|
67
67
|
...props
|
|
68
|
-
}: DataTableProps<TData>): import("react
|
|
68
|
+
}: DataTableProps<TData>): import("react").JSX.Element;
|
|
69
69
|
declare namespace Root {
|
|
70
70
|
var displayName: string;
|
|
71
71
|
}
|
|
@@ -136,7 +136,7 @@ declare function HeaderSortButton<TData, TValue>({
|
|
|
136
136
|
sortIcon: propSortIcon,
|
|
137
137
|
onClick,
|
|
138
138
|
...props
|
|
139
|
-
}: DataTableHeaderSortButtonProps<TData, TValue>): import("react
|
|
139
|
+
}: DataTableHeaderSortButtonProps<TData, TValue>): import("react").JSX.Element;
|
|
140
140
|
declare namespace HeaderSortButton {
|
|
141
141
|
var displayName: string;
|
|
142
142
|
}
|
|
@@ -167,7 +167,7 @@ declare function Header({
|
|
|
167
167
|
children,
|
|
168
168
|
className,
|
|
169
169
|
...props
|
|
170
|
-
}: DataTableHeaderProps): import("react
|
|
170
|
+
}: DataTableHeaderProps): import("react").JSX.Element;
|
|
171
171
|
declare namespace Header {
|
|
172
172
|
var displayName: string;
|
|
173
173
|
}
|
|
@@ -194,7 +194,7 @@ type DataTableHeadProps = Omit<ComponentProps<typeof Table$1.Head>, "children">;
|
|
|
194
194
|
* </DataTable.Root>
|
|
195
195
|
* ```
|
|
196
196
|
*/
|
|
197
|
-
declare function Head<TData>(props: DataTableHeadProps): import("react
|
|
197
|
+
declare function Head<TData>(props: DataTableHeadProps): import("react").JSX.Element;
|
|
198
198
|
declare namespace Head {
|
|
199
199
|
var displayName: string;
|
|
200
200
|
}
|
|
@@ -229,7 +229,7 @@ declare function Row$1<TData>({
|
|
|
229
229
|
className,
|
|
230
230
|
row,
|
|
231
231
|
...props
|
|
232
|
-
}: DataTableRowProps<TData>): import("react
|
|
232
|
+
}: DataTableRowProps<TData>): import("react").JSX.Element;
|
|
233
233
|
declare namespace Row$1 {
|
|
234
234
|
var displayName: string;
|
|
235
235
|
}
|
|
@@ -260,7 +260,7 @@ type DataTableEmptyRowProps = ComponentProps<typeof Table$1.Row>;
|
|
|
260
260
|
declare function EmptyRow<TData>({
|
|
261
261
|
children,
|
|
262
262
|
...props
|
|
263
|
-
}: DataTableEmptyRowProps): import("react
|
|
263
|
+
}: DataTableEmptyRowProps): import("react").JSX.Element;
|
|
264
264
|
declare namespace EmptyRow {
|
|
265
265
|
var displayName: string;
|
|
266
266
|
}
|
|
@@ -292,7 +292,7 @@ declare function ActionCell({
|
|
|
292
292
|
children,
|
|
293
293
|
className,
|
|
294
294
|
...props
|
|
295
|
-
}: DataTableActionCellProps): import("react
|
|
295
|
+
}: DataTableActionCellProps): import("react").JSX.Element;
|
|
296
296
|
declare namespace ActionCell {
|
|
297
297
|
var displayName: string;
|
|
298
298
|
}
|
|
@@ -317,7 +317,7 @@ declare function ActionHeader({
|
|
|
317
317
|
children,
|
|
318
318
|
className,
|
|
319
319
|
...props
|
|
320
|
-
}: DataTableActionHeaderProps): import("react
|
|
320
|
+
}: DataTableActionHeaderProps): import("react").JSX.Element;
|
|
321
321
|
declare namespace ActionHeader {
|
|
322
322
|
var displayName: string;
|
|
323
323
|
}
|