<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ECMWF DestinE STAC Viewer</title>
    <link rel="stylesheet" href="/static/styles.css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/json.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/python.min.js"></script>
    <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📚</text></svg>">

</head>
<body>
    <div id="viewer">
        <div id="catalog-list">
            <h2>STAC Items</h2>
            <p>{{ config.get('message', '')}}</p>
            <p>Select one <strong>or multiple</strong> items and then click next to iteratively build up a full request.</p>
            <p>Last database update: <time>{{config.get('last_database_update', '')}}</time></p>
            <div class="sidebar-header">
                <button id="previous-btn">Previous</button>
                <a id="stac-anchor"><button id="stac-btn">Raw STAC</button></a>
                <button id="next-btn">Next</button>
            </div>
            
            <div id="items">
                <!-- Items from the STAC catalog will be rendered here -->
            </div>
        </div>
        <div id="details">
            <h2>Current Selection</h2>
            This is a <a href="https://github.com/ecmwf/datacube-spec/blob/main/spec/selection.md">MARS Selection</a> object in JSON format. Hover over a key or value for more info.
            <!-- Container for the request part, preloaded to prevent layout shift. -->
            <pre><code id="request-breakdown" class="language-json">
{
}
            </code></pre>

            <!-- Container fo the raw STAC response -->
            <details open>
                <summary><h2>Raw STAC Response</h2></summary>
                <p>See the <a href="https://github.com/ecmwf-projects/catalogs/blob/main/structured_stac.md">STAC Extension Proposal</a> for more details on the format.</p>
                <pre class="json-pre"><code id="raw-stac" class="language-json"></code></pre>
            </details>

            <!-- Container for the debug response -->
            <details>
                <summary><h2>Debug Info</h2></summary>
                <pre class="json-pre"><code id="debug" class="language-json"></code></pre>
            </details>
        </div>
    </div>

    <script>
        window.API_URL = "{{ api_url }}";
    </script>
    <script src="/static/app.js"></script>
</body>
</html>