{# Parameters:
  - label (string) (default: '')
  - status (string) (default: 'planned')
  - badge (string) (default: '')
  - start_date (string) (default: '')
  - start_label (string) (default: '')
  - end_date (string) (default: '')
  - end_label (string) (default: '')
  - progress (string) (default: '')
  - attributes (drupal attrs)
#}

{%- set _label = label|default('') %}
{% set _status = status|default('planned') %}
{% set _badge = badge|default('') %}
{% set _start_date = start_date|default('') %}
{% set _start_label = start_label|default('') %}
{% set _end_date = end_date|default('') %}
{% set _end_label = end_label|default('') %}
{% set _progress = progress|default('') %}

{%- if attributes is empty %}
  {%- set attributes = create_attribute() %}
{% endif %}

{%- set attributes = attributes.addClass([
  'bcl-project-status',
  'border-bottom',
  'pb-4',
  'mb-4'
]) %}

{%- set _bgs = {
    ongoing: 'info',
    closed: 'dark',
    planned: 'secondary',
  } %}
{% set _bg = _bgs[_status]|default('secondary') -%}

<div {{ attributes }}>{# -#}
  <div class="row">{# -#}
    <div class="col-12 col-md-3">
    {%- if _label is not empty -%}
      <p class="fw-bold">{{ _label }}</p>
    {%- endif %}

    {%- if _badge is not empty %}
      {%- include '@oe-bcl/bcl-badge/badge.html.twig' with {
        label: _badge,
        rounded_pill: true,
        background: _bg,
        attributes: create_attribute().addClass(['mb-3', 'mb-md-0']),
      } only %}
    {%- endif -%}

    </div>{# -#}

    <div class="col-12 col-md-9">{# -#}
      <div class="d-flex justify-content-between">

      {%- if _start_date is not empty and _start_label is not empty -%}
        <p class="fw-bold">
          {{- _start_label -}} <br>{# -#}
          <span class="fw-normal">
            {{- _start_date -}}
          </span>{# -#}
        </p>
      {%- endif %}

      {%- if _end_date is not empty and _end_label is not empty -%}
        <p class="fw-bold text-end">
          {{- _end_label -}} <br>{# -#}
          <span class="fw-normal">
            {{- _end_date -}}
          </span>{# -#}
        </p>
      {%- endif -%}
      </div>

    {%- if _progress is not empty or _status != 'ongoing' %}
      {%- if _progress is empty %}
        {%- set _progress = _status == 'closed' ? 100 : 0 %}
      {%- endif %}
      {%- include '@oe-bcl/bcl-progress/progress.html.twig' with {
        variant: _bg,
        hidden_label: true,
        progress: _progress,
      } only %}
    {%- endif -%}

    </div>{# -#}
  </div>{# -#}
</div>
{#--#}
