{% extends "template.njk" %}
{% set assetPath = "/public/assets/rebrand" %}

{% if not journeyBeginning %}
    <meta name="robots" content="noindex">
{% endif %}

{% from "cookie-banner/macro.njk" import govukCookieBanner %}
{% from "header/macro.njk" import govukHeader %}
{% from "button/macro.njk" import govukButton %}
{% from "back-link/macro.njk" import govukBackLink %}

{% if pageLanguageSetToWelsh %}
    {% set htmlLang = "cy" %}
{% endif %}

{% set govukRebrand = true %}

{% macro csrf() %}
    <div><input type="hidden" name="{{CSRF_TOKEN_NAME}}" value="{{CSRF_TOKEN_VALUE}}"></div>
{% endmacro %}

{% set cbHtml %}
  <p class="govuk-body">{{ mssgs.analytics_banner_preamble_1 }}</p>
  <p class="govuk-body">{{ mssgs.analytics_banner_preamble_2 }}</p>
{% endset %}

{% block head %}
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <link href="/public/stylesheets/main.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="Cache-Control" content="no-store" />
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
{% endblock %}

{% block header %}
  <form action="{{ uri.analyticsFormAction }}" method="POST">
    {{ csrf() }}

    {% if displayAnalytics and not analyticsMessageDisplayed %}
      {% if not analyticsSelected %}
        {{ govukCookieBanner({
          rebrand: true,
          ariaLabel: mssgs.analytics_banner_title,
          messages: [
            {
              headingText: mssgs.analytics_banner_title,
              html: cbHtml,
              actions: [
                {
                  text: mssgs.analytics_banner_accept,
                  type: "submit",
                  name: "analyticsResponse",
                  id: "analytics-accept",
                  value: "accept"
                },
                {
                  text: mssgs.analytics_banner_reject,
                  type: "submit",
                  name: "analyticsResponse",
                  id: "analytics-reject",
                  value: "reject"
                },
                {
                  text: mssgs.analytics_banner_view_cookies_link,
                  href: _uri.cookies,
                  id: "analytics-view"
                }
              ]
            }
          ]
        }) }}
      {% else %}
        {% if acceptedTracking %}
          {% set messageHtml %}
            <p class="govuk-body">
              {{ mssgs.analytics_banner_acceptance_1 }}
              <a class="govuk-link" href="{{ _uri.cookies }}">{{ mssgs.analytics_banner_cookies_link }}</a>
              {{ mssgs.analytics_banner_acceptance_2 }}
            </p>
          {% endset %}
        {% else %}
          {% set messageHtml %}
            <p class="govuk-body">
              {{ mssgs.analytics_banner_rejection_1 }}
              <a class="govuk-link" href="{{ _uri.cookies }}">{{ mssgs.analytics_banner_cookies_link }}</a>
              {{ mssgs.analytics_banner_rejection_2 }}
            </p>
          {% endset %}
        {% endif %}

        {{ govukCookieBanner({
          rebrand: true,
          ariaLabel: mssgs.analytics_banner_title,
          messages: [
            {
              html: messageHtml,
              actions: [
                {
                  text: mssgs.analytics_banner_hide,
                  type: 'submit',
                  name: 'hideMessage',
                  id: 'hide-message',
                  value: "true"
                }
              ]
            }
          ]
        }) }}
      {% endif %}
    {% endif %}

    {{ govukHeader({
      rebrand: true,
      assetsPath: assetPath + '/images',
      homepageUrl: "https://www.gov.uk/",
      serviceUrl: "/",
      classes: "no-print",
      containerClasses: "govuk-width-container",
      serviceName: mssgs.header_service_name if not TELESALES else "Get a rod fishing licence (TELESALES)"
    }) }}
  </form>
{% endblock %}

{% block beforeContent %}
    {% if TELESALES %}
        <div class="govuk-phase-banner">
            <p class="govuk-phase-banner__content">
                <span class="govuk-phase-banner__text no-print">
                    <b>User:</b>&nbsp;&nbsp;{{ credentials.name + ' (' + credentials.email + ')' if credentials else 'Not logged in' }}
                </span>
            </p>
        </div>
        <div class="govuk-width-container govuk-!-display-none-print">
            <p class="govuk-body-s right-align"><a class="govuk-link" class="govuk-link" href="{{ _uri.clear }}">New customer</a></p>
        </div>
    {% else %}
        <div class="govuk-phase-banner">
            <p class="govuk-phase-banner__content">
                <span class="govuk-phase-banner__text no-print">
                    {{ mssgs.feedback_link_prefix }} <a class="govuk-link" href="{{ _uri.feedback }}" rel="noreferrer noopener" target="_blank" >{{ mssgs.feedback_link_text }}</a> {{ mssgs.feedback_link_suffix }}
                </span>
            </p>
        </div>
        {% if SHOW_WELSH_CONTENT %}
            <div class="govuk-width-container govuk-!-display-none-print govuk-!-margin-top-2">
                <p class="govuk-body-s right-align govuk-!-margin-0">
                    {% if _uri.queryParams.lang == 'cy' %}
                        <a class="govuk-link govuk-!-margin-2" href="?lang=en" hreflang="en" lang="en">English</a> | <span class="govuk-body-s govuk-!-margin-2">Cymraeg</span>
                    {% else %}
                        <span class="govuk-body-s govuk-!-margin-2">English</span> | <a class="govuk-link govuk-!-margin-2" href="?lang=cy" hreflang="cy" lang="cy" rel="alternate">Cymraeg</a>
                    {% endif%}
                </p>
            </div>
        {% endif%}
    {% endif %}
    {% if backRef %}
      {{ govukBackLink({
        text: mssgs.back,
        href: backRef,
        classes: "govuk-!-margin-bottom-7"
      }) }}
    {% elseif uri.back %}
      {{ govukBackLink({
        text: mssgs.back,
        href: uri.back,
        classes: "govuk-!-margin-bottom-7"
      }) }}
   {% endif %}
{% endblock %}

{% block bodyStart %}
{% if approvedGTM %}
    <script type="text/javascript" nonce="{{nonce}}">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','{{gtmContainerId}}');</script>
    <!-- Google Tag Manager (noscript) -->
    <noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{gtmContainerId}}" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    <!-- End Google Tag Manager (noscript) -->
{% endif %}
{% endblock %}

{% block footer %}
    <footer class="govuk-footer">
    <div class="govuk-width-container">
        <div class="govuk-footer__meta">
            <div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
                {% if (title === mssgs.address_lookup_title_you) or (title === mssgs.address_lookup_title_other) %}
                    <p class="govuk-body-s">{{ mssgs.address_lookup_crown_copyright }}<a class="govuk-link" href="http://www.ordnancesurvey.co.uk" rel="noreferrer noopener" target="_blank">{{ mssgs.address_lookup_crown_copyright_new_tab }}</a> {{ mssgs.address_lookup_crown_copyright_ref }}
                    <br>{{ mssgs.address_lookup_crown_copyright_terms }} <a class="govuk-link" href="{{ data.uri.osTerms }}">{{ mssgs.address_lookup_crown_copyright_terms_link }}</a></p>
                {% endif %}
                <p class="govuk-!-margin-top-5 govuk-!-margin-bottom-0">{{ mssgs.footer_ea_helpline }} <a class="govuk-link" href="tel:+443448005386">0344 800 5386</a></p>
                <p class="govuk-!-margin-top-0">{{ mssgs.footer_ea_helpline_opening_hours }}</p>
                <p class="govuk-!-margin-top-0"><a class="govuk-link" href="https://www.gov.uk/call-charges">{{ mssgs.footer_ea_helpline_charges_link }}</a></p>
                <ul class="govuk-footer__inline-list">
                    <li class="govuk-footer__inline-list-item">
                        <a class="govuk-link" href="{{ _uri.refunds }}">
                            {{ mssgs.footer_refund_policy }}
                        </a>
                    </li>
                    <li class="govuk-footer__inline-list-item">
                        <a class="govuk-link" href="{{ _uri.privacy }}">
                            {{ mssgs.footer_privacy_policy }}
                        </a>
                    </li>
                    <li class="govuk-footer__inline-list-item">
                        <a class="govuk-link" href="{{ _uri.accessibility }}">
                            {{ mssgs.footer_accessibility }}
                        </a>
                    </li>
                    <li class="govuk-footer__inline-list-item">
                        <a class="govuk-link" href="{{ _uri.cookies }}">
                            {{ mssgs.footer_cookies }}
                        </a>
                    </li>
                </ul>
                <svg
                aria-hidden="true"
                focusable="false"
                class="govuk-footer__licence-logo"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 483.2 195.7"
                height="17"
                width="41">
                <path
                    fill="currentColor"
                    d="M421.5 142.8V.1l-50.7 32.3v161.1h112.4v-50.7zm-122.3-9.6A47.12 47.12 0 0 1 221 97.8c0-26 21.1-47.1 47.1-47.1 16.7 0 31.4 8.7 39.7 21.8l42.7-27.2A97.63 97.63 0 0 0 268.1 0c-36.5 0-68.3 20.1-85.1 49.7A98 98 0 0 0 97.8 0C43.9 0 0 43.9 0 97.8s43.9 97.8 97.8 97.8c36.5 0 68.3-20.1 85.1-49.7a97.76 97.76 0 0 0 149.6 25.4l19.4 22.2h3v-87.8h-80l24.3 27.5zM97.8 145c-26 0-47.1-21.1-47.1-47.1s21.1-47.1 47.1-47.1 47.2 21 47.2 47S123.8 145 97.8 145" />
                </svg>
                <span class="govuk-footer__licence-description">
                {{ mssgs.footer_licence_1 }}
                <a
                    class="govuk-footer__link"
                    href="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/"
                    rel="license">{{ mssgs.footer_licence_link }}</a>{{ mssgs.footer_licence_2 }}
                </span>
            </div>
            <div class="govuk-footer__meta-item">
                <a
                class="govuk-footer__link govuk-footer__copyright-logo"
                href="https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/">
                {{ mssgs.footer_copyright }}
                </a>
            </div>
        </div>
    </div>
    </footer>
{% endblock %}

{% block bodyEnd %}
    <script type="module" src="/public/javascript/govuk-frontend-min.js"></script>
    <script nonce="{{nonce}}" type="module">
        import { initAll } from '/public/javascript/govuk-frontend-min.js'
        initAll()
    </script>
{% endblock %}
