/**
 * Simple utility to log debugging info during PDF generation steps.
 */

const DEBUG = true;

export const logPdfDebug = (stage, data) => {
    if (!DEBUG) return;
    
    const timestamp = new Date().toISOString();
    console.group(`[PDF Debug] ${stage} @ ${timestamp}`);
    if (data) {
        console.log(data);
    }
    
    // Check for font loading status if relevant
    if (stage.includes('Font')) {
        console.log('Document Fonts Status:', document.fonts.status);
        console.log('Loaded Fonts size:', document.fonts.size);
    }
    
    console.groupEnd();
};

export const compareElements = (previewEl, exportEl) => {
    if (!previewEl || !exportEl) return;
    
    const pStyle = window.getComputedStyle(previewEl);
    const eStyle = window.getComputedStyle(exportEl);
    
    const propsToCheck = ['fontFamily', 'fontSize', 'fontWeight', 'color', 'lineHeight', 'width', 'height'];
    const diffs = {};
    
    propsToCheck.forEach(prop => {
        if (pStyle[prop] !== eStyle[prop]) {
            diffs[prop] = { preview: pStyle[prop], export: eStyle[prop] };
        }
    });
    
    if (Object.keys(diffs).length > 0) {
        console.warn('Element Mismatch found:', diffs);
    } else {
        console.log('Elements match stylistically.');
    }
};