#requireResource("com.atlassian.auiplugin:aui-select2")
#set ($canEditLabels = $apply-space-category && $searchCore.canAdministerSpace($space.key) || !$apply-space-category && $searchCore.canEdit($page))
#foreach ($filterGroup in $filter-groups)
#set ($filters = $filterGroup.filtersWithSubcategories)
#set ($selected = false)
#foreach ($filter in $filters)
#if ($apply-space-category && $searchCore.hasCategory($space.key, $filter.label) || !$apply-space-category && $searchCore.hasLabel($page, $filter.label))
#set ($selected = $filter)
#end
#end
## Only display the filter group if a label in the filter group is applied to the page, or the user can edit labels
#if ($canEditLabels || $selected)
#if ($title-override)$title-override#else$filterGroup.displayName#end#if ($canEditLabels)#end
#if ($canEditLabels)
#elseif (!$selected)
$searchCore.text("com.brikit.targetedsearch.no.labels.selected")
#end
#if ($selected)
#set ($skipLink = $apply-space-category || $disable-search-link)
#foreach ($filter in $filters)
#if ($apply-space-category && $searchCore.hasCategory($space.key, $filter.label) || !$apply-space-category && $searchCore.hasLabel($page, $filter.label))
#if (!$skipLink)
#end$filter.displayName#if (!$skipLink)#end
#end
#end
#end
#end
#end