{% trans_default_domain 'seller' %}
{% set seller = this.seller %}
<div {{ attributes.defaults(stimulus_controller(this.shortName, {
      position: {
         x: seller.x,
         y: seller.y,
      }
   }))
}}>
   <h1>{{ seller.title }}</h1>
   {% if seller.thumbnails is defined and seller.thumbnails is not empty  %}
      <div class="seller-thumbnails">
         <twig:Carousel isCarousel="{{ seller.thumbnails > 1 }}" numberOfSlides="2" hasNav="{{ false }}">
            {% for thumbnail in seller.thumbnails %}
               <div class="seller-thumbnail">
                  <twig:Picture thumbnail="{{ thumbnail }}" type="seller_detail" />
               </div>
            {% endfor %}
         </twig:Carousel>
      </div>
   {% endif %}
   <div class="container">
      <div class="seller-info">
         <div class="seller-info-item">
            <div class="seller-info-icon">
               <twig:ux:icon name="location-dot" class="c-icon" />
            </div>
            <div class="seller-info-details">
               <p class="h4">
                  {{ 'address'|trans }}
               </p>
               <p class="no-margin">
                  {{ seller.street }} {{ seller.number }},<br>
                  {{ seller.psc }} {{ seller.city }}
               </p>
            </div>
         </div>
         <div class="seller-info-item">
            <div class="seller-info-icon">
               <twig:ux:icon name="phone" class="c-icon" />
            </div>
            <div class="seller-info-details">
               <p class="h4">
                  {{ 'contact'|trans }}
               </p>
               <p class="no-margin">
                  <a href="tel:{{ seller.phone|replace({'\'': ''}) }}">{{ seller.phone }}</a><br />
                  <a href="mailto:{{ seller.email }}">{{ seller.email }}</a><br />
                  <a href="{% if not (seller.web starts with 'http') %}https://{% endif %}{{ seller.web }}" target="_blank">{{ seller.web }}</a>
               </p>
            </div>
         </div>
         {% if seller.opening_hours is defined %}
            <div class="seller-info-item">
               <div class="seller-info-icon">
                  <twig:ux:icon name="clock" class="c-icon" />
               </div>
               <div class="seller-info-details">
                  <p class="h4">
                     {{ 'openingHours'|trans }}
                  </p>
                  {% if seller.data.display_opening_hours is defined and seller.data.display_opening_hours is not empty %}
                     <p>
                        {{ seller.data.display_opening_hours|replace({ '\n' : '<br />' })|raw }}
                     </p>
                  {% elseif seller.opening_hours is defined %}
                  <table class="seller-opening-hours">
                     {% set days = {
                        1: 'days.monday'|trans,
                        2: 'days.tuesday'|trans,
                        3: 'days.wednesday'|trans,
                        4: 'days.thursday'|trans,
                        5: 'days.friday'|trans,
                        6: 'days.saturday'|trans,
                        7: 'days.sunday'|trans,
                     }%}
                     {% for day, hours in seller.opening_hours %}
                        {% set from = hours[0] %}
                        {% set to = hours[1] %}
                        <tr>
                           <td>{{ days[day] }}:</td>
                           <td>{% if from is empty or to is empty %}{{ 'closed'|trans }}{% else %}{{ from }} - {{ to }}{% endif %}</td>
                        </tr>
                     {% endfor %}
                  </table>
                  {% endif %}
               </div>
            </div>
         {% endif %}
         <div class="seller-info-item seller-info-button">
            {% if module.SUB_MY_SELLER %}
               <button class="btn btn-primary-outline" {{ live_action('setActiveSeller', { 'sellerId': seller.id }) }}>
                  {{ 'saveSeller'|trans }}
               </button>
            {% endif %}
            <a href="/katalog/?dynamic_filter[storeIds][0]={{ seller.id_store }}" class="btn btn-lg btn-primary">
               {{ 'sellerProducts'|trans }}
            </a>
            <a href="http://maps.apple.com/?saddr={{ "Current+Location"|url_encode }}&daddr={{ seller.street }} {{ seller.number }},{{ seller.city }}" class="btn btn-lg btn-primary">
               {{ 'navigateToSeller'|trans }}
            </a>
         </div>
      </div>
      <div class="seller-description">
         {{ seller.descr|raw }}
         {% if body.blocks[0] is defined %}
            {{ body.blocks[0] }}
         {% endif %}
      </div>
      <div class="seller-map" {{ stimulus_target(this.shortName, 'map') }}></div>
   </div>
</div>
