var module_227384166238=void function(){"use strict";function initMegaMenu(root){if("true"===root.dataset.bncrmaInitialized)return;root.dataset.bncrmaInitialized="true";const items=Array.from(root.querySelectorAll("[data-bncrma-item]")),mobileNav=root.nextElementSibling&&root.nextElementSibling.matches("[data-bncrma-mobile]")?root.nextElementSibling:null,finePointer=window.matchMedia("(hover: hover) and (pointer: fine)"),mobileViewport=window.matchMedia("(max-width: 991px)");let openItem=null,openMethod=null;function getToggle(item){return item.querySelector(":scope > .bncr-megamenus-access__top-control [data-bncrma-toggle]")}function getSubmenu(item){return item.querySelector(":scope > [data-bncrma-submenu]")}function findPanel(submenu,panelId){return submenu&&panelId?submenu.querySelector('[id="'+panelId.replace(/"/g,'\\"')+'"]'):null}function closeItem(item,options){const settings=options||{},toggle=getToggle(item),submenu=getSubmenu(item);toggle&&submenu&&(window.clearTimeout(item.bncrmaOpenTimer),window.clearTimeout(item.bncrmaCloseTimer),toggle.setAttribute("aria-expanded","false"),submenu.hidden=!0,item.classList.remove("bncr-megamenus-access__item--open"),openItem===item&&(openItem=null,openMethod=null),settings.restoreFocus&&toggle.focus())}function closeAll(exceptItem){items.forEach(function(item){item!==exceptItem&&closeItem(item)})}function openMenuItem(item,method){const toggle=getToggle(item),submenu=getSubmenu(item);toggle&&submenu&&(window.clearTimeout(item.bncrmaOpenTimer),window.clearTimeout(item.bncrmaCloseTimer),closeAll(item),toggle.setAttribute("aria-expanded","true"),submenu.hidden=!1,item.classList.add("bncr-megamenus-access__item--open"),openItem=item,openMethod=method||"programmatic")}function activateDisclosure(disclosure,options){const settings=options||{},group=disclosure.closest("[data-bncrma-disclosure-group]"),submenu=disclosure.closest("[data-bncrma-submenu]");if(!group||!submenu)return;const disclosures=Array.from(group.querySelectorAll("[data-bncrma-disclosure]"));findPanel(submenu,disclosure.getAttribute("aria-controls"))&&(disclosures.forEach(function(currentDisclosure){const currentPanel=findPanel(submenu,currentDisclosure.getAttribute("aria-controls")),expanded=currentDisclosure===disclosure;currentDisclosure.setAttribute("aria-expanded",String(expanded)),currentPanel&&(currentPanel.hidden=!expanded)}),settings.focus&&disclosure.focus())}function closeMobileCategory(button,restoreFocus){const panel=button?document.getElementById(button.getAttribute("aria-controls")):null;button&&panel&&(button.setAttribute("aria-expanded","false"),panel.hidden=!0,restoreFocus&&button.focus())}function closeMobileSection(button,restoreFocus){const submenu=button?document.getElementById(button.getAttribute("aria-controls")):null;button&&submenu&&(submenu.querySelectorAll('[data-bncrma-mobile-level-two][aria-expanded="true"]').forEach(function(categoryButton){closeMobileCategory(categoryButton)}),button.setAttribute("aria-expanded","false"),submenu.hidden=!0,restoreFocus&&button.focus())}function closeMobileDrawer(restoreFocus){mobileNav&&(mobileNav.querySelectorAll('[data-bncrma-mobile-level-one][aria-expanded="true"]').forEach(function(sectionButton){closeMobileSection(sectionButton)}),mobileNav.hidden=!0,document.body.classList.remove("bncrma-mobile-menu-open"),mobileToggle&&(mobileToggle.setAttribute("aria-expanded","false"),mobileToggle.setAttribute("aria-label","Abrir menú principal"),restoreFocus&&mobileToggle.focus()))}items.forEach(function(item){const toggle=getToggle(item),submenu=getSubmenu(item);toggle&&submenu&&(toggle.addEventListener("click",function(){!function(item){const toggle=getToggle(item);toggle&&("true"===toggle.getAttribute("aria-expanded")?closeItem(item):openMenuItem(item,"button"))}(item)}),item.addEventListener("pointerenter",function(){finePointer.matches&&(window.clearTimeout(item.bncrmaCloseTimer),item.bncrmaOpenTimer=window.setTimeout(function(){openMenuItem(item,"hover")},140))}),item.addEventListener("pointerleave",function(){finePointer.matches&&(window.clearTimeout(item.bncrmaOpenTimer),item.bncrmaCloseTimer=window.setTimeout(function(){item.contains(document.activeElement)||closeItem(item)},260))}),item.addEventListener("focusout",function(){window.setTimeout(function(){item.contains(document.activeElement)||item.matches(":hover")||closeItem(item)},0)}),submenu.querySelectorAll("[data-bncrma-disclosure]").forEach(function(disclosure){let hoverTimer;disclosure.addEventListener("click",function(){activateDisclosure(disclosure)}),disclosure.addEventListener("pointerenter",function(){finePointer.matches&&(window.clearTimeout(hoverTimer),hoverTimer=window.setTimeout(function(){activateDisclosure(disclosure)},120))}),disclosure.addEventListener("pointerleave",function(){window.clearTimeout(hoverTimer)}),disclosure.addEventListener("keydown",function(event){const group=disclosure.closest("[data-bncrma-disclosure-group]"),disclosures=Array.from(group.querySelectorAll("[data-bncrma-disclosure]")),currentIndex=disclosures.indexOf(disclosure);let nextIndex=null;"ArrowDown"===event.key&&(nextIndex=(currentIndex+1)%disclosures.length),"ArrowUp"===event.key&&(nextIndex=(currentIndex-1+disclosures.length)%disclosures.length),"Home"===event.key&&(nextIndex=0),"End"===event.key&&(nextIndex=disclosures.length-1),null!==nextIndex&&(event.preventDefault(),disclosures[nextIndex].focus())})}))}),mobileNav&&(mobileNav.querySelectorAll("[data-bncrma-mobile-level-one]").forEach(function(sectionButton){sectionButton.addEventListener("click",function(){const submenu=document.getElementById(sectionButton.getAttribute("aria-controls")),willOpen="true"!==sectionButton.getAttribute("aria-expanded");mobileNav.querySelectorAll('[data-bncrma-mobile-level-one][aria-expanded="true"]').forEach(function(otherButton){otherButton!==sectionButton&&closeMobileSection(otherButton)}),sectionButton.setAttribute("aria-expanded",String(willOpen)),submenu&&(submenu.hidden=!willOpen)})}),mobileNav.querySelectorAll("[data-bncrma-mobile-level-two]").forEach(function(categoryButton){categoryButton.addEventListener("click",function(){const panel=document.getElementById(categoryButton.getAttribute("aria-controls")),submenu=categoryButton.closest("[data-bncrma-mobile-submenu]"),willOpen="true"!==categoryButton.getAttribute("aria-expanded");submenu.querySelectorAll('[data-bncrma-mobile-level-two][aria-expanded="true"]').forEach(function(otherButton){otherButton!==categoryButton&&closeMobileCategory(otherButton)}),categoryButton.setAttribute("aria-expanded",String(willOpen)),panel&&(panel.hidden=!willOpen)})}),mobileNav.addEventListener("click",function(event){event.target.closest("a[href]")&&closeMobileDrawer()})),document.addEventListener("keydown",function(event){if("Tab"===event.key&&mobileNav&&!mobileNav.hidden){const focusable=[mobileToggle].concat(Array.from(mobileNav.querySelectorAll('a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])'))).filter(Boolean).filter(function(element){return element.getClientRects().length>0});if(!focusable.length)return;const firstFocusable=focusable[0],lastFocusable=focusable[focusable.length-1];return void(event.shiftKey&&document.activeElement===firstFocusable?(event.preventDefault(),lastFocusable.focus()):event.shiftKey||document.activeElement!==lastFocusable||(event.preventDefault(),firstFocusable.focus()))}if("Escape"!==event.key)return;const openMobileCategory=mobileNav?mobileNav.querySelector('[data-bncrma-mobile-level-two][aria-expanded="true"]'):null;if(openMobileCategory)return event.preventDefault(),void closeMobileCategory(openMobileCategory,!0);const openMobileSection=mobileNav?mobileNav.querySelector('[data-bncrma-mobile-level-one][aria-expanded="true"]'):null;if(openMobileSection)return event.preventDefault(),void closeMobileSection(openMobileSection,!0);if(mobileNav&&!mobileNav.hidden)return event.preventDefault(),void closeMobileDrawer(!0);if(!openItem)return;event.preventDefault();const restoreFocus="hover"!==openMethod||root.contains(document.activeElement);closeItem(openItem,{restoreFocus:restoreFocus})}),document.addEventListener("pointerdown",function(event){openItem&&!root.contains(event.target)&&closeItem(openItem)});const containingHeader=root.closest(".header"),headerToggle=containingHeader?containingHeader.querySelector(".toggle"):null,standaloneToggle=root.previousElementSibling&&root.previousElementSibling.matches("[data-bncrma-mobile-trigger]")?root.previousElementSibling:null,mobileToggle=headerToggle||standaloneToggle;function resetResponsiveState(){root.classList.remove("bncr-megamenus-access--mobile-open"),mobileNav&&closeMobileDrawer(),closeAll(),mobileToggle&&(mobileToggle.setAttribute("aria-expanded","false"),mobileToggle.setAttribute("aria-label","Abrir menú principal"))}mobileToggle&&(mobileToggle.setAttribute("aria-controls",mobileNav?mobileNav.id:root.querySelector(".bncr-megamenus-access__list").id),mobileToggle.setAttribute("aria-expanded","false"),mobileToggle.addEventListener("click",function(event){event.preventDefault();const willOpen=mobileNav?mobileNav.hidden:!root.classList.contains("bncr-megamenus-access--mobile-open");if(mobileNav?(mobileNav.hidden=!willOpen,document.body.classList.toggle("bncrma-mobile-menu-open",willOpen)):root.classList.toggle("bncr-megamenus-access--mobile-open",willOpen),mobileToggle.setAttribute("aria-expanded",String(willOpen)),mobileToggle.setAttribute("aria-label",willOpen?"Cerrar menú principal":"Abrir menú principal"),willOpen){const firstControl=mobileNav?mobileNav.querySelector("button, a[href]"):root.querySelector(".bncr-megamenus-access__top-link, .bncr-megamenus-access__top-toggle");firstControl&&firstControl.focus()}else mobileNav?closeMobileDrawer():closeAll()})),"function"==typeof mobileViewport.addEventListener?mobileViewport.addEventListener("change",resetResponsiveState):"function"==typeof mobileViewport.addListener&&mobileViewport.addListener(resetResponsiveState)}function initAll(){document.querySelectorAll("[data-bncrma]").forEach(initMegaMenu)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",initAll):initAll()}(); //# sourceURL=https://48395929.fs1.hubspotusercontent-na1.net/hubfs/48395929/hub_generated/module_assets/1/227384166238/1795010728472/module_bncr-megamenus-access.js