/**
 * MK2 Phase 1B: Debug Overlay
 *
 * Top line only, never exceeds safeW
 * Shows layout info for verification
 * FIXED: Enhanced debug info when DEBUG_LAYOUT=1
 */
import blessed from 'neo-blessed';
import { safeText } from '../../tui_mk1/ui/safeText.js';
/**
 * Create debug overlay line (top of screen) - MK2 Hotfix: Show guards
 * Truncated to safeW to prevent overflow
 * If DEBUG_LAYOUT=1, shows detailed rect info
 */
export function createDebugOverlay(screen, spec) {
    // CRITICAL: Only show debug when DEBUG_LAYOUT=1
    if (process.env.DEBUG_LAYOUT !== '1') {
        return null;
    }
    // Detailed debug: show all rects and layout info
    const maxRightEdge = spec.maxRightEdge || 0;
    const maxBottomEdge = spec.maxBottomEdge || 0;
    const rects = spec.rects;
    const debugText = `cols=${spec.cols} rows=${spec.rows} safe=${spec.safeW}x${spec.safeH} mode=${spec.mode} ` +
        `leftW=${spec.leftW} centerW=${spec.centerW} rightW=${spec.rightW} ` +
        `maxR=${maxRightEdge} maxB=${maxBottomEdge} ` +
        `posture=${rects.posture.w}x${rects.posture.h} ops=${rects.operations.w}x${rects.operations.h} caps=${rects.capabilities.w}x${rects.capabilities.h}`;
    // Truncate to safeW - 2 (must fit within safe bounds with buffer)
    const maxDebugWidth = Math.min(spec.safeW - 2, 200);
    const safeTextContent = safeText(debugText, maxDebugWidth);
    return blessed.box({
        parent: screen,
        top: 0,
        left: 0,
        width: Math.min(safeTextContent.length + 1, maxDebugWidth),
        height: 1,
        content: safeTextContent,
        tags: false,
        style: {
            fg: 'yellow',
            bg: 'black',
        },
    });
}
//# sourceMappingURL=overlay.js.map