{% assign version = page.url | remove_first: "/" | split: "/" | first %}
{% assign upgrading = false %}
{% if version == '' or version == 'releases' %}
    {% assign version = site.data.project.releases.current.version %}
    {% assign upgrading = true %}
{% endif %}
{% capture version_home %}/{{ version }}/{% endcapture %}
{%- assign title = page.title | default: site.data.project.tagline -%}
{%- assign description = page.description | default: site.data.project.description -%}
{%- assign full_title = title | append: " - " | append: description -%}
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>{{ page.title }} - {{ site.data.project.title }}</title>
    {%- include meta.html -%}
</head>
<body class="bg-white text-dark font-onest antialiased relative">
<div class="relative z-10">
    <header class="flex items-center sm:justify-center pl-6 pr-6 pb-6 max-w-7xl mx-auto pb-32">
        <div class="flex gap-6 md:gap-0 md:flex-row justify-between md:items-center p-3 md:p-6 w-full max-w-7xl">
            <a class="flex items-center gap-2 sm:gap-3" href="/">
                <img src="/assets/img/csv-logo.svg" alt="Logo" class="w-[40px] sm:w-[50px] h-[40px] sm:h-[50px]"/>
                <div class="font-black">CSV</div>
            </a>
        </div>
        <div class="flex gap-6 md:gap-0 md:flex-row justify-between md:items-center p-3 md:p-6 w-full max-w-7xl">
            <input type="search" id="doc-search" class="w-64" placeholder="search the docs...">
        </div>
    </header>
    <main class="relative flex justify-center mx-auto max-w-8xl sm:px-2 lg:px-8 xl:px-12 gap-8">
        <label for="navigation" class="fixed top-5 right-5 z-50 flex items-center justify-center w-12 h-12 mb-4 ml-4 bg-white border rounded-full shadow-lg cursor-pointer text-slate-600 border-slate-300 lg:hidden transition duration-200 ease-in-out active:scale-95">
            <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                <path stroke-linecap="round" stroke-linejoin="round" d="M4 8h16M4 16h16" />
            </svg>
        </label>
        <input type="checkbox" name="navigation" id="navigation" class="hidden peer" />
        <div class="fixed top-[3.5rem] h-screen shadow-xl px-4 left-0 hidden peer-checked:block lg:relative lg:top-0 lg:h-auto lg:px-0 lg:block lg:flex-none lg:shadow-none  bg-slate-100 lg:bg-transparent z-50">
            <div class="absolute inset-y-0 right-0 w-full lg:w-[50vw]"></div>
            <nav class="sticky top-[4.5rem] w-64 pr-8 text-base lg:text-sm xl:w-72 xl:pr-16">
                <ul role="list" class="-ml-0.5 h-[calc(100vh-4.5rem)] overflow-y-auto py-7 pl-0.5 space-y-4">
                    {% if upgrading == false %}
                    {% for section in site.data.menu.version[version] %}
                    <h3 class="font-semibold tracking-tight text-slate-900">{{ section[0] }}</h3>
                    <ul role="list" class="pl-3 mt-3 space-y-2">
                        {% for link in section[1] %}
                        <li {% if page.url == link[1] %}class="selected"{% endif %}>
                            <a href="{{ link[1] }}" class="text-slate-900 hover:text-slate-800">{{ link[0] }}</a>
                        </li>
                        {% endfor %}
                    </ul>
                    {% endfor %}
                    {% else %}
                    {% for section in site.data.menu.upgrading %}
                    <h3 class="font-semibold tracking-tight text-slate-900">{{ section[0] }}</h3>
                    <ul role="list" class="pl-3 mt-3 space-y-2">
                        {% for link in section[1] %}
                        <li {% if page.url == link[1] %}class="selected"{% endif %}>
                            <a href="{{ link[1] }}" class="text-slate-900 hover:text-slate-800">{{ link[0] }}</a>
                        </li>
                        {% endfor %}
                    </ul>
                    {% endfor %}
                    {% endif %}
                    <h3 class="font-semibold tracking-tight text-slate-900">Release Notes</h3>
                    <ul role="list" class="pl-3 mt-3 space-y-2">
                        <li {% if upgrading == true %}class="selected"{% endif %}><a href="/releases/">Releases Notes</a></li>
                    </ul>
                    <h3 class="font-semibold tracking-tight text-slate-900">Older versions</h3>
                    <ul role="list" class="pl-3 mt-3 space-y-2">
                        {% for v in site.data.menu.version %}
                        <li {% if version == v[0] and upgrading == false %}class="selected"{% endif %}>
                            <a href="/{{ v[0] }}/">{{ v[0] }} {% if v[0] == site.data.project.releases.current.version %}(latest stable){% endif %}</a>
                        </li>
                        {% endfor %}
                    </ul>
                </ul>
            </nav>
        </div>
        <div class="flex-auto max-w-2xl min-w-0 px-4 py-10 lg:max-w-4xl lg:pr-0 lg:pl-8 xl:px-16">
            <article class="content">
            {% if version == site.data.project.releases.next.version %}
                <p class="message-notice">This is the documentation for the upcoming <code>version {{ version }}</code>. This is a work in progress</p>
            {% endif %}

            {% if version == site.data.project.releases.previous.version %}
                <p class="message-notice">This is the documentation for <code>version {{ version }}</code> which will be supported until <strong>{{ site.data.project.releases.previous.supported_until }}</strong>. Please consider upgrading your code to <a href="{{ site.data.project.releases.current.documentation_link }}">the latest stable version</a></p>
            {% endif %}

            {% if version == site.data.project.releases.legacy.version %}
                <p class="message-notice">This is the documentation for the unsupported <code>version {{ version }}</code>. Please consider upgrading your code to <a href="{{ site.data.project.releases.current.documentation_link }}">the latest stable version</a></p>
            {% endif %}
                {{ content }}
            </article>
        </div>
    </main>
    {%- include footer.html -%}
</div>
<script src="{{ site.data.manifest['docs.js'] }}?v={{ site.time | date:'%s' }}"></script>
<script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script> docsearch({
    apiKey: '63ba748e8f5bceb91934667c118972d0',
    indexName: 'thephpleague_csv',
    inputSelector: '#doc-search',
    algoliaOptions: { 'facetFilters': ["version:{{ version }}"] },
    debug: false // Set debug to true if you want to inspect the dropdown
});
</script>
</body>
</html>
