function anonymous(
) {
define(['jquery','underscore','vimeoApi','jquery/ui'],function($,_,Vimeo){'use strict';var videoRegister={_register:{},isRegistered:function(api){return this._register[api]!==undefined;},isLoaded:function(api){return this._register[api]!==undefined&&this._register[api]===true;},register:function(api,loaded){loaded=loaded||false;this._register[api]=loaded;}};$.widget('mage.productVideoLoader',{_create:function(){switch(this.element.data('type')){case'youtube':this.element.videoYoutube();this._player=this.element.data('mageVideoYoutube');break;case'vimeo':this.element.videoVimeo();this._player=this.element.data('mageVideoVimeo');break;default:throw{name:'Video Error',message:'Unknown video type',toString:function(){return this.name+': '+this.message;}};}},_initialize:function(){this._params=this.element.data('video-params')||{};this._code=this.element.data('code');this._width=this.element.data('width');this._height=this.element.data('height');this._autoplay=!!this.element.data('video-autoplay');this._playing=this._autoplay||false;this._loop=!!this.element.data('video-loop');this._advance=!!this.element.data('video-advance');this._rewind=!!this.element.data('video-rewind');this._mute=!!this.element.data('video-mute');this._volume=this.element.data('video-volume');this._startAt=parseFloat(this.element.data('video-start-at'));this._endAt=parseFloat(this.element.data('video-end-at'));this._cover=!!this.element.data('video-force-cover');this._autohideText=!!this.element.data('video-autohide-text');this._videocontrols=this.element.data('videocontrols');this.timeElapsed=0;this._hasStarted=false;this._hasEnded=false;},play:function(){this._player.play();},pause:function(){this._player.pause();},stop:function(){this._player.stop();},playing:function(){return this._player.playing();},destroy:function(){this._player.destroy();}});$.widget('mage.videoYoutube',$.mage.productVideoLoader,{_create:function(){var self=this,arrayHelper,param,params={};this._initialize();this.element.append('
');this._on(window,{'youtubeapiready':function(){if(self._player!==undefined){return;}
try{arrayHelper=self._params.split('&');for(var i=0;i0){params['end']=self._endAt;}}catch(e){console.info('Invalid parameters passed for YouTube video. Please check the "URL Parameters" field.');}
self._player=new window.YT.Player(self.element.children(':first')[0],{videoId:self._code,playerVars:params,events:{'onReady':function onPlayerReady(){if(self._mute){self._player.mute();}else if(parseInt(self._volume)>0){self._player.setVolume(parseInt(self._volume));}
if(self._cover){self.videoAspectRatio=parseInt($(self._player.a).attr('width'))/ parseInt($(self._player.a).attr('height'));self._forceCover();$(window).on('resize',_.debounce(function(){self._forceCover();},100));}
if(self._autoplay&&$(self.element).hasClass('slick-active')){if(self._startAt>0){self._player.seekTo(self._startAt);}
self.play();}
self.element.parents('.slick-slider').on('beforeChange',function(event,slick,currentSlide,nextSlide){var iframeId=$(self._player.getIframe()).attr('id');if($(slick.$slides[currentSlide]).find('iframe').attr('id')==iframeId){self.pause();}
if($(slick.$slides[nextSlide]).find('iframe').attr('id')==iframeId){if(self._autoplay){if(self._rewind||!self._hasStarted){if(self._startAt>0){self._player.seekTo(self._startAt);}else{self._player.seekTo(0);}}
self.play();}}});$(self._player.getIframe()).siblings('.rocket-imageslider-text-container').find('.rocket-slider-btn-play-action').on('click',function(e){e.preventDefault();if(self._hasEnded){if(self._startAt>0){self._player.seekTo(self._startAt);}else{self._player.seekTo(0);}
self._hasEnded=false;}
self.play();});self.element.find('.rocket-videocover').on('click',function(){if(self._playing){self.pause();}else{self.play();}});},onStateChange:function(data){switch(window.parseInt(data.data,10)){case 1:self._playing=true;break;default:self._playing=false;break;}
self._trigger('statechange',{},data);if(data.data===window.YT.PlayerState.ENDED&&self._loop){self._player.playVideo();}}}});}});this._loadApi();},_forceCover:function(){if(!this.element.find('.rocket-videocover').length){this.element.append($('').attr('class','rocket-videocover'));var bgImage=$(this._player.getIframe()).css('background-image');this.element.find('.rocket-videocover').css({'background-image':bgImage,'background-size':'cover','background-position':'center center'});}
this.containerAspectRatio=this.element.width()/ this.element.height();if(this.containerAspectRatio>this.videoAspectRatio){$(this._player.a).css({'width':'100%','height':Math.ceil(this.containerAspectRatio / this.videoAspectRatio*100)+'%'});}else{$(this._player.a).css({'height':'150%','width':Math.ceil(this.videoAspectRatio / this.containerAspectRatio*100)+'%'});}},_loadApi:function(){var element,scriptTag;if(videoRegister.isRegistered('youtube')){if(videoRegister.isLoaded('youtube')){$(window).trigger('youtubeapiready');}
return;}
videoRegister.register('youtube');element=document.createElement('script');scriptTag=document.getElementsByTagName('script')[0];element.async=true;element.src='https://www.youtube.com/iframe_api';scriptTag.parentNode.insertBefore(element,scriptTag);window.onYouTubeIframeAPIReady=function(){$(window).trigger('youtubeapiready');videoRegister.register('youtube',true);};},play:function(){this._player.playVideo();this._hasStarted=true;this._playing=true;this.element.find('.rocket-videocover').css('opacity',0);if(this._autohideText){setTimeout(function(){this.element.find('.rocket-imageslider-text-container').fadeOut();},1000);}},pause:function(){this._player.pauseVideo();this._playing=false;},stop:function(){this._player.stopVideo();this._playing=false;},playing:function(){return this._playing;},destroy:function(){this.stop();this._player.destroy();}});$.widget('mage.videoVimeo',$.mage.productVideoLoader,{_create:function(){var self=this,timestamp,additionalParams='',src;this._initialize();timestamp=new Date().getTime();additionalParams+='autoplay=0&';additionalParams+=this._params;if(this._loop){additionalParams+='&loop=1';}
src='https://player.vimeo.com/video/'+this._code+'?'+additionalParams;this.element.append($('').attr('frameborder',0).attr('id','vimeo'+this._code+timestamp).attr('width',this._width).attr('height',this._height).attr('src',src).attr('webkitallowfullscreen','').attr('mozallowfullscreen','').attr('allowfullscreen','').attr('allow','autoplay'));this._iframeElement=$('#vimeo'+this._code+timestamp);this._iframeElement.fadeOut();this._player=new Vimeo(this._iframeElement);if(this._mute){this._player.setMuted(true).then(function(){}).catch(function(error){console.error(error);});}
this._iframeElement.siblings('.rocket-imageslider-text-container').find('.rocket-slider-btn-play-action').on('click',function(e){e.preventDefault();if(self._hasEnded){self._player.setCurrentTime(self._startAt||0);self._hasEnded=false;}
self.play();});if(this._startAt>0){this._player.setCurrentTime(this._startAt);}
if(this._autoplay&&this.element.hasClass('slick-current')){this.play();}
if(this._cover){this.element.append($('').attr('class','rocket-videocover'));Promise.all([this._player.getVideoWidth(),this._player.getVideoHeight()]).then(function(dimensions){self.videoAspectRatio=dimensions[0]/ dimensions[1];self._forceCover();});$(window).on('resize',_.debounce(function(){self._forceCover();},100));this.element.find('.rocket-videocover').on('click',function(){if(self._playing){self.pause();}else{self.play();}});}
this._player.on('play',function(){self._onPlay(false);});this.element.parents('.slick-slider').on('breakpoint',function(){self._iframeElement.load(function(){self._player.off('play');if(self._autoplay){self.play();}
self._player.on('play',function(){self._onPlay(true);});});});this.element.parents('.slick-slider').on('beforeChange',function(event,slick,currentSlide,nextSlide){var iframeId='vimeo'+self._code+timestamp;if($(slick.$slides[currentSlide]).find('iframe').attr('id')==iframeId){self.pause();}
if($(slick.$slides[nextSlide]).find('iframe').attr('id')==iframeId){if(self._rewind&&self._hasStarted){self._iframeElement.siblings('.rocket-imageslider-img-container').css('z-index',2);if(self._startAt>0){self._player.setCurrentTime(self._startAt);}else{self._player.setCurrentTime(0);}}
if(self._autoplay){self.play();}}});},_forceCover:function(){this.containerAspectRatio=this.element.width()/ this.element.height();if(this.containerAspectRatio>this.videoAspectRatio){$(this._player.element).css({'width':'100%','height':Math.ceil(this.containerAspectRatio / this.videoAspectRatio*100)+5+'%'});}else{$(this._player.element).css({'height':'150%','width':Math.ceil(this.videoAspectRatio / this.containerAspectRatio*100)+'%'});}},_onPlay:function(resumePreviousPosition){var self=this;if(this._mute){this._player.setVolume(0);}else if(parseInt(this._volume)>0){this._player.setVolume(parseInt(this._volume)/ 100);}
if(resumePreviousPosition&&this.timeElapsed>0){this._player.setCurrentTime(this.timeElapsed);}
setTimeout(function(){self._iframeElement.fadeIn(1000);},500);this._player.off('timeupdate');this._player.on('timeupdate',function(data){self.timeElapsed=data.seconds;if(self._endAt>0&&data.seconds>=self._endAt){if(self._loop){self._player.setCurrentTime(self._startAt||0);self.play();}else{self.pause();self._hasEnded=true;self._player.setCurrentTime(self._startAt||0);self._iframeElement.siblings('.rocket-imageslider-img-container').css('z-index',2);self.element.find('.rocket-imageslider-text-container').show(300);if(self._advance){self.nextSlide();}}}});this._player.off('ended').on('ended',function(){self._hasEnded=true;self._player.setCurrentTime(self._startAt||0);self._iframeElement.siblings('.rocket-imageslider-img-container').css('z-index',2);self.element.find('.rocket-imageslider-text-container').show(300);if(self._advance){self.nextSlide();}});},nextSlide:function(){var self=this;setTimeout(function(){self.element.parents('.slick-slider').slick('slickNext');},1000);},play:function(){let self=this,playPromise=this._player.play();if(playPromise!==undefined){playPromise.then(value=>{this._iframeElement.siblings('.rocket-imageslider-img-container').css('z-index',0);this._hasStarted=true;this._playing=true;if(this._autohideText){setTimeout(function(){self.element.find('.rocket-imageslider-text-container').fadeOut();},1000);}}).catch(error=>{this._playing=false;});}},pause:function(){if(this._playing){this._player.pause();this._playing=false;this.element.find('.rocket-imageslider-text-container').fadeIn(300);}},playing:function(){return this._playing;}});});
}