import { cn } from "./index3.js";
import { tryAsciiToSvg } from "./index408.js";
import { cva } from "class-variance-authority";
import * as React from "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region src/components/organisms/ai/AIAsciiDiagram/AIAsciiDiagram.tsx
var asciiDiagramVariants = cva("relative overflow-hidden rounded-xl border border-border bg-muted", {
	variants: { scaleMode: {
		fit: "w-full [&_svg]:w-full [&_svg]:h-auto",
		scroll: "overflow-x-auto",
		responsive: "w-full [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-h-[500px]"
	} },
	defaultVariants: { scaleMode: "responsive" }
});
var captionVariants = cva("text-xs text-muted-foreground text-center py-2 border-t border-border");
/**
* AIAsciiDiagram renders ASCII box-drawing art as scalable SVG graphics.
*
* Features:
* - Converts box-drawing characters to SVG paths
* - Preserves text labels within diagrams
* - Falls back to styled monospace if conversion fails
* - Supports light/dark themes via CSS custom properties
*
* Security note: SVG content is generated internally from parsed ASCII,
* with text properly escaped. The dangerouslySetInnerHTML is safe here
* as we control the SVG generation.
*/
var AIAsciiDiagram = React.forwardRef(({ content, mode = "svg", scaleMode, caption, className, ariaLabel }, ref) => {
	const [svgContent, setSvgContent] = React.useState(null);
	const [renderMode, setRenderMode] = React.useState(mode);
	React.useEffect(() => {
		if (mode === "monospace") {
			setRenderMode("monospace");
			return;
		}
		const svg = tryAsciiToSvg(content, {
			strokeColor: "var(--border)",
			textColor: "var(--foreground)",
			backgroundColor: "transparent"
		});
		if (svg) {
			setSvgContent(svg);
			setRenderMode("svg");
		} else setRenderMode("monospace");
	}, [content, mode]);
	const accessibleLabel = ariaLabel || `ASCII diagram with ${content.split("\n").length} lines`;
	return /* @__PURE__ */ jsxs("div", {
		ref,
		"data-slot": "ai-ascii-diagram",
		className: cn(asciiDiagramVariants({ scaleMode }), className),
		role: "img",
		"aria-label": accessibleLabel,
		children: [renderMode === "svg" && svgContent ? /* @__PURE__ */ jsx("div", {
			className: "p-4 [&_svg]:text-foreground",
			"aria-hidden": "true",
			dangerouslySetInnerHTML: { __html: svgContent }
		}) : /* @__PURE__ */ jsx("pre", {
			className: "p-4 font-mono text-sm text-foreground whitespace-pre overflow-x-auto leading-relaxed",
			children: content
		}), caption && /* @__PURE__ */ jsx("div", {
			className: captionVariants(),
			children: caption
		})]
	});
});
AIAsciiDiagram.displayName = "AIAsciiDiagram";
//#endregion
export { asciiDiagramVariants, AIAsciiDiagram as default };

//# sourceMappingURL=index409.js.map