<%= if assigns[:flash] do %>
  <%= render("_flash.html", assigns) %>
<% end %>


<%= if Plausible.Auth.GracePeriod.active?(@conn.assigns[:current_user]) do %>
  <div class="container">
    <div class="rounded-md bg-yellow-100 p-4">
      <div class="flex">
        <div class="flex-shrink-0">
          <svg class="h-5 w-5 text-yellow-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
            <path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd" />
          </svg>
        </div>
        <div class="ml-3">
          <h3 class="text-sm font-medium text-yellow-800">
            <%= if Plausible.Auth.enterprise?(@conn.assigns[:current_user]) do %>
              You have outgrown your Plausible subscription tier
            <% else %>
              Please upgrade your account
            <% end %>
          </h3>
          <div class="mt-2 text-sm text-yellow-700">
            <p>
            <%= if Plausible.Auth.enterprise?(@conn.assigns[:current_user]) do %>
              In order to keep your stats running, we require you to upgrade
              your account to accommodate your new usage levels. Please contact
              us to discuss a new custom enterprise plan.
              <%= link("Contact us →", to: "mailto:enterprise@plausible.io", class: "text-sm font-medium text-yellow-800") %>
            <% else %>
              In order to keep your stats running, we require you to upgrade
              your account. If you do not upgrade your account
              <%= grace_period_end(@conn.assigns[:current_user]) %>, we will
              lock your stats and they won't be accessible.
              <%= link("Upgrade now →", to: "/settings", class: "text-sm font-medium text-yellow-800") %>
            <% end %>
            </p>
          </div>
        </div>
      </div>
    </div>
  </div>
<% end %>

<%= if Plausible.Auth.GracePeriod.expired?(@conn.assigns[:current_user]) do %>
  <div class="container">
    <div class="rounded-md bg-yellow-100 p-4">
      <div class="flex">
        <div class="flex-shrink-0">
          <svg class="h-5 w-5 text-yellow-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
            <path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd" />
          </svg>
        </div>
        <div class="ml-3">
          <h3 class="text-sm font-medium text-yellow-800">
            Dashboard locked
          </h3>
          <div class="mt-2 text-sm text-yellow-700">
            <p>
            As you have outgrown your subscription tier, we kindly ask you to
            upgrade your subscription to accommodate your new traffic levels.
            <%= link("Upgrade now →", to: "/settings", class: "text-sm font-medium text-yellow-800") %>
            </p>
          </div>
        </div>
      </div>
    </div>
  </div>
<% end %>

<%= if @conn.assigns[:current_user] && @conn.assigns[:current_user].subscription && @conn.assigns[:current_user].subscription.status == "past_due" do %>
  <aside class="container">
    <div class="rounded-lg bg-yellow-100 p-4">
      <div class="flex">
        <div class="flex-shrink-0">
          <svg class="w-5 h-5 mt-0.5 text-yellow-800" viewBox="0 0 24 24" stroke="currentColor" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
            <path d="M12 9V11M12 15H12.01M5.07183 19H18.9282C20.4678 19 21.4301 17.3333 20.6603 16L13.7321 4C12.9623 2.66667 11.0378 2.66667 10.268 4L3.33978 16C2.56998 17.3333 3.53223 19 5.07183 19Z" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
          </svg>
        </div>
        <div class="ml-3 flex-1 md:flex md:justify-between">
          <p class="text-yellow-700">There was a problem with your latest payment. Please update your payment information to keep using Plausible.</p>
          <%= link to: @conn.assigns.current_user.subscription.update_url, class: "whitespace-nowrap font-medium text-yellow-700 hover:text-yellow-600" do %>
            Update billing info
            <span aria-hidden="true"> &rarr;</span>
          <% end %>
        </div>
      </div>
    </div>
  </aside>
<% end %>

<%= if @conn.assigns[:current_user] && @conn.assigns[:current_user].subscription && @conn.assigns[:current_user].subscription.status == "paused" do %>
  <aside class="container">
    <div class="rounded-lg bg-red-100 p-4">
      <div class="flex">
        <div class="flex-shrink-0">
          <svg class="w-5 h-5 mt-0.5 text-red-800" viewBox="0 0 24 24" stroke="currentColor" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
            <path d="M12 9V11M12 15H12.01M5.07183 19H18.9282C20.4678 19 21.4301 17.3333 20.6603 16L13.7321 4C12.9623 2.66667 11.0378 2.66667 10.268 4L3.33978 16C2.56998 17.3333 3.53223 19 5.07183 19Z" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
          </svg>
        </div>
        <div class="ml-3 flex-1 md:flex md:justify-between">
          <p class="text-red-700">Your subscription is paused due to failed payments. Please provide valid payment details to keep using Plausible.</p>
          <%= link to: @conn.assigns.current_user.subscription.update_url, class: "whitespace-nowrap font-medium text-red-700 hover:text-red-600" do %>
            Update billing info
            <span aria-hidden="true"> &rarr;</span>
          <% end %>
        </div>
      </div>
    </div>
  </aside>
<% end %>
