(function () {
	"use strict";

	/*
	 * Easy selector helper function
	 */
	const select = (el, all = false) => {
		el = el.trim();
		if (all) {
			return [...document.querySelectorAll(el)];
		} else {
			return document.querySelector(el);
		}
	};

	/*
	 * Easy event listener function
	 */
	const on = (type, el, listener, all = false) => {
		let selectEl = select(el, all);
		if (selectEl) {
			if (all) {
				selectEl.forEach((e) => e.addEventListener(type, listener));
			} else {
				selectEl.addEventListener(type, listener);
			}
		}
	};

	/*
	 * Easy on scroll event listener
	 */
	const onscroll = (el, listener) => {
		el.addEventListener("scroll", listener);
	};

	/*
	 * Navbar links active state on scroll
	 */
	let navbarlinks = select("#navbar .scrollto", true);
	const navbarlinksActive = () => {
		let position = window.scrollY + 200;
		navbarlinks.forEach((navbarlink) => {
			if (!navbarlink.hash) return;
			let section = select(navbarlink.hash);
			if (!section) return;
			if (
				position >= section.offsetTop &&
				position <= section.offsetTop + section.offsetHeight
			) {
				navbarlink.classList.add("active");
			} else {
				navbarlink.classList.remove("active");
			}
		});
	};
	window.addEventListener("load", navbarlinksActive);
	onscroll(document, navbarlinksActive);

	/*
	 * Header fixed top on scroll
	 */
	let selectHeader = select("#header");
	let selectNavbar = select(".navbar");
	if (selectNavbar.classList.contains("page")) {
	} else if (selectHeader) {
		const headerScrolled = () => {
			if (window.scrollY > 100) {
				selectHeader.classList.add("header-scrolled");
				selectNavbar.classList.add("scrolled");
			} else {
				selectHeader.classList.remove("header-scrolled");
				selectNavbar.classList.remove("scrolled");
			}
		};
		window.addEventListener("load", headerScrolled);
		onscroll(document, headerScrolled);
	}

	/*
	 * Mobile nav toggle
	 */
	const mobileNavHide = document.querySelector(".mobile-nav-hide");

	document.querySelectorAll(".mobile-nav-toggle").forEach((el) => {
		el.addEventListener("click", function (event) {
			event.preventDefault();
			mobileNavToogle();
		});
	});

	function mobileNavToogle() {
		document.querySelector("body").classList.toggle("mobile-nav-active");
		mobileNavHide.classList.toggle("d-none");
	}

	/*
	 * Mobile nav dropdowns activate
	 */
	on(
		"click",
		".navbar .dropdown > a",
		function (e) {
			if (select("#navbar").classList.contains("navbar-mobile")) {
				e.preventDefault();
				this.nextElementSibling.classList.toggle("dropdown-active");
			}
		},
		true
	);

	/*
	 * Scroll with offset on page load with hash links in the url
	 */
	window.addEventListener("load", () => {
		if (window.location.hash) {
			if (select(window.location.hash)) {
				scrollto(window.location.hash);
			}
		}
	});

	/*
	 * Swipe Slider
	 */
	jQuery(function () {
		var SwiperBannerHome = new Swiper(".banners-home", {
			loop: true,
			autoplay: {
				delay: 4500,
				disableOnInteraction: false,
				speed: 700,
			},
			lazy: true,
			navigation: {
				nextEl: ".swiper-button-next",
				prevEl: ".swiper-button-prev",
			},
		});
		var SwiperGaleria = new Swiper(".galerias", {
			loop: true,
			slidesPerView: 4,
			spaceBetween: 10,
			breakpoints: {
				480: {
					slidesPerView: 2,
					spaceBetween: 15,
				},
				1366: {
					slidesPerView: 3,
					spaceBetween: 10,
				},
			},
			navigation: {
				nextEl: ".swiper-button-next",
				prevEl: ".swiper-button-prev",
			},
		});
		var SwiperDif = new Swiper(".diferenciais", {
			loop: true,
			slidesPerView: 1,
			navigation: {
				nextEl: ".swiper-button-next",
				prevEl: ".swiper-button-prev",
			},
		});
	});

	/*
	 * Animation on scroll
	 */
	window.addEventListener("load", () => {
		AOS.init({
			duration: 1000,
			easing: "ease-in-out",
			once: true,
			mirror: false,
		});
	});

	/*
	 * Padding scroll
	 */
	const navigationHeight = document.querySelector(".fixed-top").offsetHeight;

	document.documentElement.style.setProperty(
		"--scroll-padding",
		navigationHeight - 1 + "px"
	);

	// FAQ Dropdown
	document.querySelectorAll(".faq-question").forEach((button) => {
		button.addEventListener("click", () => {
			const answer = button.nextElementSibling;

			answer.style.display =
				answer.style.display === "block" ? "none" : "block";
		});
	});
	
	
	//
	document.addEventListener("DOMContentLoaded", () => {
		let mapaTags = document.querySelectorAll('.freeHtmlMapright a');

		mapaTags.forEach(tag => {
			if (tag.innerText === "HTML5 Maps for WordPress") {
				tag.remove();
			}
		});
	});


	
})();
