{#
/**
 * @file
 * Main dashboard template for Native Observability.
 *
 * Available variables:
 * - dashboard: Full dashboard payload built by the backend services.
 * - range_selector: The available range selector items.
 * - active_range: The active range key.
 */
#}

{% set primary_kpis = dashboard.sections.primary_kpis ?? null %}
{% set request_timeline = dashboard.sections.request_timeline ?? null %}
{% set ajax_activity = dashboard.sections.ajax_activity ?? null %}
{% set technical_insights = dashboard.sections.technical_insights ?? null %}
{% set cache_observability = dashboard.sections.cache_observability ?? null %}

<div class="no-dashboard-wrapper">
  <div class="no-dashboard-container">

    {% if primary_kpis and primary_kpis.enabled %}
      {% include '@native_observability_dashboard/components/native-observability-dashboard--primary-kpis.html.twig' with {
        section: primary_kpis,
        range_selector: range_selector
      } only %}
    {% elseif primary_kpis and primary_kpis.reason is defined %}
      <section class="no-dashboard-section no-dashboard-section--disabled">
        <div class="no-dashboard-empty-state">{{ primary_kpis.reason }}</div>
      </section>
    {% endif %}

    {% if request_timeline and request_timeline.enabled and ajax_activity and ajax_activity.enabled %}
      {% include '@native_observability_dashboard/components/native-observability-dashboard--activity-overview.html.twig' with {
        request_timeline: request_timeline,
        ajax_activity: ajax_activity
      } only %}
    {% else %}
      {% if request_timeline and request_timeline.enabled %}
        {% include '@native_observability_dashboard/components/native-observability-dashboard--request-timeline.html.twig' with {
          section: request_timeline
        } only %}
      {% elseif request_timeline and request_timeline.reason is defined %}
        <section class="no-dashboard-section no-dashboard-section--disabled">
          <div class="no-section-toolbar">
            <div class="no-section-header">
              <div class="no-section-header__content">
                <span class="no-section-title">{{ request_timeline.title|default('Request Activity'|t) }}</span>
                {% if request_timeline.time_range is defined and request_timeline.time_range %}
                  <span class="no-section-subtitle">{{ request_timeline.time_range }}</span>
                {% endif %}
              </div>
            </div>
          </div>

          <span class="no-section-divider"></span>

          <div class="no-dashboard-empty-state">
            {{ request_timeline.reason }}
          </div>
        </section>
      {% endif %}

      {% if ajax_activity and ajax_activity.enabled %}
        {% include '@native_observability_dashboard/components/native-observability-dashboard--request-timeline.html.twig' with {
          section: ajax_activity
        } only %}
      {% elseif ajax_activity and ajax_activity.reason is defined %}
        <section class="no-dashboard-section no-dashboard-section--disabled">
          <div class="no-section-toolbar">
            <div class="no-section-header">
              <div class="no-section-header__content">
                <span class="no-section-title">{{ ajax_activity.title|default('AJAX Activity'|t) }}</span>
                {% if ajax_activity.time_range is defined and ajax_activity.time_range %}
                  <span class="no-section-subtitle">{{ ajax_activity.time_range }}</span>
                {% endif %}
              </div>
            </div>
          </div>

          <span class="no-section-divider"></span>

          <div class="no-dashboard-empty-state">
            {{ ajax_activity.reason }}
          </div>
        </section>
      {% endif %}
    {% endif %}

    {% if technical_insights and technical_insights.enabled %}
      {% include '@native_observability_dashboard/components/native-observability-dashboard--technical-insights.html.twig' with {
        section: technical_insights
      } only %}
    {% endif %}

    {% if cache_observability %}
      {% include '@native_observability_dashboard/components/native-observability-dashboard--cache-observability.html.twig' with {
        section: cache_observability
      } only %}
    {% endif %}

  </div>
</div>
