{% extends "sprout-seo/_layouts/base" %}
{% import 'sprout-base/_includes/sproutcp' as sprout %}

{% do view.registerAssetBundle("barrelstrength\\sproutbase\\web\\assets\\cp\\CpAsset") %}

{% if title is not defined %}
    {% set title = "Global Metadata"|t %}
{% endif %}

{% set fullPageForm = true %}

{% block contextMenu %}
    {% if craft.app.getIsMultiSite() %}
        {% include "_elements/sitemenu" with {
            selectedSiteId: globals.siteId,
            urlFormat: "sprout-seo/globals/"~selectedTabHandle~"/{handle}"
        } %}
    {% endif %}
{% endblock %}

{% set navItems = {
    'identity-heading': { heading: "Knowledge Graph"|t },
    'website-identity': { title: "Website Identity"|t },
    'contacts': { title: "Contacts"|t },
    'social': { title: "Social Profiles"|t },

    'ownership-heading': { heading: "Ownership"|t },
    'verify-ownership': { title: "Verify Ownership"|t },

    'preferences': { heading: "Preferences"|t },
    'customization': { title: "Customization"|t },
    'robots': { title: "Robots"|t },
} %}

{% set docTitle = navItems[selectedTabHandle].title~' - '~title %}

{% block actionButton %}
    {% if not isPro %}
        <div class="buttons">
            {{ sprout.upgradeToProButton({
                url: cpUrl('sprout-seo/upgrade'),
                title: "Upgrade to Sprout SEO to manage Unlimited Custom Metadata Mappings, Redirects, and XML Sitemaps."|t('sprout-seo')
            }) }}
        </div>
    {% endif %}
{% endblock %}

{% block sidebar %}
    <nav>
        <ul>
            {% for tabHandle, item in navItems %}
                {% if item.heading is defined %}
                    <li class="heading"><span>{{ item.heading }}</span></li>
                {% else %}
                    {% set selected = tabHandle == selectedTabHandle ? 'sel' : null %}
                    {% set tabUrl = url('sprout-seo/globals/'~tabHandle~(currentSite.handle is not null ? '/' ~ currentSite.handle)) %}
                    <li>
                        <a href="{{ tabUrl }}" class="{{ selected }}">{{ item.title }}</a>
                    </li>
                {% endif %}
            {% endfor %}
        </ul>
    </nav>
{% endblock %}