{# LIBRARIES #}
{{ attach_library('ui_patterns/sa_calendar.sa_calendar_lib') }}
{% import '@organisms/tm-sa/sa-calendar/calendar.macros.twig' as calendar_macros %}

{# VARIABLES #}
{% set btn_next_class = btn_next_class|default('btn btn-btn-lg btn-outline-default') %}
{% set btn_next_class = btn_next_class ~ ' next-month' %}
{% set btn_next_text = "#{next_text} <i class='" ~ global_icon_right|default('fas fa-chevron-right') ~ " belir'></i>" %}
{% set btn_next_attributes = create_attribute().setAttribute('rel', 'nofollow') %}
{% set btn_prev_class = btn_prev_class|default('btn btn-btn-lg btn-outline-default') %}
{% set btn_prev_class = btn_prev_class ~ ' prev-month' %}
{% set btn_prev_text = "<i class='" ~ global_icon_left|default('fas fa-chevron-left') ~ " belil'></i> #{prev_text}" %}
{% set btn_prev_attributes = create_attribute().setAttribute('rel', 'nofollow') %}

{# TEMPLATE #}
<div id="sac-pager" class="pager">
  {% if prev_show %}
    {% include "@atoms/tm-links/standard/standard.twig" with {
      "text": btn_prev_text,
      "url": "?date=#{prev_from}--#{prev_to}",
      "class": btn_prev_class,
      'attributes': btn_prev_attributes
    } only %}
  {% else %}
    {% set btn_prev_attributes = btn_prev_attributes.setAttribute('disabled', 'disabled') %}
    {% include "@atoms/tm-links/standard/standard.twig" with {
      "text": btn_prev_text,
      "url": '#',
      "class": btn_prev_class ~ ' disabled',
      'attributes': btn_prev_attributes
    } only %}
  {% endif %}
  <h2 class="month-name">{{ calendar_start|date('F Y') }}</h2>
  {% if next_show %}
    {% include "@atoms/tm-links/standard/standard.twig" with {
      "text": btn_next_text,
      "url": "?date=#{next_from}--#{next_to}",
      "class": btn_next_class,
      'attributes': btn_next_attributes
    } only %}
  {% else %}
    {% set btn_next_attributes = btn_next_attributes.setAttribute('disabled', 'disabled') %}
    {% include "@atoms/tm-links/standard/standard.twig" with {
      "text": btn_next_text,
      "url": '#',
      "class": btn_next_class ~ ' disabled',
      'attributes': btn_next_attributes
    } only %}
  {% endif %}
</div>

<div id="sac-calendar" class="dto">
  <ul id="days-row" class="ulc">
    <li class="lic title-cell">Sun</li>
    <li class="lic title-cell">Mon</li>
    <li class="lic title-cell">Tue</li>
    <li class="lic title-cell">Wed</li>
    <li class="lic title-cell">Thur</li>
    <li class="lic title-cell">Fri</li>
    <li class="lic title-cell">Sat</li>
  </ul>
  {{ calendar_macros.listDays(calendar_start|date('N'), calendar_start, calendar_end, count, alterations) }}
</div>

{% include '@organisms/tm-sa/sa-calendar/calendar-table.twig' with {
  'alterations': alterations,
  'title': 'Alterations for the month',
  'hide': true,
  'tid': 'calendar',
} only %}
