import { RenderDeviceError } from "./RenderDevice.js";
export function captureRenderDebugIssue(kind, label, error) {
    const trimmedLabel = requireNonEmptyLabel(label);
    if (error instanceof RenderDeviceError) {
        return {
            kind,
            label: trimmedLabel,
            message: error.message,
            code: error.code,
            details: error.details
        };
    }
    if (error instanceof Error) {
        return {
            kind,
            label: trimmedLabel,
            message: error.message
        };
    }
    return {
        kind,
        label: trimmedLabel,
        message: String(error)
    };
}
export function buildRenderDebugOverlaySnapshot(issues) {
    const normalized = issues.map((issue) => ({
        ...issue,
        label: requireNonEmptyLabel(issue.label),
        message: issue.message.trim() || "Unknown render debug issue"
    }));
    const renderPassErrors = normalized.filter((issue) => issue.kind === "render-pass-error").length;
    const shaderErrors = normalized.filter((issue) => issue.kind === "shader-error").length;
    return {
        visible: normalized.length > 0,
        issueCount: normalized.length,
        renderPassErrors,
        shaderErrors,
        issues: normalized,
        lines: normalized.map(formatRenderDebugIssue)
    };
}
export function formatRenderDebugIssue(issue) {
    const code = issue.code ? ` ${issue.code}` : "";
    return `[${issue.kind}${code}] ${issue.label}: ${issue.message}`;
}
function requireNonEmptyLabel(label) {
    const trimmed = label.trim();
    if (!trimmed) {
        throw new Error("Render debug issue label is required");
    }
    return trimmed;
}
//# sourceMappingURL=RendererDebugOverlay.js.map