import { t as e } from "./use-toast-BnYFxs3T.js";
import { n as t, r as n, t as r } from "./utils-C1xOyiTe.js";
import { l as i, r as a, t as o, u as s } from "./dialog-DisDZkkN.js";
import { S as c, b as l, c as u, d, h as f, l as p, p as m, s as h, t as g, v as _, x as v, y } from "./mdx-components-DoD1nZRa.js";
import * as b from "react";
import { Check as ee, Copy as x, Download as te, ExternalLink as S, Maximize as ne, Minimize as re, RefreshCw as ie, RotateCcw as ae, RotateCw as oe, Search as se, X as ce, ZoomIn as le, ZoomOut as ue } from "lucide-react";
import { Link as C, useParams as w } from "react-router-dom";
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
import O from "remark-gfm";
import k from "remark-math";
import de from "react-markdown";
import A from "rehype-autolink-headings";
import j from "rehype-slug";
import M from "rehype-raw";
import N from "rehype-katex";
import { SKIP as P, visit as F } from "unist-util-visit";
import I from "katex-physics";
//#region src/lib/rehype-component.ts
function L(e) {
	let t = /* @__PURE__ */ new Map();
	for (let [n] of Object.entries(e)) {
		let e = n.toLowerCase(), r = e.replace(/\./g, "-");
		t.set(e, n), t.set(r, n);
	}
	return () => (e) => {
		F(e, "element", (e) => {
			let n = e.tagName.toLowerCase(), r = t.get(n);
			r && (e.tagName = r, e.properties = e.properties || {}, e.properties.isComponent = !0);
		});
	};
}
//#endregion
//#region src/lib/image-viewer.ts
var R = {
	"zh-cn": {
		preview: "预览图片",
		zoomIn: "放大",
		zoomOut: "缩小",
		fit: "适配窗口",
		actualSize: "原始比例",
		reset: "重置",
		rotateLeft: "左旋",
		rotateRight: "右旋",
		fullscreen: "全屏",
		download: "下载",
		openInNewTab: "新标签打开",
		close: "关闭图片查看器",
		imageAltFallback: "文档图片",
		downloadSuccess: "图片下载已开始",
		downloadError: "当前图片无法直接下载，请尝试新标签打开。",
		fullscreenError: "当前浏览器不支持全屏，已保留对话框预览。",
		openInNewTabError: "无法在新标签页打开图片。",
		imageLoadError: "图片加载失败"
	},
	en: {
		preview: "Preview image",
		zoomIn: "Zoom in",
		zoomOut: "Zoom out",
		fit: "Fit to viewport",
		actualSize: "Actual size",
		reset: "Reset",
		rotateLeft: "Rotate left",
		rotateRight: "Rotate right",
		fullscreen: "Fullscreen",
		download: "Download",
		openInNewTab: "Open in new tab",
		close: "Close image viewer",
		imageAltFallback: "Documentation image",
		downloadSuccess: "Image download started",
		downloadError: "This image cannot be downloaded directly. Try opening it in a new tab.",
		fullscreenError: "Fullscreen is not available in this browser. Dialog preview is still available.",
		openInNewTabError: "Unable to open the image in a new tab.",
		imageLoadError: "Failed to load image"
	}
};
function fe(e = "zh-cn", t) {
	return {
		...R[e === "en" ? "en" : "zh-cn"],
		...t
	};
}
//#endregion
//#region src/components/ImageViewer.tsx
var pe = .2, me = 5, he = .2;
function z(e) {
	return Math.min(me, Math.max(pe, Number(e.toFixed(2))));
}
function ge(e, t, n) {
	let r = (t || n || "image").trim().split("").map((e) => e.charCodeAt(0) < 32 || "<>:\"/\\|?*".includes(e) ? "-" : e).join("");
	return (e.split("?")[0]?.split("#")[0] ?? e).split("/").pop()?.trim() || r || "image";
}
function _e(e, t) {
	let n = document.createElement("a");
	n.href = e, n.download = t, n.rel = "noopener noreferrer", document.body.appendChild(n), n.click(), document.body.removeChild(n);
}
function ve(e) {
	if (e.startsWith("blob:") || e.startsWith("data:")) return !0;
	try {
		return new URL(e, window.location.href).origin === window.location.origin;
	} catch {
		return !1;
	}
}
function B({ open: t, onOpenChange: n, src: u, alt: d, title: f, lang: p = "zh-cn", labels: m }) {
	let h = b.useMemo(() => fe(p, m), [p, m]), g = b.useRef(null), ee = b.useRef(null), [x, C] = b.useState(1), [w, T] = b.useState(0), [O, k] = b.useState("fit"), [de, A] = b.useState(!1), [j, M] = b.useState(!1), [N, P] = b.useState({
		x: 0,
		y: 0
	}), [F, I] = b.useState(!1), L = b.useRef(/* @__PURE__ */ new Map()), R = b.useRef(null), B = b.useRef(null), V = d?.trim() || f?.trim() || h.imageAltFallback, H = b.useCallback(() => {
		C(1), T(0), k("fit"), M(!1), P({
			x: 0,
			y: 0
		}), I(!1), L.current.clear(), R.current = null, B.current = null;
	}, []);
	b.useEffect(() => {
		if (t) {
			H();
			return;
		}
		A(!1);
	}, [t, H]), b.useEffect(() => {
		document.fullscreenElement || A(!1);
	}, [t]), b.useEffect(() => {
		let e = () => {
			A(!!document.fullscreenElement);
		};
		return document.addEventListener("fullscreenchange", e), () => {
			document.removeEventListener("fullscreenchange", e);
		};
	}, []);
	let U = b.useMemo(() => ({
		transform: `translate(${N.x}px, ${N.y}px) scale(${x}) rotate(${w}deg)`,
		transition: F ? "none" : "transform 160ms ease",
		cursor: j ? "default" : F ? "grabbing" : "grab"
	}), [
		F,
		j,
		w,
		x,
		N.x,
		N.y
	]), W = b.useCallback(() => {
		k("actual"), C((e) => z(e + he));
	}, []), G = b.useCallback(() => {
		k("actual"), C((e) => z(e - he));
	}, []), K = b.useCallback(() => {
		k("fit"), C(1), P({
			x: 0,
			y: 0
		});
	}, []), q = b.useCallback(() => {
		k("actual"), C(1), P({
			x: 0,
			y: 0
		});
	}, []), J = b.useCallback(() => {
		T((e) => e - 90);
	}, []), Y = b.useCallback(() => {
		T((e) => e + 90);
	}, []), X = b.useCallback(async () => {
		let t = ge(u, f, d), n = null;
		try {
			if (ve(u)) {
				_e(u, t), e({ description: h.downloadSuccess });
				return;
			}
		} catch {}
		try {
			let r = await fetch(u, { mode: "cors" });
			if (!r.ok) throw Error(`Failed to fetch image: ${r.status}`);
			let i = await r.blob();
			n = URL.createObjectURL(i), _e(n, t), e({ description: h.downloadSuccess });
		} catch {
			e({
				variant: "destructive",
				description: h.downloadError
			});
		} finally {
			n && URL.revokeObjectURL(n);
		}
	}, [
		d,
		h.downloadError,
		h.downloadSuccess,
		u,
		f
	]), Z = b.useCallback(() => {
		try {
			window.open(u, "_blank", "noopener,noreferrer");
		} catch {
			e({
				variant: "destructive",
				description: h.openInNewTabError
			});
		}
	}, [h.openInNewTabError, u]), Q = b.useCallback(async () => {
		let t = g.current;
		if (!t?.requestFullscreen) {
			e({ description: h.fullscreenError });
			return;
		}
		try {
			document.fullscreenElement ? await document.exitFullscreen() : await t.requestFullscreen();
		} catch {
			e({ description: h.fullscreenError });
		}
	}, [h.fullscreenError]);
	b.useEffect(() => {
		if (!t) return;
		let e = (e) => {
			e.key === "+" ? (e.preventDefault(), W()) : e.key === "-" ? (e.preventDefault(), G()) : e.key === "0" ? (e.preventDefault(), H()) : e.key === "f" || e.key === "F" ? (e.preventDefault(), Q()) : e.key === "[" ? (e.preventDefault(), J()) : e.key === "]" && (e.preventDefault(), Y());
		};
		return window.addEventListener("keydown", e), () => {
			window.removeEventListener("keydown", e);
		};
	}, [
		Q,
		t,
		H,
		J,
		Y,
		W,
		G
	]);
	let $ = b.useCallback((e) => {
		e.preventDefault(), e.stopPropagation(), e.deltaY < 0 ? W() : G();
	}, [W, G]);
	b.useEffect(() => {
		if (!t) return;
		let e = g.current;
		if (e) return e.addEventListener("wheel", $, { passive: !1 }), () => {
			e.removeEventListener("wheel", $);
		};
	}, [$, t]);
	let ye = b.useCallback((e) => {
		L.current.set(e.pointerId, {
			x: e.clientX,
			y: e.clientY
		});
		let t = Array.from(L.current.values());
		if (t.length === 2 && B.current) {
			let [e, n] = t, r = Math.hypot(n.x - e.x, n.y - e.y), i = z(B.current.startScale * (r / B.current.startDistance));
			k("actual"), C(i);
			return;
		}
		let n = R.current;
		!n || n.pointerId !== e.pointerId || P({
			x: n.originX + (e.clientX - n.startX),
			y: n.originY + (e.clientY - n.startY)
		});
	}, []), be = b.useCallback((e) => {
		e && g.current?.hasPointerCapture(e.pointerId) && g.current.releasePointerCapture(e.pointerId), e && L.current.delete(e.pointerId), R.current = null, L.current.size < 2 && (B.current = null), I(!1);
	}, []), xe = b.useCallback((e) => {
		if (e.button !== 0 || j) return;
		e.preventDefault(), e.stopPropagation(), e.currentTarget.setPointerCapture(e.pointerId), L.current.set(e.pointerId, {
			x: e.clientX,
			y: e.clientY
		});
		let t = Array.from(L.current.values());
		if (t.length === 2) {
			let [e, n] = t;
			B.current = {
				startDistance: Math.max(1, Math.hypot(n.x - e.x, n.y - e.y)),
				startScale: x
			}, R.current = null, I(!1);
			return;
		}
		R.current = {
			pointerId: e.pointerId,
			startX: e.clientX,
			startY: e.clientY,
			originX: N.x,
			originY: N.y
		}, I(!0);
	}, [
		j,
		x,
		N.x,
		N.y
	]);
	b.useEffect(() => {
		if (!t) return;
		let e = (e) => {
			let t = g.current, n = e.target;
			!t || !(n instanceof Node) || !t.contains(n) || !e.ctrlKey || $(e);
		};
		return window.addEventListener("wheel", e, {
			passive: !1,
			capture: !0
		}), () => {
			window.removeEventListener("wheel", e, { capture: !0 });
		};
	}, [$, t]);
	let Se = b.useMemo(() => [
		{
			key: "zoom-in",
			label: h.zoomIn,
			icon: le,
			onClick: W,
			disabled: j || x >= me
		},
		{
			key: "zoom-out",
			label: h.zoomOut,
			icon: ue,
			onClick: G,
			disabled: j || x <= pe
		},
		{
			key: "fit",
			label: h.fit,
			icon: re,
			onClick: K,
			disabled: j
		},
		{
			key: "actual-size",
			label: h.actualSize,
			icon: se,
			onClick: q,
			disabled: j
		},
		{
			key: "reset",
			label: h.reset,
			icon: ie,
			onClick: H,
			disabled: j
		},
		{
			key: "rotate-left",
			label: h.rotateLeft,
			icon: ae,
			onClick: J,
			disabled: j
		},
		{
			key: "rotate-right",
			label: h.rotateRight,
			icon: oe,
			onClick: Y,
			disabled: j
		},
		{
			key: "fullscreen",
			label: h.fullscreen,
			icon: ne,
			onClick: () => void Q(),
			disabled: !1
		},
		{
			key: "download",
			label: h.download,
			icon: te,
			onClick: X,
			disabled: j
		},
		{
			key: "new-tab",
			label: h.openInNewTab,
			icon: S,
			onClick: Z,
			disabled: !1
		}
	], [
		X,
		Q,
		Z,
		j,
		h.actualSize,
		h.download,
		h.fit,
		h.fullscreen,
		h.openInNewTab,
		h.reset,
		h.rotateLeft,
		h.rotateRight,
		h.zoomIn,
		h.zoomOut,
		H,
		J,
		Y,
		x,
		q,
		K,
		W,
		G
	]);
	return /* @__PURE__ */ E(o, {
		open: t,
		onOpenChange: n,
		children: /* @__PURE__ */ D(a, {
			showCloseButton: !1,
			className: "flex h-[min(94vh,980px)] w-[calc(100vw-0.75rem)] sm:w-[40rem] md:w-[52rem] lg:w-[64rem] xl:w-[74rem] 2xl:w-[86rem] max-w-[calc(100vw-0.75rem)] flex-col gap-3 border-zinc-800 bg-zinc-950 p-3 text-zinc-50 sm:max-w-[calc(100vw-2rem)] sm:p-4",
			children: [
				/* @__PURE__ */ E(s, { children: V }),
				/* @__PURE__ */ E(i, { children: h.close }),
				/* @__PURE__ */ D(l, {
					delayDuration: 100,
					children: [/* @__PURE__ */ D("div", {
						className: "flex items-center justify-between gap-3 rounded-lg border border-zinc-800 bg-zinc-900/80 px-3 py-2",
						children: [/* @__PURE__ */ D("div", {
							className: "min-w-0",
							children: [/* @__PURE__ */ E("p", {
								className: "truncate text-sm font-medium",
								children: V
							}), /* @__PURE__ */ D("p", {
								className: "text-xs text-zinc-400",
								children: [
									O === "fit" ? h.fit : `${Math.round(x * 100)}%`,
									w === 0 ? "" : ` · ${w}deg`,
									de ? ` · ${h.fullscreen}` : ""
								]
							})]
						}), /* @__PURE__ */ E(c, {
							type: "button",
							size: "icon",
							variant: "ghost",
							className: "h-9 w-9 shrink-0 text-zinc-100 hover:bg-zinc-800 hover:text-white",
							onClick: () => n(!1),
							"aria-label": h.close,
							title: h.close,
							children: /* @__PURE__ */ E(ce, { className: "h-4 w-4" })
						})]
					}), /* @__PURE__ */ E("div", {
						className: "overflow-x-auto rounded-lg border border-zinc-800 bg-zinc-900/80 px-2 py-2",
						children: /* @__PURE__ */ E("div", {
							className: "flex min-w-max items-center gap-2",
							children: Se.map((e) => {
								let t = e.icon;
								return /* @__PURE__ */ D(_, { children: [/* @__PURE__ */ E(v, {
									asChild: !0,
									children: /* @__PURE__ */ E(c, {
										type: "button",
										size: "icon",
										variant: "secondary",
										className: "h-9 w-9 bg-zinc-800 text-zinc-100 hover:bg-zinc-700",
										onClick: e.onClick,
										disabled: e.disabled,
										"aria-label": e.label,
										title: e.label,
										children: /* @__PURE__ */ E(t, { className: "h-4 w-4" })
									})
								}), /* @__PURE__ */ E(y, { children: e.label })] }, e.key);
							})
						})
					})]
				}),
				/* @__PURE__ */ E("div", {
					ref: g,
					className: "relative flex min-h-0 flex-1 items-center justify-center overflow-hidden rounded-xl border border-zinc-800 bg-[radial-gradient(circle_at_top,_rgba(255,255,255,0.08),_transparent_40%),linear-gradient(180deg,_rgba(24,24,27,0.9),_rgba(9,9,11,1))] p-4 touch-none",
					onPointerDown: xe,
					onPointerMove: ye,
					onPointerUp: be,
					onPointerCancel: be,
					children: j ? /* @__PURE__ */ D("div", {
						className: "flex flex-col items-center gap-2 text-center",
						children: [
							/* @__PURE__ */ E("div", {
								className: "rounded-full border border-red-500/40 bg-red-500/10 p-3 text-red-300",
								children: /* @__PURE__ */ E(se, { className: "h-5 w-5" })
							}),
							/* @__PURE__ */ E("p", {
								className: "text-sm font-medium",
								children: h.imageLoadError
							}),
							/* @__PURE__ */ E("p", {
								className: "max-w-md text-xs text-zinc-400",
								children: u
							})
						]
					}) : /* @__PURE__ */ E("img", {
						ref: ee,
						src: u,
						alt: V,
						className: r("max-h-full max-w-full select-none rounded-lg object-contain shadow-2xl", O === "fit" ? "h-auto w-auto" : ""),
						style: U,
						onError: () => M(!0),
						draggable: !1
					})
				})
			]
		})
	});
}
//#endregion
//#region src/components/MdxContent.tsx
function V() {
	return (e) => {
		F(e, "element", (e, t, n) => {
			if (e.tagName === "p" && n && typeof t == "number" && e.children.some((e) => e.type === "element" && (H(e) || e.tagName === "pre"))) {
				let r = [], i = [], a = () => {
					i.length > 0 && (r.push({
						type: "element",
						tagName: "p",
						properties: {},
						children: i
					}), i = []);
				};
				for (let t of e.children) t.type === "element" && (H(t) || t.tagName === "pre") ? (a(), r.push(t)) : i.push(t);
				return a(), n.children.splice(t, 1, ...r), [P, t];
			}
		});
	};
}
function H(e) {
	if ((e.properties || {}).isComponent) return !0;
	let t = e.tagName;
	return t.charAt(0) === t.charAt(0).toUpperCase() && t.charAt(0) !== t.charAt(0).toLowerCase();
}
function U(e) {
	if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
	if (typeof e != "string") return;
	let t = e.trim();
	if (t) return /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t;
}
function W(e) {
	if (typeof e == "boolean") return e;
	if (typeof e != "string") return;
	let t = e.trim().toLowerCase();
	if ([
		"true",
		"1",
		"yes",
		"on"
	].includes(t)) return !0;
	if ([
		"false",
		"0",
		"no",
		"off"
	].includes(t)) return !1;
}
function G(e, t) {
	let n = {
		title: e,
		width: U(t?.width),
		height: U(t?.height),
		inline: W(t?.["data-inline"] ?? t?.inline),
		offsetX: U(t?.["data-offset-x"] ?? t?.offsetX ?? t?.offsetx ?? t?.x),
		offsetY: U(t?.["data-offset-y"] ?? t?.offsetY ?? t?.offsety ?? t?.y),
		preview: W(t?.["data-preview"] ?? t?.preview)
	};
	if (!e || !/(^|\s)(width|height|w|h|size|preview|inline|x|y|offsetx|offsety)=/i.test(e)) return n;
	let r = e;
	return r = r.replace(/(^|\s)(width|height|w|h|size|preview|inline|x|y|offsetx|offsety)=(?:"([^"]+)"|'([^']+)'|([^\s]+))/gi, (e, t, r, i, a, o) => {
		let s = String(r).toLowerCase(), c = i ?? a ?? o ?? "";
		if (s === "preview") n.preview = W(c) ?? n.preview;
		else if (s === "inline") n.inline = W(c) ?? n.inline;
		else if (s === "size") {
			let [e, t] = c.split("x");
			n.width = U(e) ?? n.width, n.height = U(t ?? e) ?? n.height;
		} else s === "width" || s === "w" ? n.width = U(c) ?? n.width : s === "height" || s === "h" ? n.height = U(c) ?? n.height : s === "x" || s === "offsetx" ? n.offsetX = U(c) ?? n.offsetX : (s === "y" || s === "offsety") && (n.offsetY = U(c) ?? n.offsetY);
		return t;
	}), n.title = r.replace(/\s{2,}/g, " ").trim() || void 0, n;
}
function K(e) {
	let t = e, n = "";
	for (; t !== n;) n = t, t = t.replace(/<([A-Z][a-zA-Z0-9]*(?:\.[A-Z][a-zA-Z0-9]*)*)(\s+[^>]*)>([\s\S]*?)<\/\1>/g, (e, t, n, r) => {
		let i = q(n), a = t.toLowerCase().replace(/\./g, "-");
		return `<${a}${i}>${r}</${a}>`;
	}).replace(/<([A-Z][a-zA-Z0-9]*(?:\.[A-Z][a-zA-Z0-9]*)*)(\s+[^>]*?)\s*\/>/g, (e, t, n) => {
		let r = q(n), i = t.toLowerCase().replace(/\./g, "-");
		return `<${i}${r}></${i}>`;
	});
	return t;
}
function q(e) {
	if (!e) return "";
	let t = [], n = /(\w+)=(?:{([^}]+)}|"([^"]*)"|'([^']*)')/g, r;
	for (; (r = n.exec(e)) !== null;) {
		let [, e, n, i, a] = r, o = n || i || a || "";
		t.push(`data-${e}="${o}"`);
	}
	return t.length > 0 ? " " + t.join(" ") : "";
}
function J(e) {
	let t = {};
	for (let [n, r] of Object.entries(e)) if (n.startsWith("data-")) {
		let e = n.slice(5);
		if (r === "true") t[e] = !0;
		else if (r === "false") t[e] = !1;
		else if (r === "null") t[e] = null;
		else if (r === "undefined") t[e] = void 0;
		else if (!isNaN(Number(r)) && r !== "") t[e] = Number(r);
		else if (r.startsWith("[") && r.endsWith("]")) try {
			t[e] = JSON.parse(r);
		} catch {
			t[e] = r;
		}
		else if (r.startsWith("{") && r.endsWith("}")) try {
			t[e] = JSON.parse(r);
		} catch {
			t[e] = r;
		}
		else t[e] = r;
	}
	return t;
}
var Y = {
	js: "JavaScript",
	javascript: "JavaScript",
	ts: "TypeScript",
	typescript: "TypeScript",
	jsx: "JSX",
	tsx: "TSX",
	bash: "Bash",
	shell: "Shell",
	sh: "Shell",
	python: "Python",
	py: "Python",
	java: "Java",
	c: "C",
	cpp: "C++",
	csharp: "C#",
	go: "Go",
	rust: "Rust",
	ruby: "Ruby",
	php: "PHP",
	swift: "Swift",
	kotlin: "Kotlin",
	sql: "SQL",
	json: "JSON",
	yaml: "YAML",
	yml: "YAML",
	toml: "TOML",
	markdown: "Markdown",
	md: "Markdown",
	html: "HTML",
	css: "CSS",
	scss: "SCSS",
	less: "Less",
	vue: "Vue",
	svelte: "Svelte",
	docker: "Docker",
	dockerfile: "Dockerfile",
	nginx: "Nginx",
	xml: "XML",
	diff: "Diff",
	text: "Text"
};
function X({ className: e, children: r, meta: i, codeHighlight: a, shikiBundle: o }) {
	let [s, c] = b.useState(""), [l, u] = b.useState(!1), [f, m] = b.useState(!1), g = b.useMemo(() => i?.toLowerCase().includes("showlinenumbers") ?? !1, [i]), _ = /language-(\w+)/.exec(e || ""), v = _ ? _[1] : "text", y = d(v), te = Y[v.toLowerCase()] || v.toUpperCase(), S = b.useMemo(() => {
		let e = "";
		return e = typeof r == "string" ? r : b.Children.count(r) === 1 && typeof r == "string" ? String(r) : b.Children.toArray(r).map((e) => {
			if (typeof e == "string") return e;
			if (typeof e == "object" && e && "props" in e) {
				let t = e.props;
				if (t?.node?.type === "element") {
					let e = t.node.tagName || "span", n = t.children;
					return Array.isArray(n) && n.length === 0 ? `<${e} />` : `<${e}>${n.map((e) => typeof e == "string" ? e : e?.type === "text" && e.value || "").join("")}</${e}>`;
				}
			}
			return "";
		}).join(""), e.replace(/^\n+/, "").replace(/\n+$/, "");
	}, [r]);
	b.useEffect(() => {
		let e = () => {
			u(document.documentElement.classList.contains("dark"));
		};
		e();
		let t = new MutationObserver(() => e());
		return t.observe(document.documentElement, {
			attributes: !0,
			attributeFilter: ["class"]
		}), () => t.disconnect();
	}, []), b.useEffect(() => {
		p(S, {
			lang: y,
			theme: h(l, a, o),
			showLineNumbers: g
		}, a, o).then((e) => c(n(e)));
	}, [
		S,
		y,
		l,
		g,
		a,
		o
	]);
	let ne = b.useCallback(async () => {
		try {
			await t(S), m(!0), setTimeout(() => m(!1), 2e3);
		} catch (e) {
			console.error("Failed to copy:", e);
		}
	}, [S]);
	return s ? /* @__PURE__ */ D("div", {
		className: "code-block-wrapper",
		children: [
			/* @__PURE__ */ E("span", {
				className: "code-lang-label",
				children: te
			}),
			/* @__PURE__ */ E("button", {
				className: "code-copy-btn",
				onClick: ne,
				title: f ? "已复制" : "复制代码",
				"aria-label": "复制代码",
				children: f ? /* @__PURE__ */ E(ee, { className: "h-4 w-4 text-green-500" }) : /* @__PURE__ */ E(x, { className: "h-4 w-4" })
			}),
			/* @__PURE__ */ E("pre", {
				className: `shiki-code-block${g ? " show-line-numbers" : ""}`,
				dangerouslySetInnerHTML: { __html: s }
			})
		]
	}) : /* @__PURE__ */ E("div", {
		className: "code-block-wrapper",
		children: /* @__PURE__ */ E("pre", {
			className: "shiki-code-block",
			children: /* @__PURE__ */ E("code", { children: S })
		})
	});
}
function Z({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, node: o, ...s }) {
	let [c, l] = b.useState(!1), u = b.useMemo(() => fe(e, t?.labels), [e, t?.labels]), d = b.useMemo(() => G(i, s), [s, i]), f = d.preview ?? t?.enabled !== !1, p = d.inline === !0, m = !!(d.width || d.height), h = b.useMemo(() => ({
		...s.style,
		width: d.width ?? s.style?.width,
		height: d.height ?? s.style?.height,
		transform: [s.style?.transform, d.offsetX || d.offsetY ? `translate(${d.offsetX ?? "0px"}, ${d.offsetY ?? "0px"})` : void 0].filter(Boolean).join(" ") || void 0
	}), [
		d.height,
		d.offsetX,
		d.offsetY,
		d.width,
		s.style
	]);
	return n ? f ? m || p ? /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E("button", {
		type: "button",
		className: "not-prose inline-flex max-w-full cursor-zoom-in align-middle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
		onClick: () => l(!0),
		"aria-label": u.preview,
		title: u.preview,
		children: /* @__PURE__ */ E("img", {
			...s,
			src: n,
			alt: r || u.imageAltFallback,
			title: d.title,
			className: a ?? (p ? "inline-block align-middle" : void 0),
			style: h
		})
	}), /* @__PURE__ */ E(B, {
		open: c,
		onOpenChange: l,
		src: n,
		alt: r,
		title: d.title,
		lang: e,
		labels: t?.labels
	})] }) : /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ D("span", {
		className: "not-prose group relative my-6 block",
		children: [/* @__PURE__ */ E("button", {
			type: "button",
			className: "block w-full cursor-zoom-in overflow-hidden rounded-2xl border border-border/60 bg-muted/20 shadow-sm transition duration-200 hover:-translate-y-0.5 hover:shadow-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
			onClick: () => l(!0),
			"aria-label": u.preview,
			title: u.preview,
			children: /* @__PURE__ */ E("img", {
				...s,
				src: n,
				alt: r || u.imageAltFallback,
				title: d.title,
				className: a ?? "h-auto w-full rounded-2xl object-contain",
				style: h
			})
		}), /* @__PURE__ */ D("button", {
			type: "button",
			className: "absolute right-3 top-3 inline-flex items-center gap-2 rounded-full border border-white/20 bg-black/65 px-3 py-1.5 text-xs font-medium text-white opacity-0 shadow-lg transition group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/70",
			onClick: () => l(!0),
			"aria-label": u.preview,
			children: [
				/* @__PURE__ */ E("span", {
					className: "sr-only",
					children: u.preview
				}),
				/* @__PURE__ */ D("svg", {
					"aria-hidden": "true",
					viewBox: "0 0 24 24",
					className: "h-3.5 w-3.5",
					fill: "none",
					stroke: "currentColor",
					strokeWidth: "2",
					strokeLinecap: "round",
					strokeLinejoin: "round",
					children: [/* @__PURE__ */ E("path", { d: "M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6-10-6-10-6Z" }), /* @__PURE__ */ E("circle", {
						cx: "12",
						cy: "12",
						r: "3"
					})]
				}),
				/* @__PURE__ */ E("span", { children: u.preview })
			]
		})]
	}), /* @__PURE__ */ E(B, {
		open: c,
		onOpenChange: l,
		src: n,
		alt: r,
		title: d.title,
		lang: e,
		labels: t?.labels
	})] }) : /* @__PURE__ */ E("img", {
		...s,
		src: n,
		alt: r || u.imageAltFallback,
		title: d.title,
		className: a ?? (p ? "inline-block align-middle" : void 0),
		style: h
	}) : null;
}
function Q({ source: e, skipFirstH1: t = !1, imageViewer: n, codeHighlight: r, shikiBundle: i }) {
	let a = w(), o = a.lang || "zh-cn", s = a.version, c = m();
	b.useEffect(() => {
		u(r, i);
	}, [r, i]);
	let l = b.useMemo(() => {
		if (!t) return e;
		let n = e.split("\n"), r = !1;
		return n.filter((e) => !r && e.startsWith("# ") ? (r = !0, !1) : !0).join("\n");
	}, [e, t]), d = b.useMemo(() => K(l), [l]), p = b.useMemo(() => {
		let e = /* @__PURE__ */ new Map();
		return c && Object.entries(c).forEach(([t, n]) => {
			let r = b.memo(({ children: e, ...t }) => {
				let r = J(t);
				return b.createElement(n, r, e);
			});
			if (e.set(t, r), e.set(t.toLowerCase(), r), t.includes(".")) {
				let [n, i] = t.split("."), a = `${n.toLowerCase()}-${i.toLowerCase()}`;
				e.set(a, r);
			}
		}), e;
	}, [c]), h = b.useMemo(() => Object.fromEntries(p), [p]);
	return /* @__PURE__ */ E("div", {
		className: "prose dark:prose-invert max-w-none",
		children: /* @__PURE__ */ E(de, {
			remarkPlugins: [O, k],
			rehypePlugins: [
				j,
				M,
				L(h),
				V,
				[A, { behavior: "append" }],
				[N, {
					strict: !1,
					trust: !0,
					macros: {
						"\\R": "\\mathbb{R}",
						"\\N": "\\mathbb{N}",
						"\\Z": "\\mathbb{Z}",
						"\\Q": "\\mathbb{Q}",
						"\\C": "\\mathbb{C}",
						...I
					}
				}]
			],
			components: {
				...h,
				table({ children: e, ...t }) {
					return /* @__PURE__ */ E("div", {
						className: "overflow-x-auto",
						children: /* @__PURE__ */ E("table", {
							...t,
							children: e
						})
					});
				},
				pre({ children: e, ...t }) {
					let n = b.Children.toArray(e).find((e) => e?.type === "code" || e?.props?.node?.tagName === "code");
					if (n) {
						let e = n.props, t = e?.className || "", a = /language-(\w+)/.exec(t), o = a ? a[1].toLowerCase() : "text", s = e?.node, c = e?.children, l = e?.["data-raw-value"];
						l && (c = l);
						let u = s?.data?.meta || "";
						return o === "mermaid" ? /* @__PURE__ */ E(g, { chart: typeof c == "string" ? c : String(c || "") }) : /* @__PURE__ */ E(X, {
							className: t,
							meta: u,
							codeHighlight: r,
							shikiBundle: i,
							children: c
						});
					}
					return /* @__PURE__ */ E("pre", {
						...t,
						children: e
					});
				},
				a({ href: e, children: t, ...n }) {
					return e ? e.startsWith("#") ? /* @__PURE__ */ E("a", {
						href: e,
						...n,
						children: t
					}) : /^(https?:)?\/\//i.test(e) || e.startsWith("mailto:") || e.startsWith("tel:") ? /* @__PURE__ */ E("a", {
						href: e,
						target: "_blank",
						rel: "noopener noreferrer",
						...n,
						children: t
					}) : /* @__PURE__ */ E(C, {
						to: f(o, e.startsWith("/") ? e : `/${e}`, s),
						...n,
						children: t
					}) : /* @__PURE__ */ E("a", {
						...n,
						children: t
					});
				},
				img({ src: e, alt: t, title: r, className: i, node: a, ...s }) {
					return /* @__PURE__ */ E(Z, {
						lang: o,
						viewerConfig: n,
						src: e,
						alt: t,
						title: r,
						className: i,
						node: a,
						...s
					});
				}
			},
			children: d
		})
	});
}
//#endregion
export { B as n, Q as t };
