{% macro header(image=true, color=false, parts=false, quantity=false, missing=true, missing_parts=false, damaged=true, damaged_parts=false, sets=false, minifigures=false, checked=false, hamburger_menu=false, accordion_id='') %}
  <thead>
    <tr>
      {% if image %}
        <th data-table-no-sort-and-search="true" class="no-sort" scope="col"><i class="ri-image-line fw-normal"></i> Image</th>
      {% endif %}
      <th scope="col"><i class="ri-pencil-line fw-normal"></i> Name</th>
      {% if color %}
        <th scope="col"><i class="ri-palette-line fw-normal"></i> Color</th>
      {% endif %}
      {% if parts %}
        <th data-table-number="true" scope="col"><i class="ri-shapes-line fw-normal"></i> Parts</th>
      {% endif %}
      {% if quantity %}
        <th data-table-number="true" scope="col"><i class="ri-functions fw-normal"></i> Quantity</th>
      {% endif %}
      {% if missing and not config['HIDE_TABLE_MISSING_PARTS'] %}
        <th data-table-number="true" scope="col"><i class="ri-question-line fw-normal"></i> Missing{% if missing_parts %} parts{% endif %}</th>
      {% endif %}
      {% if damaged and not config['HIDE_TABLE_DAMAGED_PARTS'] %}
      <th data-table-number="true" scope="col"><i class="ri-error-warning-line fw-normal"></i> Damaged{% if damaged_parts %} parts{% endif %}</th>
      {% endif %}
      {% if sets %}
        <th data-table-number="true" scope="col"><i class="ri-hashtag fw-normal"></i> Sets</th>
      {% endif %}
      {% if minifigures %}
        <th data-table-number="true" scope="col"><i class="ri-group-line fw-normal"></i> Minifigures</th>
      {% endif %}
      {% if checked and not config['HIDE_TABLE_CHECKED_PARTS'] %}
        <th data-table-number="true" scope="col"><i class="ri-checkbox-line fw-normal"></i> Checked</th>
      {% endif %}
      {% if hamburger_menu and g.login.is_authenticated() %}
        {% set show_missing_menu = not config['HIDE_TABLE_MISSING_PARTS'] %}
        {% set show_checked_menu = not config['HIDE_TABLE_CHECKED_PARTS'] %}
        {% set show_quick_add = not config['DISABLE_QUICK_ADD_INDIVIDUAL_PARTS'] and not config['HIDE_INDIVIDUAL_PARTS'] %}
        {% if show_missing_menu or show_checked_menu or show_quick_add %}
          <th data-table-no-sort-and-search="true" class="no-sort text-end" scope="col">
            <div class="dropdown">
              <button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" id="hamburger-{{ accordion_id }}" data-bs-toggle="dropdown" aria-expanded="false">
                <i class="ri-menu-line"></i>
              </button>
              <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="hamburger-{{ accordion_id }}">
                {% if show_missing_menu %}
                  <li><h6 class="dropdown-header">Missing Parts</h6></li>
                  <li><a class="dropdown-item" href="#" id="mark-all-missing-{{ accordion_id }}"><i class="ri-question-line me-2"></i>Mark all as missing</a></li>
                  <li><a class="dropdown-item" href="#" id="clear-all-missing-{{ accordion_id }}"><i class="ri-close-circle-line me-2"></i>Clear all missing</a></li>
                {% endif %}
                {% if show_missing_menu and show_checked_menu %}
                  <li><hr class="dropdown-divider"></li>
                {% endif %}
                {% if show_checked_menu %}
                  <li><h6 class="dropdown-header">Checked Status</h6></li>
                  <li><a class="dropdown-item" href="#" id="check-all-{{ accordion_id }}"><i class="ri-checkbox-line me-2"></i>Check all</a></li>
                  <li><a class="dropdown-item" href="#" id="uncheck-all-{{ accordion_id }}"><i class="ri-checkbox-blank-line me-2"></i>Uncheck all</a></li>
                {% endif %}
              </ul>
            </div>
          </th>
        {% endif %}
      {% endif %}
    </tr>
  </thead>
{% endmacro %}

{% macro bricklink(item) %}
  {% set url=item.url_for_bricklink() %}
  {% if url %}
    <a data-search="exclude" href="{{ url }}" target="_blank" class="badge rounded-pill text-bg-light border fw-normal">
      <i class="ri-external-link-line"></i> Bricklink
    </a>
  {% endif %}
{% endmacro %}

{% macro image(image, caption=none, alt=none, accordion=false) %}
  <td class="py-0">
    <a data-lightbox data-caption="{{ caption }}" href="{{ image }}" target="_blank">
      <img class="{% if accordion %}accordion-img{% else %}table-img{% endif %}" src="{{ image }}" {% if alt %}alt="{{ alt }}"{% endif %} loading="lazy">
    </a>
  </td>
{% endmacro %}

{% macro rebrickable(item) %}
  {% set url=item.url_for_rebrickable() %}
  {% if url %}
    <a data-search="exclude" href="{{ url }}" target="_blank" class="badge rounded-pill text-bg-light border fw-normal">
      <i class="ri-external-link-line"></i> Rebrickable
    </a>
  {% endif %}
{% endmacro %}
