<!DOCTYPE html>
<html lang="{{ current_language }}">
  <head>
    <meta charset="utf-8">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
{%- if (request.path == "/user/google-sign-in" or request.path == "/user/sign-in") and config['USE_GOOGLE_LOGIN'] %}
    <meta name="google-signin-client_id" content="{{ config['OAUTH_CREDENTIALS']['google']['id'] }}">
{%- endif %}{{ extra_meta }}
    <title>{% if tab_title %}{{ tab_title }}{% else %}{{ config['APP_NAME'] }}{% endif %}</title>
{%- for key in config['SOCIAL'] %}
{%- if key not in ('og', 'twitter', 'fb') %}
    <meta name="{{ key }}" content="{{ config['SOCIAL'][key] }}">
{%- endif %}
{%- endfor %}
    <meta itemprop="name" content="{% if page_title %}{{ config['BRAND_NAME'] }}: {{ page_title }}{% else %}{{ config['BRAND_NAME'] }}{% endif %}">
{%- if 'description' in config['SOCIAL'] %}
    <meta itemprop="description" content="{{ config['SOCIAL']['description'] }}">
{%- endif %}
{%- if 'image' in config['SOCIAL'] %}
    <meta itemprop="image" content="{{ config['SOCIAL']['image'] }}">
{%- endif %}
{%- if 'card' not in config['SOCIAL']['twitter'] %}
    <meta name="twitter:card" content="summary">
{%- endif %}
{%- for key in config['SOCIAL']['twitter'] %}
{%- if key != 'title' %}
    <meta name="twitter:{{ key }}" content="{{ config['SOCIAL']['twitter'][key] }}">
{%- endif %}
{%- endfor %}
    <meta name="twitter:title" content="{% if page_title %}{{ config['BRAND_NAME'] }}: {{ page_title }}{% else %}{{ config['BRAND_NAME'] }}{% endif %}">
{%- if 'image' in config['SOCIAL']['og'] %}
    <meta name="og:title" content="{% if page_title %}{{ config['BRAND_NAME'] }}: {{ page_title }}{% else %}{{ config['BRAND_NAME'] }}{% endif %}">
{%- for key in config['SOCIAL']['og'] %}
{%- if key not in ('locale', 'url') %}
    <meta name="og:{{ key }}" content="{{ config['SOCIAL']['og'][key] }}">
{%- endif %}
{%- endfor %}
    <meta name="og:url" content="{{ request.base_url }}">
{%- if 'locale' in config['SOCIAL']['og'] %}
    <meta name="og:locale" content="{{ config['SOCIAL']['og']['locale'] }}">
{%- else %}
    <meta name="og:locale" content="{{ config['OG_LOCALE'] }}">
{%- endif %}
{%- if 'site_name' not in config['SOCIAL']['og'] %}
    <meta name="og:site_name" content="{{ config['BRAND_NAME'] }}">
{%- endif %}
{%- if 'type' not in config['SOCIAL']['og'] %}
    <meta name="og:type" content="website">
{%- endif %}
{%- endif %}
{%- for key in config['SOCIAL']['fb'] %}
    <meta name="fb:{{ key }}" content="{{ config['SOCIAL']['fb'][key] }}">
{%- endfor %}
    <link rel="shortcut icon" href="{{ url_for('favicon') }}">
    <link rel="apple-touch-icon" sizes="180x180" href="{{ url_for('apple_touch_icon') }}">
    <link rel="icon" type="image/png" href="{{ url_for('favicon_md') }}" sizes="32x32">
    <link rel="icon" type="image/png" href="{{ url_for('favicon_sm') }}" sizes="16x16">
    <link rel="manifest" href="{{ url_for('favicon_manifest_json') }}">
    <link rel="mask-icon" href="{{ url_for('favicon_safari_pinned_tab') }}" color="{{ config['FAVICON_MASK_COLOR'] }}">
    <meta name="theme-color" content="{{ config['FAVICON_THEME_COLOR'] }}">
    <script defer src="{{ url_for('static', filename='fontawesome/js/all.min.js', v=config['DA_VERSION']) }}"></script>
    <link href="{% if config['BOOTSTRAP_THEME'] %}{{ config['BOOTSTRAP_THEME'] }}{% else %}{{ url_for('static', filename='bootstrap/css/bootstrap.min.css', v=config['DA_VERSION']) }}{% endif %}" rel="stylesheet">
    <link href="{{ url_for('static', filename='app/app.min.css', v=config['DA_VERSION']) }}" rel="stylesheet">{{ extra_css }}{{ config['GLOBAL_CSS']|safe }}
  </head>
  <body class="{% if bodyclass %}{{ bodyclass }}{% else %}dabody{% endif %} da-pad-for-navbar{% if footer_content %} da-pad-for-footer{% endif %}">
    <nav class="navbar fixed-top navbar-expand-md navbar-dark bg-dark">
      <div class="{% if userclass %}{{ config['CONTAINER_CLASS'] }} danavcontainer{% else %}{{ config['CONTAINER_CLASS'] }}{% endif %}">
        {% if back_button %}{{ back_button }}{% endif %}{% if request.path == "/playground" %}<div class="dropdown"><div class="navbar-brand dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{ page_title }}</div><div class="dropdown-menu" aria-labelledby="dropdownMenuButton">{% if current_project != 'default' %}<a class="dropdown-item" href="?project=default"><i class="fas fa-archive"></i> {{ word("Default Playground") }}</a>{% endif %}{% for project in projects %}{% if project != current_project %}<a class="dropdown-item" href="?project={{ project }}"><i class="fas fa-archive"></i> {{ project }}</a>{% endif %}{% endfor %}<a class="dropdown-item" href="{{ url_for('playground_project', project=current_project) }}"><i class="fas fa-tasks"></i> {{ word('Manage Projects') }}</a></div></div>{% else %}<a class="navbar-brand" href="#">{% if page_title %}{{ page_title }}{% else %}{{ config['BRAND_NAME'] }}{% endif %}</a>{% endif %}
        {%- if not (current_user.is_anonymous and request.path == "/user/sign-in") %}
        <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#danavbar-collapse">
          <span class="navbar-toggler-icon"></span>
        </button>
        {%- endif %}
        <div class="collapse navbar-collapse" id="danavbar-collapse">
          <ul class="navbar-nav ml-auto">
            {%- if not current_user.is_anonymous %}
            <li class="nav-item dropdown show">
              <a href="#" id="navbarDropdown" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ user_designator(current_user) }}</a>
              <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                {%- if current_user.has_roles(['admin', 'advocate']) and config['ENABLE_MONITOR'] %}
                <a class="dropdown-item" href="{{ url_for('monitor') }}">{{ word('Monitor') }}</a>
                {%- endif %}
                {%- if current_user.has_roles(['admin', 'developer', 'trainer']) %}
                <a class="dropdown-item" href="{{ url_for('train') }}">{{ word('Train') }}</a>
                {%- endif %}
                {%- if current_user.has_roles(['admin', 'developer']) %}
                {%- if config['ALLOW_UPDATES'] %}
                <a class="dropdown-item" href="{{ url_for('update_package') }}">{{ word('Package Management') }}</a>
                {%- endif %}
                <a class="dropdown-item" href="{{ url_for('logs') }}">{{ word('Logs') }}</a>
                {%- if config['ENABLE_PLAYGROUND'] %}
                <a class="dropdown-item" href="{{ url_for('playground_page') }}">{{ word('Playground') }}</a>
                {%- endif %}
                <a class="dropdown-item" href="{{ url_for('utilities') }}">{{ word('Utilities') }}</a>
                  {%- if current_user.has_roles(['admin']) %}
                <a class="dropdown-item" href="{{ url_for('user_list') }}">{{ word('User List') }}</a>
                <a class="dropdown-item" href="{{ url_for('config_page') }}">{{ word('Configuration') }}</a>
                  {%- endif %}
                {%- endif %}
                {%- if config['SHOW_DISPATCH'] %}
                <a class="dropdown-item" href="{{ url_for('interview_start') }}">{{ word('Available Interviews') }}</a>
                {%- endif %}
                {%- for item in config['ADMIN_INTERVIEWS'] %}
                  {%- if item.can_use() %}
                <a class="dropdown-item" href="{{ url_for('index', i=item.interview, new_session='1') }}">{{ item.get_title(current_language) }}</a>
                  {%- endif %}
                {%- endfor %}
                {%- if config['SHOW_MY_INTERVIEWS'] or current_user.has_roles(['admin']) %}
                <a class="dropdown-item" href="{{ url_for('interview_list') }}">{{ word('My Interviews') }}</a>
                {%- endif %}
                {%- if config['SHOW_PROFILE'] or current_user.has_roles(['admin']) %}
                <a class="dropdown-item" href="{{ url_for('user_profile_page') }}">{{ word('Profile') }}</a>
                {%- else %}
                <a class="dropdown-item" href="{{ url_for('user.change_password') }}">{{ word('Change Password') }}</a>
                {%- endif %}
                <a class="dropdown-item" href="{{ url_for('user.logout') }}">{{ word('Sign Out') }}</a>
              </div>
            </li>
            {%- elif request.path != "/login" and request.path != "/user/sign-in" and request.path != "/mfa_login" and request.url_rule != None %}
              {%- if request.path == "/user/forgot-password" or request.path == "/user/register" or request.path == "/user/change-password" or request.path == "/phone_login" or request.path == "/user/google-sign-in" %}
            <li><a class="nav-link" href="{{ url_for('user.login') }}">{{ word('Sign in') }}</a></li>
              {%- else %}
            <li><a class="nav-link" href="{{ url_for('user.login', next=url_for(request.url_rule.endpoint)) }}">{{ word('Sign in') }}</a></li>
              {%- endif %}
            {%- endif %}
          </ul>
        </div>
      </div>
    </nav>
    <div class="{{ config['CONTAINER_CLASS'] }}" id="damain">
    {%- block top %}{% endblock %}
    {%- block flash_messages %}
      {%- with messages = get_flashed_messages(with_categories=true) -%}
        {%- if messages %}
      <div class="datopcenter col-sm-7 col-md-6 col-lg-5 dacol-centered" id="daflash">
          {%- for category, message in messages %}
            {%- if category=='error' %}
              {%- set category='danger' %}
            {%- endif %}
            <div class="alert alert-{{category}}"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>{{ message|safe }}</div>
          {%- endfor %}
      </div>
        {%- endif %}
      {%- endwith %}
    {%- endblock %}
    {%- block main %}{% endblock %}
    {%- block bottom %}{% endblock %}
    </div>
    {%- if footer_content %}
    <footer class="bg-light dafooter">
      <div class="container">
        {{ footer_content }}
      </div>
    </footer>
    {% endif %}

    <script src="{{ url_for('static', filename='app/adminbundle.js', v=config['DA_VERSION']) }}"></script>
    <script>
      var daWhichButton = null;
      $( document ).ready(function(){
        {%- if request.path in ["/user/sign-in", "/user/register", "/user/forgot-password"] %}
        $("#email").focus();
        {%- elif request.path != "/playgroundfiles" %}
        $(".form").find('input[type=text],textarea,select').filter(':visible:first').focus();
        {%- endif %}
        setTimeout(function () {
          window.scrollTo(0, 1);
        }, 10);
        setTimeout(function(){
          $("#flash .alert-success").hide(300, function(){
            $(self).remove();
          });
        }, 3000);
        $(".btn-da").click(function(){
          daWhichButton = this;
        });
        $(".form").on('submit', function(){
          $(this).find(".btn-da").each(function(){
            var the_button = this;
            var disable_button = $(the_button).data('disable-button');
            if (typeof(disable_button) != "undefined" && !disable_button){
              return;
            }
            setTimeout(function(){
              $(the_button).prop("disabled", true);
            }, 1);
            if (this != daWhichButton){
              $(this).removeClass("{{ config['BUTTON_STYLE'] }}primary {{ config['BUTTON_STYLE'] }}info {{ config['BUTTON_STYLE'] }}warning {{ config['BUTTON_STYLE'] }}error {{ config['BUTTON_STYLE'] }}success");
              $(this).addClass("{{ config['BUTTON_STYLE'] }}secondary");
            }
            else{
              $(daWhichButton).removeClass("{{ config['BUTTON_STYLE'] }}primary {{ config['BUTTON_STYLE'] }}info {{ config['BUTTON_STYLE'] }}warning {{ config['BUTTON_STYLE'] }}error {{ config['BUTTON_STYLE'] }}secondary");
              $(daWhichButton).addClass("{{ config['BUTTON_STYLE'] }}success");
            }
          });
        });
      });
    </script>{{ extra_js }}{{ config['GLOBAL_JS']|safe }}
  </body>
</html>
