<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>whatsthedamage API Documentation</title>
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.10.0/swagger-ui.css">
    <style>
        body {
            margin: 0;
            padding: 0;
        }
        .version-selector {
            position: fixed;
            top: 10px;
            right: 10px;
            z-index: 1000;
            background: white;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .version-selector label {
            margin-right: 10px;
            font-weight: bold;
        }
        .version-selector select {
            padding: 5px 10px;
            border-radius: 4px;
            border: 1px solid #ccc;
        }
    </style>
</head>
<body>
    <div class="version-selector">
        <label for="version-select">API Version:</label>
        <select id="version-select" onchange="changeVersion()">
            <option value="v1" {% if version == 'v1' %}selected{% endif %}>v1 (Summary)</option>
            <option value="v2" {% if version == 'v2' %}selected{% endif %}>v2 (Detailed)</option>
        </select>
    </div>
    <div id="swagger-ui"></div>
    <script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.10.0/swagger-ui-bundle.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.10.0/swagger-ui-standalone-preset.js"></script>
    <script>
        function changeVersion() {
            const version = document.getElementById('version-select').value;
            window.location.href = '/api/docs?version=' + version;
        }

        window.onload = function() {
            const ui = SwaggerUIBundle({
                url: "/api/{{ version }}/openapi.json",
                dom_id: '#swagger-ui',
                deepLinking: true,
                presets: [
                    SwaggerUIBundle.presets.apis,
                    SwaggerUIStandalonePreset
                ],
                plugins: [
                    SwaggerUIBundle.plugins.DownloadUrl
                ],
                layout: "StandaloneLayout"
            });
            window.ui = ui;
        }
    </script>
</body>
</html>
