!function(t,$){"use strict";var i=function(t){this.instance=t,this.init()};$.extend(i.prototype,{$button:null,$grid:null,$list:null,isVisible:!1,init:function(){var t=this,i=!1,e=t.instance.group[0],s=t.instance.group[1];t.$button=t.instance.$refs.toolbar.find("[data-envirabox-thumbs]"),t.instance.group.length>1&&t.instance.group[t.instance.currIndex].opts.thumbs&&("image"==e.type||e.opts.thumb||e.opts.$thumb)&&("image"==s.type||s.opts.thumb||s.opts.$thumb)?(t.$button.on("touchstart click",function(e){e.stopImmediatePropagation(),"touchend"==e.type?(i=!0,t.toggle()):"click"!=e.type||i?i=!1:t.toggle()}),t.isActive=!0):(t.$button.hide(),t.isActive=!1)},create:function(){var t=this.instance,i,e,s,n,o;this.$grid=$('<div class="envirabox-thumbs envirabox-thumbs-'+t.opts.thumbs.position+'"></div>').appendTo(t.$refs.container),o="auto"===t.opts.thumbs.rowHeight?50:t.opts.thumbs.rowHeight;var a=new Image;a.onload=function(){a.src=t.group[0].thumb,s=0!==a.naturalHeight?a.naturalHeight:o},a.src=t.group[0].thumb,s=0!==a.naturalHeight?a.naturalHeight:o,i='<ul style="height:'+s+'px">',$.each(t.group,function(t,s){if(e=s.opts.thumb||(s.opts.$thumb?s.opts.$thumb.attr("src"):null),n=s.opts.videoPlayIcon?s.opts.videoPlayIcon:!1,e||"image"!==s.type||(e=s.src),e&&e.length){var o=void 0!==s.contentProvider?s.contentProvider:"none";i+='<li data-index="'+t+'"  tabindex="0" class="envirabox-thumbs-loading envirabox-thumb-content-provider-'+o+" envirabox-thumb-type-"+s.type+'"><img class="envirabox-thumb-image-'+s.type+" envirabox-thumb-content-provider-"+o+'" data-src="'+e+'" />',!n||"video"!=s.type&&"genericDiv"!=s.type&&"youtube"!=o&&"vimeo"!=o&&"instagram"!=o&&"twitch"!=o&&"dailymotion"!=o&&"metacafe"!=o&&"wistia"!=o&&"videopress"!=o||(i+='<div class="envira-video-play-icon">Play</div>'),i+="</li>"}}),i+="</ul>",this.$list=$(i).appendTo(this.$grid).on("click touchstart","li",function(){t.jumpTo($(this).data("index"))}),this.$list.find("img").hide().one("load",function(){var t=$(this).parent().removeClass("envirabox-thumbs-loading"),i=$(this).outerWidth(),e=$(this).outerHeight(),s,n,a,h;s=this.naturalWidth||this.width,n=this.naturalHeight||this.height,a=s/i,h=n/e,a>=1&&h>=1&&(a>h?(s/=h,n=e):(s=i,n/=a)),$(this).css({width:"auto",height:Math.floor(o),"margin-top":Math.min(0,Math.floor(.3*e-.3*n)),"margin-left":Math.min(0,Math.floor(.5*i-.5*s))}).show()}).each(function(){this.src=$(this).data("src")})},focus:function(){this.instance.current&&this.$list.children().removeClass("envirabox-thumbs-active").filter('[data-index="'+this.instance.current.index+'"]').addClass("envirabox-thumbs-active").focus()},close:function(){this.$grid.hide()},update:function(){this.instance.$refs.container.toggleClass("envirabox-show-thumbs",this.isVisible),this.isVisible?(this.$grid||this.create(),this.instance.trigger("onThumbsShow"),this.focus()):this.$grid&&this.instance.trigger("onThumbsHide"),this.instance.update()},hide:function(){this.isVisible=!1,this.update()},show:function(){this.isVisible=!0,this.update()},toggle:function(){this.isVisible=!this.isVisible,this.update()}}),$(t).on({"onInit.eb":function(t,e){e&&!e.Thumbs&&(e.Thumbs=new i(e))},"beforeShow.eb":function(t,i,e,s){var n=i&&i.Thumbs;if(n&&n.isActive){if(e.modal)return n.$button.hide(),void n.hide();s&&e.opts.thumbs.autoStart===!0&&n.show(),n.isVisible&&n.focus()}},"afterKeydown.eb":function(t,i,e,s,n){var o=i&&i.Thumbs;o&&o.isActive&&71===n&&(s.preventDefault(),o.toggle())},"beforeClose.eb":function(t,i){var e=i&&i.Thumbs;e&&e.isVisible&&i.opts.thumbs.hideOnClose!==!1&&e.close()}})}(document,window.jQuery);