var app = {
	ready: a => {
		"loading" != document.readyState ? a() : document.addEventListener("DOMContentLoaded", a)
	},
	menu: {},
	keys: {},
	overlay: {},
	animations: {
		tracked: []
	}
};
app.ready(() => {
	app.menu.init(), app.keys.init(), app.overlay.init(), document.addEventListener("keyup", a => {
		a.keyCode == app.keys.ESC && app.keys.handleESC()
	}), document.addEventListener("keydown", a => {
		a.keyCode == app.keys.arrowUp ? app.keys.handleArrowUp(a) : a.keyCode == app.keys.arrowDown ? app.keys.handleArrowDown(a) : a.keyCode == app.keys.enter && app.keys.handleEnter(a)
	}), window.addEventListener("scroll", app.animations.onlyPlayVisible)
}), app.menu.init = (() => {
	app.menu.visible = !1, app.menu.icon = document.querySelector(".menu"), app.menu.icon.addEventListener("click", a => {
		a.preventDefault(), app.menu.visible ? app.menu.hide() : app.menu.reveal(a)
	})
}), app.menu.toggleStates = (() => {
	document.querySelector("body").classList.toggle("no-scroll"), app.menu.icon.classList.toggle("menu-active"), document.querySelector(".js-nav").classList.toggle("site-nav-active")
}), app.menu.reveal = (a => {
	app.menu.visible = !0, app.menu.toggleStates(), document.dispatchEvent(new Event("app:menuWillShow")), app.overlay.show({
		position: app.clickPosition(a),
		fill: "#011463"
	});
	anime({
		targets: ".js-nav",
		opacity: [0, 1],
		delay: 200,
		easing: "easeInOutExpo",
		duration: 200
	})
}), app.menu.hide = (() => {
	app.menu.visible = !1, app.menu.toggleStates(), document.dispatchEvent(new Event("app:menuWillHide")), app.overlay.hide({
		position: app.overlay.lastStartingPoint,
		fill: "#011463",
		complete: () => document.dispatchEvent(new Event("app:menuDidHide"))
	}), anime({
		targets: ".js-nav",
		opacity: [1, 0],
		easing: "easeInOutExpo",
		duration: 200
	})
}), app.menu.hideMenuIcon = (() => {
	app.menu.icon.style.display = "none"
}), app.menu.showMenuIcon = (() => {
	app.menu.icon.style.opacity = 0, app.menu.icon.style.display = "", anime({
		targets: ".menu",
		opacity: 1,
		duration: 100,
		easing: "easeOutQuart"
	})
}), app.keys.init = (() => {
	app.keys.ESC = 27, app.keys.arrowUp = 38, app.keys.arrowDown = 40, app.keys.enter = 13
}), app.animations.track = ((a, e) => {
	app.animations.tracked.push({
		timeline: a,
		element: e
	})
}), app.animations.onlyPlayVisible = (() => {
	app.animations.tracked.forEach(a => {
		app.animations.shouldPlay(a) ? a.timeline.play() : a.timeline.pause()
	})
}), app.animations.shouldPlay = (a => {
	var e = window.innerHeight,
		p = a.element.getBoundingClientRect();
	return !(p.bottom < 5 || p.top > e - 5)
}), app.overlay.init = (() => {
	app.overlay.c = document.querySelector(".site-nav-canvas"), app.overlay.ctx = app.overlay.c.getContext("2d"), app.overlay.cH, app.overlay.cW, app.overlay.bgColor = "transparent", app.overlay.resizeCanvas(), app.overlay.lastStartingPoint = {
		x: 0,
		y: 0
	}, window.addEventListener("resize", app.overlay.resizeCanvas)
}), app.overlay.resizeCanvas = function() {
	app.overlay.cW = window.innerWidth, app.overlay.cH = window.innerHeight, app.overlay.c.width = app.overlay.cW * window.devicePixelRatio, app.overlay.c.height = app.overlay.cH * window.devicePixelRatio, app.overlay.ctx.scale(window.devicePixelRatio, window.devicePixelRatio), app.overlay.ctx.fillStyle = app.overlay.bgColor, app.overlay.ctx.fillRect(0, 0, app.overlay.cW, app.overlay.cH)
}, app.overlay.show = function(a) {
	app.overlay.c.style.display = "block", app.overlay.lastStartingPoint = a.position, a.targetRadius = app.overlay.calcPageFillRadius(a.position.x, a.position.y), a.startRadius = 0, a.easing = "easeOutQuart", app.overlay.animate(a)
}, app.overlay.hide = (a => {
	a.targetRadius = 0, a.easing = "easeInOutQuart";
	var e = a.complete;
	a.complete = (() => {
		app.overlay.c.style.display = "none", app.overlay.bgColor = "transparent", e && e()
	}), a.startRadius = app.overlay.calcPageFillRadius(a.position.x, a.position.y), app.overlay.animate(a)
}), app.overlay.animate = (a => {
	app.overlay.bgColor = a.fill, app.overlay.circle.x = a.position.x, app.overlay.circle.y = a.position.y, app.overlay.circle.r = a.startRadius, app.overlay.circle.fill = a.fill, anime({
		targets: app.overlay.circle,
		r: a.targetRadius,
		duration: Math.max(a.targetRadius / 2, 750),
		easing: a.easing,
		complete: a.complete ? a.complete : null,
		update: () => app.overlay.circle.draw({
			startRadius: a.startRadius,
			targetRadius: a.targetRadius
		})
	})
}), app.overlay.calcPageFillRadius = function(a, e) {
	var p = Math.max(a - 0, app.overlay.cW - a),
		t = Math.max(e - 0, app.overlay.cH - e);
	return Math.sqrt(Math.pow(p, 2) + Math.pow(t, 2))
}, app.clickPosition = (a => {
	if (a.touches && (a = a.touches[0]), a.clientX && a.clientY) return {
		x: a.clientX,
		y: a.clientY
	};
	var e = a.target.getBoundingClientRect();
	return {
		x: e.top + (e.bottom - e.top) / 2,
		y: e.left + (e.right - e.left) / 2
	}
}), app.overlay.circle = {}, app.overlay.circle.draw = function(a) {
	a.targetRadius < a.startRadius && app.overlay.ctx.clearRect(0, 0, app.overlay.cW, app.overlay.cH), app.overlay.ctx.beginPath(), app.overlay.ctx.arc(this.x, this.y, this.r, 0, 2 * Math.PI, !1), app.overlay.ctx.fillStyle = this.fill, app.overlay.ctx.fill(), app.overlay.ctx.closePath()
};