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,EAAkBwC,WACpB,GAAIC,OAAOxC,aACTF,EAAQC,GACR2B,SACK,GAAIC,EAvFO,EAwFhBG,YAAW,KACTC,EAAYJ,EAAgB,EAAGC,EAAc,IAAI,GAChDA,OACE,CACL,IAAIa,EAAI7C,SAAS8C,cAAc,UAC/BD,EAAEE,aAAa,MAAOC,uBACtBH,EAAEI,OAAS,WACT/C,EAAQC,EACV,EACAH,SAASkD,KAAKjB,YAAYY,EAC5B,CAGN,EAMA7C,SAASmD,iBAAiB,UAAU,WAClCtD,EAA6B+C,OAAOQ,QAC/BtD,GACH8C,OAAOS,uBAAsB,WApGXC,QAqGFzD,EApGb+C,OAAOW,YAAcD,GAAetD,SAASkD,KAAKM,cAChDtF,EAAAA,EAAAA,IAAgB6B,EAAOL,KAC1BtC,EAAAA,EAAAA,GAAkB2C,EAAOL,IAGvBxB,EAAAA,EAAAA,IAAgB6B,EAAOL,KACzB5B,EAAAA,EAAAA,IAAqBiC,EAAOL,GA+F5BI,GAAU,CACZ,IAEFA,GAAU,CACZ,IAZEqC,G","sources":["webpack://app_custom_hawkers_frontend/./cartridge/client/default/js/partials/class-list-utils.js","webpack://app_custom_hawkers_frontend/webpack/bootstrap","webpack://app_custom_hawkers_frontend/webpack/runtime/define property getters","webpack://app_custom_hawkers_frontend/webpack/runtime/hasOwnProperty shorthand","webpack://app_custom_hawkers_frontend/./cartridge/client/default/js/components/chat-online.js"],"sourcesContent":["'use strict';\n\n// Classes\nconst classes = {\n hidden: 'tw-hidden',\n is: {\n loading: 'is-loading',\n preferred: 'is-preferred',\n calculating: 'is-calculating',\n visible: 'is-visible',\n selected: 'is-selected',\n open: 'is-open',\n active: 'is-active',\n invalid: 'is-invalid',\n current: 'is-current',\n full: 'is-full',\n loaded: 'is-loaded',\n disabled: 'is-disabled',\n fullscreen: 'is-fullscreen',\n alone: 'is-alone',\n sticky: 'is-sticky',\n zoomed: 'is-zoomed',\n enabled: 'is-enabled',\n filtered: 'is-filtered',\n scrollable: 'is-scrollable',\n fixed: 'is-fixed',\n animated: 'is-animated',\n animatedOut: 'is-animated-out',\n animatedIn: 'is-animated-in',\n locked: 'is-locked',\n empty: 'is-empty',\n available: 'is-available',\n cached: 'is-cached'\n },\n has: {\n error: 'has-error',\n success: 'has-success',\n filtersVisible: 'has-filters-visible',\n subscription: 'has-subscription',\n gross: 'has-gross'\n },\n show: {\n password: 'show-password',\n resumeOrder: 'show-resume-order'\n },\n color: {\n state: {\n success: 'tw-text-state-success',\n error: 'tw-text-state-error'\n }\n },\n gtm: {\n avoidViewed: 'gtm-avoid-viewed'\n },\n not: {\n results: 'not-results'\n },\n text: {\n uppercase: 'tw-uppercase'\n }\n};\n\n// Variables\nconst RECURSIVE_SEARCH_LIMIT = 5;\n\n// Functions\n\n// Add class to element\nconst addClassToElement = ($element, ...newClasses) => {\n if ($element) {\n $element.classList.add(...newClasses);\n }\n};\n\n// Remove class from element\nconst removeClassToElement = ($element, ...newClasses) => {\n if ($element) {\n $element.classList.remove(...newClasses);\n }\n};\n\n// Toggle class to element\nconst toggleClassToElement = ($element, ...newClasses) => {\n if ($element) {\n $element.classList.toggle(...newClasses);\n }\n};\n\n// Check if element has class\nconst hasClassElement = ($element, classname) => {\n if ($element && $element.classList) {\n return $element.classList.contains(classname);\n }\n // Element does not exist or is invalid\n return null;\n};\n\n// Find element by class or parent element until RECURSIVE_SEARCH_LIMIT\nconst findParentFromClass = ($elem, classToSearch, deep = 0) => {\n if (hasClassElement($elem, classToSearch)) {\n return $elem;\n }\n\n if ($elem && deep < RECURSIVE_SEARCH_LIMIT) {\n return findParentFromClass($elem.parentNode, classToSearch, deep + 1);\n }\n\n return null;\n};\n\n// Export\nexport {\n classes,\n addClassToElement,\n removeClassToElement,\n toggleClassToElement,\n hasClassElement,\n findParentFromClass\n};\n","// 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 = function(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 = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","import { addClassToElement, removeClassToElement, hasClassElement } from '@jspartials/class-list-utils';\n\nconst BODY_SELECTOR = '.js-body';\nconst CHAT_SELECTOR = '.embeddedServiceHelpButton';\nconst INSERTABLE_ELEM_SELECTOR = '.js-insert-chat-online';\nconst VISIBLE_STATUS_CLASSNAME = 'is-visible';\nconst SCROLLED_TO_BOTTOM_STATUS_CLASSNAME = 'is-scrolled-to-bottom';\n\nconst maxInitAttempts = 3;\nconst waitingTimeBetweenInitAttempts = 900; // milliseconds\nconst maxRelocationAttempts = 5;\nconst waitingTimeBetweenRelocationAttempts = 1000; // milliseconds\nlet $chat = null;\nlet chatEstablished = false;\nlet last_known_scroll_position = 0;\nlet ticking = false;\nconst $body = document.querySelector(BODY_SELECTOR);\n\nconst chatScrolling = scroll_pos => {\n if ((window.innerHeight + scroll_pos) >= document.body.scrollHeight) {\n if (!hasClassElement($body, SCROLLED_TO_BOTTOM_STATUS_CLASSNAME)) {\n addClassToElement($body, SCROLLED_TO_BOTTOM_STATUS_CLASSNAME);\n }\n } else {\n if (hasClassElement($body, SCROLLED_TO_BOTTOM_STATUS_CLASSNAME)) {\n removeClassToElement($body, SCROLLED_TO_BOTTOM_STATUS_CLASSNAME);\n }\n }\n}\n\nfunction getChatConfiguration() {\n let chatConfiguration = {};\n const chatPreferencesParsed = JSON.parse(chatPreferences);\n\n try {\n if (chatPreferencesParsed.hasOwnProperty(countryForChat)) {\n chatConfiguration = chatPreferencesParsed[countryForChat];\n }\n } catch (e) {}\n\n return chatConfiguration;\n}\n\nconst initESW = chatConfiguration => {\n embedded_svc.settings.displayHelpButton = true;\n embedded_svc.settings.language = languageForChat;\n embedded_svc.settings.defaultMinimizedText = 'CHAT';\n embedded_svc.settings.enabledFeatures = ['LiveAgent'];\n embedded_svc.settings.entryFeature = 'LiveAgent';\n embedded_svc.init(\n chatConfiguration.init_first_domain,\n chatConfiguration.init_second_domain,\n chatConfiguration.init_esw_domain,\n chatConfiguration.console_service_id,\n chatConfiguration.country,\n {\n baseLiveAgentContentURL: chatConfiguration.base_live_agent_content_url,\n deploymentId: chatConfiguration.deployment_id,\n buttonId: chatConfiguration.button_id,\n baseLiveAgentURL: chatConfiguration.base_live_agent_url,\n eswLiveAgentDevName: chatConfiguration.esw_live_agent_dev_name,\n isOfflineSupportEnabled: chatConfiguration.is_offline_support_enabled\n }\n );\n};\n\nconst relocationChat = (\n attemptNumber = 0,\n waitingTime = waitingTimeBetweenRelocationAttempts\n) => {\n $chat = document.querySelector(CHAT_SELECTOR);\n\n if ($chat && !chatEstablished) {\n const $insertableElem = document.querySelector(INSERTABLE_ELEM_SELECTOR);\n $insertableElem.appendChild($chat);\n addClassToElement($chat, VISIBLE_STATUS_CLASSNAME);\n chatEstablished = true;\n } else if (attemptNumber < maxRelocationAttempts) {\n setTimeout(() => {\n relocationChat(attemptNumber + 1);\n }, waitingTime);\n }\n};\n\nconst tryInitChat = (\n attemptNumber = 0,\n waitingTime = waitingTimeBetweenInitAttempts\n) => {\n var chatConfiguration = getChatConfiguration();\n\n if (chatConfiguration) {\n if (chatConfiguration.is_visible) {\n if (window.embedded_svc) {\n initESW(chatConfiguration);\n relocationChat();\n } else if (attemptNumber < maxInitAttempts) {\n setTimeout(() => {\n tryInitChat(attemptNumber + 1, waitingTime - 100);\n }, waitingTime);\n } else {\n var s = document.createElement('script');\n s.setAttribute('src', scriptAttribute_value);\n s.onload = function() {\n initESW(chatConfiguration);\n };\n document.body.appendChild(s);\n }\n }\n }\n};\n\nconst initChat = () => {\n tryInitChat();\n};\n\ndocument.addEventListener('scroll', function() {\n last_known_scroll_position = window.scrollY;\n if (!ticking) {\n window.requestAnimationFrame(function() {\n chatScrolling(last_known_scroll_position);\n ticking = false;\n });\n }\n ticking = true;\n});\n\ninitChat();\n"],"names":["addClassToElement","$element","_len","arguments","length","newClasses","Array","_key","classList","add","removeClassToElement","_len2","_key2","remove","hasClassElement","classname","contains","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","SCROLLED_TO_BOTTOM_STATUS_CLASSNAME","$chat","chatEstablished","last_known_scroll_position","ticking","$body","document","querySelector","initESW","chatConfiguration","embedded_svc","settings","displayHelpButton","language","languageForChat","defaultMinimizedText","enabledFeatures","entryFeature","init","init_first_domain","init_second_domain","init_esw_domain","console_service_id","country","baseLiveAgentContentURL","base_live_agent_content_url","deploymentId","deployment_id","buttonId","button_id","baseLiveAgentURL","base_live_agent_url","eswLiveAgentDevName","esw_live_agent_dev_name","isOfflineSupportEnabled","is_offline_support_enabled","relocationChat","attemptNumber","waitingTime","appendChild","setTimeout","tryInitChat","chatPreferencesParsed","JSON","parse","chatPreferences","countryForChat","e","getChatConfiguration","is_visible","window","s","createElement","setAttribute","scriptAttribute_value","onload","body","addEventListener","scrollY","requestAnimationFrame","scroll_pos","innerHeight","scrollHeight"],"sourceRoot":""}