{% extends "packages/package_base.html" %}

{% block title %}
{{ _("Statistics") }} - {{ package.title }}
{% endblock %}

{% from "macros/stats.html" import render_package_stats, render_package_stats_js,
		render_package_selector, render_daterange_selector with context %}

{% block scriptextra %}
	{{ render_package_stats_js() }}
{% endblock %}

{% block content %}
	<div class="float-end">
		<a class="btn btn-secondary me-2" href="{{ package.get_url('packages.stats_csv') }}">
			<i class="fas fa-download me-1"></i>
			{{ _("Download (.csv)") }}
		</a>
		{{ render_daterange_selector(options, start or end) }}
		{{ render_package_selector(package.author, package=package) }}
	</div>
	<h2 class="mt-0">{{ _("Statistics") }}</h2>
	{{ render_package_stats(package.get_url('api.package_stats', start=start, end=end), package.downloads, start or end) }}
{% endblock %}
