{#
/**
 * @file
 * Template for conversion progress indicator.
 *
 * Available variables:
 * - media_id: The media entity ID.
 * - progress: Progress data array.
 */
#}
{% set status_label %}
  {% if progress.status == 'pending' %}{{ 'Pending'|t }}
  {% elseif progress.status == 'converting' or progress.status == 'processing' %}{{ 'Processing'|t }}
  {% elseif progress.status == 'completed' %}{{ 'Completed'|t }}
  {% elseif progress.status == 'failed' %}{{ 'Failed'|t }}
  {% else %}{{ progress.status }}
  {% endif %}
{% endset %}
<div class="ffmpeg-media-progress" data-media-id="{{ media_id }}">
  <div class="visually-hidden" role="status" aria-live="polite" aria-atomic="true" data-ffmpeg-progress-live>
    {% if progress %}
      {{ status_label }} {{ progress.percent }}%
    {% else %}
      {{ 'No conversion in progress.'|t }}
    {% endif %}
  </div>
  {% if progress %}
    <div class="ffmpeg-media-progress__status ffmpeg-media-progress__status--{{ progress.status }}">
      {{ status_label }}
    </div>

    <div class="ffmpeg-media-progress__bar"
         role="progressbar"
         aria-valuemin="0"
         aria-valuemax="100"
         aria-valuenow="{{ progress.percent }}"
         aria-valuetext="{{ status_label }} {{ progress.percent }}%">
      <div class="ffmpeg-media-progress__fill" style="width: {{ progress.percent }}%"></div>
    </div>

    <div class="ffmpeg-media-progress__info">
      <span class="ffmpeg-media-progress__percent">{{ progress.percent }}%</span>
      {% if progress.current_step %}
        <span class="ffmpeg-media-progress__step">{{ progress.current_step }}</span>
      {% endif %}
      {% if progress.estimated_remaining_formatted %}
        <span class="ffmpeg-media-progress__eta">
          {{ 'ETA: @time'|t({'@time': progress.estimated_remaining_formatted}) }}
        </span>
      {% endif %}
    </div>

    {% if progress.error %}
      <div class="ffmpeg-media-progress__error">
        {{ progress.error }}
      </div>
    {% endif %}
  {% else %}
    <div class="ffmpeg-media-progress__none">
      {{ 'No conversion in progress.'|t }}
    </div>
  {% endif %}
</div>
