!function(a){"use strict";var r,d,s,i,l,o=[],t=!1,n=[],c=!1,u=!1,h=!1;function f(){}(l=function(e,t,i,o){this.container=t,this.wrapID=i;var n,t=this.init(e,t);t?(n=this,t.done(function(e){n.showVideo(e),o&&o.trigger("shown.loftocean.video",e)}).always(function(){o&&o.trigger("done.loftocean.video")})):o&&o.trigger("done.loftocean.video")}).prototype={init:function(e,t){for(var i=0,o="",n=[d,s,r],i=0;i<3;i++){if("test"in(o=new n[i])&&o.test(e))return o.initialize.call(o,e,t,this);o=""}return!1},insertVideo:function(e){this.container.append(a("<div>",{class:"loftocean-video-wrap",id:this.wrapID}).append(e))},showVideo:function(e){this.container.addClass("hide"),this.container.find(".loftocean-video-wrap").addClass("hide"),this.container.find("#"+this.wrapID).removeClass("hide"),this.container.removeClass("hide").addClass("show"),a("body").css("overflow","hidden"),a("#loftocean-fullscreen-media-wrapper .close-button").data("player",e),e.resizeVideo(),e.playVideo()}},f.prototype={deferred:!((i=function(e,t,i){this.container=t,this.args=i;var o,t=this.init(e,t);t&&(o=this,t.done(function(e){o.showVideo(e)}))}).prototype={init:function(e,t){for(var i=0,o="",n=[d,s,r],i=0;i<3;i++)if("test"in(o=new n[i])&&o.test(e))return o.initialize.call(o,e,t,this);return!1},insertVideo:function(e){this.container.append(a(e).addClass("loftocean-autoplay-video hide"))},showVideo:function(e){var t=this.container.find(".loftocean-autoplay-video");e.resizeVideo(),e.playVideo(),this.args&&this.args.className&&(t.find("iframe").length?t.find("iframe"):t).addClass(this.args.className),t.removeClass("hide")}}),initialize:function(e,t,i){return this.html=e,this.deferred=a.Deferred(),this.$container=t,this.container=this.$container.get(0),this.manager=i,this.ready(),this.deferred.promise()},ready:function(){},test:function(e){return!1},getDimensions:function(){var e=this.$container.width()||0;return{width:e,height:e*(this.container.ratio||9/16)}},resizeVideo:function(){var e=this.video,t=this.getDimensions();e.width=t.width,e.height=t.height},playVideo:function(){},pauseVideo:function(){},setMuted:function(){}},r=(f.extend=function(e){function t(){return f.apply(this,arguments)}for(var i in(t.prototype=Object.create(f.prototype)).constructor=t,e)t.prototype[i]=e[i];return t})({test:function(e){var t=/\/\/.+\/.+\.(mp4|webm|ogg|mov)/;if(t.exec(e)){var i=document.createElement("video");return i.src=e.match(t)[0],this.video=i,!0}return!1},ready:function(){var e=this,t=this.video;t.autoplay=!1,t.loop="loop",t.controls="controls",this.video=t,this.manager.insertVideo(t),a(e.video).on("loadedmetadata",function(){e.container.ratio=(this.videoHeight||9)/(this.videoWidth||16),e.deferred.resolve(e)}),a(window).on("resize",function(){e.container.ratio&&e.resizeVideo.call(e)})},playVideo:function(){this.video.play()},pauseVideo:function(){this.video.pause()},setMuted:function(){this.video.muted=!0}}),d=f.extend({regex:/([^"'])*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?'"]*)([^"'])*/,test:function(e){return this.regex.exec(e)},ready:function(){var e;"YT"in window&&YT.Player?this.loadVideo():(o.push(this),t||(t=!0,(e=document.createElement("script")).src="https://www.youtube.com/iframe_api",e.onload=function(){YT.ready(function(e){for(var t="";o.length;)(t=o.pop()).loadVideo.call(t)})},document.getElementsByTagName("head")[0].appendChild(e)))},loadVideo:function(){var t=this,i=a("<div>",{class:"youtube-video"}).get(0),e=this.html.match(this.regex),o=e[2],e=(e=e[0])&&e.includes("?")?(u=u||document.createElement("textarea"),h=h||document.createElement("a"),u.innerHTML=e,h.href=u.childNodes[0].nodeValue,(e=h.search?h.search.substr(1):"").split("&").reduce((e,t)=>{let[i,o]=t.split("=");return e[i]=o?decodeURIComponent(o.replace(/\+/g," ")):"",e},{})):{},n=Object.assign({},{autoplay:0,controls:1,disablekb:1,fs:0,iv_load_policy:3,loop:1,modestbranding:1,playsinline:1,rel:0,showinfo:0},e);a.getJSON("https://noembed.com/embed",{format:"json",url:"https://www.youtube.com/watch?v="+o},function(e){t.container.ratio=(e.height||9)/(e.width||16),e=t.getDimensions.call(t),t.manager.insertVideo(i),t.player=new YT.Player(i,{videoId:o,width:e.width,height:e.height,events:{onReady:function(e){t.video=t.$container.find(".youtube-video").get(0),t.deferred.resolve(t)},onStateChange:function(e){YT.PlayerState.ENDED===e.data&&(n.start&&e.target.seekTo(n.start),e.target.playVideo())}},playerVars:n}),a(window).on("resize",function(){t.container.ratio&&t.video&&t.resizeVideo.call(t)})})},playVideo:function(){this.player.playVideo()},pauseVideo:function(){this.player.pauseVideo()},setMuted:function(){this.player.mute()}}),s=f.extend({regex:/https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)/,test:function(e){return this.regex.exec(e)},ready:function(){var e;"Vimeo"in window&&Vimeo.Player?this.loadVideo():(n.push(this),c||(c=!0,(e=document.createElement("script")).src="https://player.vimeo.com/api/player.js",e.onload=function(){for(var e="";n.length;)(e=n.pop()).loadVideo.call(e)},document.getElementsByTagName("head")[0].appendChild(e)))},loadVideo:function(){var t=this,e=this.html.match(this.regex)[3],i=this.generateID(),o=a("<div>",{id:"vimeo-video-"+i}).get(0);Vimeo&&Vimeo.Player&&(e={id:e,loop:!0,autoplay:!1},t.manager.insertVideo(o),t.player=new Vimeo.Player("vimeo-video-"+i,e),Promise.all([t.player.getVideoWidth(),t.player.getVideoHeight()]).then(function(e){t.container.ratio=e[1]/e[0],t.video=t.$container.find("iframe").get(0),t.deferred.resolve(t),a(window).on("resize",function(){t.container.ratio&&t.resizeVideo.call(t)})}))},playVideo:function(){this.player.play()},pauseVideo:function(){this.player.pause()},setMuted:function(){this.player.setVolume(0)},generateID:function(){var e="",t=10,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=i.length;do{for(e="",t=10;t--;)e+=i.charAt(Math.floor(Math.random()*o))}while(a("#"+e).length);return e}}),document.addEventListener("DOMContentLoaded",function(){a("body").on("click","#loftocean-fullscreen-media-wrapper .close-button",function(e){e.preventDefault();e=a(this);e.data("player")&&(e.data("player").pauseVideo(),e.data("player",!1)),a("#loftocean-fullscreen-media-wrapper").removeClass("show").addClass("hide"),a("body").css("overflow","")}),a(document).on("video.play",function(e,t,i){if(void 0!==t&&a(t).length&&void 0!==i){var o=a(t),n=function(e,t=0){for(var i,o=3735928559^t,n=1103547991^t,a=0;a<e.length;a++)i=e.charCodeAt(a),o=Math.imul(o^i,2654435761),n=Math.imul(n^i,1597334677);return o=Math.imul(o^o>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&(n=Math.imul(n^n>>>16,2246822507)^Math.imul(o^o>>>13,3266489909)))+(o>>>0)}(i);if(o.data("clicking"))return!1;o.data("clicking",!0),o.data("videoManager")&&o.data("player")?(o.data("videoManager").showVideo(o.data("player")),o.data("clicking",!1)):((t=a("#loftocean-fullscreen-media-wrapper")).length||(t=a("<div>",{id:"loftocean-fullscreen-media-wrapper",class:loftoceanFullscreenVideos.wrapClass+" hide"}).append(a("<div>",{class:"close-button",text:"close"})),a("body").append(t)),o.data("videoManager",new l(i,t,n,o)))}}),loftoceanFullscreenVideos&&loftoceanFullscreenVideos.videos&&Array.isArray(loftoceanFullscreenVideos.videos)&&(a(".video-block .video-play-btn, .featured-video-play-btn").on("click",function(e){var t,i,o=a(this),n="loftocean-fullscreen-"+o.data("loftocean-video-id");if(o.data("clicking"))return!1;o.data("clicking",!0),o.data("videoManager")&&o.data("player")?(o.data("videoManager").showVideo(o.data("player")),o.data("clicking",!1)):o.data("loftocean-video-id")&&(t=o.data("loftocean-video-id").replace("video-id-",""),loftoceanFullscreenVideos.videos[t]&&((i=a("#loftocean-fullscreen-media-wrapper")).length||(i=a("<div>",{id:"loftocean-fullscreen-media-wrapper",class:loftoceanFullscreenVideos.wrapClass+" hide"}).append(a("<div>",{class:"close-button",text:"close"})),a("body").append(i)),o.data("videoManager",new l(loftoceanFullscreenVideos.videos[t],i,n,o))))}).on("shown.loftocean.video",function(e,t){e.preventDefault(),a(this).data("player",t).data("clicking",!1)}).on("done.loftocean.video",function(e){e.preventDefault(),a(this).data("clicking",!1)}),a(document).on("autoplay.loftocean.video",function(e,t){t&&t.video&&t.container&&a(t.container).length&&new i(t.video,a(t.container),t.args||!1)}))})}(jQuery);