import { cn as e } from "../../../lib/utils.js";
import { t } from "../../../dist-Ber_p4PA.js";
import { memo as n, useMemo as r } from "react";
import { jsx as i } from "react/jsx-runtime";
//#region lib/components/ui/atoms/json-highlight.tsx
var a = /("(?:[^"\\]|\\.)*")\s*(?=:)|("(?:[^"\\]|\\.)*")|\b(true)\b|\b(false)\b|\b(null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;
function o(e) {
	let t = [], n = 0;
	for (let r of e.matchAll(a)) {
		let i = r.index;
		i > n && t.push(e.slice(n, i));
		let [a, o, s, c, l, u, d] = r;
		o ? t.push({
			type: "key",
			text: o,
			offset: i
		}) : s ? t.push({
			type: "str",
			text: s,
			offset: i
		}) : c ? t.push({
			type: "true",
			text: c,
			offset: i
		}) : l ? t.push({
			type: "false",
			text: l,
			offset: i
		}) : u ? t.push({
			type: "null",
			text: u,
			offset: i
		}) : d && t.push({
			type: "num",
			text: d,
			offset: i
		}), n = i + a.length;
	}
	return n < e.length && t.push(e.slice(n)), t;
}
var s = t("w-full overflow-x-auto text-[13px] text-foreground/90", {
	variants: { theme: {
		default: [
			"[--jh-key:#8a6c14] dark:[--jh-key:#b8a965]",
			"[--jh-str:#a8453a] dark:[--jh-str:#c98a7d]",
			"[--jh-num:#0f766e] dark:[--jh-num:#4c9a91]",
			"[--jh-true:#2f6e4e] dark:[--jh-true:#4d9375]",
			"[--jh-false:#a8453a] dark:[--jh-false:#c98a7d]",
			"[--jh-null:#71717a] dark:[--jh-null:#a1a1aa]"
		],
		branded: [
			"[--jh-key:var(--chart-2)]",
			"[--jh-str:var(--chart-1)]",
			"[--jh-num:var(--warning)]",
			"[--jh-true:var(--success)]",
			"[--jh-false:var(--destructive)]",
			"[--jh-null:var(--color-muted-foreground)]"
		],
		monochrome: [
			"[--jh-key:var(--color-foreground)]",
			"[--jh-str:var(--color-muted-foreground)]",
			"[--jh-num:var(--color-muted-foreground)]",
			"[--jh-true:var(--color-muted-foreground)]",
			"[--jh-false:var(--color-muted-foreground)]",
			"[--jh-null:var(--color-muted-foreground)]"
		]
	} },
	defaultVariants: { theme: "default" }
}), c = {
	key: "text-[var(--jh-key)]",
	str: "text-[var(--jh-str)]",
	num: "text-[var(--jh-num)]",
	true: "text-[var(--jh-true)]",
	false: "text-[var(--jh-false)]",
	null: "text-[var(--jh-null)]"
}, l = n(function({ code: t, theme: n, className: a, ...l }) {
	let u = r(() => o(t), [t]);
	return /* @__PURE__ */ i("div", {
		className: e(s({ theme: n }), a),
		"data-slot": "json-highlight",
		...l,
		children: /* @__PURE__ */ i("pre", {
			className: "wrap-break-word max-w-full whitespace-pre-wrap p-3 font-mono leading-relaxed",
			children: /* @__PURE__ */ i("code", { children: u.map((e) => typeof e == "string" ? e : /* @__PURE__ */ i("span", {
				className: c[e.type],
				children: e.text
			}, e.offset)) })
		})
	});
});
//#endregion
export { l as JsonHighlight, s as jsonHighlightVariants };
