var __assign=this&&this.__assign||function(){return __assign=Object.assign||function(n){for(var t,r,i=1,u=arguments.length;i<u;i++){t=arguments[i];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},__assign.apply(this,arguments)},showSingleVideoMediaQuery="(min-width:768px)";Vue.component("video-search",{props:{keywords:String,itemLimit:Number,supportOnly:Boolean,showPaging:Boolean,searchFields:Array},data:function(){return{videos:[],selectedVideo:null,showSingleVideo:!0,totalResults:0,skipResults:0,autoplay:!1}},watch:{keywords:function(){this.getResults()}},methods:{getResults:function(n){var t=this,i;n===void 0&&(n=!1);i={searchQuery:this.keywords,itemLimit:this.itemLimit,skip:this.skipResults,searchFields:this.searchFields,otherOptions:{supportOnly:this.supportOnly}};$.ajax({url:"/api/videos/search",method:"POST",contentType:"application/json",context:this,data:JSON.stringify(i)}).then(function(i){t.totalResults=i.totalCount;t.videos=i.results;(!t.selectedVideo||n)&&(t.selectedVideo=t.videos[0])})},changePage:function(n){var t=this.itemLimit===1;this.skipResults=n;this.getResults(t)},selectionChange:function(n){this.autoplay=!0;this.selectedVideo=this.videos.find(function(t){return t.id===n})}},mounted:function(){this.getResults()},template:'\n<div class="">\n\t<div v-show="videos.length">\n\t\t<video-embed v-if="selectedVideo" :embed-url="selectedVideo.embedUrl" :autoplay="autoplay" :title="selectedVideo.title"><\/video-embed>\n\t\t<div v-if="totalResults > 1" class="row justify-content-center mt-4">\n\t\t\t<video-search-result  v-for="video in videos"\n\t\t\t\t\t\t\t\t:key="video.id"\n\t\t\t\t\t\t\t\t:video="video"\n\t\t\t\t\t\t\t\t:selected="video.id === selectedVideo.id"\n\t\t\t\t\t\t\t\t@selection-change="selectionChange($event)"><\/video-search-result>\n\t\t<\/div>\n\t\t<search-paging v-if="showPaging"\n\t\t\t\t\t\tclass="mt-4"\n\t\t\t\t\t\t:totalRows="totalResults"\n\t\t\t\t\t\t:start-row="skipResults"\n\t\t\t\t\t\t:row-limit="itemLimit"\n\t\t\t\t\t\t:page-limit="3"\n\t\t\t\t\t\t@change-page="changePage($event)"><\/search-paging>\n\t<\/div>\n<\/div>'});Vue.component("video-embed",{props:{embedUrl:String,title:String,autoplay:Boolean,lazyLoad:{type:Boolean,"default":!0}},computed:{embedCode:function(){if(!this.embedUrl)return null;var n=$(this.embedUrl),t=new URL(n.attr("src")||n.attr("data-src")),i=this.autoplay?"1":"0";return t.searchParams.set("autoplay",i),this.lazyLoad?(n.addClass("embed-responsive-item lazyload"),n.attr("loading","lazy"),n.attr("data-src",t.toString()),n.removeAttr("src")):n.attr("src",t.toString()),n.attr("title")||n.attr("title",this.title),n[0].outerHTML}},template:'<div class="embed-responsive embed-responsive-16by9 mx-auto w-100" v-html="embedCode"><\/div>'});Vue.component("video-search-result",{props:{video:Object,selected:Boolean},data:function(){return{thumbnailSize:"mqdefault"}},computed:{thumbnail:function(){var n=null,t=$(this.video.embedUrl),u=t.attr("data-src")||t.attr("src"),i=/(\/embed\/)(.*?)(\?|$)/gi.exec(u),r;return i&&(r=i[2],n="https://i.ytimg.com/vi/".concat(r,"/").concat(this.thumbnailSize,".jpg")),n}},template:'\n<div class="card col-4 border-0 p-2 p-sm-3" :class="[selected ? \'gray-background selected\' : \'\']">\n  <img class="card-img-top" :src="thumbnail" :alt="video.title">\n  <div class="card-body p-0 pt-1">\n    <p class="caption text-right">Length: {{ video.videoLength }}<\/p>\n    <a v-if="!selected" href="#" class="stretched-link" @click.prevent="$emit(\'selection-change\', video.id)"><h4 class="mt-2">{{ video.title }}<\/h4><\/a>\n    <h4 v-else class="mt-2">{{ video.title }}<\/h4>\n  <\/div>\n<\/div>'});Daktronics.Components.RegisterVues(".video-search");Vue.component("video-gallery",{props:{searchQuery:String,defaultKeywords:String,searchFields:String,itemLimit:{type:Number,"default":5},showPaging:{type:Boolean,"default":!1},supportOnly:{type:Boolean,"default":!1},facetFields:{type:Array,"default":function(){return[]}}},computed:{videoResults:function(){return this.$store.state.results.search},totalResults:function(){return this.$store.state.results.totalCount},skipResults:function(){return this.$store.state.query.skip}},methods:{changePage:function(n){this.$store.dispatch("skipResults",n)},changeSelection:function(n){var t=this.videoResults.find(function(t){return t.id===n});this.$emit("selection-change",t)},loadVideoFromUrlName:function(n){var t=this;$.ajax({url:"/api/videos/getByName/".concat(n,"?supportOnly=").concat(this.supportOnly),method:"GET"}).then(function(n){n&&t.$emit("selection-change",n)}).catch(function(n){t.$emit("selection-change",{error:n})})},setSelectedVideoOnLoad:function(){var n=this.$route.query.video,t;n&&(t=this.videoResults.find(function(t){return t.urlName===n}),t?this.changeSelection(t.id):this.loadVideoFromUrlName(n))}},created:function(){var n=this;this.$store.dispatch("init",{context:{url:"/api/videos/search"},query:{userKeywords:this.searchQuery,defaultKeywords:this.defaultKeywords,itemLimit:this.itemLimit,facetFields:this.facetFields,otherSearchOptions:{supportOnly:this.supportOnly}}}).then(function(){n.setSelectedVideoOnLoad()})},template:'\n<div>\n\t<div class="row justify-content-center mt-4">\n\t\t<video-search-result v-for="video in videoResults" :key="video.id"\n\t\t\t\t\t\t\t:video="video"\n\t\t\t\t\t\t\t@selection-change="changeSelection"><\/video-search-result>\n\t<\/div>\n\t<search-paging v-if="showPaging" class="my-5"\n\t\t\t\t:total-rows="totalResults"\n\t\t\t\t:start-row="skipResults"\n\t\t\t\t:row-limit="itemLimit"\n\t\t\t\t:page-limit="5"\n\t\t\t\t@change-page="changePage($event)"><\/search-paging>\n<\/div>'});Vue.component("video-details",{props:{video:{type:Object,"default":function(){return null}}},data:function(){return{modalSelector:"#video-details-modal"}},computed:{error:function(){var n;if((n=this.video)!==null&&n!==void 0)return n.error}},methods:{setUrl:function(n){if(!this.error){var i=this.$route.query,t=__assign({},i);n?t.video=n:delete t.video;t.video!==i.video&&(i.video?this.$router.replace({query:t}):this.$router.push({query:t}))}},close:function(){this.setUrl(null);this.$emit("close")}},mounted:function(){var n=this;this.setUrl(this.video.urlName);$(this.modalSelector).modal("show").on("hidden.bs.modal",function(){n.close()});window.onpopstate=function(){$(n.modalSelector).modal("hide")}},template:'\n<div id="video-details-modal" class="modal fade" role="dialog" aria-hidden="true">\n    <div class="modal-dialog modal-dialog-centered">\n        <div class="modal-content">\n\t\t\t<div class="modal-header align-items-center">\n\t\t\t\t<h4 class="m-0">{{ video.title }}<\/h4>\n\t\t\t\t<button v-if="video.searchable" type="button" class="close" data-dismiss="modal" aria-label="Close">\n\t\t\t\t  <span aria-hidden="true">&times;<\/span>\n\t\t\t\t<\/button>\n\t\t\t<\/div>\n\t\t\t<div v-if="error" class="modal-body text-center">\n\t\t\t\t<div v-if="error.status === 404">\n                    <h2>Not Found<\/h2>\n                    <p>Sorry, we couldn\'t find the requested video.<\/p>\n                <\/div>\n                <div v-else>\n                    <h2>Error Occured<\/h2>\n                    <p>Sorry, there was a problem getting details for this video.<\/p>\n                <\/div>\n\t\t\t<\/div>\n\t\t\t<div v-else class="modal-body">\n\t\t\t\t<div class="row justify-content-center">\n\t\t\t\t\t<div class="col-12 col-lg-9">\n\t\t\t\t\t\t<video-embed :embed-url="video.embedUrl" :autoplay="false" :lazy-load="false" :title="video.title"><\/video-embed>\n\t\t\t\t\t\t<p class="caption text-right"><\/p>\n\t\t\t\t\t\t<h1 class="mt-5">{{ video.title }}<\/h1>\n\t\t\t\t\t\t<h2 class="pageSubTitle">{{ video.subTitle }}<\/h2>\n\t\t\t\t\t\t<div v-html="video.marketingHTML"><\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/div>\n\t<\/div>\n<\/div>'});$("#video-gallery-search").length&&new Vue({el:"#video-gallery-search",router:Daktronics.Components.GetVueRouter(),store:makeSearchComponentStore(),data:{selectedVideo:null},computed:{searchQuery:function(){return this.$store.state.query.userKeywords}},methods:{updateUserSearchQuery:function(n){this.$store.dispatch("newKeywordQuery",n).then(function(){$("#video-gallery-search input[type=text]").get(0).blur()})},restartSearch:function(){this.$store.dispatch("reset")}},created:function(){this.$store.commit("setRouter",this.$router)}})