{% macro mini(oob=False, count=None) %}
<div id="cart-mini" {% if oob %}hx-swap-oob="{{oob}}"{% endif %} >
  {# cart_count is set by the context processor in all apps.
     Cart app computes it from g.cart + calendar_cart_entries;
     other apps get it from the cart internal API.
     count param allows explicit override when macro is imported without context. #}
  {% if count is not none %}
    {% set _count = count %}
  {% elif cart_count is defined and cart_count is not none %}
    {% set _count = cart_count %}
  {% elif cart is defined and cart is not none %}
    {% set _count = (cart | sum(attribute="quantity")) + ((calendar_cart_entries | length) if calendar_cart_entries else 0) %}
  {% else %}
    {% set _count = 0 %}
  {% endif %}

  {% if _count == 0 %}
  <div class="h-12 w-12 rounded-full overflow-hidden border border-stone-300 flex-shrink-0">
    <a
      href="{{ coop_url('/') }}"
      class="h-full w-full font-bold text-5xl flex-shrink-0 flex flex-row items-center gap-1"
    >
      <img
        src="{{ site().logo }}"
        class="h-full w-full rounded-full object-cover border border-stone-300 flex-shrink-0"
      >
    </a>
  </div>
  {% else %}

    <a
      href="{{ cart_url('/') }}"
      class="relative inline-flex items-center justify-center text-stone-700 hover:text-emerald-700"
    >
      <i class="fa fa-shopping-cart text-5xl" aria-hidden="true"></i>

      <span
        class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 inline-flex items-center justify-center rounded-full bg-emerald-600 text-white text-sm w-5 h-5"
      >
        {{ _count }}
      </span>
    </a>
  {% endif %}
</div>
{% endmacro %}
