<hr class="formRowSep" />

<xf:textboxrow name="criteria[title]" value="{$criteria.title}" type="search"
	label="{{ phrase('title') }}" />

<xf:macro id="public:prefix_macros::row"
	arg-includeAny="{{ true }}"
	arg-prefixes="{$prefixes.prefixesGrouped}"
	arg-selected="{$criteria.prefix_id}"
	arg-name="criteria[prefix_id]"
	arg-type="thread"
	arg-multiple="{{ true }}" />

<xf:tokeninputrow name="criteria[tags]" value="{$criteria.tags}"
	href="{{ link_type('public', 'misc/tag-auto-complete') }}"
	label="{{ phrase('tags') }}" />

<div class="formRowSep"></div>

<xf:checkboxrow name="criteria[thread_type]" value="{$criteria.thread_type}" listclass="listColumns"
	label="{{ phrase('thread_type_filter') }}">
	<xf:options source="$threadTypes" />
</xf:checkboxrow>

<div class="formRowSep"></div>

<xf:formrow
	label="{{ phrase('forum') }}">

	<ul class="inputList">
		<li><xf:radio name="criteria[node_id][search_type]"
			value="{{ (is_array($criteria.node_id) ? $criteria.node_id.search_type : '') ?: 'include' }}"
			listclass="inputChoices--inline">
			<xf:option value="include">{{ phrase('include_selected') }}</xf:option>
			<xf:option value="exclude">{{ phrase('exclude_selected') }}</xf:option>
		</xf:radio></li>

		<li><xf:select name="criteria[node_id]"
			value="{{ is_array($criteria.node_id) ? $criteria.node_id|numeric_keys_only : $criteria.node_id }}"
			multiple="true" size="8">
			<xf:option value="0" label="{{ phrase('(any)') }}" />
			<xf:foreach loop="$forums" value="$forum">
				<xf:option value="{$forum.value}" disabled="{$forum.disabled}">{$forum.label}</xf:option>
			</xf:foreach>
		</xf:select></li>
	</ul>
</xf:formrow>

<div class="formRowSep"></div>

<xf:textboxrow name="criteria[username]" value="{$criteria.username}" type="search"
	label="{{ phrase('created_by') }}" />

<xf:checkboxrow name="criteria[starter_user_group_id]" value="{$criteria.starter_user_group_id}" listclass="listColumns"
	label="{{ phrase('thread_creator_in_user_groups') }}">

	<xf:foreach loop="$userGroups" value="$userGroup">
		<xf:option value="{$userGroup.user_group_id}">{$userGroup.title}</xf:option>
	</xf:foreach>
	<xf:explain>{{ phrase('true_if_thread_creator_is_in_one_or_more_of_selected_groups') }}</xf:explain>
</xf:checkboxrow>

<xf:checkboxrow name="criteria[starter_not_user_group_id]" value="{$criteria.starter_not_user_group_id}" listclass="listColumns"
	label="{{ phrase('thread_creator_not_in_user_groups') }}">

	<xf:foreach loop="$userGroups" value="$userGroup">
		<xf:option value="{$userGroup.user_group_id}">{$userGroup.title}</xf:option>
	</xf:foreach>
	<xf:explain>{{ phrase('true_if_thread_creator_is_not_in_any_of_selected_groups') }}</xf:explain>
</xf:checkboxrow>

<hr class="formRowSep" />

<xf:formrow rowtype="input"
	label="{{ phrase('created_between') }}">
	<div class="inputGroup">
		<xf:dateinput name="criteria[post_date][start]" value="{$criteria.post_date.start}" size="15" />
		<span class="inputGroup-text">-</span>
		<xf:dateinput name="criteria[post_date][end]" value="{$criteria.post_date.end}" size="15" />
	</div>
</xf:formrow>

<xf:formrow rowtype="input"
	label="{{ phrase('created_in_last') }}"
	explain="{{ phrase('use_0_to_specify_no_restriction') }}">
	<div class="inputGroup inputGroup--auto">
		<xf:numberbox name="criteria[posted_in_last][value]" value="{$criteria.posted_in_last.value}"
			size="5" min="0" />
		<span class="inputGroup-splitter"></span>
		<xf:select name="criteria[posted_in_last][unit]" value="{$criteria.posted_in_last.unit}">
			<xf:option value="hour">{{ phrase('units_hours') }}</xf:option>
			<xf:option value="day">{{ phrase('units_days') }}</xf:option>
			<xf:option value="week">{{ phrase('units_weeks') }}</xf:option>
			<xf:option value="month">{{ phrase('units_months') }}</xf:option>
			<xf:option value="year">{{ phrase('units_years') }}</xf:option>
		</xf:select>
	</div>
</xf:formrow>

<div class="formRowSep"></div>

<xf:formrow rowtype="input"
	label="{{ phrase('last_post_between') }}">
	<div class="inputGroup">
		<xf:dateinput name="criteria[last_post_date][start]" value="{$criteria.last_post_date.start}" size="15" />
		<span class="inputGroup-text">-</span>
		<xf:dateinput name="criteria[last_post_date][end]" value="{$criteria.last_post_date.end}" size="15" />
	</div>
</xf:formrow>

<xf:formrow rowtype="input"
	label="{{ phrase('last_post_in_last') }}"
	explain="{{ phrase('use_0_to_specify_no_restriction') }}">
	<div class="inputGroup inputGroup--auto">
		<xf:numberbox name="criteria[last_post_in_last][value]" value="{$criteria.last_post_in_last.value}"
			size="5" min="0" />
		<span class="inputGroup-splitter"></span>
		<xf:select name="criteria[last_post_in_last][unit]" value="{$criteria.last_post_in_last.unit}">
			<xf:option value="hour">{{ phrase('units_hours') }}</xf:option>
			<xf:option value="day">{{ phrase('units_days') }}</xf:option>
			<xf:option value="week">{{ phrase('units_weeks') }}</xf:option>
			<xf:option value="month">{{ phrase('units_months') }}</xf:option>
			<xf:option value="year">{{ phrase('units_years') }}</xf:option>
		</xf:select>
	</div>
</xf:formrow>

<hr class="formRowSep" />

<xf:formrow rowtype="input"
	label="{{ phrase('reply_count_between') }}"
	explain="{{ phrase('use_negative_one_specify_no_max') }}">
	<div class="inputGroup">
		<xf:numberbox name="criteria[reply_count][start]" value="{$criteria.reply_count.start}" size="5" min="0" />
		<span class="inputGroup-text">-</span>
		<xf:numberbox name="criteria[reply_count][end]" value="{$criteria.reply_count.end}" size="5" min="-1" />
	</div>
</xf:formrow>

<xf:formrow rowtype="input"
	label="{{ phrase('vote_score_between') }}">
	<div class="inputGroup">
		<xf:numberbox name="criteria[vote_score][start]" value="{$criteria.vote_score.start}" size="5" step="any" />
		<span class="inputGroup-text">-</span>
		<xf:numberbox name="criteria[vote_score][end]" value="{$criteria.vote_score.end}" size="5" step="any" />
	</div>
</xf:formrow>

<xf:formrow rowtype="input"
	label="{{ phrase('first_post_reaction_score_between') }}">
	<div class="inputGroup">
		<xf:numberbox name="criteria[first_post_reaction_score][start]" value="{$criteria.first_post_reaction_score.start}" size="5" step="any" />
		<span class="inputGroup-text">-</span>
		<xf:numberbox name="criteria[first_post_reaction_score][end]" value="{$criteria.first_post_reaction_score.end}" size="5" step="any" />
	</div>
</xf:formrow>

<xf:formrow rowtype="input"
	label="{{ phrase('view_count_between') }}"
	explain="{{ phrase('use_negative_one_specify_no_max') }}">
	<div class="inputGroup">
		<xf:numberbox name="criteria[view_count][start]" value="{$criteria.view_count.start}" size="5" min="0" />
		<span class="inputGroup-text">-</span>
		<xf:numberbox name="criteria[view_count][end]" value="{$criteria.view_count.end}" size="5" min="-1" />
	</div>
</xf:formrow>

<hr class="formRowSep" />

<xf:checkboxrow name="criteria[discussion_state]" value="{$criteria.discussion_state}"
	label="{{ phrase('state') }}">
	<xf:option value="visible">{{ phrase('visible') }}</xf:option>
	<xf:option value="deleted">{{ phrase('deleted') }}</xf:option>
	<xf:option value="moderated">{{ phrase('moderated') }}</xf:option>
</xf:checkboxrow>

<xf:checkboxrow name="criteria[discussion_open]" value="{$criteria.discussion_open}"
	label="{{ phrase('locked') }}">
	<xf:option value="1">{{ phrase('unlocked') }}</xf:option>
	<xf:option value="0">{{ phrase('locked') }}</xf:option>
</xf:checkboxrow>

<xf:checkboxrow name="criteria[sticky]" value="{$criteria.sticky}"
	label="{{ phrase('sticky') }}">
	<xf:option value="0">{{ phrase('not_sticky') }}</xf:option>
	<xf:option value="1">{{ phrase('sticky') }}</xf:option>
</xf:checkboxrow>

<xf:checkboxrow name="criteria[featured]" value="{$criteria.featured}"
	label="{{ phrase('featured') }}">
	<xf:option value="0">{{ phrase('not_featured') }}</xf:option>
	<xf:option value="1">{{ phrase('featured') }}</xf:option>
</xf:checkboxrow>

<xf:if contentcheck="true">
	<hr class="formRowSep" />
	<xf:contentcheck>
		<xf:foreach loop="$xf.app.em.getRepository('XF:ThreadField').getDisplayGroups()" key="$fieldGroup" value="$phrase">
			<xf:set var="$customFields" value="{$xf.app.getCustomFields('threads', $fieldGroup)}" />
			<xf:if contentcheck="true">
				<xf:contentcheck>
					<xf:foreach loop="$customFields" key="$fieldId" value="$fieldDefinition">
						<xf:set var="$choices" value="{$fieldDefinition.field_choices}" />
						<xf:set var="$fieldName" value="criteria[thread_field]{{ ($choices && $fieldDefinition.type_group != 'multiple') ? '[exact]' : '' }}[{$fieldId}]" />
						<xf:formrow rowtype="input"
							label="{$fieldDefinition.title}">
							<xf:if is="!{$choices}">
								<xf:textbox name="{$fieldName}" value="{$criteria.thread_field.{$fieldId}}" />
							<xf:else />
								<xf:checkbox name="{$fieldName}" value="{{ $fieldDefinition.type_group != 'multiple' ? $criteria.thread_field.exact.{$fieldId} : $criteria.thread_field.{$fieldId} }}" listclass="listColumns">
									<xf:foreach loop="$choices" key="$val" value="$choice">
										<xf:option value="{{ $fieldDefinition.type_group == 'multiple' ? 's:' . strlen($val) . ':"' . $val . '"' : $val }}" label="{$choice}" />
									</xf:foreach>
								</xf:checkbox>
							</xf:if>
						</xf:formrow>
					</xf:foreach>
				</xf:contentcheck>
			</xf:if>
		</xf:foreach>
	</xf:contentcheck>
</xf:if>