@ngrok/mantle 0.71.0 → 0.72.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/README.md CHANGED
@@ -38,6 +38,10 @@ Also install the required `devDependencies`:
38
38
 
39
39
  Next, check out the [Overview & Setup](https://mantle.ngrok.com/) docs and start using mantle components in your application!
40
40
 
41
+ ## Using with AI Agents
42
+
43
+ Mantle ships machine-readable entry points for coding agents — see [For AI Agents](https://mantle.ngrok.com/for-ai-agents) for the system-prompt snippet, conventions, and the full list of `/api/*.json` and `llms.txt` endpoints. An offline pointer file (`@ngrok/mantle/agent.json`) is included in the published package as a fallback when network access isn't available.
44
+
41
45
  ## Code Block Tooling
42
46
 
43
47
  Mantle ships runtime components from `@ngrok/mantle`, while build-time and server-side tooling lives in `@ngrok/mantle-vite-plugins`:
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@ngrok/mantle",
3
+ "version": "0.72.0",
4
+ "origin": "https://mantle.ngrok.com",
5
+ "endpoints": {
6
+ "docs": "https://mantle.ngrok.com/",
7
+ "forAiAgents": "https://mantle.ngrok.com/for-ai-agents",
8
+ "llmsTxt": "https://mantle.ngrok.com/llms.txt",
9
+ "llmsFullTxt": "https://mantle.ngrok.com/llms-full.txt",
10
+ "components": "https://mantle.ngrok.com/api/components.json",
11
+ "hooks": "https://mantle.ngrok.com/api/hooks.json",
12
+ "utilities": "https://mantle.ngrok.com/api/utils.json",
13
+ "package": "https://mantle.ngrok.com/api/package.json",
14
+ "changelog": "https://mantle.ngrok.com/api/changelog.json",
15
+ "searchIndex": "https://mantle.ngrok.com/api/search-index.json",
16
+ "schema": "https://mantle.ngrok.com/api/schema.json"
17
+ },
18
+ "subpaths": [
19
+ "@ngrok/mantle/accordion",
20
+ "@ngrok/mantle/alert",
21
+ "@ngrok/mantle/alert-dialog",
22
+ "@ngrok/mantle/anchor",
23
+ "@ngrok/mantle/badge",
24
+ "@ngrok/mantle/browser-only",
25
+ "@ngrok/mantle/button",
26
+ "@ngrok/mantle/calendar",
27
+ "@ngrok/mantle/card",
28
+ "@ngrok/mantle/checkbox",
29
+ "@ngrok/mantle/code",
30
+ "@ngrok/mantle/code-block",
31
+ "@ngrok/mantle/color",
32
+ "@ngrok/mantle/combobox",
33
+ "@ngrok/mantle/command",
34
+ "@ngrok/mantle/cx",
35
+ "@ngrok/mantle/data-table",
36
+ "@ngrok/mantle/description-list",
37
+ "@ngrok/mantle/dialog",
38
+ "@ngrok/mantle/dropdown-menu",
39
+ "@ngrok/mantle/empty",
40
+ "@ngrok/mantle/flag",
41
+ "@ngrok/mantle/highlight-utils",
42
+ "@ngrok/mantle/hooks",
43
+ "@ngrok/mantle/hover-card",
44
+ "@ngrok/mantle/icon",
45
+ "@ngrok/mantle/icons",
46
+ "@ngrok/mantle/input",
47
+ "@ngrok/mantle/kbd",
48
+ "@ngrok/mantle/label",
49
+ "@ngrok/mantle/main",
50
+ "@ngrok/mantle/media-object",
51
+ "@ngrok/mantle/multi-select",
52
+ "@ngrok/mantle/otp-input",
53
+ "@ngrok/mantle/pagination",
54
+ "@ngrok/mantle/popover",
55
+ "@ngrok/mantle/progress",
56
+ "@ngrok/mantle/radio-group",
57
+ "@ngrok/mantle/sandboxed-on-click",
58
+ "@ngrok/mantle/select",
59
+ "@ngrok/mantle/separator",
60
+ "@ngrok/mantle/sheet",
61
+ "@ngrok/mantle/skeleton",
62
+ "@ngrok/mantle/skip-to-main-link",
63
+ "@ngrok/mantle/slider",
64
+ "@ngrok/mantle/slot",
65
+ "@ngrok/mantle/split-button",
66
+ "@ngrok/mantle/switch",
67
+ "@ngrok/mantle/table",
68
+ "@ngrok/mantle/tabs",
69
+ "@ngrok/mantle/text-area",
70
+ "@ngrok/mantle/theme",
71
+ "@ngrok/mantle/toast",
72
+ "@ngrok/mantle/tooltip",
73
+ "@ngrok/mantle/types",
74
+ "@ngrok/mantle/utils"
75
+ ]
76
+ }
@@ -205,7 +205,7 @@ declare const AlertDialog: {
205
205
  readonly Action: _$react.ForwardRefExoticComponent<(Omit<_$react.ClassAttributes<HTMLButtonElement> & _$react.ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<_$class_variance_authority0.VariantProps<(props?: ({
206
206
  appearance?: "filled" | "link" | "ghost" | "outlined" | null | undefined;
207
207
  isLoading?: boolean | null | undefined;
208
- priority?: "default" | "danger" | "neutral" | null | undefined;
208
+ priority?: "danger" | "neutral" | "default" | null | undefined;
209
209
  } & _$class_variance_authority_types0.ClassProp) | undefined) => string>>> & {
210
210
  icon?: ReactNode;
211
211
  iconPlacement?: "start" | "end";
@@ -215,7 +215,7 @@ declare const AlertDialog: {
215
215
  }, "ref"> | Omit<_$react.ClassAttributes<HTMLButtonElement> & _$react.ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<_$class_variance_authority0.VariantProps<(props?: ({
216
216
  appearance?: "filled" | "link" | "ghost" | "outlined" | null | undefined;
217
217
  isLoading?: boolean | null | undefined;
218
- priority?: "default" | "danger" | "neutral" | null | undefined;
218
+ priority?: "danger" | "neutral" | "default" | null | undefined;
219
219
  } & _$class_variance_authority_types0.ClassProp) | undefined) => string>>> & {
220
220
  icon?: ReactNode;
221
221
  iconPlacement?: "start" | "end";
@@ -300,7 +300,7 @@ declare const AlertDialog: {
300
300
  readonly Cancel: _$react.ForwardRefExoticComponent<(Omit<_$react.ClassAttributes<HTMLButtonElement> & _$react.ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<_$class_variance_authority0.VariantProps<(props?: ({
301
301
  appearance?: "filled" | "link" | "ghost" | "outlined" | null | undefined;
302
302
  isLoading?: boolean | null | undefined;
303
- priority?: "default" | "danger" | "neutral" | null | undefined;
303
+ priority?: "danger" | "neutral" | "default" | null | undefined;
304
304
  } & _$class_variance_authority_types0.ClassProp) | undefined) => string>>> & {
305
305
  icon?: ReactNode;
306
306
  iconPlacement?: "start" | "end";
@@ -310,7 +310,7 @@ declare const AlertDialog: {
310
310
  }, "ref"> | Omit<_$react.ClassAttributes<HTMLButtonElement> & _$react.ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<_$class_variance_authority0.VariantProps<(props?: ({
311
311
  appearance?: "filled" | "link" | "ghost" | "outlined" | null | undefined;
312
312
  isLoading?: boolean | null | undefined;
313
- priority?: "default" | "danger" | "neutral" | null | undefined;
313
+ priority?: "danger" | "neutral" | "default" | null | undefined;
314
314
  } & _$class_variance_authority_types0.ClassProp) | undefined) => string>>> & {
315
315
  icon?: ReactNode;
316
316
  iconPlacement?: "start" | "end";
@@ -9,7 +9,7 @@ import * as _$class_variance_authority_types0 from "class-variance-authority/typ
9
9
  declare const buttonVariants: (props?: ({
10
10
  appearance?: "filled" | "link" | "ghost" | "outlined" | null | undefined;
11
11
  isLoading?: boolean | null | undefined;
12
- priority?: "default" | "danger" | "neutral" | null | undefined;
12
+ priority?: "danger" | "neutral" | "default" | null | undefined;
13
13
  } & _$class_variance_authority_types0.ClassProp) | undefined) => string;
14
14
  type ButtonVariants = VariantProps$1<typeof buttonVariants>;
15
15
  /**
@@ -93,7 +93,7 @@ type ButtonProps = ComponentProps<"button"> & ButtonVariants & {
93
93
  declare const Button: _$react.ForwardRefExoticComponent<(Omit<_$react.ClassAttributes<HTMLButtonElement> & _$react.ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<_$class_variance_authority0.VariantProps<(props?: ({
94
94
  appearance?: "filled" | "link" | "ghost" | "outlined" | null | undefined;
95
95
  isLoading?: boolean | null | undefined;
96
- priority?: "default" | "danger" | "neutral" | null | undefined;
96
+ priority?: "danger" | "neutral" | "default" | null | undefined;
97
97
  } & _$class_variance_authority_types0.ClassProp) | undefined) => string>>> & {
98
98
  /**
99
99
  * An icon to render inside the button. If the `state` is `"pending"`, then
@@ -139,7 +139,7 @@ declare const Button: _$react.ForwardRefExoticComponent<(Omit<_$react.ClassAttri
139
139
  }, "ref"> | Omit<_$react.ClassAttributes<HTMLButtonElement> & _$react.ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<_$class_variance_authority0.VariantProps<(props?: ({
140
140
  appearance?: "filled" | "link" | "ghost" | "outlined" | null | undefined;
141
141
  isLoading?: boolean | null | undefined;
142
- priority?: "default" | "danger" | "neutral" | null | undefined;
142
+ priority?: "danger" | "neutral" | "default" | null | undefined;
143
143
  } & _$class_variance_authority_types0.ClassProp) | undefined) => string>>> & {
144
144
  /**
145
145
  * An icon to render inside the button. If the `state` is `"pending"`, then
@@ -172,4 +172,4 @@ declare const Button: _$react.ForwardRefExoticComponent<(Omit<_$react.ClassAttri
172
172
  }, "ref">) & _$react.RefAttributes<HTMLButtonElement>>;
173
173
  //#endregion
174
174
  export { ButtonProps as n, Button as t };
175
- //# sourceMappingURL=button-Bq0x5Pv4.d.ts.map
175
+ //# sourceMappingURL=button-BMgAxAwM.d.ts.map
package/dist/button.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { n as IconButtonProps, t as IconButton } from "./icon-button-BnK4K7YK.js";
2
- import { n as ButtonProps, t as Button } from "./button-Bq0x5Pv4.js";
2
+ import { n as ButtonProps, t as Button } from "./button-BMgAxAwM.js";
3
3
  import { n as ButtonGroupProps, t as ButtonGroup } from "./index-DOJUH34Z.js";
4
4
  export { Button, ButtonGroup, ButtonGroupProps, ButtonProps, IconButton, IconButtonProps };
@@ -1,6 +1,6 @@
1
1
  import { t as SvgAttributes } from "./types-DoV0R5Ja.js";
2
2
  import { t as WithAsChild } from "./as-child-DQHfEmYB.js";
3
- import { C as Indentation, D as isSupportedLanguage, E as SupportedLanguage, M as LineRange, O as parseLanguage, S as normalizeIndentation, T as isIndentation, _ as MantleCodeBlockValue, a as Mode, c as ResolvedPreRenderedCodeBlockProps, d as parseMetastring, f as resolvePreRenderedCodeBlockProps, g as parseCodeBlockShowLineNumbers, h as parseCodeBlockLineNumberStart, i as MetaInput, j as decorateHighlightedHtml, k as supportedLanguages, l as defaultMeta, m as parseCodeBlockHighlightLines, n as DefaultMeta, o as ResolvePreRenderedCodeBlockPropsInput, p as tokenizeMetastring, r as Meta, s as ResolvePreRenderedCodeBlockPropsResult, t as CodeBlockPreElementInput, u as normalizeValue, v as MantleCodeOptions, w as inferIndentation, x as mantleCode, y as createMantleCodeBlockValue } from "./resolve-pre-rendered-props-CNUnH1fU.js";
3
+ import { A as FoldStrategy, B as computeJsonFoldRanges, C as Indentation, D as FoldExplanation, E as ComputeFoldRangesInput, F as isSupportedLanguage, H as finalizeFoldRanges, I as parseLanguage, L as supportedLanguages, M as computeFoldRanges, N as foldStrategyFor, O as FoldLine, P as SupportedLanguage, S as normalizeIndentation, T as isIndentation, U as LineRange, V as FoldableRange, _ as MantleCodeBlockValue, a as Mode, c as ResolvedPreRenderedCodeBlockProps, d as parseMetastring, f as resolvePreRenderedCodeBlockProps, g as parseCodeBlockShowLineNumbers, h as parseCodeBlockLineNumberStart, i as MetaInput, j as FoldToken, k as FoldScope, l as defaultMeta, m as parseCodeBlockHighlightLines, n as DefaultMeta, o as ResolvePreRenderedCodeBlockPropsInput, p as tokenizeMetastring, r as Meta, s as ResolvePreRenderedCodeBlockPropsResult, t as CodeBlockPreElementInput, u as normalizeValue, v as MantleCodeOptions, w as inferIndentation, x as mantleCode, y as createMantleCodeBlockValue, z as decorateHighlightedHtml } from "./resolve-pre-rendered-props-CdqAcY5m.js";
4
4
  import * as _$react from "react";
5
5
  import { ComponentProps, HTMLAttributes, ReactNode } from "react";
6
6
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
@@ -423,5 +423,5 @@ declare function escapeHtml(value: string): string;
423
423
  */
424
424
  declare function hasMoreThanNLines(value: string, maxLines: number): boolean;
425
425
  //#endregion
426
- export { CodeBlock, type CodeBlockPreElementInput, type DefaultMeta, type Indentation, type LineRange, type MantleCodeBlockValue, type MantleCodeOptions, type Meta, type MetaInput, type Mode, type ResolvePreRenderedCodeBlockPropsInput, type ResolvePreRenderedCodeBlockPropsResult, type ResolvedPreRenderedCodeBlockProps, type SupportedLanguage, createMantleCodeBlockValue, decorateHighlightedHtml, defaultMeta, escapeHtml, hasMoreThanNLines, inferIndentation, isIndentation, isSupportedLanguage, mantleCode, normalizeIndentation, normalizeValue, parseCodeBlockHighlightLines, parseCodeBlockLineNumberStart, parseCodeBlockShowLineNumbers, parseLanguage, parseMetastring, resolvePreRenderedCodeBlockProps, supportedLanguages, tokenizeMetastring };
426
+ export { CodeBlock, type CodeBlockPreElementInput, type ComputeFoldRangesInput, type DefaultMeta, type FoldExplanation, type FoldLine, type FoldScope, type FoldStrategy, type FoldToken, type FoldableRange, type Indentation, type LineRange, type MantleCodeBlockValue, type MantleCodeOptions, type Meta, type MetaInput, type Mode, type ResolvePreRenderedCodeBlockPropsInput, type ResolvePreRenderedCodeBlockPropsResult, type ResolvedPreRenderedCodeBlockProps, type SupportedLanguage, computeFoldRanges, computeJsonFoldRanges, createMantleCodeBlockValue, decorateHighlightedHtml, defaultMeta, escapeHtml, finalizeFoldRanges, foldStrategyFor, hasMoreThanNLines, inferIndentation, isIndentation, isSupportedLanguage, mantleCode, normalizeIndentation, normalizeValue, parseCodeBlockHighlightLines, parseCodeBlockLineNumberStart, parseCodeBlockShowLineNumbers, parseLanguage, parseMetastring, resolvePreRenderedCodeBlockProps, supportedLanguages, tokenizeMetastring };
427
427
  //# sourceMappingURL=code-block.d.ts.map
@@ -1,3 +1,3 @@
1
- import{t as e}from"./cx-D1HYnpvA.js";import{t}from"./icon-bWc5yC3-.js";import{t as n}from"./slot-D_ZUrdEW.js";import{t as r}from"./icon-button-ZKN0sRIJ.js";import{t as i}from"./use-copy-to-clipboard-C7vsjJe-.js";import{t as a}from"./traffic-policy-file-C6LHYrIU.js";import{a as o,c as s,d as c,f as l,g as u,h as d,i as f,l as p,m,n as h,o as g,p as _,r as v,s as y,t as b,u as x,v as S}from"./resolve-pre-rendered-props-C-kiaLHj.js";import{CaretDownIcon as C}from"@phosphor-icons/react/CaretDown";import{createContext as w,forwardRef as T,useCallback as E,useContext as D,useEffect as O,useId as ee,useLayoutEffect as te,useMemo as k,useRef as A,useState as j}from"react";import M from"tiny-invariant";import{jsx as N,jsxs as P}from"react/jsx-runtime";import{CheckIcon as F}from"@phosphor-icons/react/Check";import{CopyIcon as I}from"@phosphor-icons/react/Copy";import{FileTextIcon as L}from"@phosphor-icons/react/FileText";import{TerminalIcon as ne}from"@phosphor-icons/react/Terminal";import{Content as re,List as ie,Root as ae,Trigger as oe}from"@radix-ui/react-tabs";function R(e){let t=-1;for(let n=0;n<e.length;n++){let r=e[n];if(r===`&`||r===`<`||r===`>`||r===`"`||r===`'`){t=n;break}}if(t===-1)return e;let n=e.slice(0,t);for(let r=t;r<e.length;r++){let t=e[r];switch(t){case`&`:n+=`&amp;`;break;case`<`:n+=`&lt;`;break;case`>`:n+=`&gt;`;break;case`"`:n+=`&quot;`;break;case`'`:n+=`&#39;`;break;default:n+=t}}return n}const z=w(null);function B(){let e=D(z);return M(e!=null,`CodeBlock subcomponents must be rendered within a <CodeBlock.Root>.`),e}const V=T(({asChild:t=!1,className:r,defaultTab:i,activeTab:a,onActiveTabChange:o,...s},c)=>{let l=A(``),[u,d]=j(!1),[f,p]=j(!1),[m,h]=j(void 0),g=E(e=>{h(t=>(M(t==null,`You can only render a single CodeBlock.Code within a CodeBlock.`),e))},[]),_=E(e=>{h(t=>{M(t===e,`You can only render a single CodeBlock.Code within a CodeBlock.`)})},[]),v=k(()=>({codeId:m,copyTextRef:l,hasCodeExpander:u,isCodeExpanded:f,registerCodeId:g,setHasCodeExpander:d,setIsCodeExpanded:p,unregisterCodeId:_}),[m,u,f,g,_]),y=i!=null||a!=null,b=N(t?n:`div`,{"data-slot":`code-block`,className:e(`text-mono w-full overflow-hidden rounded-md border border-gray-300 bg-card font-mono`,`[&_svg]:shrink-0`,r),ref:c,...s});return N(z.Provider,{value:v,children:y?N(ae,{asChild:!0,defaultValue:i,value:a,onValueChange:o,children:b}):b})});V.displayName=`CodeBlock`;const H=T(({asChild:t=!1,className:r,...i},a)=>N(t?n:`div`,{"data-slot":`code-block-body`,className:e(`relative`,r),ref:a,...i}));H.displayName=`CodeBlockBody`;const se=/SHIKI_VAL_(\d+)/g;function ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const U=new Map;function le(e){if(e==null||e.length===0)return se;let t=U.get(e);return t??(U.size>=500&&U.clear(),t=RegExp(`${ce(e)}(\\d+)__`,`g`),U.set(e,t)),t}function W(e,t,n,r){if(n==null){if(!e.includes(`SHIKI_VAL_`))return e}else if(!e.includes(n))return e;return e.replaceAll(le(n),(e,n)=>{let i=Number.parseInt(n,10);return Number.isNaN(i)||i<0||i>=t.length?e:r(t[i])})}function ue(e,t,n){return W(e,t,n,e=>R(String(e)))}function de(e,t,n){return W(e,t,n,e=>String(e))}const G=T(({className:t,style:n,tabIndex:r,value:i,...a},o)=>{let s=ee(),{copyTextRef:c,hasCodeExpander:l,isCodeExpanded:u,registerCodeId:d,unregisterCodeId:f}=B(),{language:p,code:m,"~preValToken":h,"~preVals":g,"~highlightLines":_,"~lineNumberStart":v,"~preHtml":y,"~showLineNumbers":b}=i,x=_,S=v??1,C=b??!1,w=k(()=>g!=null&&g.length>0?de(m,g,h):m,[h,g,m]);te(()=>{c.current=w},[c,w]),O(()=>(d(s),()=>{f(s)}),[s,d,f]);let T=k(()=>{if(y!=null)return g!=null&&g.length>0?ue(y,g,h):y},[y,h,g]),E=T!=null,D=T??R(w);return N(`pre`,{"data-slot":`code-block-code`,"aria-expanded":l?u:void 0,className:e(`scrollbar overflow-x-auto overflow-y-hidden py-4`,!E&&`pr-14`,`data-[mantle-line-numbers~='false']:pl-4`,`text-mono m-0 font-mono`,`aria-collapsed:max-h-[13.6rem]`,t),"data-highlighted":E?`true`:`false`,"data-lang":p,"data-mantle-highlight-lines":E&&x!=null&&x.length>0?x.join(`,`):void 0,"data-mantle-line-number-start":E&&C?String(S):`1`,"data-mantle-line-numbers":E&&C?`true`:`false`,id:s,ref:o,style:{...n,"--mantle-line-number-start":String(S),tabSize:2,MozTabSize:2},tabIndex:r??-1,...a,children:N(`code`,{className:`text-size-inherit block min-w-full w-max`,dangerouslySetInnerHTML:{__html:D}})})});G.displayName=`CodeBlockCode`;const K=T(({asChild:t=!1,className:r,...i},a)=>N(t?n:`div`,{"data-slot":`code-block-header`,className:e(`flex items-center gap-1 border-b border-gray-300 bg-base px-4 py-2 text-gray-700`,r),ref:a,...i}));K.displayName=`CodeBlockHeader`;const q=T(({asChild:t=!1,className:r,...i},a)=>N(t?n:`h3`,{"data-slot":`code-block-title`,ref:a,className:e(`text-mono m-0 font-mono font-normal`,r),...i}));q.displayName=`CodeBlockTitle`;const J=T(({className:e,onCopy:t,onCopyError:n,onClick:a,...o},s)=>{let{copyTextRef:c}=B(),l=i(),[u,d]=j(!1),f=A(void 0);return O(()=>()=>{f.current!=null&&clearTimeout(f.current)},[]),N(`span`,{"data-slot":`code-block-copy-button`,className:`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`,children:N(r,{type:`button`,appearance:`ghost`,size:`sm`,label:`Copy code`,icon:N(u?F:I,{}),className:e,ref:s,onClick:async e=>{try{if(a?.(e),e.defaultPrevented){f.current!=null&&clearTimeout(f.current);return}let n=c.current;await l(n),t?.(n),d(!0),f.current!=null&&clearTimeout(f.current),f.current=setTimeout(()=>{d(!1)},2e3)}catch(e){n?.(e)}},...o})})});J.displayName=`CodeBlockCopyButton`;const Y=T(({asChild:r=!1,className:i,onClick:a,...o},s)=>{let{codeId:c,isCodeExpanded:l,setIsCodeExpanded:u,setHasCodeExpander:d}=B();return O(()=>(d(!0),()=>{d(!1)}),[d]),P(r?n:`button`,{...o,"data-slot":`code-block-expander-button`,"aria-controls":c,"aria-expanded":l,className:e(`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`,i),ref:s,type:`button`,onClick:e=>{u(e=>!e),a?.(e)},children:[l?`Show less`:`Show more`,` `,N(t,{svg:N(C,{weight:`bold`}),className:e(`size-4`,l&&`rotate-180`,`transition-all duration-150`)})]})});Y.displayName=`CodeBlockExpanderButton`;function X({className:e,preset:n,svg:r,...i}){let o=r;if(n!=null)switch(n){case`file`:o=N(L,{weight:`fill`});break;case`cli`:o=N(ne,{weight:`fill`});break;case`traffic-policy`:o=N(a,{});break}return N(t,{"data-slot":`code-block-icon`,className:e,svg:o,...i})}X.displayName=`CodeBlockIcon`;const Z=T(({className:t,...n},r)=>N(ie,{"data-slot":`code-block-tab-list`,className:e(`flex items-center gap-1`,t),ref:r,...n}));Z.displayName=`CodeBlockTabList`;const Q=T(({className:t,...n},r)=>N(oe,{"data-slot":`code-block-tab-trigger`,className:e(`cursor-pointer rounded px-1.5 py-0.5 text-xs font-medium`,`text-gray-600 outline-hidden`,`hover:text-gray-900`,`data-[state=active]:bg-neutral-500/15 data-[state=active]:text-strong`,`focus-visible:ring-focus-accent focus-visible:ring-4`,t),ref:r,...n}));Q.displayName=`CodeBlockTabTrigger`;const $=T((e,t)=>N(re,{"data-slot":`code-block-tab-content`,ref:t,...e}));$.displayName=`CodeBlockTabContent`;const fe={Root:V,Body:H,Code:G,CopyButton:J,ExpanderButton:Y,Header:K,Icon:X,TabContent:$,TabList:Z,TabTrigger:Q,Title:q};function pe(e,t){let n=1;if(n>t)return!0;for(let r=0;r<e.length;r++)if(e[r]===`
2
- `&&(n+=1,n>t))return!0;return!1}export{fe as CodeBlock,u as createMantleCodeBlockValue,d as decorateHighlightedHtml,b as defaultMeta,R as escapeHtml,pe as hasMoreThanNLines,_ as inferIndentation,m as isIndentation,p as isSupportedLanguage,S as mantleCode,l as normalizeIndentation,h as normalizeValue,g as parseCodeBlockHighlightLines,y as parseCodeBlockLineNumberStart,s as parseCodeBlockShowLineNumbers,x as parseLanguage,v as parseMetastring,f as resolvePreRenderedCodeBlockProps,c as supportedLanguages,o as tokenizeMetastring};
1
+ import{t as e}from"./cx-D1HYnpvA.js";import{t}from"./icon-bWc5yC3-.js";import{t as n}from"./slot-D_ZUrdEW.js";import{t as r}from"./icon-button-ZKN0sRIJ.js";import{t as i}from"./compose-refs-DZ3cPi47.js";import{t as a}from"./use-copy-to-clipboard-C7vsjJe-.js";import{t as o}from"./traffic-policy-file-C6LHYrIU.js";import{S as s,_ as c,a as l,b as u,c as d,d as f,f as p,g as m,h,i as g,l as _,m as v,n as y,o as b,p as x,r as ee,s as S,t as C,u as w,v as T,y as E}from"./resolve-pre-rendered-props-Bqg41IkV.js";import{CaretDownIcon as D}from"@phosphor-icons/react/CaretDown";import{createContext as O,forwardRef as k,useCallback as A,useContext as te,useEffect as j,useId as ne,useLayoutEffect as re,useMemo as M,useRef as N,useState as P}from"react";import F from"tiny-invariant";import{jsx as I,jsxs as ie}from"react/jsx-runtime";import{CheckIcon as ae}from"@phosphor-icons/react/Check";import{CopyIcon as oe}from"@phosphor-icons/react/Copy";import{FileTextIcon as se}from"@phosphor-icons/react/FileText";import{TerminalIcon as ce}from"@phosphor-icons/react/Terminal";import{Content as le,List as ue,Root as de,Trigger as fe}from"@radix-ui/react-tabs";function L(e){let t=-1;for(let n=0;n<e.length;n++){let r=e[n];if(r===`&`||r===`<`||r===`>`||r===`"`||r===`'`){t=n;break}}if(t===-1)return e;let n=e.slice(0,t);for(let r=t;r<e.length;r++){let t=e[r];switch(t){case`&`:n+=`&amp;`;break;case`<`:n+=`&lt;`;break;case`>`:n+=`&gt;`;break;case`"`:n+=`&quot;`;break;case`'`:n+=`&#39;`;break;default:n+=t}}return n}const R=new WeakMap;function z(e){let t=new Set;if(e==null||e===``)return t;for(let n of e.split(` `))n!==``&&t.add(n);return t}function pe(e){let t=R.get(e);if(t!=null&&ge(t))return t;let n=new Map,r=new WeakMap,i=e.querySelectorAll(`[data-fold-regions]`);for(let e=0;e<i.length;e+=1){let t=i[e];if(!(t instanceof HTMLElement))continue;let a=z(t.dataset.foldRegions);if(a.size!==0){r.set(t,a);for(let e of a){let r=n.get(e);r??(r=[],n.set(e,r)),r.push(t)}}}let a={regionToLines:n,lineToRegions:r};return R.set(e,a),a}function me(e){R.delete(e)}function he(e){me(e),e.removeAttribute(`data-folded-regions`)}function ge(e){for(let t of e.regionToLines.values()){if(t.length===0)continue;let e=t[0];if(e!=null)return e.isConnected}return!0}function _e(e,t,n){let r=!1;for(let e of n)if(t.has(e)){r=!0;break}r?e.dataset.foldHidden=`true`:delete e.dataset.foldHidden}function ve(e){let t=e.dataset.foldLine;if(t==null||t===``)return!1;let n=e.closest(`[data-slot='code-block-code']`)?.querySelector(`code`);if(n==null)return!1;let r=z(n.getAttribute(`data-folded-regions`)),i=!r.has(t);i?r.add(t):r.delete(t),r.size===0?n.removeAttribute(`data-folded-regions`):n.setAttribute(`data-folded-regions`,[...r].join(` `)),e.setAttribute(`aria-expanded`,i?`false`:`true`);let{regionToLines:a,lineToRegions:o}=pe(n),s=a.get(t);if(s!=null)for(let e of s){let t=o.get(e);t!=null&&_e(e,r,t)}return!0}function ye(e){let t=e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`.mantle-code-fold-toggle`);n instanceof HTMLButtonElement&&ve(n)};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}}const B=O(null);function V(){let e=te(B);return F(e!=null,`CodeBlock subcomponents must be rendered within a <CodeBlock.Root>.`),e}const H=k(({asChild:t=!1,className:r,defaultTab:i,activeTab:a,onActiveTabChange:o,...s},c)=>{let l=N(``),[u,d]=P(!1),[f,p]=P(!1),[m,h]=P(void 0),g=A(e=>{h(t=>(F(t==null,`You can only render a single CodeBlock.Code within a CodeBlock.`),e))},[]),_=A(e=>{h(t=>{F(t===e,`You can only render a single CodeBlock.Code within a CodeBlock.`)})},[]),v=M(()=>({codeId:m,copyTextRef:l,hasCodeExpander:u,isCodeExpanded:f,registerCodeId:g,setHasCodeExpander:d,setIsCodeExpanded:p,unregisterCodeId:_}),[m,u,f,g,_]),y=i!=null||a!=null,b=I(t?n:`div`,{"data-slot":`code-block`,className:e(`text-mono w-full overflow-hidden rounded-md border border-gray-300 bg-card font-mono`,`[&_svg]:shrink-0`,r),ref:c,...s});return I(B.Provider,{value:v,children:y?I(de,{asChild:!0,defaultValue:i,value:a,onValueChange:o,children:b}):b})});H.displayName=`CodeBlock`;const U=k(({asChild:t=!1,className:r,...i},a)=>I(t?n:`div`,{"data-slot":`code-block-body`,className:e(`relative`,r),ref:a,...i}));U.displayName=`CodeBlockBody`;const be=/SHIKI_VAL_(\d+)/g;function xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const W=new Map;function Se(e){if(e==null||e.length===0)return be;let t=W.get(e);return t??(W.size>=500&&W.clear(),t=RegExp(`${xe(e)}(\\d+)__`,`g`),W.set(e,t)),t}function G(e,t,n,r){if(n==null){if(!e.includes(`SHIKI_VAL_`))return e}else if(!e.includes(n))return e;return e.replaceAll(Se(n),(e,n)=>{let i=Number.parseInt(n,10);return Number.isNaN(i)||i<0||i>=t.length?e:r(t[i])})}function Ce(e,t,n){return G(e,t,n,e=>L(String(e)))}function we(e,t,n){return G(e,t,n,e=>String(e))}const K=k(({className:t,style:n,tabIndex:r,value:a,...o},s)=>{let c=ne(),l=N(null),{copyTextRef:u,hasCodeExpander:d,isCodeExpanded:f,registerCodeId:p,unregisterCodeId:m}=V(),{language:h,code:g,"~preValToken":_,"~preVals":v,"~highlightLines":y,"~lineNumberStart":b,"~preHtml":x,"~showLineNumbers":ee}=a,S=y,C=b??1,w=ee??!1,T=M(()=>v!=null&&v.length>0?we(g,v,_):g,[_,v,g]);re(()=>{u.current=T},[u,T]),j(()=>(p(c),()=>{m(c)}),[c,p,m]);let E=M(()=>{if(x!=null)return v!=null&&v.length>0?Ce(x,v,_):x},[x,_,v]);j(()=>{let e=l.current;if(e==null)return;let t=e.querySelector(`code`);return t!=null&&he(t),ye(e)},[E]);let D=E!=null,O=E??L(T),k=M(()=>({__html:O}),[O]);return I(`pre`,{"data-slot":`code-block-code`,"aria-expanded":d?f:void 0,className:e(`scrollbar overflow-x-auto overflow-y-hidden py-4`,!D&&`pr-14`,`data-[mantle-line-numbers~='false']:pl-4`,`text-mono m-0 font-mono`,`aria-collapsed:max-h-[13.6rem]`,t),"data-highlighted":D?`true`:`false`,"data-lang":h,"data-mantle-highlight-lines":D&&S!=null&&S.length>0?S.join(`,`):void 0,"data-mantle-line-number-start":D&&w?String(C):`1`,"data-mantle-line-numbers":D&&w?`true`:`false`,id:c,ref:i(l,s),style:{...n,"--mantle-line-number-start":String(C),tabSize:2,MozTabSize:2},tabIndex:r??-1,...o,children:I(`code`,{className:`text-size-inherit block min-w-full w-max`,dangerouslySetInnerHTML:k})})});K.displayName=`CodeBlockCode`;const q=k(({asChild:t=!1,className:r,...i},a)=>I(t?n:`div`,{"data-slot":`code-block-header`,className:e(`flex items-center gap-1 border-b border-gray-300 bg-base px-4 py-2 text-gray-700`,r),ref:a,...i}));q.displayName=`CodeBlockHeader`;const J=k(({asChild:t=!1,className:r,...i},a)=>I(t?n:`h3`,{"data-slot":`code-block-title`,ref:a,className:e(`text-mono m-0 font-mono font-normal`,r),...i}));J.displayName=`CodeBlockTitle`;const Y=k(({className:e,onCopy:t,onCopyError:n,onClick:i,...o},s)=>{let{copyTextRef:c}=V(),l=a(),[u,d]=P(!1),f=N(void 0);return j(()=>()=>{f.current!=null&&clearTimeout(f.current)},[]),I(`span`,{"data-slot":`code-block-copy-button`,className:`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`,children:I(r,{type:`button`,appearance:`ghost`,size:`sm`,label:`Copy code`,icon:I(u?ae:oe,{}),className:e,ref:s,onClick:async e=>{try{if(i?.(e),e.defaultPrevented){f.current!=null&&clearTimeout(f.current);return}let n=c.current;await l(n),t?.(n),d(!0),f.current!=null&&clearTimeout(f.current),f.current=setTimeout(()=>{d(!1)},2e3)}catch(e){n?.(e)}},...o})})});Y.displayName=`CodeBlockCopyButton`;const X=k(({asChild:r=!1,className:i,onClick:a,...o},s)=>{let{codeId:c,isCodeExpanded:l,setIsCodeExpanded:u,setHasCodeExpander:d}=V();return j(()=>(d(!0),()=>{d(!1)}),[d]),ie(r?n:`button`,{...o,"data-slot":`code-block-expander-button`,"aria-controls":c,"aria-expanded":l,className:e(`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`,i),ref:s,type:`button`,onClick:e=>{u(e=>!e),a?.(e)},children:[l?`Show less`:`Show more`,` `,I(t,{svg:I(D,{weight:`bold`}),className:e(`size-4`,l&&`rotate-180`,`transition-all duration-150`)})]})});X.displayName=`CodeBlockExpanderButton`;function Z({className:e,preset:n,svg:r,...i}){let a=r;if(n!=null)switch(n){case`file`:a=I(se,{weight:`fill`});break;case`cli`:a=I(ce,{weight:`fill`});break;case`traffic-policy`:a=I(o,{});break}return I(t,{"data-slot":`code-block-icon`,className:e,svg:a,...i})}Z.displayName=`CodeBlockIcon`;const Q=k(({className:t,...n},r)=>I(ue,{"data-slot":`code-block-tab-list`,className:e(`flex items-center gap-1`,t),ref:r,...n}));Q.displayName=`CodeBlockTabList`;const Te=k(({className:t,...n},r)=>I(fe,{"data-slot":`code-block-tab-trigger`,className:e(`cursor-pointer rounded px-1.5 py-0.5 text-xs font-medium`,`text-gray-600 outline-hidden`,`hover:text-gray-900`,`data-[state=active]:bg-neutral-500/15 data-[state=active]:text-strong`,`focus-visible:ring-focus-accent focus-visible:ring-4`,t),ref:r,...n}));Te.displayName=`CodeBlockTabTrigger`;const $=k((e,t)=>I(le,{"data-slot":`code-block-tab-content`,ref:t,...e}));$.displayName=`CodeBlockTabContent`;const Ee={Root:H,Body:U,Code:K,CopyButton:Y,ExpanderButton:X,Header:q,Icon:Z,TabContent:$,TabList:Q,TabTrigger:Te,Title:J};function De(e,t){let n=1;if(n>t)return!0;for(let r=0;r<e.length;r++)if(e[r]===`
2
+ `&&(n+=1,n>t))return!0;return!1}export{Ee as CodeBlock,h as computeFoldRanges,c as computeJsonFoldRanges,u as createMantleCodeBlockValue,E as decorateHighlightedHtml,C as defaultMeta,L as escapeHtml,T as finalizeFoldRanges,m as foldStrategyFor,De as hasMoreThanNLines,x as inferIndentation,v as isIndentation,_ as isSupportedLanguage,s as mantleCode,p as normalizeIndentation,y as normalizeValue,b as parseCodeBlockHighlightLines,S as parseCodeBlockLineNumberStart,d as parseCodeBlockShowLineNumbers,w as parseLanguage,ee as parseMetastring,g as resolvePreRenderedCodeBlockProps,f as supportedLanguages,l as tokenizeMetastring};
3
3
  //# sourceMappingURL=code-block.js.map
@@ -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/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 * - \\& => `&amp;`;\n * - \\< => `&lt;`;\n * - \\> => `&gt;`;\n * - \\\" => `&quot;`;\n * - \\' => `&#39;`;\n *\n * @param {string} value The raw string to be escaped.\n *\n * @example\n * escapeHtml('<div>Hello & \"world\"</div>');\n * // Returns: '&lt;div&gt;Hello &amp; &quot;world&quot;&lt;/div&gt;'\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 += \"&amp;\";\n\t\t\t\tbreak;\n\t\t\tcase \"<\":\n\t\t\t\tescaped += \"&lt;\";\n\t\t\t\tbreak;\n\t\t\tcase \">\":\n\t\t\t\tescaped += \"&gt;\";\n\t\t\t\tbreak;\n\t\t\tcase '\"':\n\t\t\t\tescaped += \"&quot;\";\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\t\tescaped += \"&#39;\";\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","\"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 { WithAsChild } from \"../../types/as-child.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 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, tabIndex, value, ...props }, ref) => {\n\t\tconst id = useId();\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\tconst isPreRendered = renderedHtml != null;\n\t\tconst displayHtml = renderedHtml ?? escapeHtml(copyText);\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\",\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={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\ttabIndex={tabIndex ?? -1}\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={{ __html: displayHtml }}\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\t/**\n\t * Callback fired when the copy button is clicked, passes the copied text as an argument.\n\t */\n\tonCopy?: (value: string) => void;\n\t/**\n\t * Callback fired when an error occurs during copying.\n\t */\n\tonCopyError?: (error: unknown) => void;\n};\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, 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=\"Copy code\"\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":"gjCAmBA,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,OA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,CAEH,CACD,EAAQ,YAAc,mBAgBtB,MAAM,EAAa,GACjB,CAAE,YAAW,GAAG,GAAS,IACzB,EAACC,GAAD,CACC,YAAU,yBACV,UAAW,EACV,2DACA,+BACA,sBACA,wEACA,uDACA,EACA,CACI,MACL,GAAI,EACH,CAAA,CAEH,CACD,EAAW,YAAc,sBAyBzB,MAAM,EAAa,GACjB,EAAO,IAAQ,EAACC,GAAD,CAAkB,YAAU,yBAA8B,MAAK,GAAI,EAAS,CAAA,CAC5F,CACD,EAAW,YAAc,sBAiEzB,MAAM,GAAY,CAmBjB,KAAA,EAmBA,OAmBA,OAmBA,aAmBA,iBAmBA,SAmBA,KAAM,EAyBN,aAyBA,UAyBA,aAmBA,QACA,CChlCD,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"}
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 * - \\& => `&amp;`;\n * - \\< => `&lt;`;\n * - \\> => `&gt;`;\n * - \\\" => `&quot;`;\n * - \\' => `&#39;`;\n *\n * @param {string} value The raw string to be escaped.\n *\n * @example\n * escapeHtml('<div>Hello & \"world\"</div>');\n * // Returns: '&lt;div&gt;Hello &amp; &quot;world&quot;&lt;/div&gt;'\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 += \"&amp;\";\n\t\t\t\tbreak;\n\t\t\tcase \"<\":\n\t\t\t\tescaped += \"&lt;\";\n\t\t\t\tbreak;\n\t\t\tcase \">\":\n\t\t\t\tescaped += \"&gt;\";\n\t\t\t\tbreak;\n\t\t\tcase '\"':\n\t\t\t\tescaped += \"&quot;\";\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\t\tescaped += \"&#39;\";\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 { 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, tabIndex, 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\",\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\ttabIndex={tabIndex ?? -1}\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\t/**\n\t * Callback fired when the copy button is clicked, passes the copied text as an argument.\n\t */\n\tonCopy?: (value: string) => void;\n\t/**\n\t * Callback fired when an error occurs during copying.\n\t */\n\tonCopyError?: (error: unknown) => void;\n};\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, 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=\"Copy code\"\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":"ioCAmBA,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,OAIF,GAAI,IAA0B,GAC7B,OAAO,EAGR,IAAI,EAAU,EAAM,MAAM,EAAG,EAAsB,CACnD,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,GAGd,OAAO,EChCR,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,IAAI,CAC9B,IAAS,IACZ,EAAI,IAAI,EAAK,CAGf,OAAO,EAYR,SAAS,GAAgB,EAAoC,CAC5D,IAAM,EAAS,EAAoB,IAAI,EAAY,CACnD,GAAI,GAAU,MAAQ,GAAoB,EAAO,CAChD,OAAO,EAER,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AAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IACjC,GAAI,EAAM,KAAO;IAChB,GAAS,EACL,EAAQ,GACX,MAAO,GAIV,MAAO"}
@@ -1,2 +1,2 @@
1
- import { A as DecorateHighlightedHtmlInput, C as Indentation, D as isSupportedLanguage, E as SupportedLanguage, M as LineRange, O as parseLanguage, S as normalizeIndentation, T as isIndentation, b as defaultShowLineNumbers, g as parseCodeBlockShowLineNumbers, h as parseCodeBlockLineNumberStart, j as decorateHighlightedHtml, k as supportedLanguages, m as parseCodeBlockHighlightLines, p as tokenizeMetastring, u as normalizeValue, w as inferIndentation } from "./resolve-pre-rendered-props-CNUnH1fU.js";
2
- export { type DecorateHighlightedHtmlInput, type Indentation, type LineRange, type SupportedLanguage, decorateHighlightedHtml, defaultShowLineNumbers, inferIndentation, isIndentation, isSupportedLanguage, normalizeIndentation, normalizeValue, parseCodeBlockHighlightLines, parseCodeBlockLineNumberStart, parseCodeBlockShowLineNumbers, parseLanguage, supportedLanguages, tokenizeMetastring };
1
+ import { A as FoldStrategy, B as computeJsonFoldRanges, C as Indentation, D as FoldExplanation, E as ComputeFoldRangesInput, F as isSupportedLanguage, H as finalizeFoldRanges, I as parseLanguage, L as supportedLanguages, M as computeFoldRanges, N as foldStrategyFor, O as FoldLine, P as SupportedLanguage, R as DecorateHighlightedHtmlInput, S as normalizeIndentation, T as isIndentation, U as LineRange, V as FoldableRange, b as defaultShowLineNumbers, g as parseCodeBlockShowLineNumbers, h as parseCodeBlockLineNumberStart, j as FoldToken, k as FoldScope, m as parseCodeBlockHighlightLines, p as tokenizeMetastring, u as normalizeValue, w as inferIndentation, z as decorateHighlightedHtml } from "./resolve-pre-rendered-props-CdqAcY5m.js";
2
+ export { type ComputeFoldRangesInput, type DecorateHighlightedHtmlInput, type FoldExplanation, type FoldLine, type FoldScope, type FoldStrategy, type FoldToken, type FoldableRange, type Indentation, type LineRange, type SupportedLanguage, computeFoldRanges, computeJsonFoldRanges, decorateHighlightedHtml, defaultShowLineNumbers, finalizeFoldRanges, foldStrategyFor, inferIndentation, isIndentation, isSupportedLanguage, normalizeIndentation, normalizeValue, parseCodeBlockHighlightLines, parseCodeBlockLineNumberStart, parseCodeBlockShowLineNumbers, parseLanguage, supportedLanguages, tokenizeMetastring };
@@ -1 +1 @@
1
- import{_ as e,a as t,c as n,d as r,f as i,h as a,l as o,m as s,n as c,o as l,p as u,s as d,u as f}from"./resolve-pre-rendered-props-C-kiaLHj.js";export{a as decorateHighlightedHtml,e as defaultShowLineNumbers,u as inferIndentation,s as isIndentation,o as isSupportedLanguage,i as normalizeIndentation,c as normalizeValue,l as parseCodeBlockHighlightLines,d as parseCodeBlockLineNumberStart,n as parseCodeBlockShowLineNumbers,f as parseLanguage,r as supportedLanguages,t as tokenizeMetastring};
1
+ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,l as s,m as c,n as l,o as u,p as d,s as f,u as p,v as m,x as h,y as g}from"./resolve-pre-rendered-props-Bqg41IkV.js";export{o as computeFoldRanges,e as computeJsonFoldRanges,g as decorateHighlightedHtml,h as defaultShowLineNumbers,m as finalizeFoldRanges,a as foldStrategyFor,d as inferIndentation,c as isIndentation,s as isSupportedLanguage,i as normalizeIndentation,l as normalizeValue,u as parseCodeBlockHighlightLines,f as parseCodeBlockLineNumberStart,n as parseCodeBlockShowLineNumbers,p as parseLanguage,r as supportedLanguages,t as tokenizeMetastring};
package/dist/command.d.ts CHANGED
@@ -330,7 +330,7 @@ declare const Command: {
330
330
  ref?: React.Ref<HTMLInputElement>;
331
331
  } & {
332
332
  asChild?: boolean;
333
- }, "key" | keyof _$react.InputHTMLAttributes<HTMLInputElement> | "asChild">, "value" | "onChange" | "type"> & {
333
+ }, "key" | "asChild" | keyof _$react.InputHTMLAttributes<HTMLInputElement>>, "onChange" | "type" | "value"> & {
334
334
  value?: string;
335
335
  onValueChange?: (search: string) => void;
336
336
  } & _$react.RefAttributes<HTMLInputElement>, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
@@ -495,7 +495,7 @@ declare const Command: {
495
495
  ref?: React.Ref<HTMLDivElement>;
496
496
  } & {
497
497
  asChild?: boolean;
498
- }, "key" | keyof _$react.HTMLAttributes<HTMLDivElement> | "asChild">, "disabled" | "value" | "onSelect"> & {
498
+ }, "key" | keyof _$react.HTMLAttributes<HTMLDivElement> | "asChild">, "disabled" | "onSelect" | "value"> & {
499
499
  disabled?: boolean;
500
500
  onSelect?: (value: string) => void;
501
501
  value?: string;
@@ -1,4 +1,4 @@
1
- import { t as Button } from "./button-Bq0x5Pv4.js";
1
+ import { t as Button } from "./button-BMgAxAwM.js";
2
2
  import { s as SortingMode } from "./direction-DtBAQn7p.js";
3
3
  import { t as Table$1 } from "./table-BsNJBKiq.js";
4
4
  import * as _$react from "react";
package/dist/hooks.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as MarginType, o as useComposedRefs, s as copyToClipboard } from "./in-view-Da08Bx6l.js";
2
- import { RefObject, useLayoutEffect } from "react";
2
+ import { RefObject, useEffect } from "react";
3
3
 
4
4
  //#region src/hooks/use-breakpoint.d.ts
5
5
  /**
@@ -282,7 +282,7 @@ declare function useIsHydrated(): boolean;
282
282
  *
283
283
  * return <div ref={ref}>Width: {width}</div>;
284
284
  */
285
- declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
285
+ declare const useIsomorphicLayoutEffect: typeof useEffect;
286
286
  //#endregion
287
287
  //#region src/hooks/use-matches-media-query.d.ts
288
288
  /**