{% macro square(background_color='#E1E1E1', border_color='#9D9D9D') -%}
    <div style="
        width: 24px;
        height: 24px;
        background-color: {{ background_color }};
        border: 3px solid {{ border_color }};
        border-radius: 5px;
        position: absolute;">
    </div>
{%- endmacro %}


{% macro extra_fields(parent) -%}
    {% if parent.extra_fields %}
        {% for key, value in parent.extra_fields.items() %}
            <tr><td style="text-align: left;"><strong>{{ key }}:</strong> {{ value }} </td></tr>
        {% endfor %}
    {% endif %}
{%- endmacro %}


{% macro links(parent) -%}
    {% if parent.links|length > 0 %}
        <details>
            <summary style="margin-bottom: 10px; margin-top: 10px">
                <h4 style="margin-bottom: 0px; display: inline;">Links</h4>
            </summary>
            {% for link in parent.links %}
                {{ link._repr_html_() }}
            {% endfor %}
        </details>
    {% endif %}
{%- endmacro %}


{% macro items(parent) -%}
    {% if parent.get_items()|is_nonempty_generator %}
        <details>
            <summary style="margin-bottom: 10px; margin-top: 10px">
                <h4 style="margin-bottom: 0px; display: inline;">Items</h4>
            </summary>
            <i> Only the first item shown </i>
            {% for item in parent.get_items()|first %}
                {{ item._repr_html_() }}
            {% endfor %}
        </details>
    {% endif %}
{%- endmacro %}


{% macro children(parent) -%}
    {% if parent.get_children()|is_nonempty_generator %}
        <details>
            <summary style="margin-bottom: 10px; margin-top: 10px">
                <h4 style="margin-bottom: 0px; display: inline;">Children</h4>
            </summary>
            <i> Only the first child shown </i>
            {% for child in parent.get_children()|first %}
                {{ child._repr_html_() }}
            {% endfor %}
        </details>
    {% endif %}
{%- endmacro %}


{% macro stac_extensions(parent) -%}
    {% if parent.stac_extensions|length > 0 %}
        <details>
            <summary style="margin-bottom: 10px; margin-top: 10px;">
                <h4 style="margin-bottom: 0px; display: inline;">STAC Extensions</h4>
            </summary>
            <table style="width: 100%; text-align: left;">
                {% for stac_extension in parent.stac_extensions %}
                    <tr><td style="text-align: left;"><a href="{{stac_extension}}">{{stac_extension}}</a></td></tr>
                {% endfor %}
            </table>
        </details>
    {% endif %}
{%- endmacro %}


{% macro assets(parent) -%}
    {% if parent.assets|length > 0 %}
        <details>
            <summary style="margin-bottom: 10px; margin-top: 10px;">
                <h4 style="margin-bottom: 0px; display: inline;">Assets</h4>
            </summary>
            {% for key, asset in parent.assets.items() %}
                {{ asset._repr_html_() }}
            {% endfor %}
        </details>
    {% endif %}
{%- endmacro %}