{% import 'content-page/_macros' as pageMacros %}
<div class="blue-swirl">
    <div class="container">

        {% if entry.id == 390 %}
            {% include 'partials/preventionCarousel.twig' %}
        {% endif %}

        <div class="row">
            <div class="col-12 col-xl-9">
                {% set block = entry.generalContentBlock.type('heroTextBlock').one() %}
                {% if block %}
                    <h1>{{ block.heading ? block.heading : entry.title }}</h1>
                    <p>{{ block.blockContent }}</p>
                {% else %}
                    <h1>{{ entry.title }}</h1>
                {% endif %}
            </div>
        </div>

        {% set contentBlocks = entry.generalContentBlock.type('block').all() %}
        {% if contentBlocks %}
            <div class="row">
                <div class="col-12">
                    {% for block in contentBlocks %}
                        <div class="overview-content-block">
                            {{ pageMacros.generalContentBlock(block) }}
                        </div>
                    {% endfor %}
                </div>
            </div>
        {% endif %}

        <div class="row">

            {% set pages = entry.children().level(2).pageShownOnOverview('1').all() %}

            {% for page in pages %}
                <div class="col-12 col-lg-4 category-wrap">
                    <div class="category-box">
                        {% set block = page.generalContentBlock.type('overviewBlock').one() %}
                        {% if block %}
                            {% if  block.backgroundImage.one() %}

                                {% set image = block.backgroundImage.one() %}
                                {% set thumb = {
                                mode: 'crop',
                                width: 340,
                                height: 180,
                                position: 'center-center'
                                } %}
                                <img src="{{ image.getUrl(thumb) }}" class="pict" alt="{{ image.title }}"/>
                            {% endif %}

                            {% if  block.icon.one() %}
                                {% set image = block.icon.one() %}
                                {% set thumb = {
                                mode: 'fit',
                                width: 181,
                                height: 150
                                } %}
                                <img src="{{ image.getUrl(thumb) }}" class="white-icon" alt="{{ image.title }}"/>
                            {% endif %}

                        {% else %}
                            <img src="{{ rev('images/example-img-1.jpg') }}" class="pict" alt="example-img"/>
                            <img src="{{ rev('images/icon-white-house-01.svg') }}" class="white-icon" alt="icon-white-house"/>
                        {% endif %}
                        <div class="category-box-content">
                            <h2>{{ page.title }}</h2>

                            {% if page.id == 2262 %}
                                {% set testimonials = craft.entries().id(170).one().textImageBlock.type('testimonialsBlock').all() %}
                                {% set testimonialOverviewPage = craft.entries().id(5995).one() %}



                                <ul>
                                    {% for testimonial in testimonials %}
                                        {% if testimonial.fullName|length > 1 %}
                                            <li><a href="{{ testimonialOverviewPage.url }}#testimonial-{{ testimonial.id }}">{{ testimonial.fullName}} <i class="fas fa-angle-right"></i></a></li>
                                        {% endif %}
                                    {% endfor %}
                                </ul>
                                <div class="clearfix"></div>

                            {% else %}
                                {% set block = page.generalContentBlock.type('block').one() %}
                                {% if block %}
                                    {{ block.blockContent }}
                                {% endif %}
                                <ul>
                                    {% set childrenPages = page.children().level(3).pageShownOnOverview('1').all() %}
                                    {% for childPage in childrenPages %}
                                        <li><a {% if childPage.id == 340 %} class="register-detector" {%endif%} href="{{ childPage.url }}">{{ childPage.title }} <i class="fas fa-angle-right"></i></a></li>
                                    {% endfor %}
                                </ul>
                                <div class="clearfix"></div>
                            {% endif %}


                        </div>
                    </div>
                </div>
            {% endfor %}

        </div>
    </div>
</div>
