!function($){"use strict";function lazyLoad(element){var $element_nested=$(element).find(".wcgs-shop-lazy-load-video"),$element=$(element),embed=$element_nested.data("embed"),type=$element_nested.data("type");if($element_nested.data("width")){var width=$element.data("width");$element_nested.css("maxWidth",width+"px")}var $iframe=$("<iframe>",{class:"wgsp-video-iframe",frameborder:"0",playsinline:"1",allowFullScreen:"1",allow:"autoplay; accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"});$element.find("button").on("click",(function(e){e.preventDefault(),embed&&$iframe.attr("src",embed),$element.append($iframe),$element.find("img").addClass("fadeout"),$element.find("button").remove()})),$element.on("click",(function(e){e.preventDefault(),$element.find("button").trigger("click")}))}$(document).ready((function(){function wcgs_add_youtube_api_script(){var youtubeScriptId="youtube-api",youtubeScript;if(null===document.getElementById("youtube-api")){var tag=document.createElement("script"),firstScript=document.getElementsByTagName("script")[0];tag.src="https://www.youtube.com/iframe_api",tag.id="youtube-api",firstScript.parentNode.insertBefore(tag,firstScript)}}function loadNonCriticalCSS(file){const publicUrl=wcgs_shop_data.wcgs_public_url,href=publicUrl+file;0===jQuery(`link[rel="stylesheet"][href="${href}"]`).length&&$("<link>",{rel:"stylesheet",href:href}).appendTo("head")}function initializeSelfHostedVideos(){const selfHostedVideos=$(document).find(".wcgs-shop-video-self-hosted video");selfHostedVideos.length>0&&"undefined"!=typeof videojs&&selfHostedVideos.each((function(index,element){"autoplay"===$(element).attr("allow")&&(element.muted=!0,element.play().catch(error=>{$(element).parents(".wcgs-shop-video-self-hosted").find(".vjs-big-play-button").trigger("click")}))}))}function checkVideoJSAPIReady(){const selfHostedVideos=$(document).find(".wcgs-shop-video-self-hosted video");if(selfHostedVideos.length>0){const checkInterval=setInterval(()=>{initializeVideoJSScript(),loadNonCriticalCSS("css/video.min.css"),"function"==typeof videojs&&(clearInterval(checkInterval),initializeSelfHostedVideos())},300);setTimeout(()=>{clearInterval(checkInterval)},5e3)}}function initializeLightbox(){"undefined"!=typeof Fancybox&&Fancybox.bind("[data-fancybox]",{mainClass:"wcgs-fancybox-wrapper",Toolbar:{display:{right:["close","fullScreen"]}},backdropClick:"close"})}function initializeFancyboxScript(){const fancyboxScriptId="wcgs-fancybox-js",publicUrl=wcgs_shop_data.wcgs_public_url;if(!document.getElementById(fancyboxScriptId)){const jsTag=document.createElement("script");jsTag.src=publicUrl+"js/fancybox-bundle.min.js",jsTag.id=fancyboxScriptId,jsTag.defer=!0;const firstScript=document.getElementsByTagName("script")[0];firstScript.parentNode.insertBefore(jsTag,firstScript)}}function checkFancyboxReady(){const checkInterval=setInterval(()=>{loadNonCriticalCSS("css/fancybox.min.css"),initializeFancyboxScript(),"undefined"!=typeof Fancybox&&(clearInterval(checkInterval),initializeLightbox())},300);setTimeout(()=>{clearInterval(checkInterval)},5e3)}function initializeVideoJSScript(){const videoJsScriptId="wcgs-videojs-js",publicUrl=wcgs_shop_data.wcgs_public_url;if(!document.getElementById(videoJsScriptId)){const jsTag=document.createElement("script");jsTag.src=publicUrl+"js/video.min.js",jsTag.id=videoJsScriptId,jsTag.defer=!0;const firstScript=document.getElementsByTagName("script")[0];firstScript.parentNode.insertBefore(jsTag,firstScript)}}if(checkVideoJSAPIReady(),jQuery(document).find(".wcgs-shoppage-video-lightbox").length>0&&checkFancyboxReady(),$(document).find(".wgsp-shop-video-iframe-wrapper.wgsp-shoppage-video-youtube").length){var checkYTInterval=setInterval((function(){wcgs_add_youtube_api_script(),"object"==typeof YT&&"function"==typeof YT.Player&&(clearInterval(checkYTInterval),$(document).find(".wgsp-shop-video-iframe-wrapper.wgsp-shoppage-video-youtube").each((function(index){var yt_player=$(this);yt_player.attr("data-unique-id",index);var $unique_id=yt_player.attr("data-unique-id"),videoId=yt_player.data("embed"),video_loop=yt_player.data("loop"),video_control=yt_player.data("control"),video_autoplay=yt_player.data("autoplay");if(video_autoplay)var player=new YT.Player(this,{videoId:videoId,playerVars:{playlist:videoId,autoplay:video_autoplay,loop:video_loop,showinfo:0,rel:0,playsinline:1,mute:video_autoplay?1:0,controls:video_control},events:{}})})))}),300);setTimeout(()=>{clearInterval(checkYTInterval)},5e3)}})),$(".wgsp-shoppage-video-inline").each((function(){$(this).find(".wcgs-iframe").hasClass("wcgs-shop-lazy-load-video")&&lazyLoad(this)})),$(document).find(".wgsp-shoppage-video-inline").on("click",(function(e){e.preventDefault(),$(this).find("button").trigger("click")})),$(document).find(".wgsp-shoppage-video-inline button").on("click",(function(e){e.preventDefault();var yt_player=$(this).siblings(".wgsp-shoppage-video-youtube"),videoId=yt_player.data("embed"),video_loop=yt_player.data("loop"),video_control=yt_player.data("control"),video_autoplay=yt_player.data("autoplay");if("object"==typeof YT&&!video_autoplay)var player=new YT.Player(this,{videoId:videoId,playerVars:{playlist:videoId,autoplay:1,loop:video_loop,showinfo:0,rel:0,playsinline:1,mute:1,controls:video_control?1:0},events:{}})})),"mouseover"==wcgs_shop_data.trigger_event&&($(document).find(".wgsp-shoppage-video-inline button").on("mouseenter",(function(e){$(this).trigger("click")})),$(document).find(".wcgs-shop-video-self-hosted").on("mouseenter",(function(e){$("video",this).get(0).play()})))}(jQuery);for(var self_hosted_video=document.getElementsByClassName("wcgs-shop-video-self-hosted"),i=0,length=self_hosted_video.length;i<length;i++)self_hosted_video[i].addEventListener("click",(function(e){e.preventDefault(i)}));