(()=>{function _toConsumableArray(r){return function(r){if(Array.isArray(r))return _arrayLikeToArray(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||function(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}Drupal.behaviors.siteLayout={attach:function(context){var HTML=document.documentElement,MENU_TOGGLE=context.querySelector('[data-js="menu-toggle"]');if(MENU_TOGGLE){var SITE_HEADER=context.querySelector('[data-js="site-header"]');if(SITE_HEADER){var SITE_HEADER_CONTENT=SITE_HEADER.querySelector(".site-header__content");if(SITE_HEADER_CONTENT){var SITE_HEADER_MENU_CONTENT=SITE_HEADER.querySelector(".site-header__menu-content");if(SITE_HEADER_MENU_CONTENT){var FOCUSABLE_SELECTORS='\n      a[href]:not([disabled]),\n      button:not([disabled]),\n      [tabindex]:not([tabindex="-1"])\n    ',focusableHeaderElements=_toConsumableArray(SITE_HEADER_CONTENT.querySelectorAll(FOCUSABLE_SELECTORS)),focusableMenuElements=_toConsumableArray(SITE_HEADER_MENU_CONTENT.querySelectorAll(FOCUSABLE_SELECTORS)),focusableElements=[].concat(_toConsumableArray(focusableHeaderElements),_toConsumableArray(focusableMenuElements)),firstFocusableElement=focusableElements[0],lastFocusableElement=focusableElements[focusableElements.length-1],closeMenu=function(){document.removeEventListener("keydown",handleKeyDown),window.dispatchEvent(new CustomEvent("main-menu:animate-out:start")),window.addEventListener("main-menu:animate-out:complete",_handleMainMenuAnimateOutComplete)};MENU_TOGGLE.addEventListener("click",function(){MENU_TOGGLE.setAttribute("disabled",!0),"false"===MENU_TOGGLE.getAttribute("aria-expanded")?(MENU_TOGGLE.setAttribute("aria-expanded",!0),SITE_HEADER.setAttribute("data-menu-opened",!0),SITE_HEADER_MENU_CONTENT.addEventListener("transitionend",_handleSiteHeaderMenuContentTransitionEnd),window.addEventListener("main-menu:animate-in:complete",_handleMainMenuAnimateInComplete)):closeMenu()});var _handleMainMenuAnimateInComplete=function(){MENU_TOGGLE.removeAttribute("disabled"),document.addEventListener("keydown",handleKeyDown),window.removeEventListener("main-menu:animate-in:complete",_handleMainMenuAnimateInComplete),focusableMenuElements[0].focus()},_handleMainMenuAnimateOutComplete=function(){HTML.style.overflow="auto",MENU_TOGGLE.removeAttribute("disabled"),MENU_TOGGLE.setAttribute("aria-expanded",!1),SITE_HEADER.removeAttribute("data-menu-opened"),window.removeEventListener("main-menu:animate-out:complete",_handleMainMenuAnimateOutComplete),document.activeElement=MENU_TOGGLE},_handleSiteHeaderMenuContentTransitionEnd=function(event){"transform"===event.propertyName&&(HTML.style.overflow="hidden",window.dispatchEvent(new CustomEvent("main-menu:animate-in:start")),SITE_HEADER_MENU_CONTENT.removeEventListener("transitionend",_handleSiteHeaderMenuContentTransitionEnd))},handleKeyDown=function(event){switch(event.key){case"Escape":closeMenu();break;case"Tab":if(0===focusableElements.length)return void event.preventDefault();event.shiftKey?document.activeElement===firstFocusableElement&&(lastFocusableElement.focus(),event.preventDefault()):document.activeElement===lastFocusableElement&&(firstFocusableElement.focus(),event.preventDefault())}}}}}}}}})();