<?php
declare(strict_types=1);

namespace ROITheme\Admin\FeaturedImage\Infrastructure\FieldMapping;

use ROITheme\Admin\Shared\Domain\Contracts\FieldMapperInterface;

/**
 * Field Mapper para Featured Image
 *
 * RESPONSABILIDAD:
 * - Mapear field IDs del formulario a atributos de BD
 * - Solo conoce sus propios campos (modularidad)
 */
final class FeaturedImageFieldMapper implements FieldMapperInterface
{
    public function getComponentName(): string
    {
        return 'featured-image';
    }

    public function getFieldMapping(): array
    {
        return [
            // Visibility
            'featuredImageEnabled' => ['group' => 'visibility', 'attribute' => 'is_enabled'],
            'featuredImageShowOnDesktop' => ['group' => 'visibility', 'attribute' => 'show_on_desktop'],
            'featuredImageShowOnMobile' => ['group' => 'visibility', 'attribute' => 'show_on_mobile'],

            // Page Visibility (grupo especial _page_visibility)
            'featuredImageVisibilityHome' => ['group' => '_page_visibility', 'attribute' => 'show_on_home'],
            'featuredImageVisibilityPosts' => ['group' => '_page_visibility', 'attribute' => 'show_on_posts'],
            'featuredImageVisibilityPages' => ['group' => '_page_visibility', 'attribute' => 'show_on_pages'],
            'featuredImageVisibilityArchives' => ['group' => '_page_visibility', 'attribute' => 'show_on_archives'],
            'featuredImageVisibilitySearch' => ['group' => '_page_visibility', 'attribute' => 'show_on_search'],

            // Exclusions (grupo especial _exclusions - Plan 99.11)
            'featuredImageExclusionsEnabled' => ['group' => '_exclusions', 'attribute' => 'exclusions_enabled'],
            'featuredImageExcludeCategories' => ['group' => '_exclusions', 'attribute' => 'exclude_categories', 'type' => 'json_array'],
            'featuredImageExcludePostIds' => ['group' => '_exclusions', 'attribute' => 'exclude_post_ids', 'type' => 'json_array_int'],
            'featuredImageExcludeUrlPatterns' => ['group' => '_exclusions', 'attribute' => 'exclude_url_patterns', 'type' => 'json_array_lines'],

            // Content
            'featuredImageSize' => ['group' => 'content', 'attribute' => 'image_size'],
            'featuredImageLazyLoading' => ['group' => 'content', 'attribute' => 'lazy_loading'],
            'featuredImageLinkToMedia' => ['group' => 'content', 'attribute' => 'link_to_media'],

            // Spacing
            'featuredImageMarginTop' => ['group' => 'spacing', 'attribute' => 'margin_top'],
            'featuredImageMarginBottom' => ['group' => 'spacing', 'attribute' => 'margin_bottom'],

            // Visual Effects
            'featuredImageBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'border_radius'],
            'featuredImageBoxShadow' => ['group' => 'visual_effects', 'attribute' => 'box_shadow'],
            'featuredImageHoverEffect' => ['group' => 'visual_effects', 'attribute' => 'hover_effect'],
            'featuredImageHoverScale' => ['group' => 'visual_effects', 'attribute' => 'hover_scale'],
            'featuredImageTransitionDuration' => ['group' => 'visual_effects', 'attribute' => 'transition_duration'],
        ];
    }
}
