{"version":3,"sources":["../../../../dev/j/v3/components/cmp-modal.js"],"names":["$","avm","require","document","querySelectorAll","forEach","modal","$modalContent","find","$videoElement","addEventListener","$iframe","length","contentWindow","postMessage","load","playIcon","video","querySelector","videoSrc","getAttribute","includes","setAttribute"],"mappings":"CAAA,WACC,YAEA,IAAIA,GAAIC,IAAIC,QAAQ,OACRC,UAASC,iBAAiB,UAE/BC,QAAQ,SAASC,GACvB,GAAIC,GAAgBP,EAAEM,GAAOE,KAAK,kBACjCC,EAAgBF,EAAcC,KAAK,SAAS,EAE7CF,GAAMI,iBAAiB,iBAAkB,WACxC,GAAIC,GAAUJ,EAAcC,KAAK,SAEV,KAAnBG,EAAQC,QAEXD,EAAQ,GAAGE,cAAcC,YACxB,uDAAwD,OAK3DR,EAAMI,iBAAiB,gBAAiB,WACvC,GAAIC,GAAUJ,EAAcC,KAAK,SAEV,KAAnBG,EAAQC,OACXD,EAAQ,GAAGE,cAAcC,YACxB,wDAAyD,KAEhDL,GACVA,EAAcM,WAQDZ,SAASC,iBAAiB,gBAChCC,QAAQ,SAASW,GAC1BA,EAASN,iBAAiB,QAAS,WAElC,KAAMO,GAAQd,SAASe,cAAc,eAErC,IAAID,EAAO,CAEV,GAAIE,GAAWF,EAAMG,aAAa,MAC7BD,GAASE,SAAS,eACtBJ,EAAMK,aAAa,MAAOH,EAAW","file":"cmp-modal.js","sourcesContent":["(function() {\n\t'use strict';\n\n\tvar $ = avm.require('cash'),\n modals = document.querySelectorAll('.modal');\n\n\tmodals.forEach(function(modal) {\n\t\tvar $modalContent = $(modal).find('.modal-content'),\n\t\t\t$videoElement = $modalContent.find('video')[0];\n\n\t\tmodal.addEventListener('shown.bs.modal', function() {\n\t\t\tvar $iframe = $modalContent.find('iframe');\n\n\t\t\tif ($iframe.length !== 0) {\n\n\t\t\t\t$iframe[0].contentWindow.postMessage(\n\t\t\t\t\t'{ \"event\":\"command\", \"func\":\"playVideo\", \"args\":\"\" }', '*'\n\t\t\t\t);\n\t\t\t} \n\t\t});\n\n\t\tmodal.addEventListener('hide.bs.modal', function() {\n\t\t\tvar $iframe = $modalContent.find('iframe');\n\n\t\t\tif ($iframe.length !== 0) {\n\t\t\t\t$iframe[0].contentWindow.postMessage(\n\t\t\t\t\t'{ \"event\":\"command\", \"func\":\"pauseVideo\", \"args\":\"\" }', '*'\n\t\t\t\t);\n\t\t\t} else if ($videoElement) {\n\t\t\t\t$videoElement.load();\n\t\t\t}\n\t\t});\n\t});\n\n\n\t// VIDEO AUTOPLAY FIX GLOWEB-9377\n\t// Add click event listener to `.icon-play-l` to trigger autoplay\n\tvar playIcons = document.querySelectorAll('.icon-play-l');\n\tplayIcons.forEach(function(playIcon) {\n\t\tplayIcon.addEventListener('click', function() {\n\t\t\t// Locate the modal video iframe\n\t\t\tconst video = document.querySelector('.modal-video');\n\t\t\t\n\t\t\tif (video) {\n\t\t\t\t// Append autoplay=1 to the video src only if it's not already added\n\t\t\t\tvar videoSrc = video.getAttribute('src');\n\t\t\t\tif (!videoSrc.includes('autoplay=1')) {\n\t\t\t\t\tvideo.setAttribute('src', videoSrc + '&autoplay=1');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t});\n\n})();\n"]}