{#
/**
 * @file
 * menu-ac-item
 *
 * See menu-ac-item.wingsuit.yaml for documentation.
 */
#}
{% set in_active_trail = in_active_trail|default(false) %}
{% set active = active|default(false) %}
{% set max_depth = max_depth|default(0) %}
{% set depth = depth|default(0) %}
{% set class = class|default('') %}
{% set icon = icon|default("fas fa-angle-right") %}
{% if icon == '<none>' %}
  {% set icon_left = false %}
{% endif %}
{% set attributes = create_attribute() %}
{% for key, value in attr %}
  {% set attributes = attributes.setAttribute(key, value) %}
{% endfor %}
{# TEMPLATE #}
{% if max_depth > depth %}
  {% if sub_links is not empty %}
    <li class="parent depth-{{ depth }} lin">
      {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
        "text": title,
        "url": url,
        "icon_left": icon_left,
        "class": (active ? 'active ') ~ (in_active_trail ? 'active-trail ') ~ class,
        "attr": attributes,
      } only %}
      <ul class="uln" id="mc-{{ lid }}">
        {% for s_link in sub_links %}
          {% set s_attributes = create_attribute() %}
          {% for key, value in s_link['attr'] %}
            {% set s_attributes = s_attributes.setAttribute(key, value) %}
          {% endfor %}
          {% include "@organisms/tm-menu/menu-std/menu-std-item.twig" with {
            "lid": s_link['lid'],
            "title": s_link['title'],
            "url": s_link['url'],
            "sub_links": s_link['sub_links'],
            "in_active_trail": s_link['in_active_trail'],
            "active": s_link['active'],
            "depth": depth + 1,
            "max_depth": max_depth,
            "class": s_link['class'],
            "attr": s_attributes,
            "icon": icon,
          } only %}
        {% endfor %}
      </ul>
    </li>
  {% else %}
    {% if title != '<none>'%}
      <li class="depth-{{ depth }} lin">
        {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
          "text": title,
          "url": url,
          "icon_left": icon_left,
          "class": (active ? 'active ') ~ (in_active_trail ? 'active-trail ') ~ class,
          "attr": attributes,
        } only %}
      </li>
    {% endif %}
  {% endif %}
{% else %}
  {% if title != '<none>'%}
    <li class="depth-{{ depth }} lin">
      {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
        "text": title,
        "url": url,
        "icon_left": icon_left,
        "class": (active ? 'active ') ~ (in_active_trail ? 'active-trail'),
        "attr": attributes,
      } only %}
    </li>
  {% endif %}
{% endif %}
