/**
 * @copyright  (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */const elSearch=document.getElementById("comModulesSelectSearch"),elSearchContainer=document.getElementById("comModulesSelectSearchContainer"),elSearchHeader=document.getElementById("comModulesSelectTypeHeader"),elSearchResults=document.getElementById("comModulesSelectResultsContainer"),alertElement=document.querySelector(".modules-alert"),elCards=[].slice.call(document.querySelectorAll(".comModulesSelectCard"));if(elSearch&&elSearchContainer){elSearch.addEventListener("keyup",o=>{const e=o.target.value;let s=!1;typeof sessionStorage<"u"&&sessionStorage.setItem("Joomla.com_modules.new.search",e),elCards.forEach(t=>{if(t.classList.remove("d-none"),!e)return;const n=t.querySelector(".new-module-title"),c=t.querySelector(".card-body"),l=n?n.textContent:"",a=c?c.textContent:"";l&&!l.toLowerCase().includes(e.toLowerCase())&&a&&!a.toLowerCase().includes(e.toLowerCase())?t.classList.add("d-none"):s=!0}),s||!e?(alertElement.classList.add("d-none"),elSearchHeader.classList.remove("d-none"),elSearchResults.classList.remove("d-none")):(alertElement.classList.remove("d-none"),elSearchHeader.classList.add("d-none"),elSearchResults.classList.add("d-none"))}),elSearchContainer.classList.remove("d-none"),elSearch.focus();try{typeof sessionStorage<"u"&&(elSearch.value=sessionStorage.getItem("Joomla.com_modules.new.search")||"",elSearch.dispatchEvent(new KeyboardEvent("keyup")))}catch{}}
