{% form_theme form with app_form_themes() only %}
{% set selectedVariant = this.selectedVariant %}
{% set selectedOption = this.selectedOption %}
{% set hasSingleVariant = form.variant.vars.choices|length == 1 %}
{% set hasOptionField = form.option is defined %}
{% set hasQuantityField = form.quantity is defined %}
{% set galleryImages = this.galleryImages %}
{% set visibleAwards = this.visibleAwards %}
{% set primaryImage = galleryImages[0] ?? null %}
{% set productImagePath = primaryImage and primaryImage.path ? primaryImage.path : (product.secondImage and product.secondImage.path ? product.secondImage.path : product.image.path) %}
{% set productImageWidth = primaryImage and primaryImage.width ? primaryImage.width : (product.secondImage and product.secondImage.width ? product.secondImage.width : product.image.width) %}
{% set productImageHeight = primaryImage and primaryImage.height ? primaryImage.height : (product.secondImage and product.secondImage.height ? product.secondImage.height : product.image.height) %}
{% set productImageSrc = asset_glide(productImagePath, 'image', {
    fm: 'avif',
    q: 75,
    fit: 'contain',
    bg: '00000000',
    w: 960,
    h: 960
}) %}
{% set isProductSoldOut = this.productOutOfStock %}
{% set showVariantAvailabilityIndicators = this.shouldShowSelectedVariantAvailabilityIndicators %}
{% set showVariantLimitedStockIndicator = this.shouldShowSelectedVariantLimitedStockIndicator %}
{% set isVariantUnavailable = this.selectedVariantOutOfStock %}
{% set canAddToCart = not isProductSoldOut and not isVariantUnavailable and hasQuantityField %}
{% set showPrices = this.shouldShowPrices %}
{% set orderingDisabledForVacation = this.orderingDisabledForVacation %}
{% set vacationAt = this.vacationAt %}

<div {{ attributes }}>
    {{ form_start(form, {'attr' : { 'class': 'space-y-10', 'data-model': 'on(change)|*', 'data-action' : 'live#action:prevent', 'data-live-action-param' : 'debounce(300)|save', 'novalidate': 'true' }}) }}
    <div class="grid gap-4 lg:grid-cols-product-detail lg:items-start">
        <div class="border border-on-foreground/70 bg-surface/70 p-4 shadow-panel sm:p-6 lg:p-8">
            <div class="relative">
                {% if galleryImages|length > 1 %}
                    <div
                        class="grid gap-4 lg:grid-cols-product-gallery"
                        data-controller="shop-product-gallery"
                    >
                        <div class="order-2 lg:order-1">
                            <div
                                class="shop-product-gallery-thumbnails splide"
                                data-shop-product-gallery-target="thumbnails"
                            >
                                <div class="splide__track">
                                    <ul class="splide__list">
                                        {% for galleryImage in galleryImages %}
                                            <li class="splide__slide">
                                                <div class="shop-product-gallery-thumb size-product-gallery-thumb">
                                                    <twig:Image
                                                        alt="{{ product.name|striptags }}"
                                                        class="h-full w-full"
                                                        row:class="w-full"
                                                        img:class="h-full w-full object-contain"
                                                        lazy="{{ false }}"
                                                        quality="{{ 60 }}"
                                                        responsive="{{ false }}"
                                                        path="{{ galleryImage.path }}"
                                                        imageWidth="{{ galleryImage.width ?: 200 }}"
                                                        imageHeight="{{ galleryImage.height ?: 200 }}"
                                                    />
                                                </div>
                                            </li>
                                        {% endfor %}
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <div class="order-1 relative lg:order-2">
                            <div class="absolute top-4 left-0 z-20 flex max-w-ribbon-stack-compact flex-col gap-2">
                                {% if product.ribbonCustom %}
                                    <div class="px-4 py-2 font-serif text-xs tracking-action text-on-foreground uppercase shadow-lg"
                                         style="background-color: {{ product.ribbonCustomColor ?: 'var(--color-accent)' }};">
                                        {{ product.ribbonCustom|raw }}
                                    </div>
                                {% endif %}
                                {% if product.new %}
                                    <div class="bg-accent px-4 py-2 font-serif text-xs tracking-action text-on-foreground uppercase shadow-lg">
                                        {{ 'shop.new'|trans }}
                                    </div>
                                {% endif %}
                                {% if showVariantLimitedStockIndicator and this.selectedVariantLimitedStock and not isProductSoldOut and not isVariantUnavailable %}
                                    <div class="bg-foreground px-4 py-2 font-serif text-xs tracking-action text-on-foreground uppercase shadow-lg">
                                        {{ 'shop.limited_quantity'|trans }}
                                    </div>
                                {% endif %}
                                {% if isProductSoldOut %}
                                    <div class="bg-foreground px-4 py-2 font-serif text-xs tracking-action text-on-foreground uppercase shadow-lg">
                                        {{ 'cart.outofstock'|trans }}
                                    </div>
                                {% endif %}
                                {% if showVariantAvailabilityIndicators and isVariantUnavailable and not isProductSoldOut %}
                                    <div class="bg-foreground px-4 py-2 font-serif text-xs tracking-action text-on-foreground uppercase shadow-lg">
                                        {{ 'shop.variant_outofstock'|trans }}
                                    </div>
                                {% endif %}
                            </div>
                            <div
                                class="shop-product-gallery-main splide h-product-gallery sm:h-product-gallery-sm"
                                data-shop-product-gallery-target="main"
                            >
                                <div class="splide__track">
                                    <ul class="splide__list">
                                        {% for galleryImage in galleryImages %}
                                            <li class="splide__slide h-full">
                                                <div class="shop-product-gallery-stage flex h-full items-center justify-center overflow-hidden bg-page p-6">
                                                    <twig:Image
                                                        alt="{{ product.name|striptags }}"
                                                        class="h-full w-full"
                                                        row:class="flex h-full w-full items-center justify-center"
                                                        row:style="width: 100%; height: 100%; max-width: 100%;"
                                                        img:class="mx-auto h-full max-h-full w-auto max-w-full object-contain"
                                                        lazy="{{ false }}"
                                                        quality="{{ 75 }}"
                                                        responsive="{{ false }}"
                                                        path="{{ galleryImage.path }}"
                                                        imageWidth="{{ galleryImage.width ?: 960 }}"
                                                        imageHeight="{{ galleryImage.height ?: 960 }}"
                                                    />
                                                </div>
                                            </li>
                                        {% endfor %}
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                {% elseif productImagePath %}
                    <div class="relative">
                        <div class="absolute top-4 left-0 z-20 flex max-w-ribbon-stack-compact flex-col gap-2">
                            {% if product.ribbonCustom %}
                                <div class="px-4 py-2 font-serif text-xs tracking-action text-on-foreground uppercase shadow-lg"
                                     style="background-color: {{ product.ribbonCustomColor ?: 'var(--color-accent)' }};">
                                    {{ product.ribbonCustom|raw }}
                                </div>
                            {% endif %}
                            {% if product.new %}
                                <div class="bg-accent px-4 py-2 font-serif text-xs tracking-action text-on-foreground uppercase shadow-lg">
                                    {{ 'shop.new'|trans }}
                                </div>
                            {% endif %}
                            {% if showVariantLimitedStockIndicator and this.selectedVariantLimitedStock and not isProductSoldOut and not isVariantUnavailable %}
                                <div class="bg-foreground px-4 py-2 font-serif text-xs tracking-action text-on-foreground uppercase shadow-lg">
                                    {{ 'shop.limited_quantity'|trans }}
                                </div>
                            {% endif %}
                            {% if isProductSoldOut %}
                                <div class="bg-foreground px-4 py-2 font-serif text-xs tracking-action text-on-foreground uppercase shadow-lg">
                                    {{ 'cart.outofstock'|trans }}
                                </div>
                            {% endif %}
                            {% if showVariantAvailabilityIndicators and isVariantUnavailable and not isProductSoldOut %}
                                <div class="bg-foreground px-4 py-2 font-serif text-xs tracking-action text-on-foreground uppercase shadow-lg">
                                    {{ 'shop.variant_outofstock'|trans }}
                                </div>
                            {% endif %}
                        </div>
                        <div class="shop-product-gallery-stage flex h-product-gallery items-center justify-center overflow-hidden bg-page p-6 sm:h-product-gallery-sm">
                            <img
                                src="{{ productImageSrc }}"
                                alt="{{ product.name|striptags }}"
                                width="{{ productImageWidth }}"
                                height="{{ productImageHeight }}"
                                class="mx-auto block h-full max-h-full w-auto max-w-full object-contain"
                            >
                        </div>
                    </div>
                {% endif %}

                {% if visibleAwards|length > 0 %}
                    <div class="mt-6 flex flex-wrap items-center gap-4 border-t border-accent/15 pt-5">
                        {% for award in visibleAwards %}
                            {% if award.image and award.image.path %}
                                <button
                                    type="button"
                                    class="block w-20 cursor-pointer transition hover:scale-105"
                                    data-action="live#action"
                                    data-live-action-param="showAwardModal"
                                    data-live-award-id-param="{{ award.id.toString }}"
                                >
                                    <twig:Image
                                        alt="{{ award.title ?? product.name|striptags }}"
                                        class="w-20"
                                        row:class="w-full"
                                        img:class="h-full w-full object-contain"
                                        lazy="{{ false }}"
                                        quality="{{ 60 }}"
                                        responsive="{{ false }}"
                                        path="{{ award.image.path }}"
                                        imageWidth="200"
                                        imageHeight="200"
                                    />
                                </button>
                            {% endif %}
                        {% endfor %}
                    </div>
                {% endif %}
            </div>
        </div>

        <div class="border border-foreground/8 bg-surface px-5 py-6 shadow-product-panel sm:px-7 sm:py-8">
            <div class="flex flex-col gap-6">
                <div>
                    {% if product.header %}
                        <div class="text-sm tracking-label uppercase text-foreground/50">{{ product.header|raw }}</div>
                    {% endif %}
                    <div class="mt-2 font-serif text-2xl tracking-card-title uppercase text-foreground sm:text-3xl">{{ product.name|raw }}</div>
                    {% if product.quality %}
                        <div class="mt-2 text-base tracking-status uppercase text-accent">{{ product.quality|raw }}</div>
                    {% endif %}
                    {% if product.otherText1 %}
                        <div class="mt-2 text-base font-bold text-foreground">{{ product.otherText1 }}</div>
                    {% endif %}
                    {% if product.introText %}
                        <div class="mt-5 text-sm leading-7 text-foreground/75 [&_p]:my-0">{{ product.introText|raw }}</div>
                    {% endif %}
                </div>

                {% if showPrices %}
                    <div class="border border-accent/15 bg-page px-5 py-4">
                    {% set variant = selectedVariant %}
                    {% set price = variant.getVariantPriceByGroupAvailable %}
                    {% set optionPrice = selectedOption ? selectedOption.price : 0 %}
                    {% set displayPrice = (price.getPrice ?: 0) + optionPrice %}
                    {% set displayDiscountPrice = price.getPriceDiscount ? price.getPriceDiscount + optionPrice : null %}
                    {% set discountPrice = displayDiscountPrice|price_format %}
                    <div class="text-xs tracking-label uppercase text-foreground/45">{{ 'shop.price'|trans }}</div>
                    <div class="mt-2 flex items-end gap-3">
                        {% if discountPrice %}
                            <span class="text-lg text-foreground-subtle line-through">
                                {{ displayPrice|price_format }} €
                            </span>
                            <span class="font-serif text-3xl text-foreground">
                                {{ discountPrice }} €
                            </span>
                        {% else %}
                            <span class="font-serif text-3xl text-foreground">
                                {{ displayPrice|price_format }} €
                            </span>
                        {% endif %}
                    </div>
                    {% if this.selectedVariantHasDegressive %}
                        <button
                            type="button"
                            class="mt-3 w-fit cursor-pointer text-sm text-link-muted uppercase underline underline-offset-4 transition hover:text-foreground"
                            data-action="live#action"
                            data-live-action-param="showDegressiveModal"
                            {% if selectedVariant %}data-live-variant-id-param="{{ selectedVariant.id }}"{% endif %}
                        >
                            {{ 'shop.degressive_link'|trans() }}
                        </button>
                    {% endif %}
                    </div>

                    {% if isProductSoldOut %}
                    <div class="border border-foreground/10 bg-foreground/10 px-4 py-4 text-center text-sm font-semibold tracking-status uppercase text-foreground">
                        {{ 'cart.outofstock'|trans }}
                    </div>
                    {% else %}
                    <div class="space-y-5">
                        <div>
                            {% if not hasSingleVariant %}
                                <label class="mb-2 block text-xs tracking-label uppercase text-foreground/50">
                                    {{ product.selectVariant ?: ('shop.select_volume'|trans) }}
                                </label>
                            {% endif %}
                            {% if hasSingleVariant %}
                                {{ form_widget(form.variant, {'attr' : {'class' : 'hidden'}}) }}
                                <div class="border border-foreground/10 bg-page px-4 py-3 text-foreground">
                                    {{ selectedVariant ? selectedVariant.label : '' }}
                                </div>
                            {% else %}
                                {{ form_widget(form.variant, {'attr' : {'class' : ''}}) }}
                            {% endif %}
                        </div>

                        {% if hasOptionField and not isVariantUnavailable %}
                            <div data-controller="option-toggle">
                                <label class="mb-2 block text-xs tracking-label uppercase text-foreground/50">
                                    {{ 'shop.select_option'|trans }}
                                </label>
                                {{ form_widget(form.option, {
                                    attr: {
                                        class: 'hidden',
                                        'data-option-toggle-target': 'select'
                                    }
                                }) }}
                                <div class="grid gap-2 sm:grid-cols-2">
                                    {% for choice in form.option.vars.choices %}
                                        {% set option = choice.data %}
                                        {% set optionId = option.id.toString %}
                                        {% set isSelected = selectedOption and selectedOption.id.toString == optionId %}
                                        {% set isOptionUnavailable = option.isAvailable == false %}
                                        <label
                                            for="{{ form.option.vars.id }}_toggle_{{ loop.index }}"
                                            class="{% if isOptionUnavailable %}cursor-not-allowed border-foreground/10 bg-page/60 text-foreground/40{% elseif isSelected %}border-accent bg-accent/20 text-foreground{% else %}border-foreground/10 bg-page text-foreground hover:border-accent/60{% endif %} flex min-h-12 items-start gap-3 border px-4 py-3 text-left transition"
                                        >
                                            <input
                                                type="checkbox"
                                                id="{{ form.option.vars.id }}_toggle_{{ loop.index }}"
                                                name="{{ form.option.vars.full_name }}"
                                                value="{{ optionId }}"
                                                class="peer sr-only"
                                                data-option-toggle-target="checkbox"
                                                data-action="option-toggle#toggle"
                                                {% if isSelected %}checked{% endif %}
                                                {% if isOptionUnavailable %}disabled{% endif %}
                                            >
                                            <span class="{% if isOptionUnavailable %}border-foreground/10 bg-surface/70 text-foreground/30{% else %}border-foreground/20 bg-surface text-foreground peer-checked:border-accent peer-checked:bg-accent{% endif %} mt-0.5 flex h-6 w-6 flex-shrink-0 items-center justify-center border text-base leading-none transition">
                                                <span class="peer-checked:hidden">+</span>
                                                <span class="hidden peer-checked:block">✓</span>
                                            </span>
                                            <span class="block min-w-0">
                                                <span class="block text-sm font-semibold">{{ option.name }}</span>
                                                {% if isOptionUnavailable %}
                                                    <span class="mt-1 block text-caption uppercase tracking-label text-foreground/45">
                                                        {{ 'cart.outofstock'|trans }}
                                                    </span>
                                                {% endif %}
                                                {% if option.price > 0 %}
                                                    <span class="mt-1 block text-xs {% if isOptionUnavailable %}text-foreground/35{% else %}text-foreground/65{% endif %}">
                                                        +{{ option.price|price_format }} €
                                                        {% if option.flatFee %}
                                                            · {{ 'shop.flat_fee'|trans|lower }}
                                                        {% else %}
                                                            · {{ 'shop.per_unit'|trans|lower }}
                                                        {% endif %}
                                                    </span>
                                                {% endif %}
                                            </span>
                                        </label>
                                    {% endfor %}
                                </div>
                            </div>
                        {% endif %}

                        <div>
                            <label class="mb-2 block text-xs tracking-label uppercase text-foreground/50">
                                {{ 'shop.quantity'|trans }}
                            </label>
                            {% if (showVariantAvailabilityIndicators and isVariantUnavailable) or not hasQuantityField %}
                                <div class="bg-foreground/10 px-4 py-3 text-center text-foreground">
                                    {{ 'shop.variant_outofstock'|trans }}
                                </div>
                            {% elseif hasQuantityField %}
                                <div data-controller="quantity-stepper" class="w-full">
                                    {{ form_widget(form.quantity, {
                                        attr : {
                                            'class' : 'hidden w-full border border-foreground/15 bg-page px-4 py-3 sm:block',
                                            'inputmode': 'numeric',
                                            'data-model': 'norender|' ~ form.quantity.vars.full_name,
                                            'data-quantity-stepper-target': 'input',
                                            'data-action': 'input->quantity-stepper#syncDisplay change->quantity-stepper#syncDisplay'
                                        }
                                    }) }}
                                    <div class="quantity-stepper-mobile sm:hidden">
                                        <div class="flex items-center justify-between border border-foreground/15 bg-page px-2 py-2">
                                            <button
                                                type="button"
                                                class="flex h-10 w-10 items-center justify-center text-2xl leading-none text-foreground"
                                                data-action="quantity-stepper#decrement"
                                                aria-label="{{ 'shop.quantity'|trans }} -"
                                            >
                                                -
                                            </button>
                                            <span
                                                class="flex min-w-10 items-center justify-center px-2 text-lg"
                                                data-quantity-stepper-target="display"
                                            >
                                                {{ form.quantity.vars.value ?: 1 }}
                                            </span>
                                            <button
                                                type="button"
                                                class="flex h-10 w-10 items-center justify-center text-2xl leading-none text-foreground"
                                                data-action="quantity-stepper#increment"
                                                aria-label="{{ 'shop.quantity'|trans }} +"
                                            >
                                                +
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            {% endif %}
                        </div>

                        {% if orderingDisabledForVacation %}
                            <div class="border border-accent/15 bg-page px-5 py-4 text-center text-base text-foreground">
                                {% include 'components/shop/_purchase_unavailable.html.twig' with {
                                    orderingDisabledForVacation: orderingDisabledForVacation,
                                    vacationAt: vacationAt
                                } only %}
                            </div>
                        {% else %}
                            <button
                                type="submit"
                                class="{% if canAddToCart %}border-accent bg-accent text-foreground cursor-pointer{% else %}border-foreground/10 bg-foreground/10 text-foreground/45 cursor-not-allowed{% endif %} inline-flex w-full items-center justify-center border px-4 py-4 text-sm font-semibold tracking-status uppercase transition hover:bg-accent-soft"
                                {% if not canAddToCart %}disabled aria-disabled="true"{% endif %}
                            >
                                {{ 'cart.add_button'|trans() }}
                            </button>
                        {% endif %}
                    </div>
                    {% endif %}
                {% else %}
                    <div class="border border-accent/15 bg-page px-5 py-4 text-center text-base text-foreground">
                        {% include 'components/shop/_purchase_unavailable.html.twig' with {
                            orderingDisabledForVacation: orderingDisabledForVacation,
                            vacationAt: vacationAt
                        } only %}
                    </div>
                {% endif %}

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

    <div class="w-full space-y-4">
        {% if product.description %}
            <section class="border border-foreground/8 bg-surface px-6 py-6 shadow-card-soft">
                <h2 class="font-serif text-lg tracking-card-title uppercase text-foreground">{{ 'shop.product.section_description'|trans }}</h2>
                <div class="mt-4 text-sm leading-7 text-foreground/75 [&_p]:mt-0 [&_p]:mb-4 [&_p:last-child]:mb-0">
                    {{ product.description|raw }}
                </div>
            </section>
        {% endif %}

        {% if product.tasting or product.assemblages is not empty or product.winemaking is not empty or product.dosage %}
            <div class="grid grid-cols-1 gap-4 lg:grid-flow-col lg:auto-cols-fr">
                {% if product.tasting %}
                    <section class="border border-foreground/8 bg-surface px-6 py-6 shadow-card-soft">
                        <h2 class="font-serif text-lg tracking-card-title uppercase text-foreground">{{ 'shop.product.section_tasting'|trans }}</h2>
                        <div class="mt-4 text-sm leading-7 text-foreground/75 [&_p]:mt-0 [&_p]:mb-4 [&_p:last-child]:mb-0">
                            {{ product.tasting|raw }}
                        </div>
                    </section>
                {% endif %}

                {% if product.assemblages is not empty %}
                    <section class="border border-foreground/8 bg-surface px-6 py-6 shadow-card-soft">
                        <h2 class="font-serif text-lg tracking-card-title uppercase text-foreground">{{ 'shop.product.section_assemblage'|trans }}</h2>
                        <div class="mt-4 space-y-1 text-sm leading-7 text-foreground/75">
                            {% for assemblage in product.assemblages %}
                                <div>{{ assemblage|raw }}</div>
                            {% endfor %}
                        </div>
                    </section>
                {% endif %}

                {% if product.winemaking is not empty %}
                    <section class="border border-foreground/8 bg-surface px-6 py-6 shadow-card-soft">
                        <h2 class="font-serif text-lg tracking-card-title uppercase text-foreground">{{ 'shop.product.section_winemaking'|trans }}</h2>
                        <div class="mt-4 space-y-1 text-sm leading-7 text-foreground/75">
                            {% for winemaking in product.winemaking %}
                                <div>{{ winemaking|raw }}</div>
                            {% endfor %}
                        </div>
                    </section>
                {% endif %}

                {% if product.dosage %}
                    <section class="border border-foreground/8 bg-surface px-6 py-6 shadow-card-soft">
                        <h2 class="font-serif text-lg tracking-card-title uppercase text-foreground">{{ 'collection.champagne.dosage'|trans }}</h2>
                        <div class="mt-4 text-sm leading-7 text-foreground/75">
                            {{ product.dosage|raw }}
                        </div>
                    </section>
                {% endif %}
            </div>
        {% endif %}

        {% if product.file %}
            <section class="border border-foreground/8 bg-surface px-6 py-6 shadow-card-soft lg:col-span-2">
                <h2 class="font-serif text-lg tracking-card-title uppercase text-foreground">{{ 'shop.product.section_documents'|trans }}</h2>
                <div class="mt-4">
                    <a href="{{ product.file.path|file_path }}" target="_blank"
                       class="flex w-fit items-center gap-3 text-accent hover:opacity-80 hover:underline hover:underline-offset-4">
                        <svg class="h-5 fill-current" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.87 20">
                            <path d="M12.54,8.78c-.2-.2-.51-.2-.71,0l-3.9,3.9V.5c0-.28-.22-.5-.5-.5s-.5.22-.5.5v12.18l-3.9-3.9c-.09-.09-.22-.15-.35-.15-.28,0-.5.22-.5.5,0,.13.05.26.14.35l4.75,4.75c.2.2.51.2.71,0l4.75-4.75c.2-.2.2-.51,0-.71Z"/>
                            <path d="M14.37,19.46H.5c-.28,0-.5-.22-.5-.5s.22-.5.5-.5h13.87c.28,0,.5.22.5.5s-.22.5-.5.5Z"/>
                        </svg>
                        {{ 'collection.champagne.file'|trans()|raw }}
                    </a>
                </div>
            </section>
        {% endif %}

        {% if product.infoShop %}
            <section class="border border-foreground/8 bg-surface px-6 py-6 shadow-card-soft lg:col-span-2">
                <h2 class="font-serif text-lg tracking-card-title uppercase text-foreground">{{ 'shop.product.section_info_shop'|trans }}</h2>
                <div class="mt-4 text-sm leading-7 text-foreground/75 [&_p]:mt-0 [&_p]:mb-4 [&_p:last-child]:mb-0">
                    {{ product.infoShop|raw }}
                </div>
            </section>
        {% endif %}
    </div>
    {% if not form.variant.isRendered() %}
        {{ form_widget(form.variant, { attr: { class: 'hidden' } }) }}
    {% endif %}
    {% if form.quantity is defined and not form.quantity.isRendered() %}
        {{ form_widget(form.quantity, { attr: { class: 'hidden' } }) }}
    {% endif %}
    {% if form.option is defined and not form.option.vars.expanded and not form.option.isRendered() %}
        {{ form_widget(form.option, { attr: { class: 'hidden' } }) }}
    {% endif %}
    {% if form._token is defined and not form._token.isRendered() %}
        {{ form_widget(form._token) }}
    {% endif %}
    {{ form_end(form, { render_rest: false }) }}
</div>
