<xf:title>{{ phrase('cookie_consent_heading') }}</xf:title>

<xf:head option="robots"><meta name="robots" content="noindex" /></xf:head>

<xf:if is="$unconsentedGroups || $unconsentedThirdParties">
	<xf:form action="{{ link('misc/cookies', null, {'update': true, 'add': true}) }}" class="block"
		ajax="true" data-force-flash-message="true"
		data-xf-init="cookie-consent-form">

		<div class="block-container">
			<div class="block-body">
				<xf:inforow>
					{{ phrase('to_access_this_page_we_will_need_your_consent_to_set_some_cookies') }}
				</xf:inforow>

				<xf:formrow rowtype="fullWidth">
					<xf:if is="$unconsentedGroups">
						<xf:foreach loop="$unconsented" value="$group">
							<dl class="pairs">
								<dt>{{ $xf.cookieConsent.getGroupLabel($group) }}</dt>
								<dd>{{ $xf.cookieConsent.getGroupDescription($group) }}</dd>
							</dl>

							<xf:hiddenval name="consent[{$group}]">1</xf:hiddenval>
						</xf:foreach>
					</xf:if>

					<xf:if is="$unconsentedThirdParties">
						<dl class="pairs">
							<dt>{{ $xf.cookieConsent.getGroupLabel('_third_party') }}</dt>
							<dd>{{ $xf.cookieConsent.getGroupDescription('_third_party') }}</dd>
						</dl>

						<xf:hiddenval name="consent[_third_party]">1</xf:hiddenval>
					</xf:if>
				</xf:formrow>
			</div>

			<xf:redirect url="{$redirect}" />

			<xf:submitrow submit="{{ phrase('accept_third_party_cookies') }}" rowtype="simple" />
		</div>
	</xf:form>
<xf:else />
	<div class="block">
		<div class="block-container">
			<div class="block-body block-row">
				<xf:macro name="cookie_consent_form" />
			</div>
		</div>
	</div>
</xf:if>

<xf:macro name="cookie_consent_form">

		<div class="cookies-main">
			<h2>{{ phrase('cookie_consent_heading') }}</h2>
			<p>{{ phrase('cookie_consent_description', {'link':link('help/cookies')}) }}</p>
			<p><a href="#" data-xf-click="toggle" data-target="#cookieConsentConfig">{{ phrase('cookie_consent_configure') }}</a></p>
		</div>

		<div class="cookies-buttons u-inputSpacer _u-alignCenter">
			<xf:button href="{{ link('misc/cookies', null, {'update': true, 'accept': true, 't': csrf_token()}) }}"
				rel="nofollow"
				class="button--notice button--primary"
				data-xf-click="cookie-consent"
				xicon="confirm">

				{{ phrase('accept_all_cookies') }}
			</xf:button>

			<xf:button href="{{ link('misc/cookies', null, {'update': true, 'reject': true, 't': csrf_token()}) }}"
				rel="nofollow"
				class="button--link"
				data-xf-click="cookie-consent"
				xicon="cancel">

				{{ phrase('reject_optional_cookies') }}
			</xf:button>
		</div>

	<xf:form action="{{ link('misc/cookies', null, {'update': true}) }}"
		ajax="true" data-force-flash-message="true"
		data-xf-init="cookie-consent-form"
		id="cookieConsentConfig">

		<div class="cookies-options">

			<xf:checkboxrow rowtype="fullWidth"
				explain="{{ $xf.cookieConsent.getGroupDescription('_required') }}">

				<xf:option selected="{{ true }}" disabled="{{ true }}"
					labelclass="iconic--toggle"
					label="{{ $xf.cookieConsent.getGroupLabel('_required') }}" />
			</xf:checkboxrow>

			<xf:foreach loop="$xf.cookieConsent.getGroups(false, false)" value="$group">
				<xf:checkboxrow rowtype="fullWidth"
					explain="{{ $xf.cookieConsent.getGroupDescription($group) }}">

					<xf:option name="consent[{$group}]" selected="{{ $xf.cookieConsent.isGroupConsented($group)}}"
						class="js-consent_{$group}"
						labelclass="iconic--toggle"
						label="{{ $xf.cookieConsent.getGroupLabel($group) }}" />
				</xf:checkboxrow>
			</xf:foreach>

			<xf:checkboxrow rowtype="fullWidth"
				explain="{{ $xf.cookieConsent.getGroupDescription('_third_party') }}">

				<xf:option name="consent[_third_party]" selected="{{ $xf.cookieConsent.isGroupConsented('_third_party') }}"
					class="js-consent__third_party"
					labelclass="iconic--toggle"
					label="{{ $xf.cookieConsent.getGroupLabel('_third_party') }}" />
			</xf:checkboxrow>

			<xf:formrow rowtype="fullWidth">
				<ul class="listInline listInline--bullet">
					<li><a href="{{ link('help/cookies') }}">{{ phrase('detailed_cookie_usage') }}</a></li>
					<xf:if is="$xf.privacyPolicyUrl">
						<li><a href="{$xf.privacyPolicyUrl}">{{ phrase('privacy_policy') }}</a></li>
					</xf:if>
				</ul>
			</xf:formrow>

		</div>

		<xf:button type="submit" class="button--notice">{{ phrase('save_cookie_preferences') }}</xf:button>
	</xf:form>

</xf:macro>

<xf:macro name="third_party_consent_form"
	arg-unconsented="{{ [] }}"
	arg-embedHtml=""
	arg-siteId=""
	arg-id="">

	<xf:form action="{{ link('misc/cookies', null, {'update': true, 'add': true}) }}" class="bbMediaJustifier"
		ajax="true" data-redirect="off"
		data-media-site-id="{$siteId}" data-media-key="{$id}"
		data-xf-init="cookie-consent-form">

		<div class="block-rowMessage block-rowMessage--alt">
			<div class="u-dimmed u-smaller">
				{{ phrase('to_view_this_content_we_will_need_your_consent_to_set_third_party_cookies', {
					'cookies_link': link('help/cookies')
				}) }}
			</div>
			<div class="u-inputSpacer">
				<xf:button type="submit" class="button--small">{{ phrase('accept_third_party_cookies') }}</xf:button>
			</div>

			<xf:hiddenval name="consent[_third_party]">1</xf:hiddenval>
			<xf:hiddenval name="_xfRedirect">{$redirect}</xf:hiddenval>
		</div>

		<xf:if is="$embedHtml">
			<template class="js-embedHtml">{$embedHtml|raw}</template>
		</xf:if>
	</xf:form>
</xf:macro>