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,CAAC,GAAGP,oEAAU,CAAC,CAAC;;MAErC;MACA;MACA,IAAIK,KAAK,KAAK,SAAS,EAAE;QACxB;MACD;MACA;MACAR,UAAU,CAAC,MAAM;QAChBW,oCAAoC,CAACD,OAAO,CAAC;MAC9C,CAAC,EAAE,GAAG,CAAC;MACPE,MAAM,CAACC,gBAAgB,CACtB,QAAQ,EACRzB,sDAAQ,CAAC,MAAM;QACduB,oCAAoC,CAACD,OAAO,CAAC;MAC9C,CAAC,EAAE,GAAG,CACP,CAAC;IACF;EACD;AACD,CAAC,CAAC;AAEF,MAAMC,oCAAoC,GAAID,OAA4B,IAAK;EAC9E,MAAMI,WAAW,GAAGJ,OAAO,EAAEK,aAAa,CACzC,+CACD,CAAuB;EACvB,MAAMC,MAAM,GAAGN,OAAO,EAAEO,OAAO,CAAC,sBAAsB,CAAuB;EAC7E,IAAI,CAACD,MAAM,IAAI,CAACF,WAAW,EAAE;IAC5B;EACD;EAEA,MAAMI,OAAO,GAAGF,MAAM,CAACG,qBAAqB,CAAC,CAAC;EAC9C,MAAMC,YAAY,GAAGN,WAAW,CAACK,qBAAqB,CAAC,CAAC;EAExD,MAAME,IAAI,GAAG,CAACH,OAAO,CAACG,IAAI,GAAG,CAACT,MAAM,CAACU,UAAU,GAAGF,YAAY,CAACZ,KAAK,IAAI,CAAC;EACzEM,WAAW,CAACS,KAAK,CAACF,IAAI,GAAG,GAAGA,IAAI,IAAI;AACrC,CAAC,C","sources":["webpack://ncmaz-fse-core/./src/utils/utils.ts","webpack://ncmaz-fse-core/external module \"@wordpress/interactivity\"","webpack://ncmaz-fse-core/webpack/bootstrap","webpack://ncmaz-fse-core/webpack/runtime/define property getters","webpack://ncmaz-fse-core/webpack/runtime/hasOwnProperty shorthand","webpack://ncmaz-fse-core/webpack/runtime/make namespace object","webpack://ncmaz-fse-core/./src/mega-menu-block/view.ts"],"sourcesContent":["// Make a debounce typescript function\nexport function debounce(func: Function, wait: number, immediate = false) {\n\tlet timeout: any;\n\treturn function (this: any) {\n\t\tconst context = this;\n\t\tconst args = arguments;\n\t\tconst later = function () {\n\t\t\ttimeout = null;\n\t\t\tif (!immediate) func.apply(context, args);\n\t\t};\n\t\tconst callNow = immediate && !timeout;\n\t\tclearTimeout(timeout);\n\t\ttimeout = setTimeout(later, wait);\n\t\tif (callNow) func.apply(context, args);\n\t};\n}\n","module.exports = __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { store, getContext, getElement } from \"@wordpress/interactivity\";\nimport { debounce } from \"../utils/utils\";\ninterface TState {}\n\ninterface TContext {\n\twidth: \"full\" | \"wide\" | \"content\";\n}\n\nconst {} = store(\"ncmfse/mega-menu\", {\n\tstate: {} as TState,\n\tactions: {},\n\tcallbacks: {\n\t\tinitCallbacks() {\n\t\t\tconst context = getContext();\n\t\t\tconst { width } = context;\n\t\t\tconst { ref: menuRef } = getElement();\n\n\t\t\t// Do not update the position of the mega menu if the width is set to \"content\".\n\t\t\t// if break the layout of the menu, so we need to custom with css to fix it.\n\t\t\tif (width === \"content\") {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Update the position of the mega menu to center the window. This is necessary for wide and full-width menus.\n\t\t\tsetTimeout(() => {\n\t\t\t\tupdatePositionMegaMenuToCenterWindow(menuRef);\n\t\t\t}, 100);\n\t\t\twindow.addEventListener(\n\t\t\t\t\"resize\",\n\t\t\t\tdebounce(() => {\n\t\t\t\t\tupdatePositionMegaMenuToCenterWindow(menuRef);\n\t\t\t\t}, 500),\n\t\t\t);\n\t\t},\n\t},\n});\n\nconst updatePositionMegaMenuToCenterWindow = (menuRef?: HTMLElement | null) => {\n\tconst megaMenuRef = menuRef?.querySelector(\n\t\t\".wp-block-outermost-mega-menu__menu-container\",\n\t) as HTMLElement | null;\n\tconst navRef = menuRef?.closest(\".wp-block-navigation\") as HTMLElement | null;\n\tif (!navRef || !megaMenuRef) {\n\t\treturn;\n\t}\n\n\tconst navRect = navRef.getBoundingClientRect();\n\tconst megaMenuRect = megaMenuRef.getBoundingClientRect();\n\n\tconst left = -navRect.left + (window.innerWidth - megaMenuRect.width) / 2;\n\tmegaMenuRef.style.left = `${left}px`;\n};\n"],"names":["debounce","func","wait","immediate","timeout","context","args","arguments","later","apply","callNow","clearTimeout","setTimeout","store","getContext","getElement","state","actions","callbacks","initCallbacks","width","ref","menuRef","updatePositionMegaMenuToCenterWindow","window","addEventListener","megaMenuRef","querySelector","navRef","closest","navRect","getBoundingClientRect","megaMenuRect","left","innerWidth","style"],"sourceRoot":""}