{%- capture section_style -%}
    padding-top: {{ section.settings.padding_top }}px;
    padding-bottom: {{ section.settings.padding_bottom }}px;
{%- endcapture -%}

<div class="header-announcement-bar swiper {% if section.settings.show_bar == false %}hide{% endif %}" {% render 'overwrite-theme-style', settings: section.settings, append_style: section_style %} data-use-slideshow="{%- if section.settings.use_slideshow -%}true{%- else -%}false{%- endif -%}" data-slideshow-speed="{{ section.settings.slideshow_speed }}">
    <div class="swiper-wrapper">

    {%- for block in section.blocks -%}
        {%- if block.settings.text == blank -%}
            {% continue %}
        {%- endif -%}

        <div class="header-announcement-bar-announcement {% if section.settings.use_slideshow %}header-announcement-bar-announcement-slideshow{% endif %} swiper-slide">
            {%- capture image_style -%}
                height: {{ block.settings.image_height }}px;

                {%- if block.settings.invert_color -%}
                    -webkit-filter: invert(100%);
                    filter: invert(100%);
                {%- endif -%}
            {%- endcapture -%}
            {% render 'image', image: block.settings.image, style: image_style, default_theme_icon: block.settings.default_theme_icon %}

            <span {% render 'overwrite-theme-style', settings: block.settings %}>{{ block.settings.text }}</span>
        </div>
    {%- endfor -%}

    </div>
</div>

{% comment %} ===== Section Help Video ===== {% endcomment %}
{%- if request.design_mode -%}
    <div 
        class="section-help-video-identifier" 
        data-title="{{ 'conrise.sectionHelpTitles.header-announcement' | t }}", 
        data-video="275ef67ea4614750ba24823e59cbc0f0?sid=355c4396-dad1-4056-87ac-7b7ddc3e5f85"
        data-padding-bottom="55.987558320373246%"
    ></div>
{%- endif -%}
{% comment %} ===== Section Help Video ===== {% endcomment %}

{% schema %}
{
    "name": "t:sections.header-announcement-bar.name",
    "settings": [
        {
            "type": "header",
            "content": "t:settings.general.section_help_video",
            "info": "[Video](https://www.loom.com/share/275ef67ea4614750ba24823e59cbc0f0?sid=355c4396-dad1-4056-87ac-7b7ddc3e5f85)"
        },
        {
            "type": "checkbox",
            "id": "show_bar",
            "default": true,
            "label": "t:sections.header-announcement-bar.settings.show_bar"
        },
        {
            "type": "header",
            "content": "t:sections.header-announcement-bar.settings.show_in_slide"
        },
        {
            "type": "checkbox",
            "id": "use_slideshow",
            "default": false,
            "label": "t:sections.header-announcement-bar.settings.use_slideshow"
        },
        {
            "type": "range",
            "id": "slideshow_speed",
            "label": "t:sections.header-announcement-bar.settings.slideshow_speed",
            "min": 0,
            "max": 15,
            "step": 0.5,
            "unit": "t:sections.header-announcement-bar.settings.slideshow_speed_unit",
            "default": 5
        },
        {
            "type": "header",
            "content": "t:sections.general.padding"
        },
        {
            "type": "range",
            "id": "padding_top",
            "label": "t:sections.header-announcement-bar.settings.padding_top",
            "min": 0,
            "max": 40,
            "step": 1,
            "unit": "px",
            "default": 10
        },
        {
            "type": "range",
            "id": "padding_bottom",
            "label": "t:sections.header-announcement-bar.settings.padding_bottom",
            "min": 0,
            "max": 40,
            "step": 1,
            "unit": "px",
            "default": 10
        },
        {
            "type": "header",
            "content": "t:sections.general.theme-settings.content",
            "info": "t:sections.general.theme-settings.info"
        },
        {
            "type": "color",
            "id": "overwrite_theme_background_color",
            "label": "t:sections.header-announcement-bar.settings.overwrite_theme_background_color",
            "info": "t:sections.header-announcement-bar.settings.overwrite_theme_background_color_info",
            "default": "#232F3E"
        }
    ],
    "blocks": [
        {
            "type": "announcement",
            "name": "t:sections.header-announcement-bar.blocks.announcement.name",
            "settings": [
                {
                    "type": "select",
                    "id": "default_theme_icon",
                    "label": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon",
                    "default": "none",
                    "info": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon_info",
                    "options": [
                        {
                            "value": "none",
                            "label": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon_none"
                        },
                        {
                            "value": "conrise-icons-checkmark.webp",
                            "label": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon_conrise-icons-checkmark_webp"
                        },
                        {
                            "value": "conrise-icon-guarantee.webp",
                            "label": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon_conrise-icon-guarantee_webp"
                        },
                        {
                            "value": "conrise-icon-invoice.webp",
                            "label": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon_conrise-icon-invoice_webp"
                        },
                        {
                            "value": "conrise-icon-return.webp",
                            "label": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon_conrise-icon-return_webp"
                        },
                        {
                            "value": "conrise-icon-return-dark.avif",
                            "label": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon_conrise-icon-return-dark_avif"
                        },
                        {
                            "value": "conrise-icon-return-white.avif",
                            "label": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon_conrise-icon-return-white_avif"
                        },
                        {
                            "value": "conrise-icon-delivery.webp",
                            "label": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon_conrise-icon-delivery_webp"
                        },
                        {
                            "value": "conrise-icon-delivery-dark.webp",
                            "label": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon_conrise-icon-delivery-dark_webp"
                        },
                        {
                            "value": "conrise-icon-delivery-white.webp",
                            "label": "t:sections.header-announcement-bar.blocks.announcement.settings.default_theme_icon_conrise-icon-delivery-white_webp"
                        }
                    ]
                },
                {
                    "type": "checkbox",
                    "id": "invert_color",
                    "default": false,
                    "label": "t:sections.header-announcement-bar.blocks.announcement.settings.invert_color",
                    "info": "t:sections.header-announcement-bar.blocks.announcement.settings.invert_color_info"
                },
                {
                    "type": "image_picker",
                    "id": "image",
                    "label": "t:sections.header-announcement-bar.blocks.announcement.settings.image"
                },
                {
                    "type": "range",
                    "id": "image_height",
                    "label": "t:sections.header-announcement-bar.blocks.announcement.settings.image_height",
                    "min": 0,
                    "max": 50,
                    "step": 1,
                    "unit": "px",
                    "default": 16
                },
                {
                    "type": "richtext",
                    "id": "text",
                    "default": "<p>Free shipping</p>",
                    "label": "t:sections.header-announcement-bar.blocks.announcement.settings.text"
                },
                {
                    "type": "header",
                    "content": "t:sections.general.theme-settings.content",
                    "info": "t:sections.general.theme-settings.info"
                },
                {
                    "type": "range",
                    "id": "overwrite_theme_font_size",
                    "label": "t:sections.header-announcement-bar.blocks.announcement.settings.overwrite_theme_font_size",
                    "min": 0,
                    "max": 40,
                    "step": 1,
                    "unit": "px",
                    "default": 0,
                    "info": "t:sections.header-announcement-bar.blocks.announcement.settings.overwrite_theme_font_size_info"
                },
                {
                    "type": "color",
                    "id": "overwrite_theme_text_color",
                    "label": "t:sections.header-announcement-bar.blocks.announcement.settings.overwrite_theme_text_color",
                    "info": "t:sections.header-announcement-bar.blocks.announcement.settings.overwrite_theme_text_color_info"
                }
            ]
        }
    ],
    "default": {
        "blocks": [
            {
                "type": "announcement",
                "settings": {
                    "text": "<p><strong>14 Tage Rückgaberecht</strong></p>",
                    "default_theme_icon": "conrise-icon-return-white.avif",
                    "overwrite_theme_font_size": 13,
                    "overwrite_theme_text_color": "#FFFFFF"
                }
            },
            {
                "type": "announcement",
                "settings": {
                    "text": "<p><strong>Kostenloser Versand</strong></p>",
                    "default_theme_icon": "conrise-icon-delivery-white.webp",
                    "overwrite_theme_font_size": 13,
                    "overwrite_theme_text_color": "#FFFFFF"
                }
            }
        ]
    }
}
{% endschema %}