{% sw_extends '@Storefront/storefront/page/product-detail/buy-widget.html.twig' %}

{% block page_product_detail_buy_inner %}
    <div class="js-magnifier-zoom-image-container">
        {% block page_product_detail_rich_snippets %}
            <meta itemprop="description" content="{{ page.product.translated.description|raw }}">

            {% block page_product_detail_rich_snippets_brand %}
                {% if page.product.manufacturer %}
                    <div itemprop="brand" itemtype="https://schema.org/Brand" itemscope>
                        <meta itemprop="name" content="{{ page.product.manufacturer.translated.name }}">
                    </div>
                {% endif %}
            {% endblock %}

            {% block page_product_detail_rich_snippets_gtin13 %}
                {% if page.product.ean %}
                    <meta itemprop="gtin13"
                          content="{{ page.product.ean }}">
                {% endif %}
            {% endblock %}

            {% block page_product_detail_rich_snippets_mpn %}
                {% if page.product.manufacturerNumber %}
                    <meta itemprop="mpn"
                          content="{{ page.product.manufacturerNumber }}">
                {% endif %}
            {% endblock %}

            {% block page_product_detail_rich_snippets_weight %}
                {% if page.product.weight %}
                    <meta itemprop="weight"
                          content="{{ page.product.weight }} kg">
                {% endif %}
            {% endblock %}

            {% block page_product_detail_rich_snippets_height %}
                {% if page.product.height %}
                    <meta itemprop="height"
                          content="{{ page.product.height }} mm">
                {% endif %}
            {% endblock %}

            {% block page_product_detail_rich_snippets_width %}
                {% if page.product.width %}
                    <meta itemprop="width"
                          content="{{ page.product.width }} mm">
                {% endif %}
            {% endblock %}

            {% block page_product_detail_rich_snippets_depth %}
                {% if page.product.length %}
                    <meta itemprop="depth"
                          content="{{ page.product.length }} mm">
                {% endif %}
            {% endblock %}

            {% block page_product_detail_rich_snippets_release_date %}
                <meta itemprop="releaseDate"
                      content="{{ page.product.releaseDate|format_date(pattern='Y-MM-dd') }}">
            {% endblock %}
        {% endblock %}

        {% block page_product_detail_buy_container %}
            <div itemprop="offers"
                 itemscope
                 itemtype="{% if page.product.calculatedPrices|length > 1 %}http://schema.org/AggregateOffer{% else %}http://schema.org/Offer{% endif %}">
                {% block page_product_detail_data %}
                    {% block page_product_detail_data_rich_snippet_url %}
                        <meta itemprop="url"
                              content="{{ seoUrl('frontend.detail.page', { productId: page.product.id }) }}">
                    {% endblock %}
                    {% block page_product_detail_data_rich_snippet_price_range %}
                        {% if page.product.calculatedPrices|length > 1 %}
                            {% set lowestPrice = false %}
                            {% set highestPrice = false %}

                            {% for price in page.product.calculatedPrices %}
                                {% if not lowestPrice or price.unitPrice < lowestPrice %}
                                    {% set lowestPrice = price.unitPrice %}
                                {% endif %}
                                {% if not highestPrice or price.unitPrice > highestPrice %}
                                    {% set highestPrice = price.unitPrice %}
                                {% endif %}
                            {% endfor %}

                            <meta itemprop="lowPrice" content="{{ lowestPrice }}">
                            <meta itemprop="highPrice" content="{{ highestPrice }}">
                            <meta itemprop="offerCount" content="{{ page.product.calculatedPrices|length }}">
                        {% endif %}
                    {% endblock %}
                    {% block page_product_detail_data_rich_snippet_price_currency %}
                        <meta itemprop="priceCurrency"
                              content="{{ context.currency.translated.shortName }}">
                    {% endblock %}

                    <div class="row flex-md-nowrap">
                        <div class="col-12 col-md-auto">
                            {% block page_product_detail_price %}
                                <div class="product-detail-price-container">
                                    {% sw_include '@Storefront/storefront/page/product-detail/buy-widget-price.html.twig' %}
                                </div>
                            {% endblock %}
                        </div>

                        <div class="col-12 col-md mt-3 mb-1 my-md-0">
                            {% block page_product_detail_buy_form %}
                                {% if page.product.active %}
                                    <div class="product-detail-form-container mb-0">
                                        {% sw_include '@Storefront/storefront/page/product-detail/buy-widget-form.html.twig' %}
                                    </div>
                                {% endif %}
                            {% endblock %}
                        </div>
                    </div>


                    {% block page_product_detail_tax %}
                        <div class="product-detail-tax-container">
                            {% if context.taxState == "gross" %}
                                {% set taxText = "general.grossTaxInformation"|trans|sw_sanitize %}
                            {% else %}
                                {% set taxText = "general.netTaxInformation"|trans|sw_sanitize %}
                            {% endif %}

                            <p class="product-detail-tax">
                                {% block page_product_detail_tax_link %}
                                    <a class="product-detail-tax-link"
                                       href="{{ path('frontend.cms.page', { id: config('core.basicInformation.shippingPaymentInfoPage') }) }}"
                                       title="{{ taxText }}"
                                       data-ajax-modal="true"
                                       data-url="{{ path('frontend.cms.page', { id: config('core.basicInformation.shippingPaymentInfoPage') }) }}">
                                        {{ taxText }}
                                    </a>
                                {% endblock %}
                            </p>
                        </div>
                    {% endblock %}

                    {% set remoteClickOptions = {
                        selector: "#review-tab",
                        scrollToElement: true
                    } %}

                    {% block page_product_detail_reviews %}
                        {% if page.product.ratingAverage > 0 and page.reviews.totalReviews > 0 and config('core.listing.showReview') %}
                            <div class="product-detail-reviews">

                                {% sw_include '@Storefront/storefront/component/review/rating.html.twig' with {
                                    points: page.product.ratingAverage,
                                    style: 'text-primary'
                                } %}
                                <a
                                        data-bs-toggle="tab"
                                        class="product-detail-reviews-link"
                                        {# @deprecated tag:v6.6.0 - Registering plugin on selector "data-offcanvas-tabs" is deprecated. Use "data-off-canvas-tabs" instead #}
                                        {% if feature('v6.6.0.0') %}
                                            data-off-canvas-tabs="true"
                                        {% else %}
                                            data-offcanvas-tabs="true"
                                        {% endif %}
                                        data-remote-click="true"
                                        {# ludtwig-ignore html-string-quotation #}
                                        data-remote-click-options='{{ remoteClickOptions|json_encode }}'
                                        href="#review-tab-pane"
                                        aria-controls="review-tab-pane"
                                >
                                    {{ page.reviews.totalReviews }}
                                    {{ "detail.reviewLinkText"|trans({'%count%': page.reviews.totalReviews})|sw_sanitize }}
                                </a>
                            </div>
                        {% endif %}
                    {% endblock %}

                    {% block page_product_detail_delivery_informations %}
                        <div class="product-detail-delivery-information">
                            {% sw_include '@Storefront/storefront/component/delivery-information.html.twig' %}
                        </div>
                    {% endblock %}
                {% endblock %}

                {% block page_product_detail_configurator_include %}
                    {% if page.product.parentId and page.configuratorSettings|length > 0 %}
                        <div class="product-detail-configurator-container">
                            {% sw_include '@Storefront/storefront/page/product-detail/configurator.html.twig' %}
                        </div>
                    {% endif %}
                {% endblock %}


            </div>
        {% endblock %}

        {% if config('core.cart.wishlistEnabled') %}
            {% block page_product_detail_wishlist %}
                {% sw_include '@Storefront/storefront/component/product/card/wishlist.html.twig' with {
                    showText: true,
                    size: 'md',
                    productId: page.product.id
                } %}
            {% endblock %}
        {% endif %}

        {% block page_product_detail_ordernumber_container %}{% endblock %}
    </div>
{% endblock %}
