{% extends "layout/base.html" %}

{% block title -%}
    {{- explorer_instance_title or 'ODC' }} Products
{%- endblock %}
{% block head %}
    {{ super() }}
    <style type="text/css">
        .panel > h2 {
            margin-bottom: 30px;
        }
    </style>
{% endblock %}

{% block content %}
    <div class="panel highlight">
        <h2 class="followed lonesome">{{ (datacube_products | count ) - (hidden_product_list | length) }} Products</h2>
        <div class="header-follow">
            <a href="{{ url_for('product.product_list_text') }}"
               class="badge header-badge">
                Text <i class="fa-solid fa-file-text" aria-hidden="true"></i>
            </a>
            <a href="{{ url_for('stac.collections') }}"
               class="badge header-badge">
                Stac <i class="fa-solid fa-file-text" aria-hidden="true"></i>
            </a>
            <a href="{{ url_for('product.raw_all_products_doc') }}"
               class="badge header-badge">
                Yaml <i class="fa-solid fa-file-text" aria-hidden="true"></i>
            </a>
        </div>

    <table class="data-table">
        {% if grouped_products %}
            {% for group_name, product_summaries in grouped_products %}
                {% if group_name %}
                    <thead>
                        <tr class="section-header">
                            <th colspan="3" class="group-name">
                                {{ group_name }}
                                {{ hanchor(group_name + '-group') }}
                            </th>
                        </tr>
                    </thead>
                {% endif %}
                {% if product_summaries %}
                    <tbody>
                        {% for product, summary in product_summaries %}
                            {% if product.name not in hidden_product_list %}
                                <tr class="collapse-when-small">
                                    <td>
                                        <a href="{{ url_for('pages.product_page', product_name=product.name) }}"
                                            >{{ product.name }}</a>
                                    </td>
                                    <td class="{% if (not summary) or summary.dataset_count == 0 %}muted{% endif %}">
                                        {{- product.definition.description -}}
                                    </td>
                                </tr>
                            {% endif %}
                        {% endfor %}
                    </tbody>
                {% endif %}
            {% endfor %}
        {% endif %}
    </table>
    {% if hidden_product_list %}
        <details>
            <summary class="muted">Hidden Products</summary>
            <table class="hidden-products">
                {% for product_name in hidden_product_list %}
                    <tr>
                        <td><a href="{{ url_for('pages.product_page', product_name=product_name) }}">{{ product_name }}</a></td>
                    </tr>
                {% endfor %}
            </table>
        </details>
    {% endif %}
    </div>
{% endblock %}
