document.addEventListener("DOMContentLoaded",(()=>{document.querySelectorAll(".ag-rtl-wrapper").forEach((e=>{const t=e.querySelector(".ag-rtl");let n=t.textContent.trim();e.addEventListener("click",(l=>{l.preventDefault(),"English"===n?(n="Arabic (RTL)",document.documentElement.setAttribute("dir","rtl"),document.body.classList.add("ag-is-rtl")):(n="English",document.documentElement.setAttribute("dir","ltr"),document.body.classList.remove("ag-is-rtl")),t.textContent=n,e.style.transform="scale(0.95)",setTimeout((()=>e.style.transform=""),100)}))})),document.querySelectorAll(".ag-theme-toggle").forEach((e=>{e.addEventListener("click",(t=>{t.preventDefault(),e.style.transform="rotate(360deg) scale(1.2)",setTimeout((()=>{e.style.transform=""}),500)}))})),document.querySelectorAll(".ag-mobile-toggle").forEach((e=>{e.addEventListener("click",(t=>{t.preventDefault();const n=e.closest(".ag-mega-menu-header");n.classList.toggle("mobile-menu-open");const l=e.querySelector("svg");n.classList.contains("mobile-menu-open")?l.innerHTML='<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>':l.innerHTML='<line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="18" x2="21" y2="18"/>'}))}));const e=document.querySelectorAll('.ag-mega-menu-header[data-sticky="true"]');e.length>0&&window.addEventListener("scroll",(()=>{e.forEach((e=>{const t=parseInt(e.getAttribute("data-sticky-offset")||"0",10);window.scrollY>t?e.classList.add("ag-is-sticky"):e.classList.remove("ag-is-sticky")}))}))}));