@searchstax-inc/searchstudio-ux-react 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,7 @@ Check the top-level render call using <`+y+">.")}return p}}function Ge(c,p){{if(
29
29
  <%s {...props} />
30
30
  React keys must be passed directly to JSX without using spread:
31
31
  let props = %s;
32
- <%s key={someKey} {...props} />`,Ie,ae,Ft,ae),et[ae+Ie]=!0}}return c===s?wt(H):Rt(H),H}}function Et(c,p,y){return tt(c,p,y,!0)}function It(c,p,y){return tt(c,p,y,!1)}var Pt=It,jt=Et;ge.Fragment=s,ge.jsx=Pt,ge.jsxs=jt}()),ge}process.env.NODE_ENV==="production"?Fe.exports=At():Fe.exports=Mt();var u=Fe.exports,Dt=Object.defineProperty,$t=(n,e,t)=>e in n?Dt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,h=(n,e,t)=>($t(n,typeof e!="symbol"?e+"":e,t),t),B=(n=>(n[n.mustache=0]="mustache",n[n.vue=1]="vue",n[n.react=2]="react",n[n.angular=3]="angular",n))(B||{});class Nt{constructor(e){h(this,"dataLayer"),this.dataLayer=e}get currentPage(){var e;return(e=this.dataLayer.searchObject)==null?void 0:e.page}get totalResults(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.totalResultsValue)||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.options)||[]}get selectedSortOption(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.selectedSortOption)||""}get startResultIndex(){var e;return(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+1}get endResultIndex(){var e;const t=(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+(this.resultsPerPage??0);return t>this.totalResults?this.totalResults:t}get isFirstPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)===1}get isLastPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||""}get originalQuery(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.query)||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswer(){return this.isFirstPage&&this.dataLayer.getAnswerData!==""&&this.dataLayer.searchObject.query!=="*"&&this.dataLayer.searchObject.facets.length===0}get searchTerm(){var e,t;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||((t=this.dataLayer.searchObject)==null?void 0:t.query)||""}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get searchExecuted(){var e,t,s;return((e=this.dataLayer.searchObject)==null?void 0:e.query)!==void 0&&((t=this.dataLayer.searchObject)==null?void 0:t.query)!=="undefined"&&((s=this.dataLayer.searchObject)==null?void 0:s.query)!==""}get selectedFacets(){var e;const t=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return t?(((e=this.dataLayer.searchObject)==null?void 0:e.facets)??[]).map(s=>{const a=s.name,r=s.value,i=t.find(l=>l.name===a);if(i){const l=i.values.find(o=>o.type==="range"?!1:o.type==="checkbox"?'"'+o.value+'"'===r:!1);if(l)return l}return null}).filter(s=>s!==null):[]}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,selectedFacets:this.selectedFacets,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption}}get trackingData(){var e,t,s,a;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:((t=this.dataLayer.searchResultsMetadata)==null?void 0:t.recordsPerPageValue)??0,totalResults:((s=this.dataLayer.searchResultsMetadata)==null?void 0:s.totalResultsValue)??0,currentPage:this.dataLayer.currentPage,latencyVal:((a=this.dataLayer.searchResultsMetadata)==null?void 0:a.latency)??0}}}class X{static deepEqual(e,t){const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(const r of s){const i=e[r],l=t[r],o=this.isObject(i)&&this.isObject(l);if(o&&!this.deepEqual(i,l)||!o&&i!==l)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class ${constructor(e){h(this,"value"),h(this,"observers",[]),this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const t=this.observers.indexOf(e);t!==-1&&this.observers.splice(t,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class Pe{static getOrSetCookie(e,t){let s=this.getCookie(e);return s==null&&(s=t??this.makeid(25),this.setCookie(e,s,{secure:!0,"max-age":3600})),s}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=s.length;for(let r=0;r<e;r++)t+=s.charAt(Math.floor(Math.random()*a));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,s){const a={path:"/",...s};s.expires instanceof Date&&(a.expires=s.expires.toUTCString());let r=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in a){r+="; "+i;const l=a[i];l!==!0&&(r+="="+l)}typeof document<"u"&&(document.cookie=r)}}class te{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",s=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(s,""):""}}class qt{constructor(e,t){h(this,"$searchTermChange",new $("")),h(this,"$loadingChange",new $(!1)),h(this,"$searchResults",new $(null)),h(this,"$searchResultsMetadata",new $(null)),h(this,"$searchAutosuggest",new $(null)),h(this,"$searchFacets",new $(null)),h(this,"$searchFacetsCached",new $(null)),h(this,"$searchstaxConfig",new $(null)),h(this,"$autosuggestResults",new $(null)),h(this,"$itemsPerPage",new $(void 0)),h(this,"$searchObject",new $({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]})),h(this,"$searchRelatedSearches",new $(null)),h(this,"$searchInputConfig",new $(null)),h(this,"$searchExternalPromotions",new $(null)),h(this,"$facetsTemplateData",new $(null)),h(this,"$selectedFacetsTemplateData",new $(null)),h(this,"$paginationData",new $(null)),h(this,"$searchFeedbackData",new $(null)),h(this,"$searchSortingData",new $(null)),h(this,"$searchRelatedSearchesData",new $(null)),h(this,"$searchExternalPromotionsData",new $(null)),h(this,"$cookiesDisabled",new $(null)),h(this,"$answer",new $("")),h(this,"$language",new $("en")),h(this,"currentPageValue",1),h(this,"isAnswerWidgetCreatedValue",!1),h(this,"renderingEngineValue",B.mustache),h(this,"parsedData",new Nt(this)),h(this,"sessionId"),h(this,"sessionIdValue",null),h(this,"autoCorrect",!0),h(this,"forceNotCorrect",!1),h(this,"lastSearchValue",""),h(this,"turnAIAnswerGenerationOn",!1),h(this,"isInfiniteScroll",!1),h(this,"firstSearchHappened",!1),h(this,"facetsWereSet",!1),this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,Pe.deleteCookie(this.sessionId),Pe.deleteCookie("ms_visitorid")):this.sessionIdValue=Pe.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(te.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setIsAnswerWidgetCreated(e){this.isAnswerWidgetCreatedValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){this.firstSearchHappened=!0,(!X.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){X.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var t,s;let a=e;a={...a,itemsPerPage:this.itemsPerPage},(s=(t=this.searchstaxConfig)==null?void 0:t.hooks)!=null&&s.beforeSearch&&a&&(a=this.searchstaxConfig.hooks.beforeSearch(a)),a&&(!X.deepEqual(a,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(a)}setSearchFacets(e){this.facetsWereSet=!0,X.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){X.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){X.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){X.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setAutosuggestResults(e){this.$autosuggestResults.setValue(e)}setFacetsTemplateData(e){this.$facetsTemplateData.setValue(e)}setSelectedFacetsTemplateData(e){this.$selectedFacetsTemplateData.setValue(e)}setPaginationData(e){this.$paginationData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCached(){return this.$searchFacetsCached.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCached.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}}class pe{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,r)=>{const i=a[e.responseHeader.params.uniqueId]??"",l={custom:null,uniqueId:i,position:s+1+r,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e,i):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e,i):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e,i):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,i):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,i,!0):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e,i):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e,i):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e,i):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e,i):null,unmappedFields:this.getUnmappedFields(a,e,i),allFields:this.getAllFields(a,e)};t.push(l)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const s of e.metadata.facets){let a={values:[]};if(a.name=s.name,a.label=s.label,s.name in e.facet_counts.facet_fields){const r=e.facet_counts.facet_fields[s.name];for(let i=0;i<r.length;i+=2){const l={};l.value=r[i],l.parentName=a.name,l.count=r[i+1],l.type="checkbox",a.values.push(l)}}a.values.length>0&&t.push(a)}return t}static extractSearchResultsMetadata(e){var t,s,a,r,i,l;let o="",d={selectedSortOption:"",options:[]},f=(t=e.metadata.results.find(g=>g.result_card==="date"))==null?void 0:t.name;if(d.options=[{key:"",value:"Relevance"},{key:f+" desc",value:"Most Recent"}],(s=e.metadata.sorts)!=null&&s.length){const g=e.metadata.sorts.map(m=>({value:m.label,key:m.name+" "+m.order}));d.options=[{key:"",value:"Relevance"},...g]}return o=((l=(i=(r=(a=e==null?void 0:e.spellcheck)==null?void 0:a.suggestions)==null?void 0:r[1])==null?void 0:i.suggestion)==null?void 0:l[0])??"",typeof o!="string"&&(o=(o==null?void 0:o.word)??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:o,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:d}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const r=s[a],i={};i.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(i.cDocTitle=this.getDataForAnalytics(r.title)),i.position=r.position,t.push(i)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(s=>s.uniqueId===e)??null}static getUnmappedFields(e,t,s){const a=t.metadata.results.filter(i=>i.result_card==="").map(i=>i.name),r=[];for(const i of Object.keys(e))if(a.indexOf(i)!==-1){const l=Array.isArray(e[i])?this.getHighlightedResults(i,e[i].join(", "),s,t):this.getHighlightedResults(i,e[i]+"",s,t);r.push({key:i,value:l,isImage:this.checkIfImage(e[i])})}return r}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const s=t.metadata.results.map(r=>r.name),a=[];for(const r of Object.keys(e))s.indexOf(r)!==-1&&a.push({key:r,value:e[r],isImage:this.checkIfImage(e[r])});return a}static doesMapExist(e,t){return t.metadata.results.find(s=>s.result_card===e)!==void 0}static getValueByKey(e,t,s,a,r=!1){const i=s.metadata.results.find(o=>o.result_card===e);if(i===void 0)return null;const l=t[i.name];return l===void 0?null:typeof l=="string"?r?l:this.getHighlightedResults(i.name,l,a,s):Array.isArray(l)?r?l.join(", "):this.getHighlightedResults(i.name,l.join(", "),a,s):null}static getHighlightedResults(e,t,s,a){if(a.highlighting&&s in a.highlighting){let r=a.highlighting[s];if(r&&e in r){let i=r[e];const l=this.cleanValue(i);if(l!=="")return l}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class rt{constructor(e){h(this,"routeName","searchstax"),h(this,"ignoredKeys",[]),h(this,"queryStringHelper"),h(this,"titleParser"),e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new _t(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=typeof document<"u"?document==null?void 0:document.title:"";this.titleParser&&(s=this.titleParser(e)),typeof document<"u"&&(document.title=s),(window==null?void 0:window.location.href)!==t&&(window==null||window.history.pushState({},s,t))}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")?(window==null?void 0:window.location.href.split("?")[0])+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):(window==null?void 0:window.location.href)+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},s=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=s+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const a in e.facets){const r=e.facets[a].type+":"+encodeURIComponent(e.facets[a].name)+":"+encodeURIComponent(e.facets[a].value);t[this.routeName+`[facets][${a}]`]=r}if(this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")){const a=this.queryStringHelper.urlToParams((window==null?void 0:window.location.href)??"");for(const r in a)r.startsWith(this.routeName)&&delete a[r];return{...a,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const s in e)s.startsWith(this.routeName)||(t[s]=e[s]);return t}extractArrayOfFacetsFromQueryParameters(e){var t,s,a;const r=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const l=te.removeXSSRiskyTags((t=e[i].split(":"))==null?void 0:t[0]),o=te.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[1])),d=te.removeXSSRiskyTags(decodeURIComponent((a=e[i].split(":"))==null?void 0:a[2]));r.push({type:l,name:o,value:d})}return r}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=te.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),i=isNaN(r)?1:r;return{query:te.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:i,itemsPerPage:t,order:te.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[]}}}class _t{constructor(e){h(this,"routeName",""),h(this,"stringify",(t,s)=>{const a=this.filterOutIgnoredKeys(t,s.ignoredKeys);return Object.keys(a).map(r=>{const i=a[r];return Array.isArray(i)?i.map(l=>`${r}=${l}`).join("&"):`${r}=${i}`}).join("&")}),this.routeName=e}filterOutIgnoredKeys(e,t){const s=t||[],a={};return Object.keys(e).forEach(r=>{s.includes(r)||e[r]!==""&&(a[r]=e[r])}),a}urlToParams(e){const t={},s=e.split("?")[1];return s&&s.split("&").forEach(a=>{const[r,i]=a.split("=");t[r]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const ie={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class Ht{constructor(e,t){h(this,"cachedQuery",""),h(this,"url",""),h(this,"relatedSearches",""),h(this,"suggester",""),h(this,"authHeader"),h(this,"authHeaderRelated"),h(this,"trackApiKey",""),h(this,"session",""),h(this,"searchAuthType"),h(this,"searchAuth",""),h(this,"controllerSearch"),h(this,"signalSearch"),h(this,"controllerSuggest"),h(this,"signalSuggest"),h(this,"dataLayer"),this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json");const s=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`;this.authHeader.append("Authorization",s),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let s=[];if(!t)e.forEach(function(a){const r=a.name+':"'+a.value+'"';s=s.concat("fq="+decodeURIComponent(r).replace(" "," "))});else{const a={};e.forEach(function(r){const i=r.name+":"+r.value,l=decodeURIComponent(i).replace(" "," ").split(":");a[l[0]]?a[l[0]].push(l[1]):a[l[0]]=[l[1]]});for(const r in a)if(Object.prototype.hasOwnProperty.call(a,r)){const i=a[r],l=r;let o="";for(const d of i)o+=` ${l}:"${d}"`;s=s.concat("fq="+o.trim())}}return s.length?"&"+s.join("&"):""}getRelatedSearches(e,t,s,a){const r=new Headers;r.append("Accept","application/json"),r.append("Authorization",s),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:r,credentials:"same-origin"}).then(i=>i.json()).then(i=>{a(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=pe.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,s=!1,a=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=new Proxy(new URLSearchParams((window==null?void 0:window.location.search)??""),{get:(m,C)=>m.get(C)??""}),i=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let l=e.itemsPerPage,o=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),d=e.order?`&sort=${e.order}`:"";const f=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+o+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(m=>m.type==="or"||m.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(m=>m.type==="and"||m.type==="tabs"),!1)+d+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!a}`+(l?`&rows=${l}`:"")+"&language="+this.dataLayer.language+i,g={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete g.signal,fetch(f,g).then(m=>m.json()).then(m=>{this.dataLayer.setLoading(!1),t(m)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.lastSearchValue===e||this.dataLayer.searchObject.facets.length>0||this.dataLayer.searchObject.page!==1)return;const s=new EventSource(ie.questionURL+e),a=this.dataLayer;s.onmessage=function(r){if(r.data===ie.question||r.data===ie.notQuestion){a.setAnswerData("");return}if(r.data===ie.close){s.close();return}t(r.data)},s.onerror=function(){s.close()}}suggest(e,t,s){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const a=this.suggester+"?q="+e.trim()+this.toQueryString(s)+"&language="+this.dataLayer.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(r=>r.json()).then(r=>{t(r)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const s of e)t.push(encodeURIComponent(s.key)+"="+encodeURIComponent(s.value));return"&"+t.join("&")}}class ne{static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language};return new Promise((s,a)=>{const r=["trackClick",t];t.key&&this.msq().push(r,(function(i,l){JSON.stringify(i)===JSON.stringify(t)&&l?s():a()}).bind(this))})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:e.currentPage,shownHits:e.recordsPerPage,totalHits:e.totalResults,language:e.language};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,latency:e.latencyVal,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}}h(ne,"subscribedToClickEvent",!1),h(ne,"msq",()=>typeof window<"u"&&window!=null&&window._msq?window==null?void 0:window._msq:[]);/*!
32
+ <%s key={someKey} {...props} />`,Ie,ae,Ft,ae),et[ae+Ie]=!0}}return c===s?wt(H):Rt(H),H}}function Et(c,p,y){return tt(c,p,y,!0)}function It(c,p,y){return tt(c,p,y,!1)}var Pt=It,jt=Et;ge.Fragment=s,ge.jsx=Pt,ge.jsxs=jt}()),ge}process.env.NODE_ENV==="production"?Fe.exports=At():Fe.exports=Mt();var u=Fe.exports,Dt=Object.defineProperty,$t=(n,e,t)=>e in n?Dt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,h=(n,e,t)=>($t(n,typeof e!="symbol"?e+"":e,t),t),B=(n=>(n[n.mustache=0]="mustache",n[n.vue=1]="vue",n[n.react=2]="react",n[n.angular=3]="angular",n))(B||{});class Nt{constructor(e){h(this,"dataLayer"),this.dataLayer=e}get currentPage(){var e;return(e=this.dataLayer.searchObject)==null?void 0:e.page}get totalResults(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.totalResultsValue)||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.options)||[]}get selectedSortOption(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.selectedSortOption)||""}get startResultIndex(){var e;return(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+1}get endResultIndex(){var e;const t=(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+(this.resultsPerPage??0);return t>this.totalResults?this.totalResults:t}get isFirstPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)===1}get isLastPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||""}get originalQuery(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.query)||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswer(){return this.isFirstPage&&this.dataLayer.getAnswerData!==""&&this.dataLayer.searchObject.query!=="*"&&this.dataLayer.searchObject.facets.length===0}get searchTerm(){var e,t;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||((t=this.dataLayer.searchObject)==null?void 0:t.query)||""}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get searchExecuted(){var e,t,s;return((e=this.dataLayer.searchObject)==null?void 0:e.query)!==void 0&&((t=this.dataLayer.searchObject)==null?void 0:t.query)!=="undefined"&&((s=this.dataLayer.searchObject)==null?void 0:s.query)!==""}get selectedFacets(){var e;const t=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return t?(((e=this.dataLayer.searchObject)==null?void 0:e.facets)??[]).map(s=>{const a=s.name,r=s.value,i=t.find(l=>l.name===a);if(i){const l=i.values.find(o=>o.type==="range"?!1:o.type==="checkbox"?'"'+o.value+'"'===r:!1);if(l)return l}return null}).filter(s=>s!==null):[]}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,selectedFacets:this.selectedFacets,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption}}get trackingData(){var e,t,s,a;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:((t=this.dataLayer.searchResultsMetadata)==null?void 0:t.recordsPerPageValue)??0,totalResults:((s=this.dataLayer.searchResultsMetadata)==null?void 0:s.totalResultsValue)??0,currentPage:this.dataLayer.currentPage,latencyVal:((a=this.dataLayer.searchResultsMetadata)==null?void 0:a.latency)??0}}}class X{static deepEqual(e,t){const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(const r of s){const i=e[r],l=t[r],o=this.isObject(i)&&this.isObject(l);if(o&&!this.deepEqual(i,l)||!o&&i!==l)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class ${constructor(e){h(this,"value"),h(this,"observers",[]),this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const t=this.observers.indexOf(e);t!==-1&&this.observers.splice(t,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class Pe{static getOrSetCookie(e,t){let s=this.getCookie(e);return s==null&&(s=t??this.makeid(25),this.setCookie(e,s,{secure:!0,"max-age":3600})),s}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=s.length;for(let r=0;r<e;r++)t+=s.charAt(Math.floor(Math.random()*a));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,s){const a={path:"/",...s};s.expires instanceof Date&&(a.expires=s.expires.toUTCString());let r=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in a){r+="; "+i;const l=a[i];l!==!0&&(r+="="+l)}typeof document<"u"&&(document.cookie=r)}}class te{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",s=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(s,""):""}}class qt{constructor(e,t){h(this,"$searchTermChange",new $("")),h(this,"$loadingChange",new $(!1)),h(this,"$searchResults",new $(null)),h(this,"$searchResultsMetadata",new $(null)),h(this,"$searchAutosuggest",new $(null)),h(this,"$searchFacets",new $(null)),h(this,"$searchFacetsCached",new $(null)),h(this,"$searchstaxConfig",new $(null)),h(this,"$autosuggestResults",new $(null)),h(this,"$itemsPerPage",new $(void 0)),h(this,"$searchObject",new $({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]})),h(this,"$searchRelatedSearches",new $(null)),h(this,"$searchInputConfig",new $(null)),h(this,"$searchExternalPromotions",new $(null)),h(this,"$facetsTemplateData",new $(null)),h(this,"$selectedFacetsTemplateData",new $(null)),h(this,"$paginationData",new $(null)),h(this,"$searchFeedbackData",new $(null)),h(this,"$searchSortingData",new $(null)),h(this,"$searchRelatedSearchesData",new $(null)),h(this,"$searchExternalPromotionsData",new $(null)),h(this,"$cookiesDisabled",new $(null)),h(this,"$answer",new $("")),h(this,"$language",new $("en")),h(this,"currentPageValue",1),h(this,"isAnswerWidgetCreatedValue",!1),h(this,"renderingEngineValue",B.mustache),h(this,"parsedData",new Nt(this)),h(this,"sessionId"),h(this,"sessionIdValue",null),h(this,"autoCorrect",!0),h(this,"forceNotCorrect",!1),h(this,"lastSearchValue",""),h(this,"turnAIAnswerGenerationOn",!1),h(this,"isInfiniteScroll",!1),h(this,"firstSearchHappened",!1),h(this,"facetsWereSet",!1),this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,Pe.deleteCookie(this.sessionId),Pe.deleteCookie("ms_visitorid")):this.sessionIdValue=Pe.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(te.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setIsAnswerWidgetCreated(e){this.isAnswerWidgetCreatedValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){this.firstSearchHappened=!0,(!X.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){X.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var t,s;let a=e;a={...a,itemsPerPage:this.itemsPerPage},(s=(t=this.searchstaxConfig)==null?void 0:t.hooks)!=null&&s.beforeSearch&&a&&(a=this.searchstaxConfig.hooks.beforeSearch(a)),a&&(!X.deepEqual(a,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(a)}setSearchFacets(e){this.facetsWereSet=!0,X.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){X.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){X.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){X.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setAutosuggestResults(e){this.$autosuggestResults.setValue(e)}setFacetsTemplateData(e){this.$facetsTemplateData.setValue(e)}setSelectedFacetsTemplateData(e){this.$selectedFacetsTemplateData.setValue(e)}setPaginationData(e){this.$paginationData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCached(){return this.$searchFacetsCached.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCached.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}}class pe{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,r)=>{const i=a[e.responseHeader.params.uniqueId]??"",l={custom:null,uniqueId:i,position:s+1+r,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e,i):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e,i):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e,i):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,i):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,i,!0):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e,i):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e,i):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e,i):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e,i):null,unmappedFields:this.getUnmappedFields(a,e,i),allFields:this.getAllFields(a,e)};t.push(l)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const s of e.metadata.facets){let a={values:[]};if(a.name=s.name,a.label=s.label,s.name in e.facet_counts.facet_fields){const r=e.facet_counts.facet_fields[s.name];for(let i=0;i<r.length;i+=2){const l={};l.value=r[i],l.parentName=a.name,l.count=r[i+1],l.type="checkbox",a.values.push(l)}}a.values.length>0&&t.push(a)}return t}static extractSearchResultsMetadata(e){var t,s,a,r,i,l;let o="",d={selectedSortOption:"",options:[]},f=(t=e.metadata.results.find(g=>g.result_card==="date"))==null?void 0:t.name;if(d.options=[{key:"",value:"Relevance"},{key:f+" desc",value:"Most Recent"}],(s=e.metadata.sorts)!=null&&s.length){const g=e.metadata.sorts.map(m=>({value:m.label,key:m.name+" "+m.order}));d.options=[{key:"",value:"Relevance"},...g]}return o=((l=(i=(r=(a=e==null?void 0:e.spellcheck)==null?void 0:a.suggestions)==null?void 0:r[1])==null?void 0:i.suggestion)==null?void 0:l[0])??"",typeof o!="string"&&(o=(o==null?void 0:o.word)??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:o,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:d}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const r=s[a],i={};i.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(i.cDocTitle=this.getDataForAnalytics(r.title)),i.position=r.position,t.push(i)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(s=>s.uniqueId===e)??null}static getUnmappedFields(e,t,s){const a=t.metadata.results.filter(i=>i.result_card==="").map(i=>i.name),r=[];for(const i of Object.keys(e))if(a.indexOf(i)!==-1){const l=Array.isArray(e[i])?this.getHighlightedResults(i,e[i].join(", "),s,t):this.getHighlightedResults(i,e[i]+"",s,t);r.push({key:i,value:l,isImage:this.checkIfImage(e[i])})}return r}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const s=t.metadata.results.map(r=>r.name),a=[];for(const r of Object.keys(e))s.indexOf(r)!==-1&&a.push({key:r,value:e[r],isImage:this.checkIfImage(e[r])});return a}static doesMapExist(e,t){return t.metadata.results.find(s=>s.result_card===e)!==void 0}static getValueByKey(e,t,s,a,r=!1){const i=s.metadata.results.find(o=>o.result_card===e);if(i===void 0)return null;const l=t[i.name];return l===void 0?null:typeof l=="string"?r?l:this.getHighlightedResults(i.name,l,a,s):Array.isArray(l)?r?l.join(", "):this.getHighlightedResults(i.name,l.join(", "),a,s):null}static getHighlightedResults(e,t,s,a){if(a.highlighting&&s in a.highlighting){let r=a.highlighting[s];if(r&&e in r){let i=r[e];const l=this.cleanValue(i);if(l!=="")return l}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class rt{constructor(e){h(this,"routeName","searchstax"),h(this,"ignoredKeys",[]),h(this,"queryStringHelper"),h(this,"titleParser"),e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new _t(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=typeof document<"u"?document==null?void 0:document.title:"";this.titleParser&&(s=this.titleParser(e)),typeof document<"u"&&(document.title=s),(window==null?void 0:window.location.href)!==t&&(window==null||window.history.replaceState(window.history.state,s,t))}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")?(window==null?void 0:window.location.href.split("?")[0])+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):(window==null?void 0:window.location.href)+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},s=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=s+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const a in e.facets){const r=e.facets[a].type+":"+encodeURIComponent(e.facets[a].name)+":"+encodeURIComponent(e.facets[a].value);t[this.routeName+`[facets][${a}]`]=r}if(this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")){const a=this.queryStringHelper.urlToParams((window==null?void 0:window.location.href)??"");for(const r in a)r.startsWith(this.routeName)&&delete a[r];return{...a,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const s in e)s.startsWith(this.routeName)||(t[s]=e[s]);return t}extractArrayOfFacetsFromQueryParameters(e){var t,s,a;const r=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const l=te.removeXSSRiskyTags((t=e[i].split(":"))==null?void 0:t[0]),o=te.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[1])),d=te.removeXSSRiskyTags(decodeURIComponent((a=e[i].split(":"))==null?void 0:a[2]));r.push({type:l,name:o,value:d})}return r}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=te.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),i=isNaN(r)?1:r;return{query:te.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:i,itemsPerPage:t,order:te.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[]}}}class _t{constructor(e){h(this,"routeName",""),h(this,"stringify",(t,s)=>{const a=this.filterOutIgnoredKeys(t,s.ignoredKeys);return Object.keys(a).map(r=>{const i=a[r];return Array.isArray(i)?i.map(l=>`${r}=${l}`).join("&"):`${r}=${i}`}).join("&")}),this.routeName=e}filterOutIgnoredKeys(e,t){const s=t||[],a={};return Object.keys(e).forEach(r=>{s.includes(r)||e[r]!==""&&(a[r]=e[r])}),a}urlToParams(e){const t={},s=e.split("?")[1];return s&&s.split("&").forEach(a=>{const[r,i]=a.split("=");t[r]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const ie={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class Ht{constructor(e,t){h(this,"cachedQuery",""),h(this,"url",""),h(this,"relatedSearches",""),h(this,"suggester",""),h(this,"authHeader"),h(this,"authHeaderRelated"),h(this,"trackApiKey",""),h(this,"session",""),h(this,"searchAuthType"),h(this,"searchAuth",""),h(this,"controllerSearch"),h(this,"signalSearch"),h(this,"controllerSuggest"),h(this,"signalSuggest"),h(this,"dataLayer"),this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json");const s=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`;this.authHeader.append("Authorization",s),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let s=[];if(!t)e.forEach(function(a){const r=a.name+':"'+a.value+'"';s=s.concat("fq="+decodeURIComponent(r).replace(" "," "))});else{const a={};e.forEach(function(r){const i=r.name+":"+r.value,l=decodeURIComponent(i).replace(" "," ").split(":");a[l[0]]?a[l[0]].push(l[1]):a[l[0]]=[l[1]]});for(const r in a)if(Object.prototype.hasOwnProperty.call(a,r)){const i=a[r],l=r;let o="";for(const d of i)o+=` ${l}:"${d}"`;s=s.concat("fq="+o.trim())}}return s.length?"&"+s.join("&"):""}getRelatedSearches(e,t,s,a){const r=new Headers;r.append("Accept","application/json"),r.append("Authorization",s),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:r,credentials:"same-origin"}).then(i=>i.json()).then(i=>{a(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=pe.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,s=!1,a=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=new Proxy(new URLSearchParams((window==null?void 0:window.location.search)??""),{get:(m,C)=>m.get(C)??""}),i=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let l=e.itemsPerPage,o=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),d=e.order?`&sort=${e.order}`:"";const f=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+o+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(m=>m.type==="or"||m.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(m=>m.type==="and"||m.type==="tabs"),!1)+d+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!a}`+(l?`&rows=${l}`:"")+"&language="+this.dataLayer.language+i,g={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete g.signal,fetch(f,g).then(m=>m.json()).then(m=>{this.dataLayer.setLoading(!1),t(m)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.lastSearchValue===e||this.dataLayer.searchObject.facets.length>0||this.dataLayer.searchObject.page!==1)return;const s=new EventSource(ie.questionURL+e),a=this.dataLayer;s.onmessage=function(r){if(r.data===ie.question||r.data===ie.notQuestion){a.setAnswerData("");return}if(r.data===ie.close){s.close();return}t(r.data)},s.onerror=function(){s.close()}}suggest(e,t,s){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const a=this.suggester+"?q="+e.trim()+this.toQueryString(s)+"&language="+this.dataLayer.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(r=>r.json()).then(r=>{t(r)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const s of e)t.push(encodeURIComponent(s.key)+"="+encodeURIComponent(s.value));return"&"+t.join("&")}}class ne{static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language};return new Promise((s,a)=>{const r=["trackClick",t];t.key&&this.msq().push(r,(function(i,l){JSON.stringify(i)===JSON.stringify(t)&&l?s():a()}).bind(this))})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:e.currentPage,shownHits:e.recordsPerPage,totalHits:e.totalResults,language:e.language};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,latency:e.latencyVal,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}}h(ne,"subscribedToClickEvent",!1),h(ne,"msq",()=>typeof window<"u"&&window!=null&&window._msq?window==null?void 0:window._msq:[]);/*!
33
33
  * mustache.js - Logic-less {{mustache}} templates with JavaScript
34
34
  * http://github.com/janl/mustache.js
35
35
  */var Wt=Object.prototype.toString,le=Array.isArray||function(n){return Wt.call(n)==="[object Array]"};function Oe(n){return typeof n=="function"}function Bt(n){return le(n)?"array":typeof n}function je(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function it(n,e){return n!=null&&typeof n=="object"&&e in n}function Vt(n,e){return n!=null&&typeof n!="object"&&n.hasOwnProperty&&n.hasOwnProperty(e)}var Ut=RegExp.prototype.test;function Kt(n,e){return Ut.call(n,e)}var Qt=/\S/;function zt(n){return!Kt(Qt,n)}var Jt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function Yt(n){return String(n).replace(/[&<>"'`=\/]/g,function(e){return Jt[e]})}var Xt=/\s*/,Gt=/\s+/,nt=/\s*=/,Zt=/\s*\}/,ea=/#|\^|\/|>|\{|&|=|!/;function ta(n,e){if(!n)return[];var t=!1,s=[],a=[],r=[],i=!1,l=!1,o="",d=0;function f(){if(i&&!l)for(;r.length;)delete a[r.pop()];else r=[];i=!1,l=!1}var g,m,C;function I(x){if(typeof x=="string"&&(x=x.split(Gt,2)),!le(x)||x.length!==2)throw new Error("Invalid tags: "+x);g=new RegExp(je(x[0])+"\\s*"),m=new RegExp("\\s*"+je(x[1])),C=new RegExp("\\s*"+je("}"+x[1]))}I(e||F.tags);for(var k=new fe(n),R,P,L,N,W,D;!k.eos();){if(R=k.pos,L=k.scanUntil(g),L)for(var Q=0,v=L.length;Q<v;++Q)N=L.charAt(Q),zt(N)?(r.push(a.length),o+=N):(l=!0,t=!0,o+=" "),a.push(["text",N,R,R+1]),R+=1,N===`
@@ -29,7 +29,7 @@ Check the top-level render call using <`+y+">.")}return p}}function rt(c,p){{if(
29
29
  <%s {...props} />
30
30
  React keys must be passed directly to JSX without using spread:
31
31
  let props = %s;
32
- <%s key={someKey} {...props} />`,Ae,se,ja,se),nt[se+Ae]=!0}}return c===s?Ra(q):ka(q),q}}function wa(c,p,y){return ct(c,p,y,!0)}function Ea(c,p,y){return ct(c,p,y,!1)}var Ia=Ea,Pa=wa;ue.Fragment=s,ue.jsx=Ia,ue.jsxs=Pa}()),ue}process.env.NODE_ENV==="production"?Ce.exports=lt():Ce.exports=ot();var u=Ce.exports,ht=Object.defineProperty,ut=(n,e,t)=>e in n?ht(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,h=(n,e,t)=>(ut(n,typeof e!="symbol"?e+"":e,t),t),B=(n=>(n[n.mustache=0]="mustache",n[n.vue=1]="vue",n[n.react=2]="react",n[n.angular=3]="angular",n))(B||{});class dt{constructor(e){h(this,"dataLayer"),this.dataLayer=e}get currentPage(){var e;return(e=this.dataLayer.searchObject)==null?void 0:e.page}get totalResults(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.totalResultsValue)||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.options)||[]}get selectedSortOption(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.selectedSortOption)||""}get startResultIndex(){var e;return(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+1}get endResultIndex(){var e;const t=(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+(this.resultsPerPage??0);return t>this.totalResults?this.totalResults:t}get isFirstPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)===1}get isLastPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||""}get originalQuery(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.query)||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswer(){return this.isFirstPage&&this.dataLayer.getAnswerData!==""&&this.dataLayer.searchObject.query!=="*"&&this.dataLayer.searchObject.facets.length===0}get searchTerm(){var e,t;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||((t=this.dataLayer.searchObject)==null?void 0:t.query)||""}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get searchExecuted(){var e,t,s;return((e=this.dataLayer.searchObject)==null?void 0:e.query)!==void 0&&((t=this.dataLayer.searchObject)==null?void 0:t.query)!=="undefined"&&((s=this.dataLayer.searchObject)==null?void 0:s.query)!==""}get selectedFacets(){var e;const t=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return t?(((e=this.dataLayer.searchObject)==null?void 0:e.facets)??[]).map(s=>{const a=s.name,r=s.value,i=t.find(l=>l.name===a);if(i){const l=i.values.find(o=>o.type==="range"?!1:o.type==="checkbox"?'"'+o.value+'"'===r:!1);if(l)return l}return null}).filter(s=>s!==null):[]}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,selectedFacets:this.selectedFacets,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption}}get trackingData(){var e,t,s,a;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:((t=this.dataLayer.searchResultsMetadata)==null?void 0:t.recordsPerPageValue)??0,totalResults:((s=this.dataLayer.searchResultsMetadata)==null?void 0:s.totalResultsValue)??0,currentPage:this.dataLayer.currentPage,latencyVal:((a=this.dataLayer.searchResultsMetadata)==null?void 0:a.latency)??0}}}class Y{static deepEqual(e,t){const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(const r of s){const i=e[r],l=t[r],o=this.isObject(i)&&this.isObject(l);if(o&&!this.deepEqual(i,l)||!o&&i!==l)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class D{constructor(e){h(this,"value"),h(this,"observers",[]),this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const t=this.observers.indexOf(e);t!==-1&&this.observers.splice(t,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class Le{static getOrSetCookie(e,t){let s=this.getCookie(e);return s==null&&(s=t??this.makeid(25),this.setCookie(e,s,{secure:!0,"max-age":3600})),s}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=s.length;for(let r=0;r<e;r++)t+=s.charAt(Math.floor(Math.random()*a));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,s){const a={path:"/",...s};s.expires instanceof Date&&(a.expires=s.expires.toUTCString());let r=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in a){r+="; "+i;const l=a[i];l!==!0&&(r+="="+l)}typeof document<"u"&&(document.cookie=r)}}class ae{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",s=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(s,""):""}}class gt{constructor(e,t){h(this,"$searchTermChange",new D("")),h(this,"$loadingChange",new D(!1)),h(this,"$searchResults",new D(null)),h(this,"$searchResultsMetadata",new D(null)),h(this,"$searchAutosuggest",new D(null)),h(this,"$searchFacets",new D(null)),h(this,"$searchFacetsCached",new D(null)),h(this,"$searchstaxConfig",new D(null)),h(this,"$autosuggestResults",new D(null)),h(this,"$itemsPerPage",new D(void 0)),h(this,"$searchObject",new D({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]})),h(this,"$searchRelatedSearches",new D(null)),h(this,"$searchInputConfig",new D(null)),h(this,"$searchExternalPromotions",new D(null)),h(this,"$facetsTemplateData",new D(null)),h(this,"$selectedFacetsTemplateData",new D(null)),h(this,"$paginationData",new D(null)),h(this,"$searchFeedbackData",new D(null)),h(this,"$searchSortingData",new D(null)),h(this,"$searchRelatedSearchesData",new D(null)),h(this,"$searchExternalPromotionsData",new D(null)),h(this,"$cookiesDisabled",new D(null)),h(this,"$answer",new D("")),h(this,"$language",new D("en")),h(this,"currentPageValue",1),h(this,"isAnswerWidgetCreatedValue",!1),h(this,"renderingEngineValue",B.mustache),h(this,"parsedData",new dt(this)),h(this,"sessionId"),h(this,"sessionIdValue",null),h(this,"autoCorrect",!0),h(this,"forceNotCorrect",!1),h(this,"lastSearchValue",""),h(this,"turnAIAnswerGenerationOn",!1),h(this,"isInfiniteScroll",!1),h(this,"firstSearchHappened",!1),h(this,"facetsWereSet",!1),this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,Le.deleteCookie(this.sessionId),Le.deleteCookie("ms_visitorid")):this.sessionIdValue=Le.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(ae.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setIsAnswerWidgetCreated(e){this.isAnswerWidgetCreatedValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){this.firstSearchHappened=!0,(!Y.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){Y.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var t,s;let a=e;a={...a,itemsPerPage:this.itemsPerPage},(s=(t=this.searchstaxConfig)==null?void 0:t.hooks)!=null&&s.beforeSearch&&a&&(a=this.searchstaxConfig.hooks.beforeSearch(a)),a&&(!Y.deepEqual(a,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(a)}setSearchFacets(e){this.facetsWereSet=!0,Y.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){Y.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){Y.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){Y.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setAutosuggestResults(e){this.$autosuggestResults.setValue(e)}setFacetsTemplateData(e){this.$facetsTemplateData.setValue(e)}setSelectedFacetsTemplateData(e){this.$selectedFacetsTemplateData.setValue(e)}setPaginationData(e){this.$paginationData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCached(){return this.$searchFacetsCached.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCached.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}}class de{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,r)=>{const i=a[e.responseHeader.params.uniqueId]??"",l={custom:null,uniqueId:i,position:s+1+r,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e,i):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e,i):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e,i):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,i):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,i,!0):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e,i):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e,i):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e,i):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e,i):null,unmappedFields:this.getUnmappedFields(a,e,i),allFields:this.getAllFields(a,e)};t.push(l)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const s of e.metadata.facets){let a={values:[]};if(a.name=s.name,a.label=s.label,s.name in e.facet_counts.facet_fields){const r=e.facet_counts.facet_fields[s.name];for(let i=0;i<r.length;i+=2){const l={};l.value=r[i],l.parentName=a.name,l.count=r[i+1],l.type="checkbox",a.values.push(l)}}a.values.length>0&&t.push(a)}return t}static extractSearchResultsMetadata(e){var t,s,a,r,i,l;let o="",d={selectedSortOption:"",options:[]},f=(t=e.metadata.results.find(g=>g.result_card==="date"))==null?void 0:t.name;if(d.options=[{key:"",value:"Relevance"},{key:f+" desc",value:"Most Recent"}],(s=e.metadata.sorts)!=null&&s.length){const g=e.metadata.sorts.map(m=>({value:m.label,key:m.name+" "+m.order}));d.options=[{key:"",value:"Relevance"},...g]}return o=((l=(i=(r=(a=e==null?void 0:e.spellcheck)==null?void 0:a.suggestions)==null?void 0:r[1])==null?void 0:i.suggestion)==null?void 0:l[0])??"",typeof o!="string"&&(o=(o==null?void 0:o.word)??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:o,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:d}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const r=s[a],i={};i.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(i.cDocTitle=this.getDataForAnalytics(r.title)),i.position=r.position,t.push(i)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(s=>s.uniqueId===e)??null}static getUnmappedFields(e,t,s){const a=t.metadata.results.filter(i=>i.result_card==="").map(i=>i.name),r=[];for(const i of Object.keys(e))if(a.indexOf(i)!==-1){const l=Array.isArray(e[i])?this.getHighlightedResults(i,e[i].join(", "),s,t):this.getHighlightedResults(i,e[i]+"",s,t);r.push({key:i,value:l,isImage:this.checkIfImage(e[i])})}return r}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const s=t.metadata.results.map(r=>r.name),a=[];for(const r of Object.keys(e))s.indexOf(r)!==-1&&a.push({key:r,value:e[r],isImage:this.checkIfImage(e[r])});return a}static doesMapExist(e,t){return t.metadata.results.find(s=>s.result_card===e)!==void 0}static getValueByKey(e,t,s,a,r=!1){const i=s.metadata.results.find(o=>o.result_card===e);if(i===void 0)return null;const l=t[i.name];return l===void 0?null:typeof l=="string"?r?l:this.getHighlightedResults(i.name,l,a,s):Array.isArray(l)?r?l.join(", "):this.getHighlightedResults(i.name,l.join(", "),a,s):null}static getHighlightedResults(e,t,s,a){if(a.highlighting&&s in a.highlighting){let r=a.highlighting[s];if(r&&e in r){let i=r[e];const l=this.cleanValue(i);if(l!=="")return l}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class Ne{constructor(e){h(this,"routeName","searchstax"),h(this,"ignoredKeys",[]),h(this,"queryStringHelper"),h(this,"titleParser"),e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new pt(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=typeof document<"u"?document==null?void 0:document.title:"";this.titleParser&&(s=this.titleParser(e)),typeof document<"u"&&(document.title=s),(window==null?void 0:window.location.href)!==t&&(window==null||window.history.pushState({},s,t))}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")?(window==null?void 0:window.location.href.split("?")[0])+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):(window==null?void 0:window.location.href)+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},s=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=s+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const a in e.facets){const r=e.facets[a].type+":"+encodeURIComponent(e.facets[a].name)+":"+encodeURIComponent(e.facets[a].value);t[this.routeName+`[facets][${a}]`]=r}if(this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")){const a=this.queryStringHelper.urlToParams((window==null?void 0:window.location.href)??"");for(const r in a)r.startsWith(this.routeName)&&delete a[r];return{...a,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const s in e)s.startsWith(this.routeName)||(t[s]=e[s]);return t}extractArrayOfFacetsFromQueryParameters(e){var t,s,a;const r=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const l=ae.removeXSSRiskyTags((t=e[i].split(":"))==null?void 0:t[0]),o=ae.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[1])),d=ae.removeXSSRiskyTags(decodeURIComponent((a=e[i].split(":"))==null?void 0:a[2]));r.push({type:l,name:o,value:d})}return r}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=ae.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),i=isNaN(r)?1:r;return{query:ae.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:i,itemsPerPage:t,order:ae.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[]}}}class pt{constructor(e){h(this,"routeName",""),h(this,"stringify",(t,s)=>{const a=this.filterOutIgnoredKeys(t,s.ignoredKeys);return Object.keys(a).map(r=>{const i=a[r];return Array.isArray(i)?i.map(l=>`${r}=${l}`).join("&"):`${r}=${i}`}).join("&")}),this.routeName=e}filterOutIgnoredKeys(e,t){const s=t||[],a={};return Object.keys(e).forEach(r=>{s.includes(r)||e[r]!==""&&(a[r]=e[r])}),a}urlToParams(e){const t={},s=e.split("?")[1];return s&&s.split("&").forEach(a=>{const[r,i]=a.split("=");t[r]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const re={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class mt{constructor(e,t){h(this,"cachedQuery",""),h(this,"url",""),h(this,"relatedSearches",""),h(this,"suggester",""),h(this,"authHeader"),h(this,"authHeaderRelated"),h(this,"trackApiKey",""),h(this,"session",""),h(this,"searchAuthType"),h(this,"searchAuth",""),h(this,"controllerSearch"),h(this,"signalSearch"),h(this,"controllerSuggest"),h(this,"signalSuggest"),h(this,"dataLayer"),this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json");const s=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`;this.authHeader.append("Authorization",s),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let s=[];if(!t)e.forEach(function(a){const r=a.name+':"'+a.value+'"';s=s.concat("fq="+decodeURIComponent(r).replace(" "," "))});else{const a={};e.forEach(function(r){const i=r.name+":"+r.value,l=decodeURIComponent(i).replace(" "," ").split(":");a[l[0]]?a[l[0]].push(l[1]):a[l[0]]=[l[1]]});for(const r in a)if(Object.prototype.hasOwnProperty.call(a,r)){const i=a[r],l=r;let o="";for(const d of i)o+=` ${l}:"${d}"`;s=s.concat("fq="+o.trim())}}return s.length?"&"+s.join("&"):""}getRelatedSearches(e,t,s,a){const r=new Headers;r.append("Accept","application/json"),r.append("Authorization",s),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:r,credentials:"same-origin"}).then(i=>i.json()).then(i=>{a(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=de.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,s=!1,a=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=new Proxy(new URLSearchParams((window==null?void 0:window.location.search)??""),{get:(m,C)=>m.get(C)??""}),i=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let l=e.itemsPerPage,o=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),d=e.order?`&sort=${e.order}`:"";const f=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+o+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(m=>m.type==="or"||m.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(m=>m.type==="and"||m.type==="tabs"),!1)+d+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!a}`+(l?`&rows=${l}`:"")+"&language="+this.dataLayer.language+i,g={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete g.signal,fetch(f,g).then(m=>m.json()).then(m=>{this.dataLayer.setLoading(!1),t(m)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.lastSearchValue===e||this.dataLayer.searchObject.facets.length>0||this.dataLayer.searchObject.page!==1)return;const s=new EventSource(re.questionURL+e),a=this.dataLayer;s.onmessage=function(r){if(r.data===re.question||r.data===re.notQuestion){a.setAnswerData("");return}if(r.data===re.close){s.close();return}t(r.data)},s.onerror=function(){s.close()}}suggest(e,t,s){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const a=this.suggester+"?q="+e.trim()+this.toQueryString(s)+"&language="+this.dataLayer.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(r=>r.json()).then(r=>{t(r)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const s of e)t.push(encodeURIComponent(s.key)+"="+encodeURIComponent(s.value));return"&"+t.join("&")}}class ie{static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language};return new Promise((s,a)=>{const r=["trackClick",t];t.key&&this.msq().push(r,(function(i,l){JSON.stringify(i)===JSON.stringify(t)&&l?s():a()}).bind(this))})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:e.currentPage,shownHits:e.recordsPerPage,totalHits:e.totalResults,language:e.language};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,latency:e.latencyVal,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}}h(ie,"subscribedToClickEvent",!1),h(ie,"msq",()=>typeof window<"u"&&window!=null&&window._msq?window==null?void 0:window._msq:[]);/*!
32
+ <%s key={someKey} {...props} />`,Ae,se,ja,se),nt[se+Ae]=!0}}return c===s?Ra(q):ka(q),q}}function wa(c,p,y){return ct(c,p,y,!0)}function Ea(c,p,y){return ct(c,p,y,!1)}var Ia=Ea,Pa=wa;ue.Fragment=s,ue.jsx=Ia,ue.jsxs=Pa}()),ue}process.env.NODE_ENV==="production"?Ce.exports=lt():Ce.exports=ot();var u=Ce.exports,ht=Object.defineProperty,ut=(n,e,t)=>e in n?ht(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,h=(n,e,t)=>(ut(n,typeof e!="symbol"?e+"":e,t),t),B=(n=>(n[n.mustache=0]="mustache",n[n.vue=1]="vue",n[n.react=2]="react",n[n.angular=3]="angular",n))(B||{});class dt{constructor(e){h(this,"dataLayer"),this.dataLayer=e}get currentPage(){var e;return(e=this.dataLayer.searchObject)==null?void 0:e.page}get totalResults(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.totalResultsValue)||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.options)||[]}get selectedSortOption(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.selectedSortOption)||""}get startResultIndex(){var e;return(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+1}get endResultIndex(){var e;const t=(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+(this.resultsPerPage??0);return t>this.totalResults?this.totalResults:t}get isFirstPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)===1}get isLastPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||""}get originalQuery(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.query)||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswer(){return this.isFirstPage&&this.dataLayer.getAnswerData!==""&&this.dataLayer.searchObject.query!=="*"&&this.dataLayer.searchObject.facets.length===0}get searchTerm(){var e,t;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||((t=this.dataLayer.searchObject)==null?void 0:t.query)||""}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get searchExecuted(){var e,t,s;return((e=this.dataLayer.searchObject)==null?void 0:e.query)!==void 0&&((t=this.dataLayer.searchObject)==null?void 0:t.query)!=="undefined"&&((s=this.dataLayer.searchObject)==null?void 0:s.query)!==""}get selectedFacets(){var e;const t=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return t?(((e=this.dataLayer.searchObject)==null?void 0:e.facets)??[]).map(s=>{const a=s.name,r=s.value,i=t.find(l=>l.name===a);if(i){const l=i.values.find(o=>o.type==="range"?!1:o.type==="checkbox"?'"'+o.value+'"'===r:!1);if(l)return l}return null}).filter(s=>s!==null):[]}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,selectedFacets:this.selectedFacets,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption}}get trackingData(){var e,t,s,a;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:((t=this.dataLayer.searchResultsMetadata)==null?void 0:t.recordsPerPageValue)??0,totalResults:((s=this.dataLayer.searchResultsMetadata)==null?void 0:s.totalResultsValue)??0,currentPage:this.dataLayer.currentPage,latencyVal:((a=this.dataLayer.searchResultsMetadata)==null?void 0:a.latency)??0}}}class Y{static deepEqual(e,t){const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(const r of s){const i=e[r],l=t[r],o=this.isObject(i)&&this.isObject(l);if(o&&!this.deepEqual(i,l)||!o&&i!==l)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class D{constructor(e){h(this,"value"),h(this,"observers",[]),this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const t=this.observers.indexOf(e);t!==-1&&this.observers.splice(t,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class Le{static getOrSetCookie(e,t){let s=this.getCookie(e);return s==null&&(s=t??this.makeid(25),this.setCookie(e,s,{secure:!0,"max-age":3600})),s}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=s.length;for(let r=0;r<e;r++)t+=s.charAt(Math.floor(Math.random()*a));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,s){const a={path:"/",...s};s.expires instanceof Date&&(a.expires=s.expires.toUTCString());let r=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in a){r+="; "+i;const l=a[i];l!==!0&&(r+="="+l)}typeof document<"u"&&(document.cookie=r)}}class ae{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",s=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(s,""):""}}class gt{constructor(e,t){h(this,"$searchTermChange",new D("")),h(this,"$loadingChange",new D(!1)),h(this,"$searchResults",new D(null)),h(this,"$searchResultsMetadata",new D(null)),h(this,"$searchAutosuggest",new D(null)),h(this,"$searchFacets",new D(null)),h(this,"$searchFacetsCached",new D(null)),h(this,"$searchstaxConfig",new D(null)),h(this,"$autosuggestResults",new D(null)),h(this,"$itemsPerPage",new D(void 0)),h(this,"$searchObject",new D({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]})),h(this,"$searchRelatedSearches",new D(null)),h(this,"$searchInputConfig",new D(null)),h(this,"$searchExternalPromotions",new D(null)),h(this,"$facetsTemplateData",new D(null)),h(this,"$selectedFacetsTemplateData",new D(null)),h(this,"$paginationData",new D(null)),h(this,"$searchFeedbackData",new D(null)),h(this,"$searchSortingData",new D(null)),h(this,"$searchRelatedSearchesData",new D(null)),h(this,"$searchExternalPromotionsData",new D(null)),h(this,"$cookiesDisabled",new D(null)),h(this,"$answer",new D("")),h(this,"$language",new D("en")),h(this,"currentPageValue",1),h(this,"isAnswerWidgetCreatedValue",!1),h(this,"renderingEngineValue",B.mustache),h(this,"parsedData",new dt(this)),h(this,"sessionId"),h(this,"sessionIdValue",null),h(this,"autoCorrect",!0),h(this,"forceNotCorrect",!1),h(this,"lastSearchValue",""),h(this,"turnAIAnswerGenerationOn",!1),h(this,"isInfiniteScroll",!1),h(this,"firstSearchHappened",!1),h(this,"facetsWereSet",!1),this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,Le.deleteCookie(this.sessionId),Le.deleteCookie("ms_visitorid")):this.sessionIdValue=Le.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(ae.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setIsAnswerWidgetCreated(e){this.isAnswerWidgetCreatedValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){this.firstSearchHappened=!0,(!Y.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){Y.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var t,s;let a=e;a={...a,itemsPerPage:this.itemsPerPage},(s=(t=this.searchstaxConfig)==null?void 0:t.hooks)!=null&&s.beforeSearch&&a&&(a=this.searchstaxConfig.hooks.beforeSearch(a)),a&&(!Y.deepEqual(a,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(a)}setSearchFacets(e){this.facetsWereSet=!0,Y.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){Y.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){Y.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){Y.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setAutosuggestResults(e){this.$autosuggestResults.setValue(e)}setFacetsTemplateData(e){this.$facetsTemplateData.setValue(e)}setSelectedFacetsTemplateData(e){this.$selectedFacetsTemplateData.setValue(e)}setPaginationData(e){this.$paginationData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCached(){return this.$searchFacetsCached.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCached.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}}class de{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,r)=>{const i=a[e.responseHeader.params.uniqueId]??"",l={custom:null,uniqueId:i,position:s+1+r,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e,i):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e,i):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e,i):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,i):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,i,!0):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e,i):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e,i):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e,i):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e,i):null,unmappedFields:this.getUnmappedFields(a,e,i),allFields:this.getAllFields(a,e)};t.push(l)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const s of e.metadata.facets){let a={values:[]};if(a.name=s.name,a.label=s.label,s.name in e.facet_counts.facet_fields){const r=e.facet_counts.facet_fields[s.name];for(let i=0;i<r.length;i+=2){const l={};l.value=r[i],l.parentName=a.name,l.count=r[i+1],l.type="checkbox",a.values.push(l)}}a.values.length>0&&t.push(a)}return t}static extractSearchResultsMetadata(e){var t,s,a,r,i,l;let o="",d={selectedSortOption:"",options:[]},f=(t=e.metadata.results.find(g=>g.result_card==="date"))==null?void 0:t.name;if(d.options=[{key:"",value:"Relevance"},{key:f+" desc",value:"Most Recent"}],(s=e.metadata.sorts)!=null&&s.length){const g=e.metadata.sorts.map(m=>({value:m.label,key:m.name+" "+m.order}));d.options=[{key:"",value:"Relevance"},...g]}return o=((l=(i=(r=(a=e==null?void 0:e.spellcheck)==null?void 0:a.suggestions)==null?void 0:r[1])==null?void 0:i.suggestion)==null?void 0:l[0])??"",typeof o!="string"&&(o=(o==null?void 0:o.word)??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:o,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:d}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const r=s[a],i={};i.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(i.cDocTitle=this.getDataForAnalytics(r.title)),i.position=r.position,t.push(i)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(s=>s.uniqueId===e)??null}static getUnmappedFields(e,t,s){const a=t.metadata.results.filter(i=>i.result_card==="").map(i=>i.name),r=[];for(const i of Object.keys(e))if(a.indexOf(i)!==-1){const l=Array.isArray(e[i])?this.getHighlightedResults(i,e[i].join(", "),s,t):this.getHighlightedResults(i,e[i]+"",s,t);r.push({key:i,value:l,isImage:this.checkIfImage(e[i])})}return r}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const s=t.metadata.results.map(r=>r.name),a=[];for(const r of Object.keys(e))s.indexOf(r)!==-1&&a.push({key:r,value:e[r],isImage:this.checkIfImage(e[r])});return a}static doesMapExist(e,t){return t.metadata.results.find(s=>s.result_card===e)!==void 0}static getValueByKey(e,t,s,a,r=!1){const i=s.metadata.results.find(o=>o.result_card===e);if(i===void 0)return null;const l=t[i.name];return l===void 0?null:typeof l=="string"?r?l:this.getHighlightedResults(i.name,l,a,s):Array.isArray(l)?r?l.join(", "):this.getHighlightedResults(i.name,l.join(", "),a,s):null}static getHighlightedResults(e,t,s,a){if(a.highlighting&&s in a.highlighting){let r=a.highlighting[s];if(r&&e in r){let i=r[e];const l=this.cleanValue(i);if(l!=="")return l}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class Ne{constructor(e){h(this,"routeName","searchstax"),h(this,"ignoredKeys",[]),h(this,"queryStringHelper"),h(this,"titleParser"),e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new pt(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=typeof document<"u"?document==null?void 0:document.title:"";this.titleParser&&(s=this.titleParser(e)),typeof document<"u"&&(document.title=s),(window==null?void 0:window.location.href)!==t&&(window==null||window.history.replaceState(window.history.state,s,t))}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")?(window==null?void 0:window.location.href.split("?")[0])+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):(window==null?void 0:window.location.href)+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},s=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=s+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const a in e.facets){const r=e.facets[a].type+":"+encodeURIComponent(e.facets[a].name)+":"+encodeURIComponent(e.facets[a].value);t[this.routeName+`[facets][${a}]`]=r}if(this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")){const a=this.queryStringHelper.urlToParams((window==null?void 0:window.location.href)??"");for(const r in a)r.startsWith(this.routeName)&&delete a[r];return{...a,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const s in e)s.startsWith(this.routeName)||(t[s]=e[s]);return t}extractArrayOfFacetsFromQueryParameters(e){var t,s,a;const r=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const l=ae.removeXSSRiskyTags((t=e[i].split(":"))==null?void 0:t[0]),o=ae.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[1])),d=ae.removeXSSRiskyTags(decodeURIComponent((a=e[i].split(":"))==null?void 0:a[2]));r.push({type:l,name:o,value:d})}return r}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=ae.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),i=isNaN(r)?1:r;return{query:ae.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:i,itemsPerPage:t,order:ae.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[]}}}class pt{constructor(e){h(this,"routeName",""),h(this,"stringify",(t,s)=>{const a=this.filterOutIgnoredKeys(t,s.ignoredKeys);return Object.keys(a).map(r=>{const i=a[r];return Array.isArray(i)?i.map(l=>`${r}=${l}`).join("&"):`${r}=${i}`}).join("&")}),this.routeName=e}filterOutIgnoredKeys(e,t){const s=t||[],a={};return Object.keys(e).forEach(r=>{s.includes(r)||e[r]!==""&&(a[r]=e[r])}),a}urlToParams(e){const t={},s=e.split("?")[1];return s&&s.split("&").forEach(a=>{const[r,i]=a.split("=");t[r]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const re={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class mt{constructor(e,t){h(this,"cachedQuery",""),h(this,"url",""),h(this,"relatedSearches",""),h(this,"suggester",""),h(this,"authHeader"),h(this,"authHeaderRelated"),h(this,"trackApiKey",""),h(this,"session",""),h(this,"searchAuthType"),h(this,"searchAuth",""),h(this,"controllerSearch"),h(this,"signalSearch"),h(this,"controllerSuggest"),h(this,"signalSuggest"),h(this,"dataLayer"),this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json");const s=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`;this.authHeader.append("Authorization",s),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let s=[];if(!t)e.forEach(function(a){const r=a.name+':"'+a.value+'"';s=s.concat("fq="+decodeURIComponent(r).replace(" "," "))});else{const a={};e.forEach(function(r){const i=r.name+":"+r.value,l=decodeURIComponent(i).replace(" "," ").split(":");a[l[0]]?a[l[0]].push(l[1]):a[l[0]]=[l[1]]});for(const r in a)if(Object.prototype.hasOwnProperty.call(a,r)){const i=a[r],l=r;let o="";for(const d of i)o+=` ${l}:"${d}"`;s=s.concat("fq="+o.trim())}}return s.length?"&"+s.join("&"):""}getRelatedSearches(e,t,s,a){const r=new Headers;r.append("Accept","application/json"),r.append("Authorization",s),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:r,credentials:"same-origin"}).then(i=>i.json()).then(i=>{a(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=de.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,s=!1,a=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=new Proxy(new URLSearchParams((window==null?void 0:window.location.search)??""),{get:(m,C)=>m.get(C)??""}),i=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let l=e.itemsPerPage,o=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),d=e.order?`&sort=${e.order}`:"";const f=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+o+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(m=>m.type==="or"||m.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(m=>m.type==="and"||m.type==="tabs"),!1)+d+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!a}`+(l?`&rows=${l}`:"")+"&language="+this.dataLayer.language+i,g={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete g.signal,fetch(f,g).then(m=>m.json()).then(m=>{this.dataLayer.setLoading(!1),t(m)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.lastSearchValue===e||this.dataLayer.searchObject.facets.length>0||this.dataLayer.searchObject.page!==1)return;const s=new EventSource(re.questionURL+e),a=this.dataLayer;s.onmessage=function(r){if(r.data===re.question||r.data===re.notQuestion){a.setAnswerData("");return}if(r.data===re.close){s.close();return}t(r.data)},s.onerror=function(){s.close()}}suggest(e,t,s){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const a=this.suggester+"?q="+e.trim()+this.toQueryString(s)+"&language="+this.dataLayer.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(r=>r.json()).then(r=>{t(r)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const s of e)t.push(encodeURIComponent(s.key)+"="+encodeURIComponent(s.value));return"&"+t.join("&")}}class ie{static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language};return new Promise((s,a)=>{const r=["trackClick",t];t.key&&this.msq().push(r,(function(i,l){JSON.stringify(i)===JSON.stringify(t)&&l?s():a()}).bind(this))})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:e.currentPage,shownHits:e.recordsPerPage,totalHits:e.totalResults,language:e.language};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,latency:e.latencyVal,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}}h(ie,"subscribedToClickEvent",!1),h(ie,"msq",()=>typeof window<"u"&&window!=null&&window._msq?window==null?void 0:window._msq:[]);/*!
33
33
  * mustache.js - Logic-less {{mustache}} templates with JavaScript
34
34
  * http://github.com/janl/mustache.js
35
35
  */var ft=Object.prototype.toString,ne=Array.isArray||function(n){return ft.call(n)==="[object Array]"};function Te(n){return typeof n=="function"}function vt(n){return ne(n)?"array":typeof n}function ke(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function _e(n,e){return n!=null&&typeof n=="object"&&e in n}function yt(n,e){return n!=null&&typeof n!="object"&&n.hasOwnProperty&&n.hasOwnProperty(e)}var xt=RegExp.prototype.test;function bt(n,e){return xt.call(n,e)}var St=/\S/;function Ct(n){return!bt(St,n)}var Lt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function Tt(n){return String(n).replace(/[&<>"'`=\/]/g,function(e){return Lt[e]})}var kt=/\s*/,Rt=/\s+/,He=/\s*=/,wt=/\s*\}/,Et=/#|\^|\/|>|\{|&|=|!/;function It(n,e){if(!n)return[];var t=!1,s=[],a=[],r=[],i=!1,l=!1,o="",d=0;function f(){if(i&&!l)for(;r.length;)delete a[r.pop()];else r=[];i=!1,l=!1}var g,m,C;function I(x){if(typeof x=="string"&&(x=x.split(Rt,2)),!ne(x)||x.length!==2)throw new Error("Invalid tags: "+x);g=new RegExp(ke(x[0])+"\\s*"),m=new RegExp("\\s*"+ke(x[1])),C=new RegExp("\\s*"+ke("}"+x[1]))}I(e||F.tags);for(var k=new ge(n),R,P,L,_,$,N;!k.eos();){if(R=k.pos,L=k.scanUntil(g),L)for(var Q=0,v=L.length;Q<v;++Q)_=L.charAt(Q),Ct(_)?(r.push(a.length),o+=_):(l=!0,t=!0,o+=" "),a.push(["text",_,R,R+1]),R+=1,_===`
@@ -1196,7 +1196,7 @@ class nt {
1196
1196
  updateUrl(e) {
1197
1197
  const t = this.searchObjectToUrl(e);
1198
1198
  let s = typeof document < "u" ? document == null ? void 0 : document.title : "";
1199
- this.titleParser && (s = this.titleParser(e)), typeof document < "u" && (document.title = s), (window == null ? void 0 : window.location.href) !== t && (window == null || window.history.pushState({}, s, t));
1199
+ this.titleParser && (s = this.titleParser(e)), typeof document < "u" && (document.title = s), (window == null ? void 0 : window.location.href) !== t && (window == null || window.history.replaceState(window.history.state, s, t));
1200
1200
  }
1201
1201
  searchObjectToUrl(e) {
1202
1202
  return this.queryStringHelper.urlHasQueryParams((window == null ? void 0 : window.location.href) ?? "") ? (window == null ? void 0 : window.location.href.split("?")[0]) + "?" + this.queryStringHelper.stringify(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@searchstax-inc/searchstudio-ux-react",
3
3
  "private": false,
4
- "version": "1.0.2",
4
+ "version": "1.0.3",
5
5
  "type": "module",
6
6
  "main": "./dist/@searchstax-inc/searchstudio-ux-react.cjs",
7
7
  "module": "./dist/@searchstax-inc/searchstudio-ux-react.mjs",
@@ -22,7 +22,7 @@
22
22
  "preview": "vite preview"
23
23
  },
24
24
  "dependencies": {
25
- "@searchstax-inc/searchstudio-ux-js": "npm:@searchstax-inc/searchstudio-ux-js@^1.0.4",
25
+ "@searchstax-inc/searchstudio-ux-js": "npm:@searchstax-inc/searchstudio-ux-js@^1.0.5",
26
26
  "react": "^18.2.0",
27
27
  "react-dom": "^18.2.0"
28
28
  },