document.addEventListener('DOMContentLoaded', function() {
    var e = document.getElementById("view-more-btn");
	e && e.addEventListener("click", function(e) {
		e.preventDefault();
		var n = document.getElementById("view-more-col");
		n && (n.style.display = "none"), document.querySelectorAll(".hidden-ep").forEach(function(e) {
			e.classList.remove("d-none");
		});
	});
	const toggleBtn = document.getElementById('kategori-toggle');
	const wrapper = document.getElementById('kategori-wrapper');
	if (toggleBtn && wrapper) {
		toggleBtn.addEventListener('click', function() {
			wrapper.classList.toggle('is-expanded');
			toggleBtn.classList.toggle('is-expanded');
		});
	}
	const copyButtons = document.querySelectorAll('.copy-link-button');
    const toast = document.getElementById('copy-toast');
    let toastTimer; 
    if (copyButtons.length > 0 && toast) {
        copyButtons.forEach(function(button) {
            button.addEventListener('click', function(e) {
                e.preventDefault(); 
                const permalink = this.dataset.permalink; 
                if (navigator.clipboard) {
                    navigator.clipboard.writeText(permalink).then(function() {
                        toast.classList.add('show');
                        clearTimeout(toastTimer);
                        toastTimer = setTimeout(function() {
                            toast.classList.remove('show');
                        }, 3000); 
                    }).catch(function(err) {
                        console.error('Gagal menyalin link: ', err);
                    });
                } else {
                    alert('Browser Anda tidak mendukung fitur salin link.');
                }
            });
        });
    }
});
function hideBanner(bannerId) {
    var banner = document.getElementById(bannerId);
    if (banner) {
        banner.style.display = 'none';
    }
}