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AE,EACxC,EAAY,IAAU,EAAI,EAAO,OAAS,EAAI,EAAQ,EACtD,EAAW,EAAO,GACxB,KAAK,eAAe,EAAU,CAAM,EACpC,EAAS,MAAM,CACjB,CAEA,mBAAmB,EAAO,EAAQ,CAChC,GAAI,CAAC,EAAO,OAAQ,OACpB,KAAM,GAAQ,SAAS,EAAM,QAAQ,MAAO,EAAE,EACxC,EAAY,IAAU,EAAO,OAAS,EAAI,EAAI,EAAQ,EACtD,EAAW,EAAO,GACxB,KAAK,eAAe,EAAU,CAAM,EACpC,EAAS,MAAM,CACjB,CAEA,oBAAoB,EAAQ,CAC1B,GAAI,CAAC,EAAO,OAAQ,OACpB,KAAM,GAAW,EAAO,GACxB,KAAK,eAAe,EAAU,CAAM,EACpC,EAAS,MAAM,CACjB,CAEA,mBAAmB,EAAQ,CACzB,GAAI,CAAC,EAAO,OAAQ,OACpB,KAAM,GAAW,EAAO,EAAO,OAAS,GACxC,KAAK,eAAe,EAAU,CAAM,EACpC,EAAS,MAAM,CACjB,CAEA,eAAe,EAAU,EAAQ,CAC/B,EAAO,QAAQ,GAAM,EAAG,aAAa,WAAY,EAAE,CAAC,EACpD,EAAS,gBAAgB,UAAU,CACrC,CACF,CAEA,QAAe,C","file":"scripts/542.827d0fa00d8c2a0f2abb.js","sourcesContent":["import { Component } from '@verndale/core';\n\nclass Module extends Component {\n setupDefaults() {\n this.dom = {\n $menuExpandTrigger: this.el._$('.header__menu-trigger--expand'),\n $menuCollapseTrigger: this.el._$('.header__menu-trigger--collapse'),\n $subMenuTriggers: this.el._$$('.header__nav-item--has-sub-menu .header__nav-link'),\n $navItemsWithSubMenu: this.el._$$('.header__nav-item--has-sub-menu'),\n $navLinks: this.el._$$('.header__nav-link'),\n $subNavLinks: this.el._$$('.header__sub-nav-link'),\n };\n\n this.expandMenuClass = 'header--menu-expanded';\n this.subNavExpandMenuClass = 'header__nav-item--expanded';\n this.subNavExpandedClass = 'header__nav-item--hovered';\n this.keyCode = Object.freeze({\n TAB: 9,\n RETURN: 13,\n ESC: 27,\n SPACE: 32,\n PAGEUP: 33,\n PAGEDOWN: 34,\n END: 35,\n HOME: 36,\n LEFT: 37,\n UP: 38,\n RIGHT: 39,\n DOWN: 40\n });\n\n this.fillMobileCta();\n this.setup();\n }\n\n addListeners() {\n this.dom.$menuExpandTrigger._on('click', this.expandMenu.bind(this));\n this.dom.$menuCollapseTrigger._on('click', this.collapseMenu.bind(this));\n this.dom.$subMenuTriggers._on('click', this.handleSubMenuTriggersClick.bind(this));\n this.dom.$navItemsWithSubMenu._on('mouseenter', this.handleNavItemHover.bind(this, true));\n this.dom.$navItemsWithSubMenu._on('mouseleave', this.handleNavItemHover.bind(this, false));\n this.dom.$navLinks._on('keydown', this.handleNavLinkKeyDown.bind(this));\n this.dom.$subNavLinks._on('keydown', this.handleSubNavLinkKeyDown.bind(this));\n }\n\n fillMobileCta() {\n const panel = document.querySelector(\".header__nav-panel\");\n const cta = document.querySelector(\".header__cta\");\n const clone = cta.cloneNode(true);\n clone.classList.add(\"header__cta--mobile\");\n\n panel.append(clone);\n }\n\n setup() {\n this.dom.$navLinks[0]?.removeAttribute?.('tabindex');\n this.dom.$navLinks.forEach((el, i) => { el.dataset.index = i });\n this.dom.$navItemsWithSubMenu.forEach(el => {\n const $subNavItems = el._$$('.header__sub-nav-link');\n $subNavItems.forEach((subLink, i) => { subLink.dataset.index = i });\n })\n }\n\n expandMenu() {\n this.el.classList.add(this.expandMenuClass);\n }\n\n collapseMenu() {\n this.el.classList.remove(this.expandMenuClass);\n }\n\n expandSubNav($nav) {\n const $link = $nav._$('.header__nav-link');\n $link.setAttribute('aria-expanded', 'true');\n $nav.classList.add(this.subNavExpandedClass);\n }\n\n collapseSubNav($nav) {\n const $link = $nav._$('.header__nav-link');\n $link.setAttribute('aria-expanded', 'false');\n $nav.classList.remove(this.subNavExpandedClass);\n }\n\n handleSubMenuTriggersClick(e) {\n const item = e.target.closest('.header__nav-item');\n item.classList.toggle(this.subNavExpandMenuClass);\n }\n\n handleNavItemHover(hovered, e) {\n if (hovered) {\n this.expandSubNav(e.target);\n } else {\n this.collapseSubNav(e.target);\n }\n }\n\n handleNavLinkKeyDown(e) {\n const $item = e.target.closest('.header__nav-item');\n const $subNavItems = $item._$$('.header__sub-nav-link');\n\n switch (e.keyCode) {\n case this.keyCode.SPACE:\n case this.keyCode.RETURN:\n case this.keyCode.DOWN:\n this.expandSubNav($item);\n this.setFocusToFirstItem($subNavItems);\n break;\n\n case this.keyCode.LEFT:\n this.setFocusToPreviousItem(e.target, this.dom.$navLinks);\n break;\n\n case this.keyCode.RIGHT:\n this.setFocusToNextItem(e.target, this.dom.$navLinks);\n break;\n\n case this.keyCode.UP:\n this.collapseSubNav($item);\n break;\n\n case this.keyCode.HOME:\n case this.keyCode.PAGEUP:\n this.setFocusToFirstItem(this.dom.$navLinks);\n break;\n\n case this.keyCode.END:\n case this.keyCode.PAGEDOWN:\n this.setFocusToLastItem(this.dom.$navLinks);\n break;\n\n case this.keyCode.TAB:\n this.collapseSubNav($item);\n break;\n\n case this.keyCode.ESC:\n this.collapseSubNav($item);\n break;\n\n default:\n break;\n }\n }\n\n handleSubNavLinkKeyDown(e) {\n const $item = e.target.closest('.header__nav-item');\n const $subNavItems = $item._$$('.header__sub-nav-link');\n\n switch (e.keyCode) {\n case this.keyCode.DOWN:\n this.setFocusToNextItem(e.target, $subNavItems);\n break;\n\n case this.keyCode.UP:\n this.setFocusToPreviousItem(e.target, $subNavItems);\n break;\n\n case this.keyCode.HOME:\n case this.keyCode.PAGEUP:\n this.setFocusToFirstItem($subNavItems);\n break;\n\n case this.keyCode.END:\n case this.keyCode.PAGEDOWN:\n this.setFocusToLastItem($subNavItems);\n break;\n\n case this.keyCode.TAB:\n this.collapseSubNav($item);\n break;\n\n case this.keyCode.ESC:\n this.collapseSubNav($item);\n this.setFocusToItem($item._$('.header__nav-link'), this.dom.$navLinks);\n break;\n\n default:\n break;\n }\n }\n\n setFocusToItem($item, $items) {\n if (!$items.length) return;\n const $current = $item;\n this.updateTabIndex($current, $items);\n $current.focus();\n }\n\n setFocusToPreviousItem($item, $items) {\n if (!$items.length) return;\n const index = parseInt($item.dataset.index, 10);\n const prevIndex = index === 0 ? $items.length - 1 : index - 1;\n const $current = $items[prevIndex];\n this.updateTabIndex($current, $items);\n $current.focus();\n }\n\n setFocusToNextItem($item, $items) {\n if (!$items.length) return;\n const index = parseInt($item.dataset.index, 10);\n const nextIndex = index === $items.length - 1 ? 0 : index + 1;\n const $current = $items[nextIndex];\n this.updateTabIndex($current, $items);\n $current.focus();\n }\n\n setFocusToFirstItem($items) {\n if (!$items.length) return;\n const $current = $items[0];\n this.updateTabIndex($current, $items);\n $current.focus();\n }\n\n setFocusToLastItem($items) {\n if (!$items.length) return;\n const $current = $items[$items.length - 1];\n this.updateTabIndex($current, $items);\n $current.focus();\n }\n\n updateTabIndex($current, $items) {\n $items.forEach(el => el.setAttribute('tabindex', -1));\n $current.removeAttribute('tabindex');\n }\n}\n\nexport default Module;\n"],"sourceRoot":""}