/**
 * Quote Block - Save/Output Generators
 *
 * Page context: Returns placeholder for server-side rendering via render.php
 * Email context: Generates inline HTML (email clients can't call server)
 *
 * This approach ensures:
 * - Single source of truth (render.php) for page display
 * - Semantic HTML with proper blockquote/cite elements
 * - Email still works without server calls
 */

/**
 * Generate placeholder for server-side rendering (page context)
 */
export const page = (props, options = {}) => {
    const serverProps = {
        text: props.text || '',
        author: props.author || '',
        authorTitle: props.authorTitle || '',
        align: props.align || 'left',
        borderColor: props.borderColor || '#635bff',
        backgroundColor: props.backgroundColor || '#f8fafc',
        textColor: props.textColor || '#475569',
        authorColor: props.authorColor || '#1e293b',
        layoutStyles: props.layoutStyles || {},
        customCSS: props.customCSS || '',
        customClass: props.customClass || '',
    };

    // Escape for HTML attribute
    const propsJson = JSON.stringify(serverProps).replace(/'/g, '&#39;');

    return `<div data-lara-block="quote" data-props='${propsJson}'></div>`;
};

/**
 * Generate placeholder for server-side rendering (email context)
 */
export const email = (props, options = {}) => {
    const serverProps = {
        text: props.text || '',
        author: props.author || '',
        authorTitle: props.authorTitle || '',
        align: props.align || 'left',
        borderColor: props.borderColor || '#635bff',
        backgroundColor: props.backgroundColor || '#f8fafc',
        textColor: props.textColor || '#475569',
        authorColor: props.authorColor || '#1e293b',
        layoutStyles: props.layoutStyles || {},
    };

    const propsJson = JSON.stringify(serverProps).replace(/'/g, '&#39;');

    return `<div data-lara-block="quote" data-props='${propsJson}'></div>`;
};

export default {
    page,
    email,
};
