!function(){"use strict";let e=e=>!!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e),t=/^(?:http:\/\/|https:\/\/)(?:youtu\.be|www\.youtube\.com)\/[\w/]+(?:\?.*)?$/im,i=e=>{var t;let i=e.match(/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/);return i&&(null===(t=i[7])||void 0===t?void 0:t.length)===11?i[7]:void 0},a=(e,t)=>{var i,a,o,l,r,n,d;switch(e){case"desktop":if((null==t?void 0:null===(i=t.desktop)||void 0===i?void 0:i.type)==="video")return{device:"desktop",data:t.desktop};break;case"tablet":if((null==t?void 0:null===(a=t.tablet)||void 0===a?void 0:a.type)==="video")return{device:"tablet",data:t.tablet};if(!(null==t?void 0:t.tablet)&&(null==t?void 0:null===(o=t.desktop)||void 0===o?void 0:o.type)==="video")return{device:"desktop",data:t.desktop};break;case"mobile":if((null==t?void 0:null===(l=t.mobile)||void 0===l?void 0:l.type)==="video")return{device:"mobile",data:t.mobile};if(!(null==t?void 0:t.mobile)&&(null==t?void 0:null===(r=t.tablet)||void 0===r?void 0:r.type)==="video")return{device:"tablet",data:t.tablet};if(!(null==t?void 0:t.mobile)&&!(null==t?void 0:null===(n=t.tablet)||void 0===n?void 0:n.type)&&(null==t?void 0:null===(d=t.desktop)||void 0===d?void 0:d.type)==="video")return{device:"desktop",data:t.desktop}}},o={src:"https://www.youtube.com/iframe_api",loading:!1,loaded:!1,listeners:[],load:function(e){let t=this;if(this.listeners.push(e),this.loaded){setTimeout(function(){t.done()});return}if(this.loading)return;this.loading=!0,window.onYouTubeIframeAPIReady=function(){t.loaded=!0,t.done()};let i=document.createElement("script");i.type="text/javascript",i.src=this.src,document.body.appendChild(i)},done:function(){for(window.onYouTubeIframeAPIReady&&delete window.onYouTubeIframeAPIReady;this.listeners.length;)this.listeners.pop()(window.YT)}};function l(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}let r="gp-hero-banner-bg";customElements.get("gp-hero-banner")||customElements.define("gp-hero-banner",class extends GP.Component{addEventResize(){window.addEventListener("resize",()=>{let e=this.getDevice();if(e!==this.device){if(this.articleSelector){if(this.articleSelector.innerHTML="",this.dataResponsive=a(e,this.background),!this.dataResponsive)return;let t=this.getDataIframe();if(void 0===t)return;this.createIframe(this.articleSelector,t)}else this.createArticle();this.addStyleBackgroundImage(e)}this.device=e,this.triggerEventPlay(),this.handleParallaxScroll()})}addEventScroll(){window.addEventListener("scroll",()=>{this.triggerEventPlay(),this.handleParallaxScroll()})}addEventSwitchTab(){window.addEventListener("visibilitychange",()=>{document.hidden||this.triggerEventPlay()})}triggerEventPlay(){var e,t,i;let a=null===(e=this.dataResponsive)||void 0===e?void 0:e.device,o=this.background[a];(null==o?void 0:o.video)&&(null==o?void 0:o.loop)&&this.iframeEl&&(null===(i=this.iframeEl)||void 0===i||null===(t=i.contentWindow)||void 0===t||t.postMessage(JSON.stringify({event:"command",func:"playVideo"}),"*"))}getDevice(){return window.innerWidth<768?"mobile":window.innerWidth>=768&&window.innerWidth<1024?"tablet":"desktop"}createArticle(){let e=this.getDataIframe();if(void 0===e)return;let t=this.querySelector(`.${this.uid} .${r}`);this.articleSelector=this.querySelector(`.${this.uid} .${r} .gp-hero-banner-article`),this.articleSelector||(this.articleSelector=document.createElement("article")),this.articleSelector.style.cssText=`
          aspect-ratio: 16/9;
          pointer-events: none;
          padding-bottom: 56.25%;
          height: 100%;
          width: 100%;
          overflow: hidden;
          max-width: none !important;
          position: relative;
        `,this.articleSelector.className="gp-hero-banner-article",this.createIframe(this.articleSelector,e),t.appendChild(this.articleSelector)}createIframe(e,t){if(t.isLoop){let{videoId:i}=t,a=this.createWrapperDiv();e.append(a);let l=`player-wrapper-${this.uid}`;a.append(this.createPlayerWrapper(l)),o.load(()=>{new YT.Player(l,{videoId:i,host:"https://www.youtube-nocookie.com",playerVars:{autoplay:1,state:1,controls:0,mute:1,enablejsapi:1,playlist:i,showinfo:0,rel:0,fs:0},events:{onReady:e=>{e.target.playVideo(),this.videoDuration=Math.floor(e.target.getDuration())},onStateChange:e=>{let t=e.target;this.isVideoStarted||(t.playVideo(),this.isVideoStarted=!0,this.runVideo(e)),0===e.data&&(this.videoDuration=t.getCurrentTime(),t.playVideo(),this.runVideo(e))}}})}),window.onbeforeunload=()=>{clearInterval(this.intervalTracker)}}else{let i=document.createElement("iframe");i.allowFullscreen=!0,i.allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",i.frameBorder="0",i.src=t.iframeSrc,i.style.cssText=`
            aspect-ratio: 16/9;
            width: 100%;
            inset: 0;
            background: #000;
            position: absolute;
            width: 500% !important;
            margin-left: -200% !important;
            height: 100% !important;
            max-width: none !important;
            scale: 1.04;
          `,this.iframeEl=i,e.append(i)}}runVideo(e){let t=e.target;if(this.videoDuration>0){let e=parseFloat((this.videoDuration/100*5).toFixed(2));clearInterval(this.intervalTracker),this.intervalTracker=setInterval(()=>{let i=parseFloat(t.getCurrentTime().toFixed(2)),a=parseFloat((this.videoDuration-i).toFixed(2));a<=1.5*e&&t.seekTo(0)},1e3*e)}}createWrapperDiv(){let e=document.createElement("div");return e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.width="100%",e.style.height="100%",e.style.aspectRatio="16/9",e}createPlayerWrapper(e){let t=document.createElement("div");return t.id=e,t.style.width="500%",t.style.marginLeft="-200%",t.style.height="100%",t.style.maxWidth="none",t.style.scale="1.04",t.style.inset="0px",t.style.backgroundColor="black",t}getDataIframe(){var e,a;let o=null===(e=this.dataResponsive)||void 0===e?void 0:e.device,l=this.background[o],r=null!==(a=null==l?void 0:l.video)&&void 0!==a?a:"",n=i(r);if(!t.test(r)||!n)return;let d=`https://www.youtube-nocookie.com/embed/${n}?autoplay=1&state=1&mute=1&loop=${(null==l?void 0:l.loop)?1:0}&playlist=${n}&controls=0&enablejsapi=1`;return{iframeSrc:d,videoId:n,isLoop:(null==l?void 0:l.loop)?1:0}}addStyleBackgroundImage(t){var i,a;let o=this.querySelector(`.${this.uid} .${r}`);e(navigator.userAgent)&&(null===(i=this.background[t])||void 0===i?void 0:i.type)!=="video"&&(null===(a=this.background[t])||void 0===a?void 0:a.attachment)==="fixed"?o.style.setProperty("-webkit-transform","translate3d(0,0,0)"):o.style.removeProperty("-webkit-transform")}handleParallaxScroll(){var e,t,i,a,o,l,n;let d=this.querySelector(`.${this.uid} .${r}`);this.scrollAmount=window.innerHeight-this.clientHeight;let s=this.getBoundingClientRect().y;window.innerHeight>s?this.scrollAmount=window.innerHeight-s:this.scrollAmount=0,d&&0!==this.speedParallax&&(d.style.backgroundAttachment=(null===(e=this.background[this.device])||void 0===e?void 0:e.type)==="image"&&this.enableParallax?"fixed":(null===(t=this.background[this.device])||void 0===t?void 0:t.attachment)||"scroll",d.style.backgroundPosition=(null===(i=this.background[this.device])||void 0===i?void 0:i.type)==="image"&&this.enableParallax?`center ${(window.innerHeight-this.scrollAmount)*(1-this.speedParallax)}px `:`${null===(o=this.background[this.device])||void 0===o?void 0:null===(a=o.position)||void 0===a?void 0:a.x}% ${null===(n=this.background[this.device])||void 0===n?void 0:null===(l=n.position)||void 0===l?void 0:l.y}%`)}constructor(){super(),l(this,"uid",void 0),l(this,"background",void 0),l(this,"device","desktop"),l(this,"articleSelector",null),l(this,"dataResponsive",void 0),l(this,"iframeEl",void 0),l(this,"enableParallax",!1),l(this,"speedParallax",0),l(this,"scrollAmount",0),l(this,"intervalTracker",void 0),l(this,"isVideoStarted",!1),l(this,"videoDuration",0),this.uid=this.getState("uid"),this.background=this.getState("background"),this.speedParallax=this.getState("speedParallax"),this.device=this.getDevice(),this.enableParallax=this.getState("enableParallax"),this.dataResponsive=a(this.device,this.background),this.dataResponsive&&this.createArticle(),this.addStyleBackgroundImage(this.device),this.addEventResize(),this.triggerEventPlay(),this.addEventSwitchTab(),this.addEventScroll(),this.handleParallaxScroll()}})}();
