{#
/**
 * @file
 * Theme override to display a single page.
 *
 * The doctype, html, head and body tags are not in this template. Instead they
 * can be found in the html.html.twig template in this directory.
 *
 * Available variables:
 *
 * General utility variables:
 * - base_path: The base URL path of the Drupal installation. Will usually be
 *   "/" unless you have installed Drupal in a sub-directory.
 * - is_front: A flag indicating if the current page is the front page.
 * - logged_in: A flag indicating if the user is registered and signed in.
 * - is_admin: A flag indicating if the user has permission to access
 *   administration pages.
 *
 * Site identity:
 * - front_page: The URL of the front page. Use this instead of base_path when
 *   linking to the front page. This includes the language domain or prefix.
 *
 * Page content (in order of occurrence in the default page.html.twig):
 * - messages: Status and error messages. Should be displayed prominently.
 * - node: Fully loaded node, if there is an automatically-loaded node
 *   associated with the page and the node ID is the second argument in the
 *   page's path (e.g. node/12345 and node/12345/revisions, but not
 *   comment/reply/12345).
 *
 * Regions:
 * - page.government_banner: USWDS Display Government site banner
 * - page.header_top: Items for above the header region.
 * - page.header: Items for the header region.
 * - page.primary_menu: Items for the primary menu region.
 * - page.secondary_menu: Items for the secondary menu region.
 * - page.breadcrumb: Items for the breadcrumb region.
 * - page.hero: USWDS Hero Banner
 * - page.highlighted: Items for the highlighted content region.
 * - page.help: Dynamic help text, mostly for admin pages.
 * - page.content: The main content of the current page.
 * - page.sidebar_first: Items for the first sidebar.
 * - page.sidebar_second: Items for the second sidebar.
 * - page.footer_primary: Items for the footer region.
 * - page.footer_bottom: Items for below the footer secondary region.
 *
 * @see template_preprocess_page()
 * @see html.html.twig
 */
#}

{% if government_banner %}
  {% block government_banner %}
    {{ include('ui_suite_uswds:banner', {
      icon_path: uswds_images,
      mil: false
    }, with_context = false) }}
  {% endblock %}
{% endif %}

<div class="usa-overlay"></div>

{% block header %}

  {% if search_url_action is null %}
    {% set search_pattern = null %}
  {% else %}
    {% set search_pattern = include('ui_suite_uswds:search', {
        variant: 'small',
        attributes: attributes.setAttribute('action', search_url_action),
        search_icon: uswds_images ~ 'usa-icons-bg/search--white.svg',
        search_id: 'extended-search-field-small',
        name: search_name ?: 'keys'
      }, with_context = false) %}
  {% endif %}

  {{ include('ui_suite_uswds:header', {
    top: page.header_top,
    nav: include('ui_suite_uswds:nav', {
      search: search_pattern,
      is_slim: header_style == 'basic' ? true : false,
      close_icon: uswds_images ~ 'usa-icons/close.svg',
      primary: primary_menu,
      secondary: secondary_menu,
      use_megamenu: use_megamenu
    }, with_context = false),
    variant: header_style,
    attributes: use_megamenu ? create_attribute({'class': [header_style ~ '-megamenu']}) : attributes,
  }, with_context = false) }}

{% endblock %}

{% if page.hero %}
  {% block hero %}
    {{ page.hero }}
  {% endblock %}
{% endif %}

{% block main %}
  <main class="main-content usa-layout-docs {{ main_classes }}" role="main" id="main-content">

    <div class="grid-container">
      {% if page.breadcrumb %}
        {{ include('ui_suite_uswds:grid_row', {
          first: page.breadcrumb
        }, with_context = false) }}
      {% endif %}

      {% if page.breadcrumb %}
        {{ include('ui_suite_uswds:grid_row', {
          first: page.highlighted
        }, with_context = false) }}
      {% endif %}

      {% if page.breadcrumb %}
        {{ include('ui_suite_uswds:grid_row', {
          first: page.help
        }, with_context = false) }}
      {% endif %}

      {% if page.sidebar_first and page.sidebar_second %}
        {{ include('ui_suite_uswds:grid_row_3', {
          first: page.sidebar_first,
          second: page.content,
          third: page.sidebar_second,
          first_column_attributes: create_attribute({
            'class': [
              'usa-layout-docs__sidenav',
              'layout-sidebar-first',
            ]
          }),
          second_column_attributes: create_attribute({
            'class': [
              'usa-layout-docs__main',
            ]
          }),
          third_column_attributes: create_attribute({
            'class': [
              'usa-layout-docs__sidenav',
              'layout-sidebar-second'
            ]
          }),
          gutters: 'grid-gap',
          desktop: [3, 6, 3]
        }, with_context = false) }}
      {% elseif page.sidebar_first and not page.sidebar_second %}
        {{ include('ui_suite_uswds:grid_row_2', {
          first: page.sidebar_first,
          second: page.content,
          first_column_attributes: create_attribute({
            'class': [
              'usa-layout-docs__sidenav',
              'layout-sidebar-first',
            ]
          }),
          second_column_attributes: create_attribute({
            'class': [
              'usa-layout-docs__main',
            ]
          }),
          gutters: 'grid-gap',
          desktop: [3, 9]
        }, with_context = false) }}
      {% elseif not page.sidebar_first and page.sidebar_second %}
        {{ include('ui_suite_uswds:grid_row_2', {
          first: page.content,
          second: page.sidebar_second,
          first_column_attributes: create_attribute({
            'class': [
              'usa-layout-docs__main',
            ]
          }),
          second_column_attributes: create_attribute({
            'class': [
              'usa-layout-docs__sidenav',
              'layout-sidebar-second'
            ]
          }),
          gutters: 'grid-gap',
          desktop: [9, 3]
        }, with_context = false) }}
      {% else %}
        {{ include('ui_suite_uswds:grid_row', {
          first: page.content,
          first_column_attributes: create_attribute({
            'class': [
              'usa-layout-docs__main',
            ]
          }),
          gutters: 'grid-gap',
          desktop: ['fill']
        }, with_context = false) }}
      {% endif %}
    </div>
  </main>
{% endblock %}

{% block footer %}

  {% if footer_menu is null %}
    {% set nav_footer_pattern = null %}
  {% else %}
    {% set nav_footer_pattern = include('ui_suite_uswds:nav_footer', {
      footer: footer_menu,
      first_level_only: footer_style == 'big' ? FALSE : TRUE,
    }, with_context = false) %}
  {% endif %}

  {% if sign_up_block_url is not null %}
    {% set sign_up_block = include('ui_suite_uswds:sign_up_block', {
      heading: sign_up_block_header,
      label: sign_up_block_label,
      button_label: sign_up_block_button_label,
      form_url: sign_up_block_url
    }, with_context = false) %}
  {% endif %}

  {{ include('ui_suite_uswds:footer', {
    nav_footer: nav_footer_pattern,
    sign_up_block: sign_up_block,
    footer_bottom: page.footer_bottom,
    footer_contact_region: include('ui_suite_uswds:footer_contact_region', {
      is_slim: footer_style == 'slim' ? true : false,
      social_links: footer_social_links,
      agency_contact_center: contact_center,
      agency_email: email,
      agency_phone: phone,
    }, with_context = false),
    variant: footer_style,
    attributes: create_attribute({}),
    back_to_top: back_to_top,
    back_to_top_text: back_to_top_text,
    agency_name: footer_agency_name,
    agency_url: footer_agency_url,
    agency_logo: footer_agency_logo,
  }, with_context = false) }}
{% endblock %}
