{"version":3,"file":"assets/js/725.caf8b5a98e9e0c5edbe6.js","mappings":"oHAIO,SAASA,EAAQC,GACtB,OAAUA,EAAU,GAAZ,KACT,C,8BCJD,MAAMC,EAAcC,SAASC,eAAe,uBACtCC,EAAiBF,SAASG,cAAc,wBACxCC,EAAkBJ,SAASG,cAAc,iCAEtB,IAAIE,kBAAiB,CAACC,EAAWC,KACxD,IAAK,MAAMC,KAAYF,EAAW,CAKhC,GAJmB,IAAIE,EAASC,YACJC,MAAMC,GAAqB,yBAAZA,EAAKC,KAO9C,OAHAC,SAEAN,EAASO,YAGZ,KAGcC,QAAQf,SAASgB,KAAM,CAAEC,WAAW,EAAMC,SAAS,IAKpE,MAAMC,EAAU,GACVC,EAAkB,IAGxB,SAASC,IACgBrB,SAASC,eAAe,uBAChCqB,SAEfC,GACD,CAeD,SAASV,IACP,MAAMW,EAAiBxB,SAASG,cAAc,uBACxCsB,EAAiBzB,SAASC,eAAe,uBAG/C,IAAKwB,EAAgB,OAGrB,IAAKvB,IAAmBE,EACtB,OAIF,GAAIsB,OAAOC,WAAaP,EAEtB,YADAG,IAKF,MAAM,OAAEK,GAAWH,EAAeI,wBAC5BC,EA7BiB9B,SAASG,cAAc,uBAKvCD,EAAe2B,wBAAwBD,OAAST,EAH9C,EA6BHY,EAASH,EAAST,EAIxBjB,EAAe8B,MAAMC,OAASpC,EAAQkC,EAASD,GAC/C1B,EAAgB4B,MAAMC,OAASpC,EAAQkC,GAElCP,IACLA,EAAeQ,MAAMC,OAASpC,EAAQkC,GACvC,CAGD,SAASR,IACP,MAAMC,EAAiBxB,SAASG,cAAc,uBAC9CD,EAAe8B,MAAMC,OAAS,GAC9B7B,EAAgB4B,MAAMC,OAAS,GAE1BT,IACLA,EAAeQ,MAAMC,OAAS,GAC/B,CAWD,QATA,WACOlC,IACLA,EAAYmC,iBAAiB,QAASb,GAGtCR,IACAa,OAAOQ,iBAAiB,SAAUrB,GACnC,C","sources":["webpack://ssen-distribution/./src/scripts/lib/px-to-rem.js","webpack://ssen-distribution/./src/templates/02-components/floating-cta-banner/mando-ui.floating-cta-banner.js"],"sourcesContent":["/** Converts pixel value to rem value\r\n *  @param {number} pxValue - The value to convert to rem\r\n *  @return string - The rem string to set to the style attribute.\r\n * */\r\nexport function pxToRem(pxValue) {\r\n  return `${pxValue / 16}rem`;\r\n}\r\n","import { pxToRem } from '../../../scripts/lib/px-to-rem';\r\n\r\nconst closeButton = document.getElementById('close-banner-button');\r\nconst reciteMeButton = document.querySelector('.c-recite-me__button');\r\nconst messengerButton = document.querySelector('.c-facebook-messenger__button');\r\n\r\nconst mutationObserver = new MutationObserver((mutations, observer) => {\r\n  for (const mutation of mutations) {\r\n    const addedNodes = [...mutation.addedNodes];\r\n    const otButton = addedNodes.find((node) => node.id === 'onetrust-consent-sdk');\r\n\r\n    // We have found the OT button. Want to exit the loop\r\n    if (otButton) {\r\n      onWindowResized();\r\n      // disconnect as we have found our mutation\r\n      observer.disconnect();\r\n      return;\r\n    }\r\n  }\r\n});\r\n\r\nmutationObserver.observe(document.body, { childList: true, subtree: true });\r\n\r\n// SSENDPO-514 (https://jira.mandogroup.com/browse/SSENDPO-514)\r\n// Following a discussion with Alex H and Abs the decision is to hide this component when the site is rendered in viewports less that 980px.\r\n// There will be an enhancement delivered in a future sprint for lower resolution viewports.\r\nconst padding = 16;\r\nconst largeBreakpoint = 980;\r\n\r\n/** Closes the banner and resets the messenger and recite me buttons to their proper positions */\r\nfunction onBannerClosed() {\r\n  const floatingBanner = document.getElementById('floating-cta-banner');\r\n  floatingBanner.remove();\r\n\r\n  resetFixedButtons();\r\n}\r\n\r\n/* Gets the height offset needed for the recite me bottom height\r\n * @returns number\r\n * **/\r\nfunction getOneTrustShieldOffset() {\r\n  const otShieldButton = document.querySelector('.ot-floating-button');\r\n  if (!otShieldButton) {\r\n    return 0;\r\n  }\r\n  // Recite me button and OT button are the same height. On local dev, OT button is huge, so use this as failsafe\r\n  return reciteMeButton.getBoundingClientRect().height + padding;\r\n}\r\n\r\n/** Fires each time the window is resized */\r\nfunction onWindowResized() {\r\n  const otShieldButton = document.querySelector('.ot-floating-button');\r\n  const floatingBanner = document.getElementById('floating-cta-banner');\r\n\r\n  // Floating banner isn't here. No need to run the rest of the function.\r\n  if (!floatingBanner) return;\r\n\r\n  // Can't reset buttons if they don't exist\r\n  if (!reciteMeButton || !messengerButton) {\r\n    return;\r\n  }\r\n\r\n  // Window is smaller than the break point, or the floating banner has been dismissed. Reset button position.\r\n  if (window.innerWidth < largeBreakpoint) {\r\n    resetFixedButtons();\r\n    return;\r\n  }\r\n\r\n  // Get the height of the banner\r\n  const { height } = floatingBanner.getBoundingClientRect();\r\n  const otShieldOffset = getOneTrustShieldOffset();\r\n\r\n  const offset = height + padding;\r\n\r\n  // Update the bottom of each button to have some padding between the floating CTA footer\r\n  // One Trust Button sits below the Recite Me Button. So add the offset to it.\r\n  reciteMeButton.style.bottom = pxToRem(offset + otShieldOffset);\r\n  messengerButton.style.bottom = pxToRem(offset);\r\n\r\n  if (!otShieldButton) return;\r\n  otShieldButton.style.bottom = pxToRem(offset);\r\n}\r\n\r\n/** Resets the buttons to the correct position */\r\nfunction resetFixedButtons() {\r\n  const otShieldButton = document.querySelector('.ot-floating-button');\r\n  reciteMeButton.style.bottom = '';\r\n  messengerButton.style.bottom = '';\r\n\r\n  if (!otShieldButton) return;\r\n  otShieldButton.style.bottom = '';\r\n}\r\n\r\nfunction init() {\r\n  if (!closeButton) return;\r\n  closeButton.addEventListener('click', onBannerClosed);\r\n\r\n  // Trigger initial resize to set button up as needed.\r\n  onWindowResized();\r\n  window.addEventListener('resize', onWindowResized);\r\n}\r\n\r\nexport default init;\r\n"],"names":["pxToRem","pxValue","closeButton","document","getElementById","reciteMeButton","querySelector","messengerButton","MutationObserver","mutations","observer","mutation","addedNodes","find","node","id","onWindowResized","disconnect","observe","body","childList","subtree","padding","largeBreakpoint","onBannerClosed","remove","resetFixedButtons","otShieldButton","floatingBanner","window","innerWidth","height","getBoundingClientRect","otShieldOffset","offset","style","bottom","addEventListener"],"sourceRoot":""}