{{ attach_library('ui_patterns/tm_itinerary_item.tm_itinerary_item_lib') }}
{{ attach_library('ui_patterns/tm_bits_tags.tm_bits_tags_lib') }}

{% set link_text = link_text|default('View offer') %}
{% set remove_text = remove_text|default('Remove offer') %}
{% set print_text = print_text|default('Print offer') %}

<div class="itin-item mb-3 ps-3 pe-3">
  <div class="row " id="itin-item-{{ iid }}">
    <div class="col-sm-9">
      <div class="row mb-3">
        <div class="col-sm-12">
          <h3 class="itin-title">{{ title }}</h3>
        </div>
        {% if img_src and img_alt %}
          <div class="col-sm-4">
            {% include "@atoms/html5/image/image.twig" with {
              "url": img_src,
              "alt": img_alt,
              "type": 'fg',
              "img_class": 'w-100',
              'img_attributes': img_attributes|default(create_attribute()),
            } only %}
          </div>
        {% endif %}
        <div class="col-sm-4 itin-body">
          {{ description }}
        </div>
        <div class="col-sm-4">
          <div class="itin-date-wrapper">
            <div class="itin-date"><h4>Dates available</h4>Until {{ date|date("dS F") }}</div>
            <div class="itin-location"><h4>Where</h4>{{ location }}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-3 pt-3">
      {% if print_url and print_link %}
        {% include "@atoms/tm-links/standard/standard.twig" with {
          "text": '<i class="fas fa-print"></i> ' ~ print_link,
          "url": print_url,
          'class': 'btn-outline-default btn-md btn w-100'
        } only %}
      {% endif %}
      {% if item_url and item_link %}
        {% include "@atoms/tm-links/standard/standard.twig" with {
          "text": item_link ~ ' <i class="' ~ global_icon_right|default('fas fa-chevron-right') ~ '"></i>',
          "url": item_url,
          'class': 'btn-outline-default btn-md btn w-100'
        } only %}
      {% endif %}
    </div>
    <div class="col-sm-9 mb-3 itin-tags">
      {% include "@molecules/tm-bits/tm-bits-tags.twig" with {
        'tags': tags,
        'not_links': true,
      } only %}
    </div>
    <div class="col-sm-3 mb-3">
      {% if remove_link %}
        {% set remove_attrs = create_attribute()
          .setAttribute('data-itinerary-id', iid)
          .setAttribute('data-itinerary-action', 'remove')
        %}
        {% include "@atoms/tm-links/standard/standard.twig" with {
          "text": '<i class="fas fa-trash-alt"></i> ' ~ remove_link,
          'class': 'btn-outline-default btn-md btn w-100 mb-0',
          'attributes': remove_attrs,
        } only %}
      {% endif %}
    </div>
  </div>
</div>
