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YC,UAAWpG,EAAMoG,UAAWC,aAAcrG,EAAMqG,aAAcC,gBAAiBtG,EAAMsG,gBAAiBC,aAAcvG,EAAMuG,aAAcC,UAAWxG,EAAMwG,UAAWxF,YAAaA,EAAayF,UAAW,IAAM9F,GAAkB,KAAc,gBAAoB,IAAkB,CAAEoF,YAAa/F,EAAM0G,iBAAkBD,UAAW,IAAM9F,GAAkB,GAAQL,cAAeA,EAAeqG,WAAY3G,EAAM2G,WAAYC,cAAe5G,EAAM4G,cAAeC,mBAAoB7G,EAAM6G,mBAAoB9F,eAAgBA,EAAgB+F,aAAc,YACvgC7G,GAAa,gBAAoB,IAAK,CAAEmF,KAAMpF,EAAMwG,UAAW3C,UAAW,iBAAkB,iBAAkB,gFAAkF3C,EAAE,mBAAqB,C","sources":["webpack:///./assets/moncler/src/components/menu/AccountMenuDesktop.tsx"],"sourcesContent":["import { menu } from '@utils/constants';\nimport useBreakpoint from '@utils/useBreakpoint';\nimport classNames from 'classnames';\nimport FocusTrap from 'focus-trap-react';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport customEventBus from '@common/scripts/libs/eventBus';\nimport AccountMenuGuest from './AccountMenuGuest';\nimport AccountMenuLogged from './AccountMenuLogged';\nimport { Provider } from 'react-redux';\nimport { configureSearchStore } from '@common/state';\nlet previuslyScrolled = false;\nconst store = configureSearchStore();\nconst AccountMenuDesktop = (props) => {\n const [loggedIn, setLoggedIn] = useState(window.loggedin);\n const [wishlistCount, setWishlistCount] = useState(window.wishlistIds.length);\n const [overlayVisible, setOverlayVisible] = useState(false);\n const [animateWishlistIcon, setAnimateWishlistIcon] = useState(false);\n const [forceReload, setForceReload] = useState(false);\n const [profileName, setProfileName] = useState(props.profileName);\n const { t } = useTranslation();\n const breakpoint = useBreakpoint();\n const wrapper = useRef(null);\n const mouseOutTimeout = useRef();\n const mouseInTimeout = useRef();\n useEffect(() => {\n const body = document.querySelector('body');\n let footer = document.querySelector('.footer');\n if (window.innerWidth >= window.mqObj.md && footer) {\n body.style.setProperty('--footer-height', `${footer.clientHeight}px`);\n }\n });\n const handlePreviouslyScrolled = () => {\n var _a;\n let header = document.querySelector('header');\n if (header === null || header === void 0 ? void 0 : header.classList.contains('scrolled')) {\n previuslyScrolled = true;\n }\n else {\n previuslyScrolled = false;\n (_a = document.querySelector('header')) === null || _a === void 0 ? void 0 : _a.classList.add('scrolled');\n }\n };\n const firstRender = useRef(true);\n useEffect(() => {\n var _a;\n const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;\n if (!firstRender.current) {\n window.sprChat && window.sprChat(overlayVisible ? 'disable' : 'enable');\n if (overlayVisible) {\n handlePreviouslyScrolled();\n }\n else if (!previuslyScrolled) {\n (_a = document.querySelector('header')) === null || _a === void 0 ? void 0 : _a.classList.remove('scrolled');\n }\n document.body.classList[overlayVisible ? 'add' : 'remove']('overlay');\n document.body.classList[overlayVisible ? 'add' : 'remove']('no-overflow');\n document.body.style[overlayVisible ? 'setProperty' : 'removeProperty']('--scrollbar-width', scrollBarWidth + 'px');\n if (!overlayVisible && forceReload) {\n window.location.reload();\n }\n }\n firstRender.current = false;\n }, [overlayVisible]);\n useEffect(() => {\n let animateTimeout;\n customEventBus.on('account:update', (data) => {\n let adding = false;\n if (data === null || data === void 0 ? void 0 : data.wishlistIds) {\n if (data.wishlistIds.length > window.wishlistIds.length) {\n // adding to wishlist\n adding = true;\n }\n if (breakpoint >= window.mqObj.md) {\n window.wishlistIds = data.wishlistIds;\n }\n setWishlistCount(data.wishlistIds.length);\n }\n else {\n // window.loggedin updated\n setLoggedIn(window.loggedin);\n if (data.firstName) {\n setProfileName(data.firstName);\n }\n }\n // >=1 wishlist products\n if (adding && breakpoint >= window.mqObj.md) {\n clearTimeout(animateTimeout);\n setAnimateWishlistIcon(true);\n animateTimeout = setTimeout(() => {\n setAnimateWishlistIcon(false);\n }, 1500);\n }\n });\n //center menu\n const selectedPage = document.querySelector('.section-menu-new-wrapper .section-menu-new li.selected');\n setTimeout(() => {\n selectedPage === null || selectedPage === void 0 ? void 0 : selectedPage.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });\n }, 1000);\n }, []);\n if (breakpoint < window.mqObj.md) {\n return React.createElement(React.Fragment, null);\n }\n return (React.createElement(Provider, { store: store },\n React.createElement(\"div\", { className: classNames('account-wrapper__item', { logged: loggedIn }) },\n React.createElement(\"div\", { className: classNames('account-menu', { 'animate-wishlist-add': animateWishlistIcon }), onMouseEnter: () => {\n clearTimeout(mouseOutTimeout.current);\n mouseInTimeout.current = setTimeout(() => {\n setOverlayVisible(true);\n }, menu.overlay.timeout);\n }, onMouseLeave: (e) => {\n let wrapperRects = wrapper.current.getBoundingClientRect();\n // safety padding, added a standard 20 as fallback\n let padding = parseInt(window.getComputedStyle(wrapper.current).getPropertyValue('padding-left')) || 20;\n if (e.clientX < wrapperRects.x + padding ||\n e.clientX > wrapperRects.right - padding ||\n e.clientY < wrapperRects.y + padding ||\n e.clientY > wrapperRects.bottom - padding) {\n clearTimeout(mouseInTimeout.current);\n mouseOutTimeout.current = setTimeout(() => {\n setOverlayVisible(false);\n }, menu.overlay.timeout);\n }\n } },\n React.createElement(\"button\", { type: \"button\", \"data-href\": loggedIn ? props.myaccountUrl : window.loginUrl, className: classNames('account-cta', { 'with-wishlisticon': wishlistCount > 0 }), \"aria-haspopup\": \"true\", id: \"accountButton\", \"data-analytics\": `{\"event\": \"menu\", \"eventCategory\": \"account menu\", \"eventAction\": ${loggedIn ? '\"my moncler\"' : '\"login\"'}}`, onClick: () => {\n if (document.body.classList.contains('keyboard-mode') || document.documentElement.getAttribute('data-whatintent') == 'touch') {\n setOverlayVisible(true);\n }\n else {\n window.location.href = loggedIn ? props.myaccountUrl : window.loginUrl;\n }\n } },\n React.createElement(\"span\", { className: loggedIn ? 'icon--account-logged' : 'icon--account' }),\n React.createElement(\"span\", { className: \"account-cta__label\" }, t(loggedIn ? 'label.mymoncler' : 'account.login'))),\n React.createElement(FocusTrap, { focusTrapOptions: {\n onDeactivate: () => setOverlayVisible(false),\n fallbackFocus: () => wrapper.current,\n initialFocus: () => wrapper.current,\n clickOutsideDeactivates: true,\n }, active: overlayVisible },\n React.createElement(\"div\", { ref: wrapper, className: classNames(loggedIn ? 'account-dropdown account-dropdown-logged-new' : 'account-dropdown', { visible: overlayVisible }), \"aria-modal\": overlayVisible, role: \"dialog\", tabIndex: -1 }, loggedIn ? (React.createElement(AccountMenuLogged, { wishlistUrl: props.wishlistLoggedUrl, myaccountUrl: props.myaccountUrl, wishlistCount: wishlistCount, feedUrl: props.feedUrl, profileUrl: props.profileUrl, detailsUrl: props.detailsUrl, ordersUrl: props.ordersUrl, aftercareUrl: props.aftercareUrl, appointmentsUrl: props.appointmentsUrl, nftWalletUrl: props.nftWalletUrl, logoutUrl: props.logoutUrl, profileName: profileName, closeMenu: () => setOverlayVisible(false) })) : (React.createElement(AccountMenuGuest, { wishlistUrl: props.wishlistGuestUrl, closeMenu: () => setOverlayVisible(false), wishlistCount: wishlistCount, rememberme: props.rememberme, privacypolicy: props.privacypolicy, forgotpasswordform: props.forgotpasswordform, setForceReload: setForceReload, analyticsKey: \"menu\" }))))),\n loggedIn && (React.createElement(\"a\", { href: props.logoutUrl, className: \"account-logout\", \"data-analytics\": '{\"event\": \"menu\", \"eventCategory\": \"account menu\", \"eventAction\": \"log out\"}' }, t('label.signout'))))));\n};\nexport default AccountMenuDesktop;\n"],"names":["previuslyScrolled","store","props","loggedIn","setLoggedIn","useState","window","loggedin","wishlistCount","setWishlistCount","wishlistIds","length","overlayVisible","setOverlayVisible","animateWishlistIcon","setAnimateWishlistIcon","forceReload","setForceReload","profileName","setProfileName","t","breakpoint","wrapper","useRef","mouseOutTimeout","mouseInTimeout","useEffect","body","document","querySelector","footer","innerWidth","mqObj","md","style","setProperty","clientHeight","firstRender","_a","scrollBarWidth","documentElement","clientWidth","current","sprChat","header","classList","contains","add","handlePreviouslyScrolled","remove","location","reload","animateTimeout","data","adding","firstName","clearTimeout","setTimeout","selectedPage","scrollIntoView","behavior","block","inline","className","logged","onMouseEnter","onMouseLeave","e","wrapperRects","getBoundingClientRect","padding","parseInt","getComputedStyle","getPropertyValue","clientX","x","right","clientY","y","bottom","type","myaccountUrl","loginUrl","id","onClick","getAttribute","href","focusTrapOptions","onDeactivate","fallbackFocus","initialFocus","clickOutsideDeactivates","active","ref","visible","role","tabIndex","wishlistUrl","wishlistLoggedUrl","feedUrl","profileUrl","detailsUrl","ordersUrl","aftercareUrl","appointmentsUrl","nftWalletUrl","logoutUrl","closeMenu","wishlistGuestUrl","rememberme","privacypolicy","forgotpasswordform","analyticsKey"],"sourceRoot":""}