'use strict'

function applyFocusVisiblePolyfill(scope) {
	let hadKeyboardEvent = true
	let hadFocusVisibleRecently = false
	let hadFocusVisibleRecentlyTimeout = null
	const inputTypesAllowlist = {
		'text': true,
		'search': true,
		'url': true,
		'tel': true,
		'email': true,
		'password': true,
		'number': true,
		'date': true,
		'month': true,
		'week': true,
		'time': true,
		'datetime': true,
		'datetime-local': true,
	}

	function isValidFocusTarget(el) {
		if (el && el !== document && el.nodeName !== 'HTML' && el.nodeName !== 'BODY' && 'classList' in el && 'contains' in el.classList) {
			return true
		}

		return false
	}

	function focusTriggersKeyboardModality(el) {
		const type = el.type
		const tagName = el.tagName

		if (tagName === 'INPUT' && inputTypesAllowlist[type] && !el.readOnly) {
			return true
		}

		if (tagName === 'TEXTAREA' && !el.readOnly) {
			return true
		}

		if (el.isContentEditable) {
			return true
		}

		return false
	}

	function addFocusVisibleClass(el) {
		if (el.classList.contains('focus-visible')) {
			return
		}

		el.classList.add('focus-visible')
		el.setAttribute('data-focus-visible-added', '')
	}

	function removeFocusVisibleClass(el) {
		if (!el.hasAttribute('data-focus-visible-added')) {
			return
		}

		el.classList.remove('focus-visible')
		el.removeAttribute('data-focus-visible-added')
	}

	function onKeyDown(e) {
		if (e.metaKey || e.altKey || e.ctrlKey) {
			return
		}

		if (isValidFocusTarget(scope.activeElement)) {
			addFocusVisibleClass(scope.activeElement)
		}

		hadKeyboardEvent = true
	}

	function onPointerDown() {
		hadKeyboardEvent = false
	}

	function onFocus(e) {
		if (!isValidFocusTarget(e.target)) {
			return
		}

		if (hadKeyboardEvent || focusTriggersKeyboardModality(e.target)) {
			addFocusVisibleClass(e.target)
		}
	}

	function onBlur(e) {
		if (!isValidFocusTarget(e.target)) {
			return
		}

		if (e.target.classList.contains('focus-visible') || e.target.hasAttribute('data-focus-visible-added')) {
			hadFocusVisibleRecently = true
			window.clearTimeout(hadFocusVisibleRecentlyTimeout)
			hadFocusVisibleRecentlyTimeout = window.setTimeout(() => {
				hadFocusVisibleRecently = false
			}, 100)
			removeFocusVisibleClass(e.target)
		}
	}

	function onVisibilityChange() {
		if (document.visibilityState === 'hidden') {
			if (hadFocusVisibleRecently) {
				hadKeyboardEvent = true
			}

			addInitialPointerMoveListeners()
		}
	}

	function addInitialPointerMoveListeners() {
		document.addEventListener('mousemove', onInitialPointerMove)
		document.addEventListener('mousedown', onInitialPointerMove)
		document.addEventListener('mouseup', onInitialPointerMove)
		document.addEventListener('pointermove', onInitialPointerMove)
		document.addEventListener('pointerdown', onInitialPointerMove)
		document.addEventListener('pointerup', onInitialPointerMove)
		document.addEventListener('touchmove', onInitialPointerMove)
		document.addEventListener('touchstart', onInitialPointerMove)
		document.addEventListener('touchend', onInitialPointerMove)
	}

	function removeInitialPointerMoveListeners() {
		document.removeEventListener('mousemove', onInitialPointerMove)
		document.removeEventListener('mousedown', onInitialPointerMove)
		document.removeEventListener('mouseup', onInitialPointerMove)
		document.removeEventListener('pointermove', onInitialPointerMove)
		document.removeEventListener('pointerdown', onInitialPointerMove)
		document.removeEventListener('pointerup', onInitialPointerMove)
		document.removeEventListener('touchmove', onInitialPointerMove)
		document.removeEventListener('touchstart', onInitialPointerMove)
		document.removeEventListener('touchend', onInitialPointerMove)
	}

	function onInitialPointerMove(e) {
		if (e.target.nodeName && e.target.nodeName.toLowerCase() === 'html') {
			return
		}

		hadKeyboardEvent = false
		removeInitialPointerMoveListeners()
	}

	document.addEventListener('keydown', onKeyDown, true)
	document.addEventListener('mousedown', onPointerDown, true)
	document.addEventListener('pointerdown', onPointerDown, true)
	document.addEventListener('touchstart', onPointerDown, true)
	document.addEventListener('visibilitychange', onVisibilityChange, true)
	addInitialPointerMoveListeners()
	scope.addEventListener('focus', onFocus, true)
	scope.addEventListener('blur', onBlur, true)

	if (scope.nodeType === Node.DOCUMENT_FRAGMENT_NODE && scope.host) {
		scope.host.setAttribute('data-js-focus-visible', '')
	}
	else if (scope.nodeType === Node.DOCUMENT_NODE) {
		document.documentElement.classList.add('js-focus-visible')
		document.documentElement.setAttribute('data-js-focus-visible', '')
	}
}

if (typeof window !== 'undefined' && typeof document !== 'undefined') {
	window.applyFocusVisiblePolyfill = applyFocusVisiblePolyfill
	let event

	try {
		event = new CustomEvent('focus-visible-polyfill-ready')
	}
	catch (error) {
		event = document.createEvent('CustomEvent')
		event.initCustomEvent('focus-visible-polyfill-ready', false, false, {})
	}

	window.dispatchEvent(event)
}

if (typeof document !== 'undefined') {
	applyFocusVisiblePolyfill(document)
}

var contrast = {
	buttons: '',
	init: function init() {
		const foundButtons = document.querySelectorAll('[data-high-contrast]')
		if (!foundButtons)
			return
		contrast.buttons = foundButtons
		const state = contrast.getCookie() !== null ? contrast.getCookie() : 'false'
		contrast.addAttributes(state)
		contrast.setCookie(state)
		contrast.setContrastMode(state)
		contrast.addListeners()
	},
	addAttributes: function addAttributes(state) {
		contrast.buttons.forEach((element) => {
			element.setAttribute('aria-pressed', ''.concat(state))
			contrast.setLabel(state, element)
		})
	},
	addListeners: function addListeners() {
		contrast.buttons.forEach((element) => {
			element.addEventListener('click', contrast.handleButton, true)
		})
	},
	handleButton: function handleButton(event) {
		const element = event.currentTarget
		const state = element.getAttribute('aria-pressed') === 'false' ? 'true' : 'false'
		contrast.buttons.forEach((element) => {
			element.setAttribute('aria-pressed', state)
			contrast.setLabel(state, element)
			contrast.setContrastMode(state)
			contrast.setCookie(state)
		})
	},
	setLabel: function setLabel(state, element) {
		const label = state === 'true' ? element.getAttribute('data-high-contrast-on') : element.getAttribute('data-high-contrast-off')
		element.setAttribute('aria-label', label)
	},
	setContrastMode: function setContrastMode(state) {
		const body = document.querySelector('body')
		if (!body)
			return

		if (state === 'true') {
			body.classList.add('has-high-contrast')
		}
		else {
			body.classList.remove('has-high-contrast')
		}
	},
	getCookie: function getCookie() {
		const myCookie = document.cookie.match('(^|;) ?' + 'HighContrastModeActive' + '=([^;]*)(;|$)')
		return myCookie ? myCookie[2] : null
	},
	setCookie: function setCookie(state) {
		const daysToKeep = 1
		const myDate = new Date()
		myDate.setTime(myDate.getTime() + 24 * 60 * 60 * 1000 * daysToKeep)
		document.cookie = `HighContrastModeActive` + `=${state};path=/;expires=${myDate.toGMTString()}`
	},
}
contrast.init();

(function () {
	const embedLink = document.querySelectorAll('.js-embed-link')

	if (embedLink) {
		for (let i = 0; i < embedLink.length; i++) {
			embedLink[i].addEventListener('click', function (e) {
				const container = this.closest('.video--embed')
				const video = container.querySelector('.iframe-media')
				let parameters = ''

				if (video.src.includes('you')) {
					parameters = '&autoplay=1&mute=1'
				}
				else if (video.src.includes('vim')) {
					parameters = '&autoplay=1&muted=1'
				}
				else {
					parameters = ''
				}

				video.src = video.src + parameters
				container.dataset.state = 'active'
				e.preventDefault()
			})
		}
	}
})();

(function () {
	const formfields = document.querySelectorAll('input[type=text], input[type=number], input[type=tel], input[type=email], textarea')
	const dropdowns = document.querySelectorAll('select')

	if (formfields) {
		for (var i = 0; i < formfields.length; i++) {
			formfields[i].addEventListener('blur', (event) => {
				event.target.classList.add('interacted')
			}, false)
		}
	}

	if (dropdowns) {
		for (i = 0; i < dropdowns.length; i++) {
			dropdowns[i].addEventListener('change', (event) => {
				event.target.classList.add('interacted')
			}, false)
		}
	}
})()

var languageswitch = {
	picker: {},
	selectbox: {},
	dropdown: {},
	listId: '',
	switchbutton: {},
	useFlags: false,
	showText: true,
	config: {
		selectId: 'languageswitch',
		buttonLabel: 'Select your language',
		globeSvg: '<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm193.2 152h-82.5c-9-44.4-24.1-82.2-43.2-109.1 55 18.2 100.2 57.9 125.7 109.1zM336 256c0 22.9-1.6 44.2-4.3 64H164.3c-2.7-19.8-4.3-41.1-4.3-64s1.6-44.2 4.3-64h167.4c2.7 19.8 4.3 41.1 4.3 64zM248 40c26.9 0 61.4 44.1 78.1 120H169.9C186.6 84.1 221.1 40 248 40zm-67.5 10.9c-19 26.8-34.2 64.6-43.2 109.1H54.8c25.5-51.2 70.7-90.9 125.7-109.1zM32 256c0-22.3 3.4-43.8 9.7-64h90.5c-2.6 20.5-4.2 41.8-4.2 64s1.5 43.5 4.2 64H41.7c-6.3-20.2-9.7-41.7-9.7-64zm22.8 96h82.5c9 44.4 24.1 82.2 43.2 109.1-55-18.2-100.2-57.9-125.7-109.1zM248 472c-26.9 0-61.4-44.1-78.1-120h156.2c-16.7 75.9-51.2 120-78.1 120zm67.5-10.9c19-26.8 34.2-64.6 43.2-109.1h82.5c-25.5 51.2-70.7 90.9-125.7 109.1zM363.8 320c2.6-20.5 4.2-41.8 4.2-64s-1.5-43.5-4.2-64h90.5c6.3 20.2 9.7 41.7 9.7 64s-3.4 43.8-9.7 64h-90.5z"></path></svg>',
	},
	init: function init() {
		this.picker = document.querySelector('[data-language-switch]')
		if (!this.picker)
			return
		this.setGlobalVariables()
		this.testForSelectedOption()
		this.picker.insertAdjacentHTML('beforeend', this.createButton() + this.createList())
		this.dropdown = document.querySelector('[data-languageswitch-list]')
		this.hideOriginalSelect()
		this.setListeners()
	},
	setGlobalVariables: function setGlobalVariables() {
		this.useFlags = this.picker.getAttribute('data-languageswitch-useflags') === 'true'
		this.showText = this.picker.getAttribute('data-languageswitch-showtext') === 'true'
		this.selectbox = this.picker.querySelector('select')
		const selectId = this.selectbox.getAttribute('id')
		this.listId = selectId !== null ? `${selectId}-list` : `${this.config.selectId}-list`
	},
	createButton: function createButton() {
		const attributeValue = this.picker.getAttribute('data-languageswitch-label-button')
		const ariaLabel = attributeValue !== null ? attributeValue : this.config.buttonLabel
		const flagsClass = this.useFlags ? 'languageswitch__button--use-flags' : ''
		const showTextClass = this.showText ? '' : 'languageswitch__button-text--no-text'
		const template = '<button class="languageswitch__button '.concat(flagsClass, '"\n                              data-language-switch-button aria-expanded="false"\n                              aria-label="').concat(this.getSelectedOptionText(), ' - ').concat(ariaLabel, '"\n                              aria-controls="').concat(this.listId, '"\n                              lang="').concat(this.selectbox.querySelector('option[selected]').getAttribute('lang'), '"\n                        >\n                        <span class="icon languageswitch__icon" aria-hidden="true">\n                        ').concat(this.config.globeSvg, '\n                        </span>\n                        <span aria-hidden="true" class="languageswitch__button-text ').concat(showTextClass, '">\n                          <span>\n                            ').concat(this.getSelectedOptionText(), '\n                          </span>\n                        </span>\n                      </button>\n                      ')
		return template
	},
	createList: function createList() {
		const flagsClass = this.useFlags ? 'languageswitch__link--use-flags' : ''
		const showTextClass = this.showText ? '' : 'languageswitch__link--no-text'
		let list = '<div class="languageswitch__dropdown" data-language-switch-dropdown aria-describedby="'.concat(this.listId, '-description" id="').concat(this.listId, '" aria-hidden="true" hidden>\n                    <p class="visually-hidden" id="').concat(this.listId, '-description">').concat(this.picker.querySelector('label').textContent, '</p>\n                    <ul class="languageswitch__list" role="listbox" data-languageswitch-list>')

		for (let i = 0; i < this.selectbox.options.length; i++) {
			const selected = this.selectbox.options[i].selected ? ' aria-selected="true"' : ''
			const language = this.selectbox.options[i].getAttribute('lang')
			const link = this.selectbox.options[i].getAttribute('data-link')
			list = list + '<li class="languageswitch__item">\n                        <a lang="'.concat(language, '" hreflang="').concat(language, '" href="').concat(link, '" ').concat(selected, '\n                            role="option" data-value="').concat(this.selectbox.options[i].value, '"\n                            class="languageswitch__link ').concat(flagsClass, ' ').concat(showTextClass, '">\n                          <span class="languageswitch__link-text">\n                            <span>\n                              ').concat(this.selectbox.options[i].text, '\n                            </span>\n                          </span>\n                        </a>\n                      </li>\n                      ')
		}

		return ''.concat(list, '</ul></div>')
	},
	hideOriginalSelect: function hideOriginalSelect() {
		const element = this.picker.querySelector('form')
		element.setAttribute('aria-hidden', 'true')
		element.setAttribute('hidden', '')
		element.style.display = 'none'
	},
	getSelectedOptionText: function getSelectedOptionText() {
		return this.selectbox.querySelector('option[selected]').text
	},
	testForSelectedOption: function testForSelectedOption() {
		const selectedOption = this.selectbox.querySelector('option[selected]')

		if (!selectedOption) {
			this.selectbox.querySelectorAll('option')[0].setAttribute('selected', '')
		}
	},
	setListeners: function setListeners() {
		this.switchbutton = this.picker.querySelector('[data-language-switch-button]')
		this.switchbutton.addEventListener('click', languageswitch.handleButtonClick)
	},
	handleButtonClick: function handleButtonClick() {
		const element = languageswitch.switchbutton
		const target = document.getElementById(element.getAttribute('aria-controls'))
		const state = element.getAttribute('aria-expanded') !== 'true'
		element.setAttribute('aria-expanded', state)
		target.setAttribute('aria-hidden', !state)

		if (state) {
			target.removeAttribute('hidden')
			languageswitch.addEventListeners()
			languageswitch.dropdown.querySelector('li a').focus()
		}
		else {
			target.setAttribute('hidden', '')
			languageswitch.removeEventListeners()
			element.focus()
		}

		const bounding = target.getBoundingClientRect()

		if (bounding.right > (window.innerWidth || document.documentElement.clientWidth)) {
			target.setAttribute('data-language-switch-overflow-x', 'true')
		}
		else {
			target.removeAttribute('data-language-switch-overflow-x')
		}

		if (bounding.bottom > (window.innerHeight || document.documentElement.clientHeight)) {
			target.setAttribute('data-language-switch-overflow-y', 'true')
		}
		else {
			target.removeAttribute('data-language-switch-overflow-y')
		}
	},
	addEventListeners: function addEventListeners() {
		window.addEventListener('keyup', languageswitch.handleKeys)
		window.addEventListener('click', languageswitch.checkOutsideClick)
		languageswitch.dropdown.addEventListener('keydown', languageswitch.handleArrows, true)
	},
	removeEventListeners: function removeEventListeners() {
		window.removeEventListener('keyup', languageswitch.handleKeys)
		window.removeEventListener('click', languageswitch.checkOutsideClick)
		languageswitch.dropdown.removeEventListener('keydown', languageswitch.handleArrows, true)
	},
	handleKeys: function handleKeys(event) {
		if (event.keyCode && event.keyCode == 27 || event.key && event.key.toLowerCase() == 'escape') {
			languageswitch.handleButtonClick()
		}
	},
	handleArrows: function handleArrows(event) {
		if (!event.keyCode && !event.key)
			return
		if (event.keyCode == 9 || event.key.toLowerCase() == 'tab')
			return

		if (event.keyCode == 38 || event.key.toLowerCase() == 'arrowup') {
			languageswitch.moveArrowFocus('up')
		}
		else if (event.keyCode == 40 || event.key.toLowerCase() == 'arrowdown') {
			languageswitch.moveArrowFocus('down')
		}
		else if (event.keyCode == 13 || event.key.toLowerCase() == 'enter') {
			document.activeElement.click()
		}

		event.preventDefault()
	},
	moveArrowFocus: function moveArrowFocus(direction) {
		const listItems = languageswitch.dropdown.querySelectorAll('li a')
		const listItemsArray = Array.prototype.slice.call(listItems)
		let index = listItemsArray.indexOf(document.activeElement)
		index = direction == 'down' ? index + 1 : index - 1
		if (index < 0)
			index = listItemsArray.length - 1
		if (index >= listItemsArray.length)
			index = 0
		listItems.item(index).focus()
	},
	checkOutsideClick: function checkOutsideClick(event) {
		if (!languageswitch.picker.contains(event.target))
			languageswitch.handleButtonClick()
	},
}
languageswitch.init()
const makeClickable = {
	init: function init() {
		const element = document.querySelectorAll('[data-clickable]')
		Array.prototype.forEach.call(element, (element) => {
			let timer
			const assignedLink = element.querySelector('[data-clickable-link]')
			const link = assignedLink || element.querySelector('a')
			if (!link || element.hasAttribute('data-clickable--enabled'))
				return
			element.setAttribute('data-clickable--enabled', '')
			link && (element.style.cursor = 'pointer', (element.addEventListener('click', () => {
				link.click()
			}), {
				passive: true,
			}))
		})
	},
}
makeClickable.init()
var notification = {
	cookiename: 'disabledNotifications',
	daysToKeep: 1,
	collection: document.querySelectorAll('.band--notification'),
	init: function init() {
		this.collection.forEach((element) => {
			const button = element.querySelector('.js-notification-button')
			if (!button)
				return
			button.addEventListener('click', function (event) {
				const notificationElement = this.closest('[data-nodeid]')
				notificationElement.className += ' notification-close'
				const closeButtonEvent = notification.whichAnimationEvent()
				closeButtonEvent && notificationElement.addEventListener(closeButtonEvent, () => {
					notification.setCookie(notificationElement.getAttribute('data-nodeid'))
					notificationElement.remove()
					const cssRoot = document.querySelector(':root')
					if (!cssRoot)
						return
					cssRoot.style.setProperty('--notification-padding', '0px')
				})
				event.preventDefault()
			})
		})
	},
	addDataToCookie: function addDataToCookie(value) {
		let dataToStore = ''
		const originalData = this.getCookie(this.cookiename) !== null ? this.getCookie(this.cookiename) : ''

		if (originalData.length > 0) {
			for (let i = 0; i < originalData.length; i++) {
				if (value !== originalData[i])
					dataToStore += originalData[i]
			}
		}

		dataToStore += `${value}|`
		return dataToStore
	},
	getCookie: function getCookie(name) {
		const myCookie = document.cookie.match(`(^|;) ?${name}=([^;]*)(;|$)`)
		return myCookie ? myCookie[2] : null
	},
	setCookie: function setCookie(value) {
		const dataToStore = this.addDataToCookie(value)
		const myDate = new Date()
		myDate.setTime(myDate.getTime() + 24 * 60 * 60 * 1000 * this.daysToKeep)
		document.cookie = `${this.cookiename}=${dataToStore};path=/;expires=${myDate.toGMTString()}`
	},
	whichAnimationEvent: function whichAnimationEvent() {
		let animation
		const element = document.createElement('fakeelement')
		const animations = {
			animation: 'animationend',
			OAnimation: 'oAnimationEnd',
			MozAnimation: 'animationend',
			WebkitAnimation: 'webkitAnimationEnd',
		}

		for (animation in animations) {
			if (element.style[animation] !== undefined) {
				return animations[animation]
			}
		}
	},
};

(function () {
	notification.init()
})()

function initSlider() {
	const slider = document.querySelectorAll('.swiper--default')
	let i = 0

	if (slider) {
		for (i = 0; i < slider.length; i++) {
			const setLoop = slider[i].dataset.swiperLoop === 'true'
			const setCenter = slider[i].dataset.swiperCenter === 'true'
			const setAutoHeight = slider[i].dataset.swiperAutoheight === 'true'
			const setScrolling = slider[i].dataset.swiperScrolling === 'true'
			let setAutoplay = false

			if (slider[i].dataset.swiperAutoplay === 'true') {
				setAutoplay = {
					delay: 5000,
					pauseOnMouseEnter: true,
				}
			}

			const setSpaceBetween = 18
			let hasBreakpoints = false

			if (slider[i].dataset.layoutPreset == 2) {
				hasBreakpoints = {
					768: {
						slidesPerView: 2,
					},
					1280: {
						slidesPerView: 2,
						spaceBetween: 26,
					},
				}
			}

			if (slider[i].dataset.layoutPreset == 3) {
				hasBreakpoints = {
					768: {
						slidesPerView: 3,
					},
					1280: {
						slidesPerView: 3,
						spaceBetween: 26,
					},
				}
			}

			if (slider[i].dataset.layoutPreset == 4) {
				hasBreakpoints = {
					768: {
						slidesPerView: 2,
					},
					1024: {
						slidesPerView: 4,
					},
					1280: {
						slidesPerView: 4,
						spaceBetween: 26,
					},
				}
			}

			if (slider[i].dataset.layoutPreset == 5) {
				hasBreakpoints = {
					200: {
						slidesPerView: 2,
					},
					768: {
						slidesPerView: 3,
					},
					1024: {
						slidesPerView: 4,
					},
					1280: {
						slidesPerView: 5,
						spaceBetween: 26,
					},
				}
			}

			if (slider[i].dataset.layoutPreset == 6) {
				hasBreakpoints = {
					200: {
						slidesPerView: 2,
					},
					768: {
						slidesPerView: 3,
					},
					1024: {
						slidesPerView: 5,
					},
					1280: {
						slidesPerView: 6,
						spaceBetween: 26,
					},
				}
			}

			const hasNavigation = slider[i].dataset.swiperNavigation === 'true'
				? {
						nextEl: '.swiper-button-next',
						prevEl: '.swiper-button-prev',
					}
				: false
			let hasPagination = false

			if (slider[i].dataset.swiperBullets === 'true') {
				hasPagination = {
					el: '.swiper-pagination',
					clickable: true,
				}
			}

			if (slider[i].dataset.swiperBullets === 'true' && slider[i].dataset.swiperDynamicBullets === 'true') {
				hasPagination = {
					el: '.swiper-pagination',
					clickable: true,
					dynamicBullets: true,
					dynamicMainBullets: 1,
				}
			}

			new Swiper(slider[i], {
				mousewheel: setScrolling,
				keyboard: setScrolling,
				autoHeight: setAutoHeight,
				loop: setLoop,
				centeredSlides: setCenter,
				navigation: hasNavigation,
				pagination: hasPagination,
				autoplay: setAutoplay,
				slidesPerView: 1,
				spaceBetween: setSpaceBetween,
				breakpoints: hasBreakpoints,
			})
		}
	}
}

var toggle = {
	toggleGroups: document.querySelectorAll('[data-toggle-group]'),
	toggleIndex: 0,
	toggleGroupIndex: 0,
	init: function init() {
		const _this = this

		if (!this.toggleGroups.length > 0)
			return
		this.toggleGroups.forEach((element) => {
			const maxItems = element.getAttribute('data-toggle-max-items') === '' ? null : element.getAttribute('data-toggle-max-items')
			const toggleItems = element.querySelectorAll('[data-toggle-item]')
			if (!toggleItems.length > 0)
				return
			element.setAttribute('aria-live', 'polite')
			toggleItems.forEach((element) => {
				_this.toggleIndex++

				_this.createButton(element)

				_this.addContentAttributes(element)

				_this.setItemState(element, false)
			})

			if (maxItems !== null && toggleItems.length > maxItems) {
				_this.toggleGroupIndex++

				_this.moveMoreItems(toggleItems, element, maxItems)

				_this.createMoreButton(element)
			}
		})
	},
	createButton: function createButton(element) {
		const title = element.querySelector('[data-toggle-title]')
		const button = document.createElement('BUTTON')
		title.parentNode.insertBefore(button, title)
		button.appendChild(title)
		this.addButtonAttributes(button)
		button.addEventListener('click', toggle.handleButton, true)
	},
	createMoreButton: function createMoreButton(element) {
		const parentGroup = element.closest('[data-toggle-group]')
		const buttonLabel = toggle.dataHasValue(element, 'data-toggle-more-open-label') ? parentGroup.getAttribute('data-toggle-more-open-label') : 'Toon meer'
		const buttonClass = toggle.dataHasValue(element, 'data-toggle-more-button-class') ? parentGroup.getAttribute('data-toggle-more-button-class') : ''
		const button = document.createElement('BUTTON')
		button.setAttribute('aria-expanded', false)
		button.setAttribute('data-toggle-more-button', '')
		button.setAttribute('aria-controls', 'togglegroup'.concat(this.toggleGroupIndex))
		button.setAttribute('class', buttonClass)

		if (parentGroup.getAttribute('data-toggle-more-remove-after') === 'true') {
			button.setAttribute('data-toggle-more-remove-after', true)
		}

		element.appendChild(button)
		button.innerHTML = buttonLabel + toggle.showCounter(button)
		button.addEventListener('click', toggle.handleButton, true)
	},
	moveMoreItems: function moveMoreItems(toggleItems, element, maxItems) {
		const moreItems = document.createElement('DIV')
		moreItems.setAttribute('id', 'togglegroup'.concat(this.toggleGroupIndex))
		moreItems.setAttribute('aria-hidden', true)
		moreItems.setAttribute('hidden', '')
		moreItems.setAttribute('data-toggle-more-group', '')
		toggleItems.forEach((element, index) => {
			if (index >= maxItems) {
				moreItems.appendChild(element)
			}
		})
		element.appendChild(moreItems)
	},
	addButtonAttributes: function addButtonAttributes(element) {
		element.setAttribute('data-toggle-button', '')
		element.setAttribute('aria-expanded', false)
		element.setAttribute('aria-controls', 'toggle'.concat(this.toggleIndex))
		element.setAttribute('type', 'button')
		element.setAttribute('aria-label', toggle.getButtonLabel(element, false))
	},
	getButtonLabel: function getButtonLabel(element, state, interValue) {
		let label
		const inter = interValue !== null ? '-'.concat(interValue) : ''
		const parentGroup = element.closest('[data-toggle-group]')

		if (!state) {
			label = toggle.dataHasValue(element, 'data-toggle'.concat(inter, '-open-label')) ? parentGroup.getAttribute('data-toggle'.concat(inter, '-open-label')) : 'Openen'
		}
		else {
			label = toggle.dataHasValue(element, 'data-toggle'.concat(inter, '-close-label')) ? parentGroup.getAttribute('data-toggle'.concat(inter, '-close-label')) : 'Sluiten'
		}

		return label
	},
	addContentAttributes: function addContentAttributes(element) {
		const content = element.querySelector('[data-toggle-content]')
		content.setAttribute('id', `toggle${this.toggleIndex}`)
		content.setAttribute('aria-hidden', true)
		content.setAttribute('hidden', '')
		content.style.transitionDuration = ''.concat(Math.round(content.scrollHeight * 1.5), 'ms')
	},
	handleButton: function handleButton(event) {
		const element = event.currentTarget
		const target = document.getElementById(element.getAttribute('aria-controls'))
		const state = element.getAttribute('aria-expanded') !== 'true'
		target.style.transitionDuration = ''.concat(Math.round(target.scrollHeight * 1.5), 'ms')
		target.style.maxHeight = state ? ''.concat(target.scrollHeight, 'px') : '0px'
		element.setAttribute('aria-expanded', state)
		target.setAttribute('aria-hidden', !state)

		if (state) {
			target.removeAttribute('hidden')
		}
		else {
			target.setAttribute('hidden', '')
		}

		if (element.getAttribute('data-toggle-more-button') !== null) {
			if (element.getAttribute('data-toggle-more-remove-after') !== null) {
				element.remove()
			}
			else {
				element.innerHTML = toggle.getButtonLabel(element, state, 'more') + toggle.showCounter(element)
			}
		}
		else {
			const label = toggle.getButtonLabel(element, state)
			toggle.setItemState(element, state)
			element.setAttribute('aria-label', label)
		}
	},
	showCounter: function showCounter(element) {
		const useBadge = toggle.dataHasValue(element, 'data-toggle-use-counter') !== null
		if (!useBadge)
			return
		const moreItemsContainer = element.parentNode.querySelector('[data-toggle-more-group]')
		const amount = moreItemsContainer.querySelectorAll('[data-toggle-item]').length
		return ' <span data-toggle-badge>'.concat(amount, '</span>')
	},
	setItemState: function setItemState(element, state) {
		const parentGroup = element.closest('[data-toggle-item]')
		parentGroup.setAttribute('data-toggle-item-is-open', state)
	},
	dataHasValue: function dataHasValue(element, datatag) {
		const parentGroup = element.closest('[data-toggle-group]')
		const hasValue = !!(parentGroup.getAttribute(datatag) !== '' && parentGroup.getAttribute(datatag) !== null)
		return hasValue
	},
}
toggle.init();

(function () {
	const toggleMenuLink = document.querySelector('.js-toggle-menu')

	if (toggleMenuLink) {
		toggleMenuLink.setAttribute('aria-expanded', false)
		toggleMenuLink.setAttribute('aria-label', 'Open menu')
		toggleMenuLink.addEventListener('click', function (e) {
			const state = this.getAttribute('aria-expanded') === 'true'
			this.classList.toggle('active')
			this.setAttribute('aria-expanded', !state)
			this.setAttribute('aria-label', !state ? 'Close menu' : 'Open menu')
			document.body.classList.toggle('show-menu')
			e.preventDefault()
		})
	}
})();

(function () {
	var navigation = {
		throttleTimeoutObject: false,
		throttleDelay: 250,
		desktopThreshold: 1024,
		mode: 'init',
		init: function init() {
			this.resizeCheck()
			this.addResizeListener()
		},
		addResizeListener: function addResizeListener() {
			window.addEventListener('resize', () => {
				clearTimeout(navigation.throttleTimeoutObject)
				navigation.throttleTimeoutObject = setTimeout(navigation.resizeCheck(), navigation.throttleDelay)
			})
		},
		resizeCheck: function resizeCheck() {
			if (window.innerWidth <= navigation.desktopThreshold) {
				if (this.mode == 'desktop' || this.mode == 'init') {
					this.removeDesktopEvents()
					this.removeAriaRoles()
					this.createMobileButtons()
					this.moveTopMenuToMenu()
					this.mode = 'mobile'
				}
			}
			else {
				if (this.mode == 'mobile' || this.mode == 'init') {
					this.removeMobileButtons()
					this.removeAriaRoles()
					this.createDesktopEvents()
					this.moveTopMenuToOriginalLocation()
					this.mode = 'desktop'
				}
			}

			this.calculateNotificationHeight()
		},
		calculateNotificationHeight: function calculateNotificationHeight() {
			const cssRoot = document.querySelector(':root')
			const notificationElement = document.querySelector('.band--notification')
			if (!cssRoot || !notificationElement)
				return
			const notificationHeight = notificationElement.offsetHeight
			const notificationMargin = Number.parseInt(getComputedStyle(notificationElement).marginTop)
			cssRoot.style.setProperty('--notification-padding', `${notificationMargin + notificationHeight}px`)
		},
		createToggleMenuButton: function createToggleMenuButton() {
			const menu = document.querySelector('[data-nav-menu]')
			if (!menu)
				return
			const element = document.createElement('BUTTON')
			element.innerHTML = '\n          <span></span>\n          <span></span>\n          <span></span>\n        '
			element.setAttribute('aria-expanded', false)
			element.setAttribute('aria-label', 'Open menu')
			element.setAttribute('aria-controls', 'main-menu')
			element.setAttribute('id', 'main-menu-toggle')
			element.classList.add('menu__menu-toggle')
			menu.setAttribute('id', 'main-menu')
			menu.hidden = true
			menu.setAttribute('aria-hidden', 'true')
			menu.parentNode.insertBefore(element, menu.parentNode.childNodes[0])
			element.addEventListener('click', navigation.toggleMenuHandler)
		},
		toggleMenuHandler: function toggleMenuHandler() {
			const state = this.getAttribute('aria-expanded') === 'true'
			const menu = document.getElementById(this.getAttribute('aria-controls'))
			this.classList.toggle('active')
			this.setAttribute('aria-expanded', !state)
			this.setAttribute('aria-label', !state ? 'Close menu' : 'Open menu')
			menu.hidden = state
			menu.setAttribute('aria-hidden', state)
		},
		createMobileButtons: function createMobileButtons() {
			navigation.removeAriaRoles()
			navigation.createToggleMenuButton()
			const submenuCollection = document.querySelectorAll('[data-nav-submenu]')

			for (let i = 0; i < submenuCollection.length; i++) {
				const element = document.createElement('BUTTON')
				const currentSubmenu = submenuCollection[i]
				let currentSubmenuId = ''

				if (currentSubmenu.getAttribute('id') !== null) {
					currentSubmenuId = currentSubmenu.getAttribute('id')
				}
				else {
					currentSubmenuId = 'js-submenu-'.concat(i)
					currentSubmenu.setAttribute('id', currentSubmenuId)
				}

				const isSelected = currentSubmenu.parentNode.classList.contains('menu__item--selected')
				element.setAttribute('aria-expanded', isSelected)
				element.setAttribute('aria-label', isSelected ? 'Close submenu' : 'Open submenu')
				element.setAttribute('aria-controls', currentSubmenuId)
				element.setAttribute('data-nav-menubutton', '')
				element.classList.add('menuitem__toggle')
				currentSubmenu.setAttribute('aria-label', 'Submenu')
				currentSubmenu.setAttribute('aria-hidden', !isSelected)
				currentSubmenu.removeAttribute('aria-haspopup')
				currentSubmenu.parentNode.insertBefore(element, currentSubmenu.parentNode.childNodes[0])
				element.addEventListener('click', navigation.handleMobileButton, false)
			}
		},
		handleMobileButton: function handleMobileButton() {
			const state = this.getAttribute('aria-expanded') === 'true'
			const flyoutMenu = document.getElementById(this.getAttribute('aria-controls'))
			this.classList.toggle('active')
			this.setAttribute('aria-expanded', !state)
			this.setAttribute('aria-label', !state ? 'Close submenu' : 'Open submenu')
			flyoutMenu.setAttribute('aria-hidden', state)
		},
		removeMobileButtons: function removeMobileButtons() {
			const menuButtons = document.querySelectorAll('[data-nav-menubutton]')
			const mainMenuToggle = document.getElementById('main-menu-toggle')
			if (!menuButtons || !mainMenuToggle)
				return
			mainMenuToggle.remove()

			for (let i = 0; i < menuButtons.length; i++) {
				menuButtons[i].remove()
			}
		},
		removeAriaRoles: function removeAriaRoles() {
			const menu = document.querySelector('[data-nav-menu]')
			if (!menu)
				return
			menu.removeAttribute('aria-hidden')
			menu.hidden = false
			const menuRoles = menu.querySelectorAll('[aria-hidden]')
			if (!menuRoles)
				return

			for (let i = 0; i < menuRoles.length; i++) {
				menuRoles[i].removeAttribute('aria-hidden')
				menuRoles[i].removeAttribute('aria-haspopup')

				if (this.mode === 'desktop') {
					const menuLink = menuRoles[i].previousElementSibling
					if (!menuLink)
						return
					menuLink.removeAttribute('aria-expanded')
					menuLink.removeAttribute('aria-haspopup')
				}
			}
		},
		createDesktopEvents: function createDesktopEvents() {
			const navigationCollection = document.querySelectorAll('[data-nav-menu] [data-nav-item]')
			if (!navigationCollection)
				return

			for (let i = 0; i < navigationCollection.length; i++) {
				const currentSubmenu = navigationCollection[i].querySelector('[data-nav-submenu]')
				const menuLink = navigationCollection[i].querySelector('a')
				const menuListItem = navigationCollection[i]

				if (currentSubmenu && menuLink) {
					currentSubmenu.setAttribute('aria-hidden', true)
					currentSubmenu.setAttribute('aria-label', 'Submenu')
					menuLink.setAttribute('aria-haspopup', true)
					menuLink.setAttribute('aria-expanded', false)
					menuListItem.addEventListener('mouseover', this.handleDesktopEnterEvents, true)
					menuListItem.addEventListener('mouseout', this.handleDesktopLeaveEvents, true)
					menuListItem.addEventListener('focusin', this.handleDesktopEnterEvents, true)
					menuListItem.addEventListener('focusout', this.handleDesktopLeaveEvents, true)
				}
			}
		},
		handleDesktopLeaveEvents: function handleDesktopLeaveEvents() {
			const subMenu = this.querySelector('[data-nav-submenu]')
			navigation.changeDesktopMouseOverStates(subMenu, false)
		},
		handleDesktopEnterEvents: function handleDesktopEnterEvents() {
			const subMenu = this.querySelector('[data-nav-submenu]')
			navigation.changeDesktopMouseOverStates(subMenu, true)
		},
		changeDesktopMouseOverStates: function changeDesktopMouseOverStates(subMenu, state) {
			subMenu.previousElementSibling.setAttribute('aria-expanded', state)
			subMenu.setAttribute('aria-hidden', !state)
		},
		removeDesktopEvents: function removeDesktopEvents() {
			const navigationCollection = document.querySelectorAll('[data-nav-menu] [data-nav-item]')
			if (!navigationCollection)
				return

			for (let i = 0; i < navigationCollection.length; i++) {
				const menuListItem = navigationCollection[i]
				menuListItem.removeEventListener('mouseover', this.handleDesktopEnterEvents, true)
				menuListItem.removeEventListener('mouseout', this.handleDesktopLeaveEvents, true)
				menuListItem.removeEventListener('focusin', this.handleDesktopEnterEvents, true)
				menuListItem.removeEventListener('focusout', this.handleDesktopLeaveEvents, true)
			}
		},
		moveTopMenuToMenu: function moveTopMenuToMenu() {
			const topMenu = document.querySelector('[data-navigation-top]')
			if (!topMenu)
				return
			topMenu.setAttribute('role', 'listitem')
			const menu = document.querySelector('[data-nav-menu] [data-nav-item]:last-child')
			menu.after(topMenu)
		},
		moveTopMenuToOriginalLocation: function moveTopMenuToOriginalLocation() {
			const topMenu = document.querySelector('[data-navigation-top]')
			if (!topMenu)
				return
			topMenu.removeAttribute('role')
			const menu = topMenu.closest('.band__content').firstChild
			menu.before(topMenu)
		},
	}
	navigation.init()
})()
