{"version":3,"file":"MegaMenu.min.js","sources":["MegaMenu.js"],"sourcesContent":["(function (w) {\n const assetId = '~/theme/v1/Views/Menu/MegaMenu.min.js';\n\n if (!w.umwAssets || !w.umwAssets[assetId]) {\n console.error('No context found for ' + assetId);\n return;\n }\n\n w.umwAssets[assetId].forEach(ctx => {\n const prefixClass = \"uc203-full-width\";\n const classes = {\n control: \"js-\" + prefixClass,\n lvl1Item: \"js-\" + prefixClass + \"-lvl1-item\",\n popup: prefixClass + \"-popup\",\n lvl1ItemHovered: prefixClass + \"-lvl1-item-hovered\",\n };\n\n const desktopHeaderContainer = document.querySelector('.site-header-desktop');\n const control = document.querySelector(\".\" + classes.control);\n if (!control) return; // Exit if control is not found\n\n let hoverTimerId;\n\n // Using event delegation for mouseenter and mouseleave\n control.addEventListener(\"mouseenter\", handleMouseOver, true);\n control.addEventListener(\"mouseleave\", handleMouseOut, true);\n\n function handleMouseOver(e) {\n if (!e.target.matches(\".\" + classes.lvl1Item)) return;\n\n const beforeMegaMenuLvl1Mouseenter = new CustomEvent(\"megamenu:lvl1:beforemouseenter\");\n control.dispatchEvent(beforeMegaMenuLvl1Mouseenter);\n if (beforeMegaMenuLvl1Mouseenter.defaultPrevented) return;\n\n clearTimeout(hoverTimerId);\n hoverTimerId = setTimeout(() => applyHoverState(e.target), 250);\n }\n\n function handleMouseOut(e) {\n if (!e.target.matches(\".\" + classes.lvl1Item)) return;\n\n const beforeMegaMenuLvl1Mouseleave = new CustomEvent(\"megamenu:lvl1:beforemouseleave\");\n control.dispatchEvent(beforeMegaMenuLvl1Mouseleave);\n if (beforeMegaMenuLvl1Mouseleave.defaultPrevented) return;\n\n clearTimeout(hoverTimerId);\n hoverTimerId = setTimeout(removeHoverState, 250);\n }\n\n function applyHoverState(target) {\n control.querySelectorAll(\".\" + classes.lvl1Item).forEach(item => item.classList.remove(classes.lvl1ItemHovered));\n target.classList.add(classes.lvl1ItemHovered);\n adjustPopupIfNecessary(target);\n }\n\n function removeHoverState() {\n control.querySelectorAll(\".\" + classes.lvl1Item).forEach(item => item.classList.remove(classes.lvl1ItemHovered));\n document.body.classList.remove('uc203-hovered');\n }\n\n function adjustPopupIfNecessary(target) {\n if (!target.classList.contains('has-submenu')) {\n document.body.classList.remove('uc203-hovered');\n return;\n }\n\n const hoveredLevel1PopupContainer = target.querySelector('.' + classes.popup);\n const heightHeaderAndMegaMenu = desktopHeaderContainer.clientHeight + hoveredLevel1PopupContainer.clientHeight;\n if (heightHeaderAndMegaMenu > window.innerHeight) {\n hoveredLevel1PopupContainer.classList.add('scrollable');\n hoveredLevel1PopupContainer.style.height = `calc(${window.innerHeight * .9 - desktopHeaderContainer.clientHeight}px)`;\n }\n document.body.classList.add('uc203-hovered');\n }\n });\n})(window);"],"names":["w","assetId","umwAssets","forEach","ctx","prefixClass","classes","control","lvl1Item","popup","lvl1ItemHovered","desktopHeaderContainer","document","querySelector","let","hoverTimerId","removeHoverState","querySelectorAll","item","classList","remove","body","addEventListener","e","beforeMegaMenuLvl1Mouseenter","target","matches","CustomEvent","dispatchEvent","defaultPrevented","clearTimeout","setTimeout","applyHoverState","add","contains","hoveredLevel1PopupContainer","clientHeight","window","innerHeight","style","height","beforeMegaMenuLvl1Mouseleave","console","error"],"mappings":"CAAA,SAAWA,GACP,IAAMC,EAAU,wCAEXD,EAAEE,WAAcF,EAAEE,UAAUD,GAKjCD,EAAEE,UAAUD,GAASE,QAAQC,IACzB,IAAMC,EAAc,mBACpB,MAAMC,EAAU,CACZC,QAAS,MAAQF,EACjBG,SAAU,MAAQH,EAAc,aAChCI,MAAOJ,EAAc,SACrBK,gBAAiBL,EAAc,sBAG7BM,EAAyBC,SAASC,cAAc,wBAChDN,EAAUK,SAASC,cAAc,IAAMP,EAAQC,SACrD,GAAKA,EAAL,CAEAO,IAAIC,EAkCJ,SAASC,IACLT,EAAQU,iBAAiB,IAAMX,EAAQE,UAAUL,QAAQe,GAAQA,EAAKC,UAAUC,OAAOd,EAAQI,kBAC/FE,SAASS,KAAK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