{"version":3,"file":"tooltip-tooltip.chunk.772566c047d22c473b47.js","mappings":"4LAEe,SAASA,EAAcC,GAClC,IAAMC,EAAsB,yBA6CtBC,EAAgB,WAElB,IAAMC,EAAeC,MAAMC,KAAKL,GAAUM,QAAO,SAAAC,GAAO,OACpDA,EAAQC,UAAUC,SAASR,EAAoB,IAE/CE,GACAA,EAAaO,SAAQ,SAAAC,GACjBA,EAAYH,UAAUI,OAAOX,EACjC,GAER,EAEID,GACAI,MAAMC,KAAKL,GAAUU,SAAQ,SAAAH,GACzB,IAAMM,EAAgBN,EAAQO,cAAc,yBACtCC,EAAgBR,EAAQO,cAAc,yBACxCD,GAAiBE,IA1DzBC,SAASC,iBAAiB,WAAW,SAAAC,GAClB,WAAXA,EAAEC,MAAgC,QAAXD,EAAEC,MACzBjB,GAER,IAGAc,SAASC,iBAAiB,SAAS,SAAAC,GAGE,WAA7BA,EAAEE,OAAOC,QAAQd,SACY,WAA7BW,EAAEE,OAAOC,QAAQd,SACY,oBAA7BW,EAAEE,OAAOC,QAAQd,SACY,QAA7BW,EAAEE,OAAOC,QAAQd,SACY,SAA7BW,EAAEE,OAAOC,QAAQd,SAEjBL,GAER,IAE6B,SAACK,EAASM,GAMvCA,EAAcI,iBAAiB,SAAS,WAChCV,EAAQC,UAAUC,SAASR,GAC3BM,EAAQC,UAAUI,OAAOX,IAEzBC,IACAK,EAAQC,UAAUc,IAAIrB,IAGtBsB,EAAAA,EAAAA,KAAiBC,cAAc,0BAA2B,CACtDC,WAAY,iBACZC,KAAM,CAAC,WACPC,SAAU,eAGtB,GACJ,CAoBYC,CAAyBrB,EAASM,GAE1C,GAER,C","sources":["webpack:///./html/wp-content/themes/ls/src/js/main/components/tooltip/tooltip.js"],"sourcesContent":["import { LoggingHandler } from 'root/utils/errorReporting/LoggingHandler';\n\nexport default function tooltipOpener(tooltips) {\n    const tooltipDisplayClass = 'js-show-tooltip-dialog';\n    const handleEscKeyEvent = () => {\n        // this closes the tooltip when the user presses \"esc\" or \"tab\"\n        document.addEventListener('keydown', e => {\n            if (e.code === 'Escape' || e.code === 'Tab') {\n                closeTooltips();\n            }\n        });\n    };\n    const handleDocumentClickEvent = () => {\n        document.addEventListener('click', e => {\n            // this hides the tooltip when the user clicks outside the dialog\n            if (\n                e.target.dataset.tooltip !== 'dialog' &&\n                e.target.dataset.tooltip !== 'button' &&\n                e.target.dataset.tooltip !== 'tabtrap-element' &&\n                e.target.dataset.tooltip !== 'svg' &&\n                e.target.dataset.tooltip !== 'path'\n            ) {\n                closeTooltips();\n            }\n        });\n    };\n    const handleTooltipButtonClick = (tooltip, tooltipButton) => {\n        /*\n         * This toggles the tooltip when the user clicks the open tooltip button.\n         * When a user presses \"enter\" or \"space\" a click event gets triggered,\n         * so this covers that part of the keyboard interaction as well\n         * */\n        tooltipButton.addEventListener('click', () => {\n            if (tooltip.classList.contains(tooltipDisplayClass)) {\n                tooltip.classList.remove(tooltipDisplayClass);\n            } else {\n                closeTooltips();\n                tooltip.classList.add(tooltipDisplayClass);\n                // @email-hook change\n                // logging added to track how often these tooltips are clicked on during the test\n                LoggingHandler().logUserAction('User opened the tooltip', {\n                    searchTerm: 'tooltip-opened',\n                    tags: ['tooltip'],\n                    fileName: 'tooltip.js',\n                });\n            }\n        });\n    };\n    const closeTooltips = () => {\n        // this const finds all tooltips that have a js-show-tooltip-dialog class\n        const openTooltips = Array.from(tooltips).filter(tooltip =>\n            tooltip.classList.contains(tooltipDisplayClass)\n        );\n        if (openTooltips) {\n            openTooltips.forEach(openTooltip => {\n                openTooltip.classList.remove(tooltipDisplayClass);\n            });\n        }\n    };\n\n    if (tooltips) {\n        Array.from(tooltips).forEach(tooltip => {\n            const tooltipButton = tooltip.querySelector('[data-tooltip=button]');\n            const tooltipDialog = tooltip.querySelector('[data-tooltip=dialog]');\n            if (tooltipButton && tooltipDialog) {\n                handleEscKeyEvent();\n                handleDocumentClickEvent();\n                handleTooltipButtonClick(tooltip, tooltipButton);\n            }\n        });\n    }\n}\n"],"names":["tooltipOpener","tooltips","tooltipDisplayClass","closeTooltips","openTooltips","Array","from","filter","tooltip","classList","contains","forEach","openTooltip","remove","tooltipButton","querySelector","tooltipDialog","document","addEventListener","e","code","target","dataset","add","LoggingHandler","logUserAction","searchTerm","tags","fileName","handleTooltipButtonClick"],"sourceRoot":""}