@ngrok/mantle 0.67.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion.d.ts +9 -9
- package/dist/alert-dialog.d.ts +31 -31
- package/dist/alert-dialog.js +1 -1
- package/dist/alert.d.ts +10 -10
- package/dist/alert.js +1 -1
- package/dist/alert.js.map +1 -1
- package/dist/anchor.d.ts +2 -2
- package/dist/badge.d.ts +3 -3
- package/dist/badge.js +1 -1
- package/dist/badge.js.map +1 -1
- package/dist/button-BKykcpgJ.js +2 -0
- package/dist/button-BKykcpgJ.js.map +1 -0
- package/dist/{button-B--2eT25.d.ts → button-BaNwe1ud.d.ts} +13 -13
- package/dist/button.d.ts +3 -3
- package/dist/button.js +1 -1
- package/dist/calendar.d.ts +2 -2
- package/dist/calendar.js +1 -1
- package/dist/card.d.ts +6 -6
- package/dist/checkbox.d.ts +3 -3
- package/dist/checkbox.js +1 -1
- package/dist/checkbox.js.map +1 -1
- package/dist/code-block.d.ts +15 -15
- package/dist/code-block.js +2 -2
- package/dist/code-block.js.map +1 -1
- package/dist/code.d.ts +2 -2
- package/dist/code.js +1 -1
- package/dist/code.js.map +1 -1
- package/dist/color.d.ts +1 -1
- package/dist/color.js +1 -1
- package/dist/color.js.map +1 -1
- package/dist/combobox.d.ts +11 -11
- package/dist/combobox.js +1 -1
- package/dist/combobox.js.map +1 -1
- package/dist/command.d.ts +33 -33
- package/dist/command.js +1 -1
- package/dist/command.js.map +1 -1
- package/dist/data-table.d.ts +14 -14
- package/dist/data-table.js +1 -1
- package/dist/data-table.js.map +1 -1
- package/dist/description-list.d.ts +5 -5
- package/dist/description-list.js +1 -1
- package/dist/description-list.js.map +1 -1
- package/dist/{dialog-PqWYibMO.js → dialog-DxkpMIzB.js} +2 -2
- package/dist/{dialog-PqWYibMO.js.map → dialog-DxkpMIzB.js.map} +1 -1
- package/dist/dialog.d.ts +17 -17
- package/dist/dialog.js +1 -1
- package/dist/{direction-C_bMxZXm.d.ts → direction-MVSxfKWx.d.ts} +2 -2
- package/dist/{dropdown-menu-slQCdKvp.d.ts → dropdown-menu-D6MiVSR-.d.ts} +23 -23
- package/dist/dropdown-menu.d.ts +1 -1
- package/dist/flag.d.ts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/hover-card.d.ts +6 -6
- package/dist/{icon-BkSBkfH9.d.ts → icon-Dh1ONyO_.d.ts} +3 -3
- package/dist/icon-button-CxxVPiKp.js +2 -0
- package/dist/icon-button-CxxVPiKp.js.map +1 -0
- package/dist/{icon-button-DMNdrMSf.d.ts → icon-button-gO-7F_MZ.d.ts} +6 -6
- package/dist/icon.d.ts +2 -2
- package/dist/icons.d.ts +8 -8
- package/dist/{index-Cxmuw3UT.d.ts → index-Bw97R9Kw.d.ts} +8 -8
- package/dist/{index-C0yxjFyf.d.ts → index-C3IiAC5H.d.ts} +3 -3
- package/dist/{index-CI-RDnHZ.d.ts → index-Cj2NX2Dg.d.ts} +5 -5
- package/dist/input.d.ts +1 -1
- package/dist/kbd.d.ts +2 -2
- package/dist/label.d.ts +3 -3
- package/dist/mantle-dark-high-contrast.css +18 -9
- package/dist/mantle-dark.css +37 -43
- package/dist/mantle-light-high-contrast.css +15 -9
- package/dist/mantle.css +108 -74
- package/dist/media-object.d.ts +4 -4
- package/dist/multi-select.d.ts +16 -16
- package/dist/pagination.d.ts +8 -8
- package/dist/pagination.js +1 -1
- package/dist/popover.d.ts +7 -7
- package/dist/{primitive-BmWrmUz1.d.ts → primitive-BqLYh79k.d.ts} +3 -3
- package/dist/progress.d.ts +5 -5
- package/dist/radio-group.d.ts +19 -19
- package/dist/radio-group.js +1 -1
- package/dist/radio-group.js.map +1 -1
- package/dist/sandboxed-on-click.d.ts +3 -3
- package/dist/{select-B3jxZhYg.d.ts → select-DJmjfGjt.d.ts} +14 -14
- package/dist/select.d.ts +1 -1
- package/dist/separator.d.ts +4 -4
- package/dist/sheet.d.ts +19 -19
- package/dist/sheet.js +1 -1
- package/dist/skeleton.d.ts +5 -5
- package/dist/slider.d.ts +2 -2
- package/dist/slider.js +1 -1
- package/dist/slider.js.map +1 -1
- package/dist/slot.d.ts +3 -3
- package/dist/split-button.d.ts +20 -20
- package/dist/split-button.js +1 -1
- package/dist/split-button.js.map +1 -1
- package/dist/{svg-only-BH9PBSGl.d.ts → svg-only-Db3eUPWM.d.ts} +3 -3
- package/dist/switch.d.ts +4 -4
- package/dist/switch.js +1 -1
- package/dist/switch.js.map +1 -1
- package/dist/{table-CU7zx1pH.d.ts → table-C7BejaFW.d.ts} +11 -11
- package/dist/table-CnYWz6IT.js +2 -0
- package/dist/table-CnYWz6IT.js.map +1 -0
- package/dist/table.d.ts +1 -1
- package/dist/table.js +1 -1
- package/dist/tabs.d.ts +9 -9
- package/dist/tabs.js +1 -1
- package/dist/tabs.js.map +1 -1
- package/dist/text-area.d.ts +2 -2
- package/dist/theme.d.ts +6 -6
- package/dist/toast.d.ts +8 -8
- package/dist/tooltip.d.ts +6 -6
- package/dist/utils.d.ts +1 -1
- package/package.json +14 -14
- package/dist/button-CdPMhyKg.js +0 -2
- package/dist/button-CdPMhyKg.js.map +0 -1
- package/dist/icon-button-CeeHZOhh.js +0 -2
- package/dist/icon-button-CeeHZOhh.js.map +0 -1
- package/dist/table-OYhLMxeE.js +0 -2
- package/dist/table-OYhLMxeE.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { t as DeepNonNullable } from "./deep-non-nullable-BBByg3-i.js";
|
|
2
2
|
import { t as VariantProps$1 } from "./variant-props-Bm6Y-jfm.js";
|
|
3
|
-
import * as react from "react";
|
|
3
|
+
import * as _$react from "react";
|
|
4
4
|
import { ComponentProps, ReactNode } from "react";
|
|
5
|
-
import * as class_variance_authority0 from "class-variance-authority";
|
|
6
|
-
import * as class_variance_authority_types0 from "class-variance-authority/types";
|
|
5
|
+
import * as _$class_variance_authority0 from "class-variance-authority";
|
|
6
|
+
import * as _$class_variance_authority_types0 from "class-variance-authority/types";
|
|
7
7
|
|
|
8
8
|
//#region src/components/button/button.d.ts
|
|
9
9
|
declare const buttonVariants: (props?: ({
|
|
10
|
-
appearance?: "
|
|
10
|
+
appearance?: "filled" | "link" | "ghost" | "outlined" | null | undefined;
|
|
11
11
|
isLoading?: boolean | null | undefined;
|
|
12
12
|
priority?: "default" | "danger" | "neutral" | null | undefined;
|
|
13
|
-
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
13
|
+
} & _$class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
14
14
|
type ButtonVariants = VariantProps$1<typeof buttonVariants>;
|
|
15
15
|
/**
|
|
16
16
|
* The props for the `Button` component.
|
|
@@ -90,11 +90,11 @@ type ButtonProps = ComponentProps<"button"> & ButtonVariants & {
|
|
|
90
90
|
* </Button>
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
|
-
declare const Button: react.ForwardRefExoticComponent<(Omit<react.ClassAttributes<HTMLButtonElement> & react.ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<class_variance_authority0.VariantProps<(props?: ({
|
|
94
|
-
appearance?: "
|
|
93
|
+
declare const Button: _$react.ForwardRefExoticComponent<(Omit<_$react.ClassAttributes<HTMLButtonElement> & _$react.ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<_$class_variance_authority0.VariantProps<(props?: ({
|
|
94
|
+
appearance?: "filled" | "link" | "ghost" | "outlined" | null | undefined;
|
|
95
95
|
isLoading?: boolean | null | undefined;
|
|
96
96
|
priority?: "default" | "danger" | "neutral" | null | undefined;
|
|
97
|
-
} & class_variance_authority_types0.ClassProp) | undefined) => string>>> & {
|
|
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
|
|
100
100
|
* the icon will automatically be replaced with a spinner.
|
|
@@ -136,11 +136,11 @@ declare const Button: react.ForwardRefExoticComponent<(Omit<react.ClassAttribute
|
|
|
136
136
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
137
137
|
*/
|
|
138
138
|
type?: ComponentProps<"button">["type"];
|
|
139
|
-
}, "ref"> | Omit<react.ClassAttributes<HTMLButtonElement> & react.ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<class_variance_authority0.VariantProps<(props?: ({
|
|
140
|
-
appearance?: "
|
|
139
|
+
}, "ref"> | Omit<_$react.ClassAttributes<HTMLButtonElement> & _$react.ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<_$class_variance_authority0.VariantProps<(props?: ({
|
|
140
|
+
appearance?: "filled" | "link" | "ghost" | "outlined" | null | undefined;
|
|
141
141
|
isLoading?: boolean | null | undefined;
|
|
142
142
|
priority?: "default" | "danger" | "neutral" | null | undefined;
|
|
143
|
-
} & class_variance_authority_types0.ClassProp) | undefined) => string>>> & {
|
|
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
|
|
146
146
|
* the icon will automatically be replaced with a spinner.
|
|
@@ -169,7 +169,7 @@ declare const Button: react.ForwardRefExoticComponent<(Omit<react.ClassAttribute
|
|
|
169
169
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
170
170
|
*/
|
|
171
171
|
type: Exclude<ComponentProps<"button">["type"], undefined>;
|
|
172
|
-
}, "ref">) & react.RefAttributes<HTMLButtonElement>>;
|
|
172
|
+
}, "ref">) & _$react.RefAttributes<HTMLButtonElement>>;
|
|
173
173
|
//#endregion
|
|
174
174
|
export { ButtonProps as n, Button as t };
|
|
175
|
-
//# sourceMappingURL=button-
|
|
175
|
+
//# sourceMappingURL=button-BaNwe1ud.d.ts.map
|
package/dist/button.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as IconButtonProps, t as IconButton } from "./icon-button-
|
|
2
|
-
import { n as ButtonProps, t as Button } from "./button-
|
|
3
|
-
import { n as ButtonGroupProps, t as ButtonGroup } from "./index-
|
|
1
|
+
import { n as IconButtonProps, t as IconButton } from "./icon-button-gO-7F_MZ.js";
|
|
2
|
+
import { n as ButtonProps, t as Button } from "./button-BaNwe1ud.js";
|
|
3
|
+
import { n as ButtonGroupProps, t as ButtonGroup } from "./index-Cj2NX2Dg.js";
|
|
4
4
|
export { Button, ButtonGroup, ButtonGroupProps, ButtonProps, IconButton, IconButtonProps };
|
package/dist/button.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./icon-button-
|
|
1
|
+
import{t as e}from"./icon-button-CxxVPiKp.js";import{t}from"./button-BKykcpgJ.js";import{t as n}from"./button-eAPtlsYO.js";export{t as Button,n as ButtonGroup,e as IconButton};
|
package/dist/calendar.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
import { DateRange, DayPicker } from "react-day-picker";
|
|
4
4
|
|
|
5
5
|
//#region src/components/calendar/calendar.d.ts
|
|
@@ -34,7 +34,7 @@ declare function Calendar({
|
|
|
34
34
|
classNames,
|
|
35
35
|
showOutsideDays,
|
|
36
36
|
...props
|
|
37
|
-
}: CalendarProps): react_jsx_runtime0.JSX.Element;
|
|
37
|
+
}: CalendarProps): _$react_jsx_runtime0.JSX.Element;
|
|
38
38
|
declare namespace Calendar {
|
|
39
39
|
var displayName: string;
|
|
40
40
|
}
|
package/dist/calendar.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./cx-D1HYnpvA.js";import{t}from"./icon-BMH0fD_b.js";import{n,r}from"./icon-button-
|
|
1
|
+
import{t as e}from"./cx-D1HYnpvA.js";import{t}from"./icon-BMH0fD_b.js";import{n,r}from"./icon-button-CxxVPiKp.js";import{jsx as i}from"react/jsx-runtime";import{CaretLeftIcon as a}from"@phosphor-icons/react/CaretLeft";import{CaretRightIcon as o}from"@phosphor-icons/react/CaretRight";import{DayPicker as s}from"react-day-picker";function c({className:c,classNames:l,showOutsideDays:u=!1,...d}){return i(s,{animate:!1,components:{Chevron:e=>i(t,{svg:e.orientation===`left`?i(a,{}):i(o,{}),className:`size-4`})},classNames:{root:e(`isolate`,c),button_next:e(n,r({appearance:`ghost`,size:`sm`}),`absolute right-0`),button_previous:e(n,r({appearance:`ghost`,size:`sm`}),`absolute left-0`),caption_label:`text-sm font-medium`,day:e(`overflow-hidden text-center text-sm p-0 relative focus-within:relative focus-within:z-20 size-7 rounded-md`,d.mode===`range`?`first:has-aria-selected:rounded-l-md last:has-aria-selected:rounded-r-md`:``),day_button:`day size-full rounded-md not-aria-selected:not-disabled:hover:bg-filled-accent/15`,disabled:`text-muted opacity-50`,hidden:`invisible`,month:`space-y-4`,month_caption:`flex justify-center pt-1 relative items-center`,month_grid:`w-full border-collapse space-y-1`,months:`flex flex-col sm:flex-row gap-y-4 sm:gap-x-4 sm:gap-y-0 relative max-w-min`,nav:`flex items-center absolute inset-x-0 top-1 h-5 justify-between z-10`,outside:`day-outside aria-selected:text-on-filled opacity-50 text-muted`,range_end:`day-range-end [&:not(.day-range-start)]:rounded-l-none`,range_middle:`day-range-middle not-disabled:aria-selected:bg-filled-accent/15 aria-selected:text-strong rounded-none not-disabled:aria-selected:hover:bg-filled-accent/25`,range_start:`day-range-start [&:not(.day-range-end)]:rounded-r-none`,selected:`not-disabled:bg-filled-accent text-on-filled not-disabled:hover:bg-filled-accent`,today:`not-aria-selected:not-disabled:text-accent-600 font-medium not-aria-selected:not-disabled:bg-filled-accent/10 rounded-md`,week:`flex w-full mt-1`,weekday:`text-body w-7 text-[0.8rem] text-center font-normal`,weekdays:`flex`,...l},showOutsideDays:u,...d})}c.displayName=`Calendar`;export{c as Calendar};
|
|
2
2
|
//# sourceMappingURL=calendar.js.map
|
package/dist/card.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as WithAsChild } from "./as-child-CRRsxi3Y.js";
|
|
2
|
-
import * as react from "react";
|
|
2
|
+
import * as _$react from "react";
|
|
3
3
|
import { ComponentProps, HTMLAttributes } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/components/card/card.d.ts
|
|
@@ -47,7 +47,7 @@ declare const Card: {
|
|
|
47
47
|
* </Card.Root>
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
readonly Root: react.ForwardRefExoticComponent<Omit<CardProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
50
|
+
readonly Root: _$react.ForwardRefExoticComponent<Omit<CardProps, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
51
51
|
/**
|
|
52
52
|
* The main content of a card.
|
|
53
53
|
*
|
|
@@ -62,7 +62,7 @@ declare const Card: {
|
|
|
62
62
|
* </Card.Root>
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
|
-
readonly Body: react.ForwardRefExoticComponent<Omit<CardProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
65
|
+
readonly Body: _$react.ForwardRefExoticComponent<Omit<CardProps, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
66
66
|
/**
|
|
67
67
|
* The footer container of a card.
|
|
68
68
|
*
|
|
@@ -83,7 +83,7 @@ declare const Card: {
|
|
|
83
83
|
* </Card.Root>
|
|
84
84
|
* ```
|
|
85
85
|
*/
|
|
86
|
-
readonly Footer: react.ForwardRefExoticComponent<Omit<CardProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
86
|
+
readonly Footer: _$react.ForwardRefExoticComponent<Omit<CardProps, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
87
87
|
/**
|
|
88
88
|
* The header container of a card.
|
|
89
89
|
*
|
|
@@ -104,7 +104,7 @@ declare const Card: {
|
|
|
104
104
|
* </Card.Root>
|
|
105
105
|
* ```
|
|
106
106
|
*/
|
|
107
|
-
readonly Header: react.ForwardRefExoticComponent<Omit<CardProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
107
|
+
readonly Header: _$react.ForwardRefExoticComponent<Omit<CardProps, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
108
108
|
/**
|
|
109
109
|
* The title of a card.
|
|
110
110
|
*
|
|
@@ -125,7 +125,7 @@ declare const Card: {
|
|
|
125
125
|
* </Card.Root>
|
|
126
126
|
* ```
|
|
127
127
|
*/
|
|
128
|
-
readonly Title: react.ForwardRefExoticComponent<HTMLAttributes<HTMLHeadingElement> & WithAsChild & react.RefAttributes<HTMLHeadingElement>>;
|
|
128
|
+
readonly Title: _$react.ForwardRefExoticComponent<HTMLAttributes<HTMLHeadingElement> & WithAsChild & _$react.RefAttributes<HTMLHeadingElement>>;
|
|
129
129
|
};
|
|
130
130
|
//#endregion
|
|
131
131
|
export { Card, type CardProps, type CardTitleProps };
|
package/dist/checkbox.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as WithValidation } from "./types-Cq6RWU7Q.js";
|
|
2
|
-
import * as react from "react";
|
|
2
|
+
import * as _$react from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/checkbox/checkbox.d.ts
|
|
5
5
|
type CheckedState = boolean | "indeterminate";
|
|
@@ -19,7 +19,7 @@ type CheckedState = boolean | "indeterminate";
|
|
|
19
19
|
* </form>
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
declare const Checkbox: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "defaultChecked" | "type" | "checked"> & WithValidation & {
|
|
22
|
+
declare const Checkbox: _$react.ForwardRefExoticComponent<Omit<Omit<_$react.DetailedHTMLProps<_$react.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "defaultChecked" | "type" | "checked"> & WithValidation & {
|
|
23
23
|
/**
|
|
24
24
|
* The controlled checked state of the checkbox. Must be used in conjunction with onChange.
|
|
25
25
|
*/
|
|
@@ -28,7 +28,7 @@ declare const Checkbox: react.ForwardRefExoticComponent<Omit<Omit<react.Detailed
|
|
|
28
28
|
* The checked state of the checkbox when it is initially rendered. Use when you do not need to control its checked state.
|
|
29
29
|
*/
|
|
30
30
|
defaultChecked?: CheckedState;
|
|
31
|
-
} & react.RefAttributes<HTMLInputElement>>;
|
|
31
|
+
} & _$react.RefAttributes<HTMLInputElement>>;
|
|
32
32
|
//#endregion
|
|
33
33
|
export { Checkbox };
|
|
34
34
|
//# sourceMappingURL=checkbox.d.ts.map
|
package/dist/checkbox.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./compose-refs-DeIsFv68.js";import{forwardRef as t,useEffect as n,useRef as r,useState as i}from"react";import a from"clsx";import{jsx as o}from"react/jsx-runtime";const s=e=>e===`indeterminate`,c=t(({"aria-invalid":t,className:c,checked:l,defaultChecked:u,defaultValue:d=`on`,onClick:f,readOnly:p,validation:m,...h},g)=>{let _=r(null),[v]=i(u),y=t!=null&&t!==`false`?`error`:typeof m==`function`?m():m,b=t??y===`error`;return n(()=>{_.current&&(_.current.indeterminate=s(l))},[l]),n(()=>{_.current&&(_.current.indeterminate=s(v))},[v]),o(`input`,{"aria-checked":s(l)?`mixed`:l,"aria-invalid":b,className:a(`border-form bg-form shrink-0 cursor-pointer select-none appearance-none rounded border disabled:cursor-default disabled:opacity-50`,`bg-center bg-no-repeat focus:outline-hidden`,`focus-visible:border-accent-600 focus-visible:ring-focus-accent focus-visible:outline-hidden focus-visible:ring-4`,`checked:border-accent-
|
|
1
|
+
import{t as e}from"./compose-refs-DeIsFv68.js";import{forwardRef as t,useEffect as n,useRef as r,useState as i}from"react";import a from"clsx";import{jsx as o}from"react/jsx-runtime";const s=e=>e===`indeterminate`,c=t(({"aria-invalid":t,className:c,checked:l,defaultChecked:u,defaultValue:d=`on`,onClick:f,readOnly:p,validation:m,...h},g)=>{let _=r(null),[v]=i(u),y=t!=null&&t!==`false`?`error`:typeof m==`function`?m():m,b=t??y===`error`;return n(()=>{_.current&&(_.current.indeterminate=s(l))},[l]),n(()=>{_.current&&(_.current.indeterminate=s(v))},[v]),o(`input`,{"aria-checked":s(l)?`mixed`:l,"aria-invalid":b,className:a(`border-form bg-form shrink-0 cursor-pointer select-none appearance-none rounded border disabled:cursor-default disabled:opacity-50`,`bg-center bg-no-repeat focus:outline-hidden`,`focus-visible:border-accent-600 focus-visible:ring-focus-accent focus-visible:outline-hidden focus-visible:ring-4`,`checked:border-accent-600 checked:bg-accent-600 checked:bg-checked-icon`,`indeterminate:border-accent-600 indeterminate:bg-accent-600 indeterminate:bg-indeterminate-icon`,`data-validation-success:border-success-600 data-validation-success:checked:bg-success-600 data-validation-success:indeterminate:bg-success-600 focus-visible:data-validation-success:border-success-600 focus-visible:data-validation-success:ring-focus-success`,`data-validation-warning:border-warning-600 data-validation-warning:checked:bg-warning-600 data-validation-warning:indeterminate:bg-warning-600 focus-visible:data-validation-warning:border-warning-600 focus-visible:data-validation-warning:ring-focus-warning`,`data-validation-error:border-danger-600 data-validation-error:checked:bg-danger-600 data-validation-error:indeterminate:bg-danger-600 focus-visible:data-validation-error:border-danger-600 focus-visible:data-validation-error:ring-focus-danger`,`where:block where:size-4 where:p-0`,c),checked:s(l)?void 0:l,"data-validation":y||void 0,defaultChecked:s(v)?void 0:v,defaultValue:d,onClick:e=>{if(p){e.preventDefault();return}f?.(e)},readOnly:p,ref:e(_,g),type:`checkbox`,...h})});c.displayName=`Checkbox`;export{c as Checkbox};
|
|
2
2
|
//# sourceMappingURL=checkbox.js.map
|
package/dist/checkbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","names":["clsx"],"sources":["../src/components/checkbox/checkbox.tsx"],"sourcesContent":["\"use client\";\n\nimport clsx from \"clsx\";\nimport { forwardRef, useEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ComponentRef } from \"react\";\nimport { composeRefs } from \"../../utils/compose-refs/index.js\";\nimport type { WithValidation } from \"../input/index.js\";\n\ntype CheckedState = boolean | \"indeterminate\";\n\nconst isIndeterminate = (checked: CheckedState | undefined): checked is \"indeterminate\" =>\n\tchecked === \"indeterminate\";\n\ntype Props = Omit<ComponentPropsWithoutRef<\"input\">, \"type\" | \"checked\" | \"defaultChecked\"> &\n\tWithValidation & {\n\t\t/**\n\t\t * The controlled checked state of the checkbox. Must be used in conjunction with onChange.\n\t\t */\n\t\tchecked?: CheckedState;\n\t\t/**\n\t\t * The checked state of the checkbox when it is initially rendered. Use when you do not need to control its checked state.\n\t\t */\n\t\tdefaultChecked?: CheckedState;\n\t};\n\n/**\n * A form control that allows the user to toggle between checked and not checked.\n * Supports indeterminate state.\n *\n * @see https://mantle.ngrok.com/components/checkbox\n *\n * @example\n * ```tsx\n * <form>\n * <Label htmlFor=\"terms\" className=\"flex items-center gap-2\">\n * <Checkbox name=\"terms\" id=\"terms\" />\n * Accept terms and conditions\n * </Label>\n * </form>\n * ```\n */\nconst Checkbox = forwardRef<ComponentRef<\"input\">, Props>(\n\t(\n\t\t{\n\t\t\t\"aria-invalid\": _ariaInvalid,\n\t\t\tclassName,\n\t\t\tchecked: _checked,\n\t\t\tdefaultChecked: _defaultChecked,\n\t\t\tdefaultValue = \"on\",\n\t\t\tonClick,\n\t\t\treadOnly,\n\t\t\tvalidation: _validation,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst innerRef = useRef<ComponentRef<\"input\">>(null);\n\t\tconst [defaultChecked] = useState(_defaultChecked);\n\t\tconst isInvalid = _ariaInvalid != null && _ariaInvalid !== \"false\";\n\t\tconst validation = isInvalid\n\t\t\t? \"error\"\n\t\t\t: typeof _validation === \"function\"\n\t\t\t\t? _validation()\n\t\t\t\t: _validation;\n\t\tconst ariaInvalid = _ariaInvalid ?? validation === \"error\";\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef.current) {\n\t\t\t\tinnerRef.current.indeterminate = isIndeterminate(_checked);\n\t\t\t}\n\t\t}, [_checked]);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef.current) {\n\t\t\t\tinnerRef.current.indeterminate = isIndeterminate(defaultChecked);\n\t\t\t}\n\t\t}, [defaultChecked]);\n\n\t\treturn (\n\t\t\t<input\n\t\t\t\taria-checked={isIndeterminate(_checked) ? \"mixed\" : _checked}\n\t\t\t\taria-invalid={ariaInvalid}\n\t\t\t\tclassName={clsx(\n\t\t\t\t\t\"border-form bg-form shrink-0 cursor-pointer select-none appearance-none rounded border disabled:cursor-default disabled:opacity-50\",\n\t\t\t\t\t\"bg-center bg-no-repeat focus:outline-hidden\",\n\t\t\t\t\t\"focus-visible:border-accent-600 focus-visible:ring-focus-accent focus-visible:outline-hidden focus-visible:ring-4\",\n\t\t\t\t\t\"checked:border-accent-
|
|
1
|
+
{"version":3,"file":"checkbox.js","names":["clsx"],"sources":["../src/components/checkbox/checkbox.tsx"],"sourcesContent":["\"use client\";\n\nimport clsx from \"clsx\";\nimport { forwardRef, useEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ComponentRef } from \"react\";\nimport { composeRefs } from \"../../utils/compose-refs/index.js\";\nimport type { WithValidation } from \"../input/index.js\";\n\ntype CheckedState = boolean | \"indeterminate\";\n\nconst isIndeterminate = (checked: CheckedState | undefined): checked is \"indeterminate\" =>\n\tchecked === \"indeterminate\";\n\ntype Props = Omit<ComponentPropsWithoutRef<\"input\">, \"type\" | \"checked\" | \"defaultChecked\"> &\n\tWithValidation & {\n\t\t/**\n\t\t * The controlled checked state of the checkbox. Must be used in conjunction with onChange.\n\t\t */\n\t\tchecked?: CheckedState;\n\t\t/**\n\t\t * The checked state of the checkbox when it is initially rendered. Use when you do not need to control its checked state.\n\t\t */\n\t\tdefaultChecked?: CheckedState;\n\t};\n\n/**\n * A form control that allows the user to toggle between checked and not checked.\n * Supports indeterminate state.\n *\n * @see https://mantle.ngrok.com/components/checkbox\n *\n * @example\n * ```tsx\n * <form>\n * <Label htmlFor=\"terms\" className=\"flex items-center gap-2\">\n * <Checkbox name=\"terms\" id=\"terms\" />\n * Accept terms and conditions\n * </Label>\n * </form>\n * ```\n */\nconst Checkbox = forwardRef<ComponentRef<\"input\">, Props>(\n\t(\n\t\t{\n\t\t\t\"aria-invalid\": _ariaInvalid,\n\t\t\tclassName,\n\t\t\tchecked: _checked,\n\t\t\tdefaultChecked: _defaultChecked,\n\t\t\tdefaultValue = \"on\",\n\t\t\tonClick,\n\t\t\treadOnly,\n\t\t\tvalidation: _validation,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst innerRef = useRef<ComponentRef<\"input\">>(null);\n\t\tconst [defaultChecked] = useState(_defaultChecked);\n\t\tconst isInvalid = _ariaInvalid != null && _ariaInvalid !== \"false\";\n\t\tconst validation = isInvalid\n\t\t\t? \"error\"\n\t\t\t: typeof _validation === \"function\"\n\t\t\t\t? _validation()\n\t\t\t\t: _validation;\n\t\tconst ariaInvalid = _ariaInvalid ?? validation === \"error\";\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef.current) {\n\t\t\t\tinnerRef.current.indeterminate = isIndeterminate(_checked);\n\t\t\t}\n\t\t}, [_checked]);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef.current) {\n\t\t\t\tinnerRef.current.indeterminate = isIndeterminate(defaultChecked);\n\t\t\t}\n\t\t}, [defaultChecked]);\n\n\t\treturn (\n\t\t\t<input\n\t\t\t\taria-checked={isIndeterminate(_checked) ? \"mixed\" : _checked}\n\t\t\t\taria-invalid={ariaInvalid}\n\t\t\t\tclassName={clsx(\n\t\t\t\t\t\"border-form bg-form shrink-0 cursor-pointer select-none appearance-none rounded border disabled:cursor-default disabled:opacity-50\",\n\t\t\t\t\t\"bg-center bg-no-repeat focus:outline-hidden\",\n\t\t\t\t\t\"focus-visible:border-accent-600 focus-visible:ring-focus-accent focus-visible:outline-hidden focus-visible:ring-4\",\n\t\t\t\t\t\"checked:border-accent-600 checked:bg-accent-600 checked:bg-checked-icon\",\n\t\t\t\t\t\"indeterminate:border-accent-600 indeterminate:bg-accent-600 indeterminate:bg-indeterminate-icon\",\n\t\t\t\t\t\"data-validation-success:border-success-600 data-validation-success:checked:bg-success-600 data-validation-success:indeterminate:bg-success-600 focus-visible:data-validation-success:border-success-600 focus-visible:data-validation-success:ring-focus-success\",\n\t\t\t\t\t\"data-validation-warning:border-warning-600 data-validation-warning:checked:bg-warning-600 data-validation-warning:indeterminate:bg-warning-600 focus-visible:data-validation-warning:border-warning-600 focus-visible:data-validation-warning:ring-focus-warning\",\n\t\t\t\t\t\"data-validation-error:border-danger-600 data-validation-error:checked:bg-danger-600 data-validation-error:indeterminate:bg-danger-600 focus-visible:data-validation-error:border-danger-600 focus-visible:data-validation-error:ring-focus-danger\",\n\t\t\t\t\t\"where:block where:size-4 where:p-0\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tchecked={isIndeterminate(_checked) ? undefined : _checked}\n\t\t\t\tdata-validation={validation || undefined}\n\t\t\t\tdefaultChecked={isIndeterminate(defaultChecked) ? undefined : defaultChecked}\n\t\t\t\tdefaultValue={defaultValue}\n\t\t\t\tonClick={(event) => {\n\t\t\t\t\tif (readOnly) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tonClick?.(event);\n\t\t\t\t}}\n\t\t\t\treadOnly={readOnly}\n\t\t\t\tref={composeRefs(innerRef, ref)}\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t},\n);\nCheckbox.displayName = \"Checkbox\";\n\nexport {\n\t//,\n\tCheckbox,\n};\n"],"mappings":"uLAUA,MAAM,EAAmB,GACxB,IAAY,gBA8BP,EAAW,GAEf,CACC,eAAgB,EAChB,YACA,QAAS,EACT,eAAgB,EAChB,eAAe,KACf,UACA,WACA,WAAY,EACZ,GAAG,GAEJ,IACI,CACJ,IAAM,EAAW,EAA8B,KAAK,CAC9C,CAAC,GAAkB,EAAS,EAAgB,CAE5C,EADY,GAAgB,MAAQ,IAAiB,QAExD,QACA,OAAO,GAAgB,WACtB,GAAa,CACb,EACE,EAAc,GAAgB,IAAe,QAcnD,OAZA,MAAgB,CACX,EAAS,UACZ,EAAS,QAAQ,cAAgB,EAAgB,EAAS,GAEzD,CAAC,EAAS,CAAC,CAEd,MAAgB,CACX,EAAS,UACZ,EAAS,QAAQ,cAAgB,EAAgB,EAAe,GAE/D,CAAC,EAAe,CAAC,CAGnB,EAAC,QAAD,CACC,eAAc,EAAgB,EAAS,CAAG,QAAU,EACpD,eAAc,EACd,UAAWA,EACV,qIACA,8CACA,oHACA,0EACA,kGACA,mQACA,mQACA,oPACA,qCACA,EACA,CACD,QAAS,EAAgB,EAAS,CAAG,IAAA,GAAY,EACjD,kBAAiB,GAAc,IAAA,GAC/B,eAAgB,EAAgB,EAAe,CAAG,IAAA,GAAY,EAChD,eACd,QAAU,GAAU,CACnB,GAAI,EAAU,CACb,EAAM,gBAAgB,CACtB,OAED,IAAU,EAAM,EAEP,WACV,IAAK,EAAY,EAAU,EAAI,CAC/B,KAAK,WACL,GAAI,EACH,CAAA,EAGJ,CACD,EAAS,YAAc"}
|
package/dist/code-block.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as SvgAttributes } from "./types-yU-Byhue.js";
|
|
2
2
|
import { t as WithAsChild } from "./as-child-CRRsxi3Y.js";
|
|
3
3
|
import { C as parseLanguage, D as LineRange, E as decorateHighlightedHtml, S as isSupportedLanguage, _ as normalizeIndentation, a as Mode, b as isIndentation, c as ResolvedPreRenderedCodeBlockProps, d as parseMetastring, f as resolvePreRenderedCodeBlockProps, g as parseCodeBlockShowLineNumbers, h as parseCodeBlockLineNumberStart, i as MetaInput, 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 Indentation, w as supportedLanguages, x as SupportedLanguage, y as inferIndentation } from "./resolve-pre-rendered-props-51i50IL2.js";
|
|
4
|
-
import * as react from "react";
|
|
4
|
+
import * as _$react from "react";
|
|
5
5
|
import { ComponentProps, HTMLAttributes, ReactNode } from "react";
|
|
6
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
7
|
import { Content, List, Trigger } from "@radix-ui/react-tabs";
|
|
8
8
|
|
|
9
9
|
//#region src/components/code-block/mantle-code.d.ts
|
|
@@ -135,7 +135,7 @@ type CodeBlockCodeProps = Omit<ComponentProps<"pre">, "children"> & {
|
|
|
135
135
|
*/
|
|
136
136
|
value: MantleCodeBlockValue;
|
|
137
137
|
};
|
|
138
|
-
type CodeBlockCopyButtonProps = Omit<ComponentProps<"button">, "children" | "type"> &
|
|
138
|
+
type CodeBlockCopyButtonProps = Omit<ComponentProps<"button">, "children" | "type"> & {
|
|
139
139
|
/**
|
|
140
140
|
* Callback fired when the copy button is clicked, passes the copied text as an argument.
|
|
141
141
|
*/
|
|
@@ -186,7 +186,7 @@ declare function CodeBlockIconComponent({
|
|
|
186
186
|
preset,
|
|
187
187
|
svg: _svgProp,
|
|
188
188
|
...props
|
|
189
|
-
}: CodeBlockIconProps): react_jsx_runtime0.JSX.Element;
|
|
189
|
+
}: CodeBlockIconProps): _$react_jsx_runtime0.JSX.Element;
|
|
190
190
|
declare namespace CodeBlockIconComponent {
|
|
191
191
|
var displayName: string;
|
|
192
192
|
}
|
|
@@ -235,27 +235,27 @@ declare const CodeBlock: {
|
|
|
235
235
|
/**
|
|
236
236
|
* The root component of the `CodeBlock`.
|
|
237
237
|
*/
|
|
238
|
-
readonly Root: react.ForwardRefExoticComponent<Omit<CodeBlockRootProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
238
|
+
readonly Root: _$react.ForwardRefExoticComponent<Omit<CodeBlockRootProps, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
239
239
|
/**
|
|
240
240
|
* The body of the `CodeBlock`. Contains `Code` and optional `CopyButton`.
|
|
241
241
|
*/
|
|
242
|
-
readonly Body: react.ForwardRefExoticComponent<Omit<react.ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & WithAsChild, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
242
|
+
readonly Body: _$react.ForwardRefExoticComponent<Omit<_$react.ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & WithAsChild, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
243
243
|
/**
|
|
244
244
|
* The code content. Renders pre-highlighted Shiki HTML when the Vite plugin is active.
|
|
245
245
|
*/
|
|
246
|
-
readonly Code: react.ForwardRefExoticComponent<Omit<CodeBlockCodeProps, "ref"> & react.RefAttributes<HTMLPreElement>>;
|
|
246
|
+
readonly Code: _$react.ForwardRefExoticComponent<Omit<CodeBlockCodeProps, "ref"> & _$react.RefAttributes<HTMLPreElement>>;
|
|
247
247
|
/**
|
|
248
248
|
* The optional copy button.
|
|
249
249
|
*/
|
|
250
|
-
readonly CopyButton: react.ForwardRefExoticComponent<Omit<CodeBlockCopyButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
250
|
+
readonly CopyButton: _$react.ForwardRefExoticComponent<Omit<CodeBlockCopyButtonProps, "ref"> & _$react.RefAttributes<HTMLButtonElement>>;
|
|
251
251
|
/**
|
|
252
252
|
* The optional expander button for collapsible code blocks.
|
|
253
253
|
*/
|
|
254
|
-
readonly ExpanderButton: react.ForwardRefExoticComponent<Omit<CodeBlockExpanderButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
254
|
+
readonly ExpanderButton: _$react.ForwardRefExoticComponent<Omit<CodeBlockExpanderButtonProps, "ref"> & _$react.RefAttributes<HTMLButtonElement>>;
|
|
255
255
|
/**
|
|
256
256
|
* The optional header slot for icon and title.
|
|
257
257
|
*/
|
|
258
|
-
readonly Header: react.ForwardRefExoticComponent<Omit<react.ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & WithAsChild, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
258
|
+
readonly Header: _$react.ForwardRefExoticComponent<Omit<_$react.ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & WithAsChild, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
259
259
|
/**
|
|
260
260
|
* A small icon for the code block header. Use `preset` or `svg`.
|
|
261
261
|
*/
|
|
@@ -263,21 +263,21 @@ declare const CodeBlock: {
|
|
|
263
263
|
/**
|
|
264
264
|
* Conditionally renders children when the associated tab is active.
|
|
265
265
|
*/
|
|
266
|
-
readonly TabContent: react.ForwardRefExoticComponent<Omit<CodeBlockTabContentProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
266
|
+
readonly TabContent: _$react.ForwardRefExoticComponent<Omit<CodeBlockTabContentProps, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
267
267
|
/**
|
|
268
268
|
* A tab list for the code block header. Renders pill-styled tabs for switching code.
|
|
269
269
|
*/
|
|
270
|
-
readonly TabList: react.ForwardRefExoticComponent<Omit<CodeBlockTabListProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
270
|
+
readonly TabList: _$react.ForwardRefExoticComponent<Omit<CodeBlockTabListProps, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
271
271
|
/**
|
|
272
272
|
* A pill-styled tab trigger for the code block header. Must be inside `TabList`.
|
|
273
273
|
*/
|
|
274
|
-
readonly TabTrigger: react.ForwardRefExoticComponent<Omit<CodeBlockTabTriggerProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
274
|
+
readonly TabTrigger: _$react.ForwardRefExoticComponent<Omit<CodeBlockTabTriggerProps, "ref"> & _$react.RefAttributes<HTMLButtonElement>>;
|
|
275
275
|
/**
|
|
276
276
|
* The optional title rendered in the header.
|
|
277
277
|
*/
|
|
278
|
-
readonly Title: react.ForwardRefExoticComponent<HTMLAttributes<HTMLHeadingElement> & {
|
|
278
|
+
readonly Title: _$react.ForwardRefExoticComponent<HTMLAttributes<HTMLHeadingElement> & {
|
|
279
279
|
asChild?: boolean;
|
|
280
|
-
} & react.RefAttributes<HTMLHeadingElement>>;
|
|
280
|
+
} & _$react.RefAttributes<HTMLHeadingElement>>;
|
|
281
281
|
};
|
|
282
282
|
//#endregion
|
|
283
283
|
//#region src/components/code-block/escape-html.d.ts
|
package/dist/code-block.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./cx-D1HYnpvA.js";import{t}from"./icon-BMH0fD_b.js";import{t as n}from"./slot-D_ZUrdEW.js";import{t as r}from"./use-copy-to-clipboard-B6wH6hDd.js";import{t as
|
|
2
|
-
`&&(n+=1,n>t))return!0;return!1}export{Q as CodeBlock,$ as createMantleCodeBlockValue,
|
|
1
|
+
import{t as e}from"./cx-D1HYnpvA.js";import{t}from"./icon-BMH0fD_b.js";import{t as n}from"./slot-D_ZUrdEW.js";import{t as r}from"./icon-button-CxxVPiKp.js";import{t as i}from"./use-copy-to-clipboard-B6wH6hDd.js";import{t as a}from"./traffic-policy-file-CroUMbsd.js";import{a as o,c as s,d as c,f as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b}from"./resolve-pre-rendered-props-Bu2cvS9A.js";import{CaretDownIcon as x}from"@phosphor-icons/react/CaretDown";import{createContext as S,forwardRef as C,useCallback as w,useContext as T,useEffect as E,useId as ee,useLayoutEffect as te,useMemo as D,useRef as O,useState as k}from"react";import A from"tiny-invariant";import{jsx as j,jsxs as ne}from"react/jsx-runtime";import{CheckIcon as re}from"@phosphor-icons/react/Check";import{CopyIcon as ie}from"@phosphor-icons/react/Copy";import{FileTextIcon as M}from"@phosphor-icons/react/FileText";import{TerminalIcon as ae}from"@phosphor-icons/react/Terminal";import{Content as oe,List as se,Root as N,Trigger as ce}from"@radix-ui/react-tabs";function P(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+=`&`;break;case`<`:n+=`<`;break;case`>`:n+=`>`;break;case`"`:n+=`"`;break;case`'`:n+=`'`;break;default:n+=t}}return n}const F=S(null);function I(){let e=T(F);return A(e!=null,`CodeBlock subcomponents must be rendered within a <CodeBlock.Root>.`),e}const L=C(({asChild:t=!1,className:r,defaultTab:i,activeTab:a,onActiveTabChange:o,...s},c)=>{let l=O(``),[u,d]=k(!1),[f,p]=k(!1),[m,h]=k(void 0),g=w(e=>{h(t=>(A(t==null,`You can only render a single CodeBlock.Code within a CodeBlock.`),e))},[]),_=w(e=>{h(t=>{A(t===e,`You can only render a single CodeBlock.Code within a CodeBlock.`)})},[]),v=D(()=>({codeId:m,copyTextRef:l,hasCodeExpander:u,isCodeExpanded:f,registerCodeId:g,setHasCodeExpander:d,setIsCodeExpanded:p,unregisterCodeId:_}),[m,u,f,g,_]),y=i!==void 0||a!==void 0,b=j(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 j(F.Provider,{value:v,children:y?j(N,{asChild:!0,defaultValue:i,value:a,onValueChange:o,children:b}):b})});L.displayName=`CodeBlock`;const R=C(({asChild:t=!1,className:r,...i},a)=>j(t?n:`div`,{className:e(`relative`,r),ref:a,...i}));R.displayName=`CodeBlockBody`;const le=/SHIKI_VAL_(\d+)/g;function ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const z=new Map;function B(e){if(e==null||e.length===0)return le;let t=z.get(e);return t??(z.size>=500&&z.clear(),t=RegExp(`${ue(e)}(\\d+)__`,`g`),z.set(e,t)),t}function V(e,t,n,r){if(n==null){if(!e.includes(`SHIKI_VAL_`))return e}else if(!e.includes(n))return e;return e.replaceAll(B(n),(e,n)=>{let i=Number.parseInt(n,10);return Number.isNaN(i)||i<0||i>=t.length?e:r(t[i])})}function H(e,t,n){return V(e,t,n,e=>P(String(e)))}function de(e,t,n){return V(e,t,n,e=>String(e))}const U=C(({className:t,style:n,tabIndex:r,value:i,...a},o)=>{let s=ee(),{copyTextRef:c,hasCodeExpander:l,isCodeExpanded:u,registerCodeId:d,unregisterCodeId:f}=I(),{language:p,code:m,"~preValToken":h,"~preVals":g,"~highlightLines":_,"~lineNumberStart":v,"~preHtml":y,"~showLineNumbers":b}=i,x=_,S=v??1,C=b??!1,w=D(()=>g!=null&&g.length>0?de(m,g,h):m,[h,g,m]);te(()=>{c.current=w},[c,w]),E(()=>(d(s),()=>{f(s)}),[s,d,f]);let T=D(()=>{if(y!=null)return g!=null&&g.length>0?H(y,g,h):y},[y,h,g]),O=T!=null,k=T??P(w);return j(`pre`,{"aria-expanded":l?u:void 0,className:e(`scrollbar overflow-x-auto overflow-y-hidden py-4`,!O&&`pr-14`,`data-[mantle-line-numbers~='false']:pl-4`,`text-mono m-0 font-mono`,`aria-collapsed:max-h-[13.6rem]`,t),"data-highlighted":O?`true`:`false`,"data-lang":p,"data-mantle-highlight-lines":O&&x!=null&&x.length>0?x.join(`,`):void 0,"data-mantle-line-number-start":O&&C?String(S):`1`,"data-mantle-line-numbers":O&&C?`true`:`false`,id:s,ref:o,style:{...n,"--mantle-line-number-start":String(S),tabSize:2,MozTabSize:2},tabIndex:r??-1,...a,children:j(`code`,{className:`text-size-inherit block min-w-full w-max`,dangerouslySetInnerHTML:{__html:k}})})});U.displayName=`CodeBlockCode`;const W=C(({asChild:t=!1,className:r,...i},a)=>j(t?n:`div`,{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}));W.displayName=`CodeBlockHeader`;const G=C(({asChild:t=!1,className:r,...i},a)=>j(t?n:`h3`,{ref:a,className:e(`text-mono m-0 font-mono font-normal`,r),...i}));G.displayName=`CodeBlockTitle`;const K=C(({className:e,onCopy:t,onCopyError:n,onClick:a,...o},s)=>{let{copyTextRef:c}=I(),[,l]=i(),[u,d]=k(!1),f=O(void 0);return E(()=>()=>{f.current!=null&&clearTimeout(f.current)},[]),j(`span`,{className:`absolute right-2.5 top-2.5 z-10 bg-card`,children:j(r,{type:`button`,appearance:`ghost`,size:`sm`,label:`Copy code`,icon:j(u?re:ie,{}),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})})});K.displayName=`CodeBlockCopyButton`;const q=C(({asChild:r=!1,className:i,onClick:a,...o},s)=>{let{codeId:c,isCodeExpanded:l,setIsCodeExpanded:u,setHasCodeExpander:d}=I();return E(()=>(d(!0),()=>{d(!1)}),[d]),ne(r?n:`button`,{...o,"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`,` `,j(t,{svg:j(x,{weight:`bold`}),className:e(`size-4`,l&&`rotate-180`,`transition-all duration-150`)})]})});q.displayName=`CodeBlockExpanderButton`;function J({className:e,preset:n,svg:r,...i}){let o=r;if(n!=null)switch(n){case`file`:o=j(M,{weight:`fill`});break;case`cli`:o=j(ae,{weight:`fill`});break;case`traffic-policy`:o=j(a,{});break}return j(t,{className:e,svg:o,...i})}J.displayName=`CodeBlockIcon`;const Y=C(({className:t,...n},r)=>j(se,{className:e(`flex items-center gap-1`,t),ref:r,...n}));Y.displayName=`CodeBlockTabList`;const X=C(({className:t,...n},r)=>j(ce,{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}));X.displayName=`CodeBlockTabTrigger`;const Z=C((e,t)=>j(oe,{ref:t,...e}));Z.displayName=`CodeBlockTabContent`;const Q={Root:L,Body:R,Code:U,CopyButton:K,ExpanderButton:q,Header:W,Icon:J,TabContent:Z,TabList:Y,TabTrigger:X,Title:G},fe=Symbol(`MantleCodeBlockValue`);function $({preHtml:e,preValToken:t,preVals:n,highlightLines:r,lineNumberStart:i,showLineNumbers:a,code:o,language:s}){return{[fe]:!0,language:s,code:o,"~preHtml":e,"~preValToken":t,"~preVals":n,"~highlightLines":r,"~lineNumberStart":i,"~showLineNumbers":a}}function pe(e,t){let n=``;for(let r=0;r<e.length;r+=1)n+=e[r]??``,r<t.length&&(n+=String(t[r]));return n}function me(e,t={}){return(n,...r)=>$({language:e,code:pe(n,r),preHtml:void 0,preVals:r.length>0?r:void 0,highlightLines:t.highlightLines,lineNumberStart:t.lineNumberStart,showLineNumbers:t.showLineNumbers})}function he(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{Q as CodeBlock,$ as createMantleCodeBlockValue,u as decorateHighlightedHtml,y as defaultMeta,P as escapeHtml,he as hasMoreThanNLines,g as inferIndentation,p as isIndentation,f as isSupportedLanguage,me as mantleCode,l as normalizeIndentation,m as normalizeValue,h as parseCodeBlockHighlightLines,v as parseCodeBlockLineNumberStart,s as parseCodeBlockShowLineNumbers,b as parseLanguage,_ as parseMetastring,d as resolvePreRenderedCodeBlockProps,c as supportedLanguages,o as tokenizeMetastring};
|
|
3
3
|
//# sourceMappingURL=code-block.js.map
|
package/dist/code-block.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-block.js","names":["Root","RadixTabsRoot","MantleIcon","RadixTabsList","RadixTabsTrigger","RadixTabsContent"],"sources":["../src/components/code-block/escape-html.ts","../src/components/code-block/code-block.tsx","../src/components/code-block/mantle-code.ts","../src/components/code-block/has-more-than-n-lines.ts"],"sourcesContent":["/**\n * Escapes special HTML characters in a string to their corresponding\n * HTML entities, preventing issues like unintended HTML rendering or\n * cross-site scripting (XSS) when injecting raw strings into the DOM\n * using `dangerouslySetInnerHTML`.\n *\n * Characters escaped:\n * - \\& => `&`;\n * - \\< => `<`;\n * - \\> => `>`;\n * - \\\" => `"`;\n * - \\' => `'`;\n *\n * @param {string} value The raw string to be escaped.\n *\n * @example\n * escapeHtml('<div>Hello & \"world\"</div>');\n * // Returns: '<div>Hello & "world"</div>'\n */\nfunction escapeHtml(value: string): string {\n\tlet firstSpecialCharIndex = -1;\n\tfor (let i = 0; i < value.length; i++) {\n\t\tconst character = value[i];\n\t\tif (\n\t\t\tcharacter === \"&\" ||\n\t\t\tcharacter === \"<\" ||\n\t\t\tcharacter === \">\" ||\n\t\t\tcharacter === '\"' ||\n\t\t\tcharacter === \"'\"\n\t\t) {\n\t\t\tfirstSpecialCharIndex = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (firstSpecialCharIndex === -1) {\n\t\treturn value;\n\t}\n\n\tlet escaped = value.slice(0, firstSpecialCharIndex);\n\tfor (let i = firstSpecialCharIndex; i < value.length; i++) {\n\t\tconst character = value[i];\n\t\tswitch (character) {\n\t\t\tcase \"&\":\n\t\t\t\tescaped += \"&\";\n\t\t\t\tbreak;\n\t\t\tcase \"<\":\n\t\t\t\tescaped += \"<\";\n\t\t\t\tbreak;\n\t\t\tcase \">\":\n\t\t\t\tescaped += \">\";\n\t\t\t\tbreak;\n\t\t\tcase '\"':\n\t\t\t\tescaped += \""\";\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\t\tescaped += \"'\";\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tescaped += character;\n\t\t}\n\t}\n\treturn escaped;\n}\n\nexport {\n\t//,\n\tescapeHtml,\n};\n","\"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 { 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 !== undefined || activeTab !== undefined;\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-gray-50 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.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\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 <Component className={cx(\"relative\", className)} ref={ref} {...props} />;\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.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\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\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.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\tclassName={cx(\n\t\t\t\t\t\"flex items-center gap-1 border-b border-gray-300 bg-gray-100 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.Header>\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\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\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\tWithAsChild & {\n\t\t/**\n\t\t * Callback fired when the copy button is clicked, passes the copied text as an argument.\n\t\t */\n\t\tonCopy?: (value: string) => void;\n\t\t/**\n\t\t * Callback fired when an error occurs during copying.\n\t\t */\n\t\tonCopyError?: (error: unknown) => void;\n\t};\n\n/**\n * The (optional) copy button of the `CodeBlock`. Copies the code content\n * to the clipboard when clicked.\n *\n * @example\n * ```tsx\n * <CodeBlock.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`…`} />\n * </CodeBlock.Body>\n * ```\n */\nconst CopyButton = forwardRef<ComponentRef<\"button\">, CodeBlockCopyButtonProps>(\n\t({ asChild = false, 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\tconst Component = asChild ? Slot : \"button\";\n\n\t\treturn (\n\t\t\t<Component\n\t\t\t\ttype=\"button\"\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"focus-visible:border-accent-600 focus-visible:ring-focus-accent absolute right-2.5 top-2.5 z-10 flex size-7 items-center justify-center rounded border border-gray-300 bg-gray-50 hover:border-gray-400 hover:bg-gray-200 focus-visible:outline-hidden focus-visible:ring-4\",\n\t\t\t\t\t\"shadow-[-1rem_0_0.75rem_-0.375rem_var(--color-gray-50),1rem_0_0_-0.25rem_var(--color-gray-50)]\",\n\t\t\t\t\twasCopied &&\n\t\t\t\t\t\t\"bg-filled-success text-on-filled hover:bg-filled-success focus:bg-filled-success focus-visible:border-success-600 focus-visible:ring-focus-success w-auto gap-1 border-transparent pl-2 pr-1.5 hover:border-transparent\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\tonClick={async (event) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tonClick?.(event);\n\t\t\t\t\t\tif (event.defaultPrevented) {\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\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst text = copyTextRef.current;\n\t\t\t\t\t\tawait copyToClipboard(text);\n\t\t\t\t\t\tonCopy?.(text);\n\t\t\t\t\t\tsetWasCopied(true);\n\t\t\t\t\t\tif (timeoutHandle.current != null) {\n\t\t\t\t\t\t\tclearTimeout(timeoutHandle.current);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttimeoutHandle.current = setTimeout(() => {\n\t\t\t\t\t\t\tsetWasCopied(false);\n\t\t\t\t\t\t}, 2000);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tonCopyError?.(error);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<span className=\"sr-only\">Copy code</span>\n\t\t\t\t{wasCopied ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\tCopied\n\t\t\t\t\t\t<MantleIcon svg={<CheckIcon weight=\"bold\" />} className=\"size-4\" />\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<MantleIcon svg={<CopyIcon />} className=\"-ml-px\" />\n\t\t\t\t)}\n\t\t\t</Component>\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.Body>\n * <CodeBlock.Code value={mantleCode(\"typescript\")`…`} />\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\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-gray-50 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.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\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 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 className={cx(\"flex items-center gap-1\", className)} ref={ref} {...props} />\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\tclassName={cx(\n\t\t\t\t\"cursor-pointer rounded-full px-3 py-1 text-sm 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-accent-500/20 data-[state=active]:text-blue-700\",\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 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 * ```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\tRoot,\n\t/**\n\t * The body of the `CodeBlock`. Contains `Code` and optional `CopyButton`.\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\tCode,\n\t/**\n\t * The optional copy button.\n\t */\n\tCopyButton,\n\t/**\n\t * The optional expander button for collapsible code blocks.\n\t */\n\tExpanderButton,\n\t/**\n\t * The optional header slot for icon and title.\n\t */\n\tHeader,\n\t/**\n\t * A small icon for the code block header. Use `preset` or `svg`.\n\t */\n\tIcon: CodeBlockIconComponent,\n\t/**\n\t * Conditionally renders children when the associated tab is active.\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\tTabList,\n\t/**\n\t * A pill-styled tab trigger for the code block header. Must be inside `TabList`.\n\t */\n\tTabTrigger,\n\t/**\n\t * The optional title rendered in the header.\n\t */\n\tTitle,\n} as const;\n\nexport {\n\t//,\n\tCodeBlock,\n};\n","import type { SupportedLanguage } from \"../code-block/supported-languages.js\";\nimport type { LineRange } from \"../code-block/line-numbers.js\";\nimport type { Indentation } from \"../code-block/indentation.js\";\n\nconst mantleCodeBlockValueBrand: unique symbol = Symbol(\"MantleCodeBlockValue\");\n\n/**\n * The value produced by `mantleCode()`. Contains pre-rendered Shiki HTML (injected\n * by the Vite plugin at build time) and the original code string for the copy button.\n *\n * `~preHtml` is required at render time. Runtime syntax highlighting is intentionally\n * unsupported; only placeholder substitution for interpolated values is performed.\n */\ntype MantleCodeBlockValue = {\n\t/**\n\t * Nominal type brand to prevent accidental use of plain objects.\n\t */\n\t[mantleCodeBlockValueBrand]: true;\n\t/**\n\t * The language used for syntax highlighting.\n\t */\n\tlanguage: SupportedLanguage;\n\t/**\n\t * The original code string (used by the copy button).\n\t */\n\tcode: string;\n\t/**\n\t * Fully pre-rendered Shiki HTML injected by the Vite plugin or server highlighter.\n\t * This must be present for rendering.\n\t *\n\t * **Security:** This HTML is injected via `dangerouslySetInnerHTML`. It must\n\t * come from a trusted source (Shiki output from the Vite plugin or\n\t * `createMantleServerSyntaxHighlighter`). Never pass unsanitized user input.\n\t */\n\t\"~preHtml\"?: string | undefined;\n\t/**\n\t * Runtime values used to replace `SHIKI_VAL_N` placeholders in `~preHtml`.\n\t * This enables interpolated template expressions while preserving build-time highlighting.\n\t */\n\t\"~preVals\"?: unknown[] | undefined;\n\t/**\n\t * Placeholder token prefix used by the Vite transform for interpolated values.\n\t * When omitted, CodeBlock falls back to the legacy `SHIKI_VAL_<n>` format.\n\t */\n\t\"~preValToken\"?: string | undefined;\n\t/**\n\t * Optional default for line-number rendering when this value is displayed.\n\t */\n\t\"~showLineNumbers\"?: boolean | undefined;\n\t/**\n\t * Optional default highlighted line numbers/ranges when this value is displayed.\n\t */\n\t\"~highlightLines\"?: (LineRange | number)[] | undefined;\n\t/**\n\t * Optional default start line number when line numbers are displayed.\n\t * @default 1\n\t */\n\t\"~lineNumberStart\"?: number | undefined;\n};\n\n/** Maps each key starting with `OldPrefix` to `NewPrefix`, leaving other keys unchanged. */\ntype ReplacePrefix<T, OldPrefix extends string, NewPrefix extends string> = {\n\t[K in keyof T as K extends `${OldPrefix}${infer Rest}` ? `${NewPrefix}${Rest}` : K]: T[K];\n};\n\n/** Public input shape for `createMantleCodeBlockValue`, with `~`-prefixed keys renamed to unprefixed. */\ntype MantleCodeBlockValueInput = ReplacePrefix<\n\tOmit<MantleCodeBlockValue, typeof mantleCodeBlockValueBrand>,\n\t\"~\",\n\t\"\"\n>;\n\n/** Options for configuring line numbers, highlights, and indentation in `mantleCode()`. */\ntype MantleCodeOptions = {\n\thighlightLines?: (LineRange | number)[] | undefined;\n\tindentation?: Indentation | undefined;\n\tlineNumberStart?: number | undefined;\n\tshowLineNumbers?: boolean | undefined;\n};\n\n/**\n * Creates a `MantleCodeBlockValue` for use with `CodeBlock.Code`.\n *\n * **Security:** The `preHtml` field is rendered via `dangerouslySetInnerHTML`.\n * Only pass HTML produced by Shiki (via the Vite plugin or\n * `createMantleServerSyntaxHighlighter`). Never pass unsanitized user input as `preHtml`.\n */\nfunction createMantleCodeBlockValue({\n\tpreHtml,\n\tpreValToken,\n\tpreVals,\n\thighlightLines,\n\tlineNumberStart,\n\tshowLineNumbers,\n\tcode,\n\tlanguage,\n}: MantleCodeBlockValueInput): MantleCodeBlockValue {\n\treturn {\n\t\t[mantleCodeBlockValueBrand]: true,\n\t\tlanguage,\n\t\tcode,\n\t\t\"~preHtml\": preHtml,\n\t\t\"~preValToken\": preValToken,\n\t\t\"~preVals\": preVals,\n\t\t\"~highlightLines\": highlightLines,\n\t\t\"~lineNumberStart\": lineNumberStart,\n\t\t\"~showLineNumbers\": showLineNumbers,\n\t};\n}\n\n/** Joins a `TemplateStringsArray` and its interpolated values into a single code string. */\nfunction buildCodeFromTemplate(strings: TemplateStringsArray, values: unknown[]): string {\n\tlet code = \"\";\n\tfor (let index = 0; index < strings.length; index += 1) {\n\t\tcode += strings[index] ?? \"\";\n\t\tif (index < values.length) {\n\t\t\tcode += String(values[index]);\n\t\t}\n\t}\n\treturn code;\n}\n\n/**\n * Tagged template literal for Shiki syntax highlighting.\n *\n * Returns a `MantleCodeBlockValue` that `CodeBlock.Code` renders.\n * The Vite transform plugin rewrites calls to this function at build time,\n * inlining pre-rendered Shiki HTML so that no highlighting work happens in the browser.\n * Configure it via `mantleCodeBlockPlugins()` in `vite.config.ts`.\n *\n * Interpolated template expressions are supported via placeholder substitution.\n *\n * @example\n * ```tsx\n * // Static string\n * mantleCode(\"typescript\")`const x: string = \"hello\";`\n * // Interpolated string\n * mantleCode(\"typescript\")`const greeting = \"Hello, ${name}!\";`\n * ```\n */\nfunction mantleCode(\n\tlanguage: SupportedLanguage,\n\toptions: MantleCodeOptions = {},\n): (strings: TemplateStringsArray, ...values: unknown[]) => MantleCodeBlockValue {\n\treturn (strings, ...values) => {\n\t\tconst code = buildCodeFromTemplate(strings, values);\n\n\t\treturn createMantleCodeBlockValue({\n\t\t\tlanguage,\n\t\t\tcode,\n\t\t\tpreHtml: undefined,\n\t\t\tpreVals: values.length > 0 ? values : undefined,\n\t\t\thighlightLines: options.highlightLines,\n\t\t\tlineNumberStart: options.lineNumberStart,\n\t\t\tshowLineNumbers: options.showLineNumbers,\n\t\t});\n\t};\n}\n\nexport { mantleCode };\nexport { createMantleCodeBlockValue };\nexport type { MantleCodeBlockValue, MantleCodeOptions };\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":"ogCAmBA,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,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AQ,gBACzB,CAAC,CCrJJ,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/code-block.tsx","../src/components/code-block/mantle-code.ts","../src/components/code-block/has-more-than-n-lines.ts"],"sourcesContent":["/**\n * Escapes special HTML characters in a string to their corresponding\n * HTML entities, preventing issues like unintended HTML rendering or\n * cross-site scripting (XSS) when injecting raw strings into the DOM\n * using `dangerouslySetInnerHTML`.\n *\n * Characters escaped:\n * - \\& => `&`;\n * - \\< => `<`;\n * - \\> => `>`;\n * - \\\" => `"`;\n * - \\' => `'`;\n *\n * @param {string} value The raw string to be escaped.\n *\n * @example\n * escapeHtml('<div>Hello & \"world\"</div>');\n * // Returns: '<div>Hello & "world"</div>'\n */\nfunction escapeHtml(value: string): string {\n\tlet firstSpecialCharIndex = -1;\n\tfor (let i = 0; i < value.length; i++) {\n\t\tconst character = value[i];\n\t\tif (\n\t\t\tcharacter === \"&\" ||\n\t\t\tcharacter === \"<\" ||\n\t\t\tcharacter === \">\" ||\n\t\t\tcharacter === '\"' ||\n\t\t\tcharacter === \"'\"\n\t\t) {\n\t\t\tfirstSpecialCharIndex = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (firstSpecialCharIndex === -1) {\n\t\treturn value;\n\t}\n\n\tlet escaped = value.slice(0, firstSpecialCharIndex);\n\tfor (let i = firstSpecialCharIndex; i < value.length; i++) {\n\t\tconst character = value[i];\n\t\tswitch (character) {\n\t\t\tcase \"&\":\n\t\t\t\tescaped += \"&\";\n\t\t\t\tbreak;\n\t\t\tcase \"<\":\n\t\t\t\tescaped += \"<\";\n\t\t\t\tbreak;\n\t\t\tcase \">\":\n\t\t\t\tescaped += \">\";\n\t\t\t\tbreak;\n\t\t\tcase '\"':\n\t\t\t\tescaped += \""\";\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\t\tescaped += \"'\";\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tescaped += character;\n\t\t}\n\t}\n\treturn escaped;\n}\n\nexport {\n\t//,\n\tescapeHtml,\n};\n","\"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 !== undefined || activeTab !== undefined;\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.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\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 <Component className={cx(\"relative\", className)} ref={ref} {...props} />;\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.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`const x = \"hello\";`} />\n * </CodeBlock.Body>\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\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.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\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.Header>\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\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\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.Body>\n * <CodeBlock.CopyButton />\n * <CodeBlock.Code value={mantleCode(\"typescript\")`…`} />\n * </CodeBlock.Body>\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 className=\"absolute right-2.5 top-2.5 z-10 bg-card\">\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.Body>\n * <CodeBlock.Code value={mantleCode(\"typescript\")`…`} />\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\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.Header>\n * <CodeBlock.Icon preset=\"file\" />\n * <CodeBlock.Title>example.ts</CodeBlock.Title>\n * </CodeBlock.Header>\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 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 className={cx(\"flex items-center gap-1\", className)} ref={ref} {...props} />\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\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 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 * ```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\tRoot,\n\t/**\n\t * The body of the `CodeBlock`. Contains `Code` and optional `CopyButton`.\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\tCode,\n\t/**\n\t * The optional copy button.\n\t */\n\tCopyButton,\n\t/**\n\t * The optional expander button for collapsible code blocks.\n\t */\n\tExpanderButton,\n\t/**\n\t * The optional header slot for icon and title.\n\t */\n\tHeader,\n\t/**\n\t * A small icon for the code block header. Use `preset` or `svg`.\n\t */\n\tIcon: CodeBlockIconComponent,\n\t/**\n\t * Conditionally renders children when the associated tab is active.\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\tTabList,\n\t/**\n\t * A pill-styled tab trigger for the code block header. Must be inside `TabList`.\n\t */\n\tTabTrigger,\n\t/**\n\t * The optional title rendered in the header.\n\t */\n\tTitle,\n} as const;\n\nexport {\n\t//,\n\tCodeBlock,\n};\n","import type { SupportedLanguage } from \"../code-block/supported-languages.js\";\nimport type { LineRange } from \"../code-block/line-numbers.js\";\nimport type { Indentation } from \"../code-block/indentation.js\";\n\nconst mantleCodeBlockValueBrand: unique symbol = Symbol(\"MantleCodeBlockValue\");\n\n/**\n * The value produced by `mantleCode()`. Contains pre-rendered Shiki HTML (injected\n * by the Vite plugin at build time) and the original code string for the copy button.\n *\n * `~preHtml` is required at render time. Runtime syntax highlighting is intentionally\n * unsupported; only placeholder substitution for interpolated values is performed.\n */\ntype MantleCodeBlockValue = {\n\t/**\n\t * Nominal type brand to prevent accidental use of plain objects.\n\t */\n\t[mantleCodeBlockValueBrand]: true;\n\t/**\n\t * The language used for syntax highlighting.\n\t */\n\tlanguage: SupportedLanguage;\n\t/**\n\t * The original code string (used by the copy button).\n\t */\n\tcode: string;\n\t/**\n\t * Fully pre-rendered Shiki HTML injected by the Vite plugin or server highlighter.\n\t * This must be present for rendering.\n\t *\n\t * **Security:** This HTML is injected via `dangerouslySetInnerHTML`. It must\n\t * come from a trusted source (Shiki output from the Vite plugin or\n\t * `createMantleServerSyntaxHighlighter`). Never pass unsanitized user input.\n\t */\n\t\"~preHtml\"?: string | undefined;\n\t/**\n\t * Runtime values used to replace `SHIKI_VAL_N` placeholders in `~preHtml`.\n\t * This enables interpolated template expressions while preserving build-time highlighting.\n\t */\n\t\"~preVals\"?: unknown[] | undefined;\n\t/**\n\t * Placeholder token prefix used by the Vite transform for interpolated values.\n\t * When omitted, CodeBlock falls back to the legacy `SHIKI_VAL_<n>` format.\n\t */\n\t\"~preValToken\"?: string | undefined;\n\t/**\n\t * Optional default for line-number rendering when this value is displayed.\n\t */\n\t\"~showLineNumbers\"?: boolean | undefined;\n\t/**\n\t * Optional default highlighted line numbers/ranges when this value is displayed.\n\t */\n\t\"~highlightLines\"?: (LineRange | number)[] | undefined;\n\t/**\n\t * Optional default start line number when line numbers are displayed.\n\t * @default 1\n\t */\n\t\"~lineNumberStart\"?: number | undefined;\n};\n\n/** Maps each key starting with `OldPrefix` to `NewPrefix`, leaving other keys unchanged. */\ntype ReplacePrefix<T, OldPrefix extends string, NewPrefix extends string> = {\n\t[K in keyof T as K extends `${OldPrefix}${infer Rest}` ? `${NewPrefix}${Rest}` : K]: T[K];\n};\n\n/** Public input shape for `createMantleCodeBlockValue`, with `~`-prefixed keys renamed to unprefixed. */\ntype MantleCodeBlockValueInput = ReplacePrefix<\n\tOmit<MantleCodeBlockValue, typeof mantleCodeBlockValueBrand>,\n\t\"~\",\n\t\"\"\n>;\n\n/** Options for configuring line numbers, highlights, and indentation in `mantleCode()`. */\ntype MantleCodeOptions = {\n\thighlightLines?: (LineRange | number)[] | undefined;\n\tindentation?: Indentation | undefined;\n\tlineNumberStart?: number | undefined;\n\tshowLineNumbers?: boolean | undefined;\n};\n\n/**\n * Creates a `MantleCodeBlockValue` for use with `CodeBlock.Code`.\n *\n * **Security:** The `preHtml` field is rendered via `dangerouslySetInnerHTML`.\n * Only pass HTML produced by Shiki (via the Vite plugin or\n * `createMantleServerSyntaxHighlighter`). Never pass unsanitized user input as `preHtml`.\n */\nfunction createMantleCodeBlockValue({\n\tpreHtml,\n\tpreValToken,\n\tpreVals,\n\thighlightLines,\n\tlineNumberStart,\n\tshowLineNumbers,\n\tcode,\n\tlanguage,\n}: MantleCodeBlockValueInput): MantleCodeBlockValue {\n\treturn {\n\t\t[mantleCodeBlockValueBrand]: true,\n\t\tlanguage,\n\t\tcode,\n\t\t\"~preHtml\": preHtml,\n\t\t\"~preValToken\": preValToken,\n\t\t\"~preVals\": preVals,\n\t\t\"~highlightLines\": highlightLines,\n\t\t\"~lineNumberStart\": lineNumberStart,\n\t\t\"~showLineNumbers\": showLineNumbers,\n\t};\n}\n\n/** Joins a `TemplateStringsArray` and its interpolated values into a single code string. */\nfunction buildCodeFromTemplate(strings: TemplateStringsArray, values: unknown[]): string {\n\tlet code = \"\";\n\tfor (let index = 0; index < strings.length; index += 1) {\n\t\tcode += strings[index] ?? \"\";\n\t\tif (index < values.length) {\n\t\t\tcode += String(values[index]);\n\t\t}\n\t}\n\treturn code;\n}\n\n/**\n * Tagged template literal for Shiki syntax highlighting.\n *\n * Returns a `MantleCodeBlockValue` that `CodeBlock.Code` renders.\n * The Vite transform plugin rewrites calls to this function at build time,\n * inlining pre-rendered Shiki HTML so that no highlighting work happens in the browser.\n * Configure it via `mantleCodeBlockPlugins()` in `vite.config.ts`.\n *\n * Interpolated template expressions are supported via placeholder substitution.\n *\n * @example\n * ```tsx\n * // Static string\n * mantleCode(\"typescript\")`const x: string = \"hello\";`\n * // Interpolated string\n * mantleCode(\"typescript\")`const greeting = \"Hello, ${name}!\";`\n * ```\n */\nfunction mantleCode(\n\tlanguage: SupportedLanguage,\n\toptions: MantleCodeOptions = {},\n): (strings: TemplateStringsArray, ...values: unknown[]) => MantleCodeBlockValue {\n\treturn (strings, ...values) => {\n\t\tconst code = buildCodeFromTemplate(strings, values);\n\n\t\treturn createMantleCodeBlockValue({\n\t\t\tlanguage,\n\t\t\tcode,\n\t\t\tpreHtml: undefined,\n\t\t\tpreVals: values.length > 0 ? values : undefined,\n\t\t\thighlightLines: options.highlightLines,\n\t\t\tlineNumberStart: options.lineNumberStart,\n\t\t\tshowLineNumbers: options.showLineNumbers,\n\t\t});\n\t};\n}\n\nexport { mantleCode };\nexport { createMantleCodeBlockValue };\nexport type { MantleCodeBlockValue, MantleCodeOptions };\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":"yiCAmBA,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,M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