const CORE_BLOCKS = [
    {
        type: 'hero',
        label: 'Hero',
        icon: 'Star',
        description: 'Large banner section with headline, image, and call-to-action',
        variants: [
            {
                name: 'centered',
                label: 'Centered',
                description: 'Content centered over background image',
            },
            {
                name: 'split-image',
                label: 'Split Image',
                description: 'Text on one side, image on the other',
            },
            {
                name: 'video-bg',
                label: 'Video Background',
                description: 'Fullscreen video with text overlay',
            },
            { name: 'minimal', label: 'Minimal', description: 'Simple text-only hero with no media' },
        ],
        fields: {
            title: { type: 'text', label: 'Title', required: true },
            subtitle: { type: 'text', label: 'Subtitle' },
            image: { type: 'media', label: 'Image' },
            videoUrl: { type: 'url', label: 'Video URL' },
            ctaText: { type: 'text', label: 'CTA Text' },
            ctaLink: { type: 'url', label: 'CTA Link' },
            overlayOpacity: { type: 'number', label: 'Overlay Opacity', min: 0, max: 100 },
        },
    },
    {
        type: 'text',
        label: 'Text',
        icon: 'Type',
        description: 'Rich text content block with optional heading',
        variants: [
            { name: 'prose', label: 'Prose', description: 'Single-column readable text' },
            { name: 'two-column', label: 'Two Column', description: 'Text split across two columns' },
            {
                name: 'with-sidebar',
                label: 'With Sidebar',
                description: 'Main text with a sidebar annotation',
            },
        ],
        fields: {
            body: { type: 'richText', label: 'Body', required: true },
            heading: { type: 'text', label: 'Heading' },
            headingLevel: {
                type: 'select',
                label: 'Heading Level',
                options: [
                    { label: 'H2', value: 'h2' },
                    { label: 'H3', value: 'h3' },
                    { label: 'H4', value: 'h4' },
                ],
            },
        },
    },
    {
        type: 'image',
        label: 'Image',
        icon: 'Image',
        description: 'Single image with optional caption and link',
        variants: [
            { name: 'full-width', label: 'Full Width', description: 'Edge-to-edge image' },
            { name: 'captioned', label: 'Captioned', description: 'Image with visible caption below' },
            { name: 'rounded', label: 'Rounded', description: 'Image with rounded corners' },
            {
                name: 'side-by-side',
                label: 'Side by Side',
                description: 'Two images displayed horizontally',
            },
        ],
        fields: {
            src: { type: 'media', label: 'Source', required: true },
            alt: { type: 'text', label: 'Alt Text', required: true },
            caption: { type: 'text', label: 'Caption' },
            link: { type: 'url', label: 'Link' },
            aspectRatio: {
                type: 'select',
                label: 'Aspect Ratio',
                options: [
                    { label: 'Auto', value: 'auto' },
                    { label: '16:9', value: '16:9' },
                    { label: '4:3', value: '4:3' },
                    { label: '1:1', value: '1:1' },
                ],
            },
        },
    },
    {
        type: 'cards',
        label: 'Cards',
        icon: 'LayoutGrid',
        description: 'Grid or list of cards with title, description, and image',
        variants: [
            { name: 'grid-2', label: '2 Column Grid', description: 'Cards in a 2-column grid' },
            { name: 'grid-3', label: '3 Column Grid', description: 'Cards in a 3-column grid' },
            { name: 'grid-4', label: '4 Column Grid', description: 'Cards in a 4-column grid' },
            {
                name: 'horizontal',
                label: 'Horizontal',
                description: 'Cards in a horizontal scrolling row',
            },
        ],
        fields: {
            items: {
                type: 'array',
                label: 'Items',
                fields: {
                    title: { type: 'text', label: 'Title', required: true },
                    description: { type: 'text', label: 'Description' },
                    image: { type: 'media', label: 'Image' },
                    link: { type: 'url', label: 'Link' },
                    icon: { type: 'text', label: 'Icon' },
                },
            },
        },
    },
    {
        type: 'cta',
        label: 'Call to Action',
        icon: 'MousePointer',
        description: 'Prominent call-to-action with button',
        variants: [
            { name: 'banner', label: 'Banner', description: 'Full-width colored banner' },
            { name: 'inline', label: 'Inline', description: 'Compact inline CTA' },
            { name: 'floating', label: 'Floating', description: 'Floating card-style CTA' },
            { name: 'split', label: 'Split', description: 'Text on one side, button on the other' },
        ],
        fields: {
            heading: { type: 'text', label: 'Heading', required: true },
            body: { type: 'text', label: 'Body' },
            buttonText: { type: 'text', label: 'Button Text', required: true },
            buttonLink: { type: 'url', label: 'Button Link', required: true },
            buttonStyle: {
                type: 'select',
                label: 'Button Style',
                options: [
                    { label: 'Primary', value: 'primary' },
                    { label: 'Secondary', value: 'secondary' },
                    { label: 'Outline', value: 'outline' },
                ],
            },
        },
    },
    {
        type: 'video',
        label: 'Video',
        icon: 'Play',
        description: 'Embedded video player',
        variants: [
            { name: 'inline', label: 'Inline', description: 'Video embedded directly in the page' },
            {
                name: 'lightbox',
                label: 'Lightbox',
                description: 'Thumbnail that opens video in a lightbox',
            },
            {
                name: 'background',
                label: 'Background',
                description: 'Muted video as a background element',
            },
        ],
        fields: {
            url: { type: 'url', label: 'URL', required: true },
            poster: { type: 'media', label: 'Poster' },
            autoplay: { type: 'boolean', label: 'Autoplay' },
            loop: { type: 'boolean', label: 'Loop' },
        },
    },
    {
        type: 'gallery',
        label: 'Gallery',
        icon: 'Grid',
        description: 'Collection of images displayed in various layouts',
        variants: [
            { name: 'grid', label: 'Grid', description: 'Equal-sized image grid' },
            { name: 'masonry', label: 'Masonry', description: 'Varied-height masonry layout' },
            { name: 'carousel', label: 'Carousel', description: 'Horizontal scrolling carousel' },
            { name: 'lightbox', label: 'Lightbox', description: 'Thumbnails that open in a lightbox' },
        ],
        fields: {
            images: {
                type: 'array',
                label: 'Images',
                fields: {
                    src: { type: 'media', label: 'Source', required: true },
                    alt: { type: 'text', label: 'Alt Text', required: true },
                    caption: { type: 'text', label: 'Caption' },
                },
            },
        },
    },
    {
        type: 'faq',
        label: 'FAQ',
        icon: 'HelpCircle',
        description: 'Frequently asked questions list',
        variants: [
            { name: 'accordion', label: 'Accordion', description: 'Collapsible accordion panels' },
            { name: 'list', label: 'List', description: 'All questions visible in a flat list' },
            {
                name: 'two-column',
                label: 'Two Column',
                description: 'Questions split across two columns',
            },
        ],
        fields: {
            items: {
                type: 'array',
                label: 'Items',
                fields: {
                    question: { type: 'text', label: 'Question', required: true },
                    answer: { type: 'richText', label: 'Answer', required: true },
                },
            },
        },
    },
    {
        type: 'form',
        label: 'Form',
        icon: 'FileText',
        description: 'Embedded form from the forms collection',
        variants: [
            { name: 'contact', label: 'Contact', description: 'Standard contact form layout' },
            { name: 'newsletter', label: 'Newsletter', description: 'Compact email signup' },
            { name: 'custom', label: 'Custom', description: 'Fully custom form layout' },
        ],
        fields: {
            formId: { type: 'relationship', label: 'Form', relationTo: 'forms' },
            successMessage: { type: 'text', label: 'Success Message' },
        },
    },
    {
        type: 'code',
        label: 'Code',
        icon: 'Code',
        description: 'Embed raw HTML, JavaScript, or CSS',
        variants: [
            { name: 'embed', label: 'Embed', description: 'Generic embed code' },
            { name: 'html', label: 'HTML', description: 'Raw HTML block' },
            { name: 'script', label: 'Script', description: 'JavaScript or tracking script' },
        ],
        fields: {
            content: { type: 'text', label: 'Content', required: true },
            language: {
                type: 'select',
                label: 'Language',
                options: [
                    { label: 'HTML', value: 'html' },
                    { label: 'JavaScript', value: 'javascript' },
                    { label: 'CSS', value: 'css' },
                ],
            },
            sandboxed: { type: 'boolean', label: 'Sandboxed' },
        },
    },
];
function readCustomBlocksFromGlobalConfig() {
    if (typeof globalThis === 'undefined')
        return [];
    // We read directly from `globalThis` (rather than via `getActuateConfig()`)
    // so this stays synchronous at module-load time and avoids importing the
    // wider runtime module from inside page-builder. The shape we need is
    // narrow enough that a local typed cast is safer than `as any`.
    const config = globalThis
        .__actuateConfig;
    const blocks = config?.pageBuilder?.blocks;
    if (Array.isArray(blocks)) {
        return blocks.filter((b) => !!b && typeof b.type === 'string');
    }
    return [];
}
export class BlockCatalog {
    blocks;
    constructor(options = {}) {
        const includeCore = options.includeCore !== false;
        this.blocks = new Map();
        if (includeCore) {
            for (const block of CORE_BLOCKS) {
                this.blocks.set(block.type, block);
            }
        }
        // Pull from explicit `customBlocks` first; otherwise fall back to the
        // global config so consumers don't have to thread their custom blocks
        // through every BlockEditor / BlockPicker call site.
        const custom = options.customBlocks ?? readCustomBlocksFromGlobalConfig();
        for (const block of custom) {
            this.blocks.set(block.type, block);
        }
    }
    get(type) {
        return this.blocks.get(type);
    }
    getAll() {
        return Array.from(this.blocks.values());
    }
    register(block) {
        this.blocks.set(block.type, block);
    }
    getVariant(blockType, variantName) {
        const block = this.blocks.get(blockType);
        if (!block)
            return undefined;
        return block.variants.find((v) => v.name === variantName);
    }
}
//# sourceMappingURL=blocks.js.map