{% assign segmented-icons = include.icons | default: "" | split: "," %}
{% assign segmented-items = include.items | default: "" | split: "," %}
{% assign segmented-disabled = include.disabled | default: "" | split: "," %}
{% assign segmented-hover = include.hover | default: "" %}
{% assign segmented-default = include.default | default: 1 | plus: 0 %}

{% assign segmented-items-count = segmented-items | size %}
{% assign segmented-icons-count = segmented-icons | size %}
{% assign segmented-all-count = segmented-items-count %}

{% if segmented-icons-count > segmented-all-count %}{% assign segmented-all-count = segmented-icons-count %}{% endif %}

<nav class="nav nav-segmented{% if include.vertical %} nav-segmented-vertical{% endif %}{% if include.size %} nav-{{ include.size }}{% endif %}{% if include.full-width %} w-100{% endif %}{% if include.class %} {{ include.class }}{% endif %}" role="tablist"{% if include.vertical %} aria-orientation="vertical"{% endif %}>
	{% for i in (1..segmented-all-count) %}
		{% assign index = forloop.index | append: "" %}
		{% assign disabled = segmented-disabled | contains: index %}
		{% assign is-default = forloop.index == segmented-default %}

		{% if include.name %}<input type="radio" class="nav-link-input" name="{{ include.name }}" id="segmented-{{include.name }}-{{ index }}" {% if is-default %}checked{% endif %} />{% endif %}

		<{% if include.name %}label for="segmented-{{include.name }}-{{ index }}"{% else %}button{% endif %} class="nav-link{% if disabled %} disabled{% endif %}{% if is-default and not include.name %} active{% endif %}{% if segmented-hover == index %} hover{% endif %}" role="tab"{% unless include.name %} data-bs-toggle="tab"{% endunless %} aria-selected="{% if is-default %}true{% else %}false{% endif %}" {% if disabled %} aria-disabled="true"{% endif %}{% if is-default %} aria-current="page"{% endif %}>
			{% if segmented-icons[forloop.index0] %}
				{% include "ui/icon.html" icon=segmented-icons[forloop.index0] class="nav-link-icon" %}
			{% endif %}
			{% if segmented-items[forloop.index0] %}
				{{ segmented-items[forloop.index0] }}
			{% endif %}
		</{% if include.name %}label{% else %}button{% endif %}>
	{% endfor %}
</nav>