{#
Copyright 2022 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#}

{% extends "base.html" %}

{% block content %}
  {% set client_name = client.client_name | default(client.client_id) %}
  <section class="flex items-center justify-center flex-1">
    <div class="w-96 mx-2 my-8 flex flex-col gap-6">
      <div class="flex flex-col gap-2 text-center">
        {% if client.logo_uri %}
          <img class="consent-client-icon image" referrerpolicy="no-referrer" src="{{ client.logo_uri }}" />
        {% else %}
          <div class="consent-client-icon generic">
            {{ icon.web_browser() }}
          </div>
        {% endif %}

        <h1 class="cpd-text-primary cpd-text-heading-xl-semibold"><a target="_blank" href="{{ client.client_uri }}">{{ client_name }}</a></h1>
        <p class="cpd-text-secondary cpd-text-body-lg-regular"><span class="whitespace-nowrap">at {{ grant.redirect_uri | simplify_url }}</span> wants to access your account. This will allow <span class="whitespace-nowrap">{{ client_name }}</span> to:</p>
      </div>

      <div class="consent-scope-list">
        {{ scope.list(scopes=grant.scope) }}
      </div>

      <div class="my-2 text-center cpd-text-body-md-regular">
        <span class="font-semibold">Make sure that you trust <span class="whitespace-nowrap">{{ client_name }}</span>.</span>
        You may be sharing sensitive information with this site or app.
        {% if client.policy_uri or client.tos_uri %}
          Find out how {{ client_name }} will handle your data by reviewing its
          {% if client.policy_uri %}
            <a target="_blank" href="{{ client.policy_uri }}" class="cpd-link" data-kind="primary">privacy policy</a>{% if not client.tos_uri %}.{% endif %}
          {% endif %}
          {% if client.policy_uri and client.tos_uri%}
            and
          {% endif %}
          {% if client.tos_uri %}
            <a target="_blank" href="{{ client.tos_uri }}" class="cpd-link" data-kind="primary">terms of service</a>.
          {% endif %}
        {% endif %}
      </div>

      <form method="POST" class="flex flex-col">
        <input type="hidden" name="csrf" value="{{ csrf_token }}" />
        {{ button.button(text=_("action.continue")) }}
      </form>

      {{ back_to_client.link(
        text=_("action.cancel"),
        kind="tertiary",
        uri=grant.redirect_uri,
        mode=grant.response_mode,
        params=dict(error="access_denied", state=grant.state)
      ) }}

      <div class="text-center">
        {{ _("mas.not_you", username=current_session.user.username) }}
        {{ logout.button(text=_("action.sign_out"), csrf_token=csrf_token, post_logout_action=action, as_link=true) }}
      </div>
    </div>
  </section>
{% endblock content %}
