Daktronics.Conversions=Daktronics.Conversions||{millimeterToFeet:function(mm){return mm/304.8},millimeterToInch:function(mm){return mm/25.4},feetToMillimeter:function(ft){return ft*304.8},meterToInches:function(m){return m*39.3700787},millimeterToMeter:function(mm){return mm/1e3},millimeterToCentimeter:function(mm){return mm/10},meterToMillimeter:function(m){return m*1e3},feetToMeter:function(ft){return Daktronics.Conversions.millimeterToMeter(Daktronics.Conversions.feetToMillimeter(ft))},meterToFeet:function(m){return Daktronics.Conversions.millimeterToFeet(Daktronics.Conversions.meterToMillimeter(m))},poundToKilo:function(lb){return lb/2.2046},inchesToFeet:function(inches,inchesFactionDigits=1){var feet=Math.floor(inches/12),inchesPrecision=Math.pow(10,inchesFactionDigits),inchesRemainder=Math.round(inches%12*inchesPrecision)/inchesPrecision,inchesRounded,returnVal;if(inchesRemainder>0&&inchesRemainder<12){let inchesFormat=new Intl.NumberFormat("en-US",{maximumFractionDigits:inchesFactionDigits});inchesRounded=inchesFormat.format(inchesRemainder)}else inchesRemainder===12&&feet++;return returnVal=feet+"'",inchesRounded&&(returnVal+=` ${inchesRounded}"`),returnVal},inchesToFeetDecimal:function(inches){return inches/12},inchesToFeetRounded:function(inches,feetDecimalPlaces=0){const feetPrecision=Math.pow(10,feetDecimalPlaces);return Math.round(Daktronics.Conversions.inchesToFeetDecimal(inches)*feetPrecision)/feetPrecision},inchesToCentimeter:function(inches){return inches*2.54},inchesToMeters:function(inches,formatted=false){let val=inches/39.3700787;return formatted?Daktronics.Conversions.decimalRoundedToHundreths(val)+"m":val},feetToInches:function(ft){return ft*12},mmToInches:function(mm){return mm*.03937},kiloToPound:function(kg){return kg*2.2046},decimalRoundedToHundreths:function(value){let epsilon=Number.EPSILON||Math.pow(2,-52);return Math.round((value+epsilon)*100)/100},decimalRoundedToTenths:function(value){let epsilon=Number.EPSILON||Math.pow(2,-52);return Math.round((value+epsilon)*10)/10}};Daktronics.Dimensions=Daktronics.Dimensions||function(heightInches=0,lengthInches=0,depthInches=0){this.heightInches=heightInches;this.lengthInches=lengthInches;this.depthInches=depthInches;this.heightInFeet=function(){return this.heightInches?Daktronics.Conversions.inchesToFeet(this.heightInches):null};this.lengthInFeet=function(){return this.lengthInches?Daktronics.Conversions.inchesToFeet(this.lengthInches):null};this.depthInFeet=function(){return this.depthInches?Daktronics.Conversions.inchesToFeet(this.depthInches):null};this.heightInMeters=function(){return this.heightInches?Daktronics.Conversions.inchesToMeters(this.heightInches,!0):null};this.lengthInMeters=function(){return this.lengthInches?Daktronics.Conversions.inchesToMeters(this.lengthInches,!0):null};this.depthInMeters=function(){return this.depthInches?Daktronics.Conversions.inchesToMeters(this.depthInches,!0):null}};Daktronics.Dimensions.prototype.toString=function(standardOnly=false,metricOnly=false){let stdSB=[],metricSB=[],stringVal="";if(this.heightInFeet()&&stdSB.push(this.heightInFeet()),this.lengthInFeet()&&stdSB.push(this.lengthInFeet()),this.depthInFeet()&&stdSB.push(this.depthInFeet()),this.heightInMeters()&&metricSB.push(this.heightInMeters()),this.lengthInMeters()&&metricSB.push(this.lengthInMeters()),this.depthInMeters()&&metricSB.push(this.depthInMeters()),stdSB.length&&(stringVal=stdSB.join(" x "),standardOnly))return stringVal;if(metricSB.length){let metricVal=metricSB.join(" x ");if(metricOnly)return metricVal;stringVal+=` (${metricVal})`}return stringVal};
Vue.component("site-search-results",{props:{searchQuery:String,defaultKeywords:{type:String,"default":null},itemLimit:{type:Number,"default":10},parentIds:{type:Array,"default":function(){return null}}},computed:{show(){return!!this.results.length&&!!this.searchQuery},results(){return this.$store.state.results.search||[]},totalResults(){return this.$store.state.results.totalCount},skipResults(){return this.$store.state.query.skip},error(){return this.$store.state.error}},watch:{results(newResults){this.$emit("results-updated",newResults)}},methods:{changePage(skipResults){this.$store.dispatch("skipResults",skipResults)}},created(){this.$store.dispatch("init",{context:{url:"/api/pages/search"},query:{userKeywords:this.searchQuery,defaultKeywords:this.defaultKeywords,itemLimit:this.itemLimit,otherSearchOptions:{parentIds:this.parentIds}}})},template:`
<div>
    <h2 v-if="searchQuery">Site Results</h2>
    <div v-if="error">Sorry, there was a problem getting results. Please try again later.</div>
    <div v-else-if="!results.length && searchQuery">No results found.</div>
    <div v-for="(result, index) in results" :key="index" class="search-result p-2 mx-n2 position-relative">
        <h3 class="search-result-name mb-0">{{ result.name }}</h3>
        <div v-html="result.description"></div>
        <a class="search-result-url stretched-link" :href="result.url">{{ result.url }}</a>
    </div>
	<search-paging v-if="totalResults > itemLimit" class="my-5"
				:total-rows="totalResults"
				:start-row="skipResults"
				:row-limit="itemLimit"
				:page-limit="5"
				@change-page="changePage($event)"></search-paging>
</div>`});Vue.component("site-search-photos",{props:{searchQuery:String,defaultKeywords:{type:String,"default":null}},router:Daktronics.Components.GetVueRouter(),store:makeSearchComponentStore(),computed:{keywords(){let keywords=this.searchQuery;return this.defaultKeywords&&(keywords=`(${this.defaultKeywords}) AND (${this.searchQuery})`),keywords}},template:`
<div id="site-search-photos">
    <photo-band v-if="searchQuery"
                :keywords="keywords"
                :item-limit="12"
                id="site-search-photos" />
</div>`});Vue.component("site-search-documents",{props:{searchQuery:String,defaultKeywords:{type:String,"default":null}},store:makeSearchComponentStore(),data(){return{hasResults:!1}},computed:{show(){return this.hasResults&&!!this.searchQuery},keywords(){let keywords=this.searchQuery;return this.defaultKeywords&&(keywords=`(${this.defaultKeywords}) AND (${this.searchQuery})`),keywords}},template:`
<div v-show="show" id="site-search-documents">
    <h3>Document Results</h3>
    <document-search v-if="searchQuery"
                     :search-query="keywords"
                     :item-limit="5"
                     :show-paging="true"
                     @has-results="hasResults = $event"></document-search>
</div>`});Vue.component("site-search-products",{props:{scoreboardModelPage:String,searchQuery:String,defaultKeywords:String},store:makeSearchComponentStore(),data(){return{itemLimit:5}},computed:{show(){return!!this.results.length&&!!this.searchQuery},results(){return this.$store.state.results.search.map(result=>{let url=this.scoreboardModelPage+result.modelNumber;this.scoreboardModelPage.includes("/en-us/products/sports/")||(url=this.scoreboardModelPage+"?model="+result.modelNumber);let lengthFt=Daktronics.Conversions.inchesToFeet(result.length);return{name:result.title,description:lengthFt+" "+result.subTitle,url:url}})},totalResults(){return this.$store.state.results.totalCount},skipResults(){return this.$store.state.query.skip}},watch:{searchQuery(newSearchQuery){this.$store.dispatch("newKeywordQuery",newSearchQuery)}},methods:{changePage(skipResults){this.$store.dispatch("skipResults",skipResults)}},created(){this.$store.dispatch("init",{context:{url:"/api/products/scoreboards/search"},query:{userKeywords:this.searchQuery,defaultKeywords:this.defaultKeywords,itemLimit:this.itemLimit,searchFields:["SubTitle","ProductDescription","Product/Family","Product/Model","ScoreboardInfo/PrimarySport","ScoreboardInfo/ScoringCapabilities","ScoreboardInfo/InformationDisplayed"]},fetch:!1})},template:`
<div v-show="show">
    <h2>Scoreboard Product Results</h2>
    <div v-for="(result, index) in results" :key="index" class="search-result p-2 mx-n2 position-relative">
        <h3 class="search-result-name mb-0 d-inline-block">{{ result.name }}</h3>
        <span v-if="result.description">({{ result.description }})</span>
        <a class="search-result-url stretched-link" :href="result.url"></a>
    </div>
    <search-paging class="my-5"
            :total-rows="totalResults"
            :start-row="skipResults"
            :row-limit="itemLimit"
            :page-limit="5"
            @change-page="changePage($event)"></search-paging>
</div>`});Vue.component("site-search-kb",{props:{searchQuery:String,defaultKeywords:{type:String,"default":null}},store:makeSearchComponentStore(),data(){return{hasResults:!1}},computed:{show(){return this.hasResults&&!!this.searchQuery}},watch:{searchQuery(value){this.$store.dispatch("newKeywordQuery",value)}},template:`
<div v-if="searchQuery" id="site-search-kb">
    <h3>Knowledge Base Results</h3>
    <service-knowledge :search-query="searchQuery"
                       :default-keywords="defaultKeywords"
                       :item-limit="3"
                       :show-paging="true"
                        @has-results="hasResults = $event"></service-knowledge>
</div>`});new Vue({el:"#site-search",router:Daktronics.Components.GetVueRouter(),store:makeSearchComponentStore(),data:{contentPageResultCount:0,bestBetResultCount:0},computed:{searchQuery(){return this.$store.state.query.userKeywords}},methods:{updateUserSearchQuery(keywords){this.$store.dispatch("newKeywordQuery",keywords).then(()=>{$(`#site-search input[type=text]`).get(0).blur(),this.contentPageResultCount=0,this.bestBetResultCount=0})},restartSearch(){this.$store.dispatch("reset")}},created(){this.$store.commit("setRouter",this.$router)}});
