<html>
<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, shrink-to-fit=no">

<title>Stashr - {{ title }}</title>

<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/bootstrap.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/stashr.css') }}?v=0.1.0">

<link href="https://cdn.jsdelivr.net/npm/vue-toast-notification/dist/theme-sugar.css" rel="stylesheet">

<link rel="stylesheet" href="{{ url_for('static', filename='css/all.css') }}">

<link href="https://fonts.googleapis.com/css?family=Grand+Hotel" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">

<link rel="manifest" href="{{ url_for('static', filename='manifest/manifest.json') }}">

<link rel="apple-touch-icon" href="touch-icon-iphone.png">
<link rel="apple-touch-icon" sizes="152x152" href="{{ url_for('static', filename='assets/stashr-152.png') }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ url_for('static', filename='assets/stashr-180.png') }}">
<link rel="apple-touch-icon" sizes="167x167" href="{{ url_for('static', filename='assets/stashr-167.png') }}">
<meta name="apple-mobile-web-app-title" content="Stashr">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">

<script src="{{ url_for('static', filename='js/stashr.js') }}"></script>
<script src="{{ url_for('static', filename='js/vue.dev.js') }}"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-toast-notification"></script>

{% block header_script_files %}{% endblock %}
{{ emit_tep('base_page_header_script_files') }}

</head>
<body>

<div class="container-fluid d-flex min-vh-100 m-0 p-0">
    <div class="stashr-menu d-flex flex-column p-3 text-white bg-dark text-center min-vh-100 sticky-top overflow-auto" id="sideMenu" style="width:280px;">
        <div class="d-flex flex-row">
            <a class="navbar-brand" href="{{ url_for('index_page') }}">
                <img class="border rounded-circle" src="{{ url_for('static', filename='assets/stashr.svg') }}" width="40" height="40" />
                <img src="{{ url_for('static', filename='assets/title.svg') }}" height="25" />
            </a>         
        </div>
        <hr/>
        <ul class="nav nav-pills flex-column mb-auto text-start">
            <li>
                <a data-bs-toggle="collapse" data-bs-target="#collapseLibrary" class="nav-link text-white collapsed">
                    <i class="fas fa-chevron-right"></i>
                    Library
                </a>
                <div class="collapse{% if (request.path == url_for('all_volumes_page')) or
                                          (request.path == url_for('all_publishers_page')) or
                                          (request.path == url_for('scrape_folders_page')) %} show{% endif %}"  id="collapseLibrary">
                    <ul class="ps-3 nav nav-pills flex-column">
                        <li>
                            <a href="{{ url_for('all_volumes_page') }}" class="nav-link text-white{% if request.path == url_for('all_volumes_page') %} active{% endif %}">
                                Volumes
                            </a>
                        </li>
                        {% if current_user.role == 'admin' %}
                        <li>
                            <a href="{{ url_for('scrape_folders_page') }}" class="nav-link text-white{% if request.path == url_for('scrape_folders_page') %} active{% endif %}">
                                Scrape
                            </a>
                        </li>
                        {% endif %}
                    </ul>
                </div>
            </li>
            {% if current_user.role == 'admin' or current_user.role == 'librarian' %}
            <li>
                <a href="{{ url_for('new_releases_page') }}" class="nav-link text-white{% if request.path == url_for('new_releases_page') %} active{% endif %}">
                    New Releases
                </a>
            </li>
            {% endif %}
            {% if current_user.role == 'admin' or current_user.role == 'librarian' or current_user.role == 'reader' %}
            <li>
                <a href="{{ url_for('reading_list_page') }}" class="nav-link text-white{% if request.path == url_for('reading_list_page') %} active{% endif %}">
                    Reading List
                </a>
            </li>
            <li>
                <a href="{{ url_for('all_collections_page') }}" class="nav-link text-white{% if request.path == url_for('all_collections_page') %} active{% endif %}">
                    Collections
                </a>
            </li>
            {% endif %}
            {{ emit_tep("base_page_main_menu") }}
        </ul>
        <hr />
        <ul class="nav nav-pills d-flex flex-column text-start">
            <li>
                <a href="{{ url_for('settings_single_user_page', user_id=current_user.id) }}" class="nav-link text-white">
                    <i class="fa fa-user"></i>
                    {{ current_user.username }}
                </a>
            </li>
            {% if current_user.role == 'admin' %}
            <li>
                <a href="{{ url_for('settings_page') }}" class="nav-link text-white">
                    <i class="fas fa-cogs"></i>
                    Settings
                </a>
            </li>
            {% endif %}
            <li>
                <a href="{{ url_for('logout_page') }}" class="nav-link text-white">
                    <i class="fas fa-sign-out-alt"></i>
                    Logout
                </a>
            </li>
        </ul>
    </div>
    <div class="d-flex flex-column w-100 m-0 px-0 min-vh-100 overflow-auto">

        <!-- v CONTENT v -->
        {% block content %}{% endblock %}
        <!-- ^ CONTENT ^ -->

        <!-- v BUTTON CONTAINER v -->
        <div>
            <div class="d-grid m-0 p-0 stashr-menu_button bg-dark">
                <div class="row d-flex flex-nowrap m-0 p-0 py-2">
                    <i class="text-white fas fa-ellipsis-v fa-2x" onclick="toggleMenu()"></i>
                </div>
            </div>
        </div>
        <!-- ^ BUTTON CONTAINER ^ -->
    </div>
</div>

<!-- v MODALS v -->
{% block modals %}{% endblock %}
{{ emit_tep('base_page_modals') }}
<!-- ^ MODALS ^ -->

<!-- v FOOTER SCRIPT INCLUDES v -->
<script src="{{ url_for('static', filename='js/bootstrap.bundle.js') }}"></script>
{% block footer_script_files %}{% endblock %}
{{ emit_tep('base_page_footer_script_files') }}
<!-- ^ FOOTER SCRIPT INCLUDES ^ -->

<!-- v FOOTER SCRIPT v -->
<script type="text/javascript">

Vue.use(VueToast);

// Flashes
{% with flashes = get_flashed_messages(with_categories=true) %}
    {% if flashes %}
        {% for category, message in flashes %}
            stashrToast('{{ message }}', '{{ category }}');
        {% endfor %}
    {% endif %}
{% endwith %}

/*
window.addEventListener("load", () => {
    if ("serviceWorker" in navigator) {
    navigator.serviceWorker.register("service-worker.js");
    }
});
*/

{% block script %}{% endblock %}

</script>
<!-- ^ FOOTER SCRIPT ^ -->

</body>
</html>