{% trans_default_domain 'admin' %}

{# Offer status → icon indicator, keyed by status/transition name. Pass an
   `offer` object (its primary status is derived) OR an explicit `status` string.
   With `label: true` the status text is shown beside the icon (icon + label);
   the default (used by the offer lists/headers) is icon-only. #}
{% set status = status ?? (offer is defined and offer ? offer.status|keys|sort((a, b) => b == 'completed' or b == 'cancelled' ? 1 : 0)|first : null) %}
{% set icons = {
    draft: ['plus-circle', 'text-orange-600'],
    to_draft: ['plus-circle', 'text-orange-600'],
    to_draft_2: ['plus-circle', 'text-orange-600'],
    cancel: ['x-circle-fill', 'text-red-600'],
    cancelled: ['x-circle-fill', 'text-red-600'],
    finalize: ['check-circle', 'text-green-600'],
    finalized: ['check-circle', 'text-green-600'],
    approve: ['shield-check', 'text-green-600'],
    reviewed: ['shield-check', 'text-green-600'],
    publish: ['check-circle-fill', 'text-green-600'],
    relaunch: ['check-circle-fill', 'text-green-600'],
    published: ['check-circle-fill', 'text-green-600'],
    unpublish: ['x-circle', 'text-gray-500'],
    unpublished: ['x-circle', 'text-gray-500'],
    complete: ['check-circle-fill', 'text-blue-600'],
    completed: ['check-circle-fill', 'text-blue-600'],
} %}

{% set icon_config = icons[status] ?? null %}
{% set icon = icon_config[0] ?? 'circle' %}
{% set color = icon_config[1] ?? 'text-gray-400' %}
{% set status_label = ("offers.status.#{status}")|trans([], "admin") %}

{% if label|default(false) %}
    <span class="inline-flex items-center gap-x-1.5 align-middle">
        <span aria-hidden="true" class="{{ color }} {{ size|default('size-4') }} flex-none">{{ ux_icon('ph:'~icon) }}</span>
        <span class="font-medium text-gray-700 dark:text-gray-200">{{ status_label }}</span>
    </span>
{% else %}
    <span aria-label="{{ status_label }}" class="inline-flex">
        <span aria-hidden="true"
              title="{{ status_label }}"
              class="{{ color }} {{ size|default('size-5') }}">
            {{ ux_icon('ph:'~icon) }}
        </span>
    </span>
{% endif %}
