{#
    Params:
    - product:                item entity (item)
    - in_stock:               bool
    - from_price:             initial "from" price
    - basket_button_data:     hash for add-to-basket
    - out_of_stock_url:       string
    - delivery_cutoff:        string|number|false
    - has_full_description:   bool — if false, sidebar acts as the full description placement
    - show_doctor_warnings:   bool
#}

{% set product = product|default(item) %}
{% set in_stock = in_stock|default(false) %}
{% set from_price = from_price|default(false) %}
{% set basket_button_data = basket_button_data|default({}) %}
{% set out_of_stock_url = out_of_stock_url|default('/no-stock-url') %}
{% set delivery_cutoff = delivery_cutoff|default(0) %}
{% set show_doctor_warnings = show_doctor_warnings|default(false) %}

{% set has_multi_sizes = product.sizes is defined and product.sizes is iterable and (product.sizes|length) > 1 %}
{% set show_from_price = in_stock and from_price and has_multi_sizes %}

<div class="productSidebar">
    <div class="itemTitle">
        {% if product.name %}
            <h1 class="mainTitle">{{ product.name|raw }}</h1>
        {% endif %}

        {% if product.custom.product_subtitle %}
            <h2 class="itemSubtitle">{{ product.custom.product_subtitle|raw }}</h2>
        {% endif %}
    </div>

    {% if show_from_price %}
        <div class="fromPrice">
            <span class="fromText">From</span>
            <span class="multiPrice">{{ from_price|multi_currency|raw }}</span>
        </div>
    {% endif %}

    {% if not in_stock %}
        <out-of-stock-notify
            :url-submit="{{ out_of_stock_url|json_encode }}"
            button-label="Notify me when back in stock"
            :shop-item-id="{{ product.id|json_encode }}"
        ></out-of-stock-notify>
    {% endif %}

    {% if product.description %}
        <div class="itemDescription wysiwyg">
            <div class="itemDescription__content">
                {{ product.description|raw }}
            </div>
            <button type="button" class="itemDescription__toggle js_itemDescriptionToggle">
                Read more
            </button>
        </div>
    {% endif %}

    <add-to-basket
        :ajax-add-to-basket="$store.state.minibasket.productCardsQuickAdd"
        :basket-button-data="{{ basket_button_data|json_encode }}"
        :product="{{ product|json_encode }}"
        :default-size-selected-id="{{ (product.recommended_size_id ?? 0) > 0 ? product.recommended_size_id : 0 }}"
        :show-price="true"
        :price-set="{{ from_price|json_encode }}"
        :large-button="true"
        :in-stock="{{ in_stock|json_encode }}"
        :single-size-select="false"
    ></add-to-basket>

    {% if delivery_cutoff %}
        <delivery-countdown :cutoff="{{ delivery_cutoff|json_encode }}"></delivery-countdown>
    {% endif %}

    {% if show_doctor_warnings and (product.product_type == 'doctor' or (product.warnings is defined and product.warnings|length)) %}
        <div class="doctorWarnings">
            <div class="alert">
                <p>
                    Please note: This page is only to be used as a reference of our price for this medication. If you
                    are approved you will be offered treatment for you and the prescriber to jointly consider. However,
                    the final decision will always be the prescriber's.
                </p>
            </div>

            {% if product.warnings is defined %}
                {% for warning in product.warnings %}
                    <div class="{{ warning.type }}">{{ warning.content|raw }}</div>
                {% endfor %}
            {% endif %}
        </div>
    {% endif %}
</div>
