<!DOCTYPE html>
<html lang="{% if pwic.env.language %}{{pwic.env.language.value|escape}}{% else %}{{pwic.language|escape}}{% endif %}"
	dir="{% if pwic.env.language and (pwic.env.language.value in pwic.constants.rtl) %}rtl{% else %}ltr{% endif %}">
<head>
	<!-- General headers -->
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="generator" content="Pwic.wiki version {{pwic.constants.version|escape}}">
	{% if pwic.env.robots %}
		<meta name="robots" content="{{pwic.env.robots.value|replace(' ',', ')|escape}}">
	{% endif %}
	<meta charset="utf-8">
	<meta name="description" content="{{(pwic.description or gettext('No description'))|escape}}">
	{% if pwic.keywords %}
		<meta name="keywords" content="{{pwic.keywords|escape}}">
	{% endif %}
	<title>{% block title %}{{pwic.title|escape}}{% endblock %}{% if pwic.env.title %} - {{pwic.env.title.value|escape}}{% endif %}</title>
	{% if pwic.canonical %}
		<link rel="canonical" href="{{pwic.canonical|escape}}">
	{% endif %}
	<link rel="icon" type="image/png" href="/static/favicon.png">
	{% if pwic.project and (pwic.project not in pwic.constants.not_project) %}
		{% if not pwic.env.no_sitemap %}
			<link rel="sitemap" type="application/xml" href="/{{pwic.project|urlencode}}/special/sitemap">
		{% endif  %}
		{% if not pwic.env.no_search %}
			<link rel="search" type="application/opensearchdescription+xml" href="/{{pwic.project|urlencode}}/special/searchlink" title="{{ gettext('Search in project %(project)s')|format(project=pwic.project|escape) }}">
		{% endif  %}
		{% if pwic.env.manifest %}
			<link rel="manifest" href="/{{pwic.project|urlencode}}/special/manifest">
		{% endif  %}
		{% if not pwic.env.no_feed and (not pwic.pure_reader or not pwic.env.no_history) %}
			<link rel="alternate" type="application/atom+xml" href="/{{pwic.project|urlencode}}/special/feed/atom" title="{{ gettext('Recent changes for %(project)s (%(format)s)')|format(project=pwic.project|escape, format='ATOM') }}">
			<link rel="alternate" type="application/rss+xml" href="/{{pwic.project|urlencode}}/special/feed/rss" title="{{ gettext('Recent changes for %(project)s (%(format)s)')|format(project=pwic.project|escape, format='RSS') }}">
		{% endif  %}
	{% endif %}

	<!-- Styles -->
	<link rel="stylesheet" type="text/css" href="/static/styles.css" media="all">
	{% if pwic.env.css %}
		{% set list = pwic.env.css.value.split(';') %}
		{% for css in list %}
			<link rel="stylesheet" type="text/css" href="{{css|trim|urlencode}}" media="all">
		{% endfor %}
	{% endif %}

	{% if pwic.env.dark_theme %}
		<link rel="stylesheet" type="text/css" href="/static/styles_dark.css" media="screen">
		{% if pwic.env.css_dark %}
			{% set list = pwic.env.css_dark.value.split(';') %}
			{% for css in list %}
				<link rel="stylesheet" type="text/css" href="{{css|trim|urlencode}}" media="screen">
			{% endfor %}
		{% endif %}
	{% endif %}

	<link rel="stylesheet" type="text/css" href="/static/styles-print.css" media="print">
	{% if pwic.env.css_printing %}
		{% set list = pwic.env.css_printing.value.split(';') %}
		{% for css in list %}
			<link rel="stylesheet" type="text/css" href="{{css|trim|urlencode}}" media="print">
		{% endfor %}
	{% endif %}

	{% if pwic.env.no_printing %}
		<style media="print">
			BODY { display: none }
		</style>
	{% endif %}

	<!-- Scripts -->
	<script src="/static/cash.min.js"></script>
	{% block header_scripts %}{% endblock %}

	<script>
		'use strict';

		function pwic_entities(value) {
			return value.replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;');
		}

		function pwic_is_safe(name) {
			if (name == '')
				return false;
			var chars = '{{pwic.constants.unsafe_chars|replace("\\", "\\\\")|replace("'", "\\'")}}';
			for (var i=0 ; i<chars.length ; i++)
				if (name.indexOf(chars[i]) !== -1)
					return false;
			return true;
		}

		function pwic_kick(value, chars) {
			while (true) {
				var curlen = value.length;
				for (var i=0 ; i<chars.length ; i++)
					value = value.replaceAll(chars[i], '');
				if (value.length == curlen)
					break;
			}
			return value;
		}

		function pwic_slash(value) {
			{# sof/18251399 #}
			return value.split("'").join("\\'").split('"').join('\\"');
		}

		function pwic_unimoji(value) {
			return value.replace(/&#x([0-9a-f]+);/gi, (match, v) => {
				return String.fromCodePoint(parseInt(v, 16));
			});
		}

		function pwic_url_status(success, failed) {
			var url = window.location.toString();
			if ((url.indexOf('?success') !== -1) || (url.indexOf('&success') !== -1))
				alert(success);
			else
				if ((url.indexOf('?failed') !== -1) || (url.indexOf('&failed') !== -1))
					alert(failed);
		}
	</script>
</head>
<body id="top">
	{% block content %}{% endblock %}

	{% include 'html/footer.html' %}

	<script>
		'use strict';

		{% if not pwic.env.no_sort_table %}
			function pwic_table_sort(that, column) {
				function _get_sort_key(obj) {
					var v, list = $(obj).find('INPUT[type=checkbox]');
					if (list.length > 0)
						return (!list.prop('checked')).toString();
					v = (obj.dataset.sort || obj.innerText).trim();
					if (v == '')
						return '';
					if (/^-?\d+( *%)?$/.test(v))
						return parseInt(v.replace('%', '').trim());
					v = v.replaceAll(',', '.');
					if ((/^-?\d+(\.\d*)?(e-?\d+)?$/.test(v)) || (/^-?\.\d+(e-?\d+)?$/.test(v)))
						return parseFloat(v);
					return v.trim().toLowerCase();
				}

				var e = $(that),
					table = e.parents('TABLE')[0],
					i, j, op, data, src;

				// Sort order
				op = parseInt(e.data('sort') || '1');
				e.data('sort', -op);

				// Cache and sort the data
				data = [];
				for (i=1 ; i<table.rows.length ; i++)
					data.push([i, _get_sort_key($(table.rows[i]).find('TD')[column])]);
				data.sort(function(a, b) {
							if (a[1] == b[1])
								return 0;
							return (a[1] < b[1] ? -1 : 1) * op;
						});

				// Update DOM
				for (i=0 ; i<data.length ; i++) {
					src = data[i][0];
					if (src != i + 1) {
						table.rows[src].parentNode.insertBefore(table.rows[src], table.rows[i+1]);
						for (j=0; j<data.length; j++)
							if (data[j][0] < src)
								data[j][0]++;
					}
				}
			}

			$('TABLE').each(function(i, e) {
				$(e).find('TR TH').each(function(i, e) {
					e.innerHTML = '<span class="pwic_cursor" title="{% trans %}Sort{% endtrans %}" onclick="pwic_table_sort(this, '+i+')">' + (e.innerHTML||'...') + '<\/span>';
				});
			});
		{% endif %}

		{% if pwic.env.link_new_tab %}
			$('A[href^="http"]').attr('target','_blank');
		{% endif %}
	</script>
</body>
</html>