@searchstax-inc/searchstudio-ux-react 0.2.17 → 0.2.18
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.
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Check the render method of \``+n+"`."}return""}}function St(n){{if(n!==void 0){v
|
|
|
24
24
|
|
|
25
25
|
Check your code at `+p+":"+y+"."}return""}}var ze={};function Ct(n){{var p=Ke();if(!p){var y=typeof n=="string"?n:n.displayName||n.name;y&&(p=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+y+">.")}return p}}function Je(n,p){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var y=Ct(p);if(ze[y])return;ze[y]=!0;var L="";n&&n._owner&&n._owner!==Te.current&&(L=" It was passed a child from "+K(n._owner.type)+"."),ee(n),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',y,L),ee(null)}}function Ye(n,p){{if(typeof n!="object")return;if(Ce(n))for(var y=0;y<n.length;y++){var L=n[y];Re(L)&&Je(L,p)}else if(Re(n))n._store&&(n._store.validated=!0);else if(n){var O=k(n);if(typeof O=="function"&&O!==n.entries)for(var A=O.call(n),I;!(I=A.next()).done;)Re(I.value)&&Je(I.value,p)}}}function Lt(n){{var p=n.type;if(p==null||typeof p=="string")return;var y;if(typeof p=="function")y=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===u||p.$$typeof===m))y=p.propTypes;else return;if(y){var L=K(p);ot(y,n.props,"prop",L,n)}else if(p.PropTypes!==void 0&&!ke){ke=!0;var O=K(p);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",O||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Tt(n){{for(var p=Object.keys(n.props),y=0;y<p.length;y++){var L=p[y];if(L!=="children"&&L!=="key"){ee(n),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",L),ee(null);break}}n.ref!==null&&(ee(n),T("Invalid attribute `ref` supplied to `React.Fragment`."),ee(null))}}function Ge(n,p,y,L,O,A){{var I=_(n);if(!I){var E="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var V=St(O);V?E+=V:E+=Ke();var q;n===null?q="null":Ce(n)?q="array":n!==void 0&&n.$$typeof===e?(q="<"+(K(n.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):q=typeof n,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",q,E)}var H=bt(n,p,y,O,A);if(H==null)return H;if(I){var z=p.children;if(z!==void 0)if(L)if(Ce(z)){for(var te=0;te<z.length;te++)Ye(z[te],n);Object.freeze&&Object.freeze(z)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ye(z,n)}return n===s?Tt(H):Lt(H),H}}function kt(n,p,y){return Ge(n,p,y,!0)}function Rt(n,p,y){return Ge(n,p,y,!1)}var Et=Rt,wt=kt;le.Fragment=s,le.jsx=Et,le.jsxs=wt}()),le}process.env.NODE_ENV==="production"?Ie.exports=It():Ie.exports=Pt();var o=Ie.exports,jt=Object.defineProperty,Ft=(i,e,t)=>e in i?jt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,h=(i,e,t)=>(Ft(i,typeof e!="symbol"?e+"":e,t),t),B=(i=>(i[i.mustache=0]="mustache",i[i.vue=1]="vue",i[i.react=2]="react",i[i.angular=3]="angular",i))(B||{});class Ot{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.searchObject.itemsPerPage||0}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,c=t.find(l=>l.name===a);if(c){const l=c.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.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}}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.sessionId,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 J{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 c=e[r],l=t[r],u=this.isObject(c)&&this.isObject(l);if(u&&!this.deepEqual(c,l)||!u&&c!==l)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class N{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 Ee{static getOrSetCookie(e){let t=this.getCookie(e);return t==null&&(t=this.makeid(25),this.setCookie(e,t,{secure:!0,"max-age":3600})),t}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=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));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 c in a){r+="; "+c;const l=a[c];l!==!0&&(r+="="+l)}document.cookie=r}}class Z{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 Mt{constructor(e){h(this,"$searchTermChange",new N("")),h(this,"$loadingChange",new N(!1)),h(this,"$searchResults",new N(null)),h(this,"$searchResultsMetadata",new N(null)),h(this,"$searchAutosuggest",new N(null)),h(this,"$searchFacets",new N(null)),h(this,"$searchFacetsCached",new N(null)),h(this,"$searchstaxConfig",new N(null)),h(this,"$autosuggestResults",new N(null)),h(this,"$searchObject",new N({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]})),h(this,"$searchRelatedSearches",new N(null)),h(this,"$searchInputConfig",new N(null)),h(this,"$searchExternalPromotions",new N(null)),h(this,"$facetsTemplateData",new N(null)),h(this,"$selectedFacetsTemplateData",new N(null)),h(this,"$paginationData",new N(null)),h(this,"$searchFeedbackData",new N(null)),h(this,"$searchSortingData",new N(null)),h(this,"$searchRelatedSearchesData",new N(null)),h(this,"$searchExternalPromotionsData",new N(null)),h(this,"$cookiesDisabled",new N(null)),h(this,"$answer",new N("")),h(this,"$language",new N("en")),h(this,"currentPageValue",1),h(this,"isAnswerWidgetCreatedValue",!1),h(this,"renderingEngineValue",B.mustache),h(this,"parsedData",new Ot(this)),h(this,"sessionId"),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,this.cookieHandlingCallback(),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback()})}cookieHandlingCallback(){this.cookiesDisabled?(Ee.deleteCookie(this.sessionId),Ee.deleteCookie("ms_visitorid")):Ee.getOrSetCookie(this.sessionId)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(Z.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,(!J.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){J.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var t,s;let a=e;(s=(t=this.searchstaxConfig)==null?void 0:t.hooks)!=null&&s.beforeSearch&&a&&(a=this.searchstaxConfig.hooks.beforeSearch(a)),a&&(!J.deepEqual(a,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(a)}setSearchFacets(e){J.deepEqual(e,this.searchFacets??[])||(this.facetsWereSet=!0,this.$searchFacets.setValue(e))}setSearchFacetsCached(e){J.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){J.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){J.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)}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.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}}class oe{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"")-1,a=parseInt(e.responseHeader.params.rows);return e.response.docs.forEach((r,c)=>{const l={custom:null,uniqueId:r[e.responseHeader.params.uniqueId]??"",position:s*a+1+c,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",r,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",r,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",r,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",r,e):null,promoted:r["[elevated]"]?r["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",r,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",r,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",r,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",r,e):null,unmappedFields:this.getUnmappedFields(r,e),allFields:this.getAllFields(r,e)};t.push(l)}),t}static extractFacets(e){const t=[];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 c=0;c<r.length;c+=2){const l={};l.value=r[c],l.parentName=a.name,l.count=r[c+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;let c="";return c=((r=(a=(s=(t=e==null?void 0:e.spellcheck)==null?void 0:t.suggestions)==null?void 0:s[0])==null?void 0:a.suggestion)==null?void 0:r[0])??"",typeof c!="string"&&(c=(c==null?void 0:c.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:c,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e)}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const r=s[a],c={};c.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(c.cDocTitle=this.getDataForAnalytics(r.title)),c.position=r.position,t.push(c)}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){const s=t.metadata.results.filter(r=>r.result_card==="").map(r=>r.name),a=[];for(const r of Object.keys(e))if(s.indexOf(r)!==-1){const c=Array.isArray(e[r])?e[r].join(", "):e[r];a.push({key:r,value:c,isImage:this.checkIfImage(e[r])})}return a}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){const a=s.metadata.results.find(c=>c.result_card===e);if(a===void 0)return null;const r=t[a.name];return r===void 0?null:typeof r=="string"?r:Array.isArray(r)?r.join(", "):null}}class tt{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 At(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=document.title;this.titleParser&&(s=this.titleParser(e)),document.title=s,window.location.href!==t&&window.history.pushState({},s,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window.location.href)?window.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):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.location.href)){const a=this.queryStringHelper.urlToParams(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 c in e)if(c.startsWith(this.routeName+"[facets]")){const l=Z.removeXSSRiskyTags((t=e[c].split(":"))==null?void 0:t[0]),u=Z.removeXSSRiskyTags(decodeURIComponent((s=e[c].split(":"))==null?void 0:s[1])),d=Z.removeXSSRiskyTags(decodeURIComponent((a=e[c].split(":"))==null?void 0:a[2]));r.push({type:l,name:u,value:d})}return r}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=Z.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),c=isNaN(r)?1:r;return{query:Z.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:c,itemsPerPage:t,order:Z.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[]}}}class At{constructor(e){h(this,"routeName",""),h(this,"stringify",(t,s)=>{const a=this.filterOutIgnoredKeys(t,s.ignoredKeys);return Object.keys(a).map(r=>{const c=a[r];return Array.isArray(c)?c.map(l=>`${r}=${l}`).join("&"):`${r}=${c}`}).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,c]=a.split("=");t[r]=c}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const ae={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class Dt{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 c=r.name+":"+r.value,l=decodeURIComponent(c).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 c=a[r],l=r;let u="";for(const d of c)u+=` ${l}:"${d}"`;s=s.concat("fq="+u.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(c=>c.json()).then(c=>{a(c)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:10,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=oe.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,s=!1,a=!1){if(e.query&&e.query!=="undefined"&&e.itemsPerPage!==void 0){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.location.search),{get:(v,C)=>v.get(C)??""}),c=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let l=e.itemsPerPage,u=e.itemsPerPage*(e.page-1),d=e.order?`&sort=${e.order}`:"";const g=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+u+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(v=>v.type==="or"||v.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(v=>v.type==="and"||v.type==="tabs"),!1)+d+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!a}&rows=${l}&language=`+this.dataLayer.language+c,m={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete m.signal,fetch(g,m).then(v=>v.json()).then(v=>{this.dataLayer.setLoading(!1),t(v)}).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(ae.questionURL+e),a=this.dataLayer;s.onmessage=function(r){if(r.data===ae.question||r.data===ae.notQuestion){a.setAnswerData("");return}if(r.data===ae.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 he{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.title,position:e.result.position,language:e.language};setTimeout(()=>{t.key&&this.msq.push(["trackClick",t])},0)}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(he,"msq",window._msq||[]);/*!
|
|
27
|
+
Check the top-level render call using <`+y+">.")}return p}}function Je(n,p){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var y=Ct(p);if(ze[y])return;ze[y]=!0;var L="";n&&n._owner&&n._owner!==Te.current&&(L=" It was passed a child from "+K(n._owner.type)+"."),ee(n),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',y,L),ee(null)}}function Ye(n,p){{if(typeof n!="object")return;if(Ce(n))for(var y=0;y<n.length;y++){var L=n[y];Re(L)&&Je(L,p)}else if(Re(n))n._store&&(n._store.validated=!0);else if(n){var O=k(n);if(typeof O=="function"&&O!==n.entries)for(var A=O.call(n),I;!(I=A.next()).done;)Re(I.value)&&Je(I.value,p)}}}function Lt(n){{var p=n.type;if(p==null||typeof p=="string")return;var y;if(typeof p=="function")y=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===u||p.$$typeof===m))y=p.propTypes;else return;if(y){var L=K(p);ot(y,n.props,"prop",L,n)}else if(p.PropTypes!==void 0&&!ke){ke=!0;var O=K(p);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",O||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Tt(n){{for(var p=Object.keys(n.props),y=0;y<p.length;y++){var L=p[y];if(L!=="children"&&L!=="key"){ee(n),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",L),ee(null);break}}n.ref!==null&&(ee(n),T("Invalid attribute `ref` supplied to `React.Fragment`."),ee(null))}}function Ge(n,p,y,L,O,A){{var I=_(n);if(!I){var E="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var V=St(O);V?E+=V:E+=Ke();var q;n===null?q="null":Ce(n)?q="array":n!==void 0&&n.$$typeof===e?(q="<"+(K(n.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):q=typeof n,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",q,E)}var H=bt(n,p,y,O,A);if(H==null)return H;if(I){var z=p.children;if(z!==void 0)if(L)if(Ce(z)){for(var te=0;te<z.length;te++)Ye(z[te],n);Object.freeze&&Object.freeze(z)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ye(z,n)}return n===s?Tt(H):Lt(H),H}}function kt(n,p,y){return Ge(n,p,y,!0)}function Rt(n,p,y){return Ge(n,p,y,!1)}var Et=Rt,wt=kt;le.Fragment=s,le.jsx=Et,le.jsxs=wt}()),le}process.env.NODE_ENV==="production"?Ie.exports=It():Ie.exports=Pt();var o=Ie.exports,jt=Object.defineProperty,Ft=(i,e,t)=>e in i?jt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,h=(i,e,t)=>(Ft(i,typeof e!="symbol"?e+"":e,t),t),B=(i=>(i[i.mustache=0]="mustache",i[i.vue=1]="vue",i[i.react=2]="react",i[i.angular=3]="angular",i))(B||{});class Ot{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.searchObject.itemsPerPage||0}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,c=t.find(l=>l.name===a);if(c){const l=c.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.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}}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.sessionId,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 J{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 c=e[r],l=t[r],u=this.isObject(c)&&this.isObject(l);if(u&&!this.deepEqual(c,l)||!u&&c!==l)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class N{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 Ee{static getOrSetCookie(e){let t=this.getCookie(e);return t==null&&(t=this.makeid(25),this.setCookie(e,t,{secure:!0,"max-age":3600})),t}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=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));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 c in a){r+="; "+c;const l=a[c];l!==!0&&(r+="="+l)}document.cookie=r}}class Z{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 Mt{constructor(e){h(this,"$searchTermChange",new N("")),h(this,"$loadingChange",new N(!1)),h(this,"$searchResults",new N(null)),h(this,"$searchResultsMetadata",new N(null)),h(this,"$searchAutosuggest",new N(null)),h(this,"$searchFacets",new N(null)),h(this,"$searchFacetsCached",new N(null)),h(this,"$searchstaxConfig",new N(null)),h(this,"$autosuggestResults",new N(null)),h(this,"$searchObject",new N({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]})),h(this,"$searchRelatedSearches",new N(null)),h(this,"$searchInputConfig",new N(null)),h(this,"$searchExternalPromotions",new N(null)),h(this,"$facetsTemplateData",new N(null)),h(this,"$selectedFacetsTemplateData",new N(null)),h(this,"$paginationData",new N(null)),h(this,"$searchFeedbackData",new N(null)),h(this,"$searchSortingData",new N(null)),h(this,"$searchRelatedSearchesData",new N(null)),h(this,"$searchExternalPromotionsData",new N(null)),h(this,"$cookiesDisabled",new N(null)),h(this,"$answer",new N("")),h(this,"$language",new N("en")),h(this,"currentPageValue",1),h(this,"isAnswerWidgetCreatedValue",!1),h(this,"renderingEngineValue",B.mustache),h(this,"parsedData",new Ot(this)),h(this,"sessionId"),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,this.cookieHandlingCallback(),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback()})}cookieHandlingCallback(){this.cookiesDisabled?(Ee.deleteCookie(this.sessionId),Ee.deleteCookie("ms_visitorid")):Ee.getOrSetCookie(this.sessionId)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(Z.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,(!J.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){J.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var t,s;let a=e;(s=(t=this.searchstaxConfig)==null?void 0:t.hooks)!=null&&s.beforeSearch&&a&&(a=this.searchstaxConfig.hooks.beforeSearch(a)),a&&(!J.deepEqual(a,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(a)}setSearchFacets(e){this.facetsWereSet=!0,J.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){J.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){J.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){J.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)}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.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}}class oe{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"")-1,a=parseInt(e.responseHeader.params.rows);return e.response.docs.forEach((r,c)=>{const l={custom:null,uniqueId:r[e.responseHeader.params.uniqueId]??"",position:s*a+1+c,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",r,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",r,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",r,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",r,e):null,promoted:r["[elevated]"]?r["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",r,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",r,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",r,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",r,e):null,unmappedFields:this.getUnmappedFields(r,e),allFields:this.getAllFields(r,e)};t.push(l)}),t}static extractFacets(e){const t=[];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 c=0;c<r.length;c+=2){const l={};l.value=r[c],l.parentName=a.name,l.count=r[c+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;let c="";return c=((r=(a=(s=(t=e==null?void 0:e.spellcheck)==null?void 0:t.suggestions)==null?void 0:s[0])==null?void 0:a.suggestion)==null?void 0:r[0])??"",typeof c!="string"&&(c=(c==null?void 0:c.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:c,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e)}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const r=s[a],c={};c.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(c.cDocTitle=this.getDataForAnalytics(r.title)),c.position=r.position,t.push(c)}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){const s=t.metadata.results.filter(r=>r.result_card==="").map(r=>r.name),a=[];for(const r of Object.keys(e))if(s.indexOf(r)!==-1){const c=Array.isArray(e[r])?e[r].join(", "):e[r];a.push({key:r,value:c,isImage:this.checkIfImage(e[r])})}return a}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){const a=s.metadata.results.find(c=>c.result_card===e);if(a===void 0)return null;const r=t[a.name];return r===void 0?null:typeof r=="string"?r:Array.isArray(r)?r.join(", "):null}}class tt{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 At(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=document.title;this.titleParser&&(s=this.titleParser(e)),document.title=s,window.location.href!==t&&window.history.pushState({},s,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window.location.href)?window.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):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.location.href)){const a=this.queryStringHelper.urlToParams(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 c in e)if(c.startsWith(this.routeName+"[facets]")){const l=Z.removeXSSRiskyTags((t=e[c].split(":"))==null?void 0:t[0]),u=Z.removeXSSRiskyTags(decodeURIComponent((s=e[c].split(":"))==null?void 0:s[1])),d=Z.removeXSSRiskyTags(decodeURIComponent((a=e[c].split(":"))==null?void 0:a[2]));r.push({type:l,name:u,value:d})}return r}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=Z.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),c=isNaN(r)?1:r;return{query:Z.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:c,itemsPerPage:t,order:Z.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[]}}}class At{constructor(e){h(this,"routeName",""),h(this,"stringify",(t,s)=>{const a=this.filterOutIgnoredKeys(t,s.ignoredKeys);return Object.keys(a).map(r=>{const c=a[r];return Array.isArray(c)?c.map(l=>`${r}=${l}`).join("&"):`${r}=${c}`}).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,c]=a.split("=");t[r]=c}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const ae={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class Dt{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 c=r.name+":"+r.value,l=decodeURIComponent(c).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 c=a[r],l=r;let u="";for(const d of c)u+=` ${l}:"${d}"`;s=s.concat("fq="+u.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(c=>c.json()).then(c=>{a(c)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:10,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=oe.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,s=!1,a=!1){if(e.query&&e.query!=="undefined"&&e.itemsPerPage!==void 0){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.location.search),{get:(v,C)=>v.get(C)??""}),c=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let l=e.itemsPerPage,u=e.itemsPerPage*(e.page-1),d=e.order?`&sort=${e.order}`:"";const g=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+u+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(v=>v.type==="or"||v.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(v=>v.type==="and"||v.type==="tabs"),!1)+d+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!a}&rows=${l}&language=`+this.dataLayer.language+c,m={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete m.signal,fetch(g,m).then(v=>v.json()).then(v=>{this.dataLayer.setLoading(!1),t(v)}).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(ae.questionURL+e),a=this.dataLayer;s.onmessage=function(r){if(r.data===ae.question||r.data===ae.notQuestion){a.setAnswerData("");return}if(r.data===ae.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 he{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.title,position:e.result.position,language:e.language};setTimeout(()=>{t.key&&this.msq.push(["trackClick",t])},0)}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(he,"msq",window._msq||[]);/*!
|
|
28
28
|
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
29
29
|
* http://github.com/janl/mustache.js
|
|
30
30
|
*/var Nt=Object.prototype.toString,re=Array.isArray||function(i){return Nt.call(i)==="[object Array]"};function Pe(i){return typeof i=="function"}function $t(i){return re(i)?"array":typeof i}function we(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function at(i,e){return i!=null&&typeof i=="object"&&e in i}function qt(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var _t=RegExp.prototype.test;function Ht(i,e){return _t.call(i,e)}var Wt=/\S/;function Bt(i){return!Ht(Wt,i)}var Vt={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function Ut(i){return String(i).replace(/[&<>"'`=\/]/g,function(e){return Vt[e]})}var Qt=/\s*/,Kt=/\s+/,st=/\s*=/,zt=/\s*\}/,Jt=/#|\^|\/|>|\{|&|=|!/;function Yt(i,e){if(!i)return[];var t=!1,s=[],a=[],r=[],c=!1,l=!1,u="",d=0;function g(){if(c&&!l)for(;r.length;)delete a[r.pop()];else r=[];c=!1,l=!1}var m,v,C;function M(b){if(typeof b=="string"&&(b=b.split(Kt,2)),!re(b)||b.length!==2)throw new Error("Invalid tags: "+b);m=new RegExp(we(b[0])+"\\s*"),v=new RegExp("\\s*"+we(b[1])),C=new RegExp("\\s*"+we("}"+b[1]))}M(e||j.tags);for(var R=new de(i),k,w,T,$,W,D;!R.eos();){if(k=R.pos,T=R.scanUntil(m),T)for(var Q=0,f=T.length;Q<f;++Q)$=T.charAt(Q),Bt($)?(r.push(a.length),u+=$):(l=!0,t=!0,u+=" "),a.push(["text",$,k,k+1]),k+=1,$===`
|
|
@@ -24,7 +24,7 @@ Check the render method of \``+n+"`."}return""}}function ba(n){{if(n!==void 0){v
|
|
|
24
24
|
|
|
25
25
|
Check your code at `+p+":"+y+"."}return""}}var et={};function Sa(n){{var p=Ze();if(!p){var y=typeof n=="string"?n:n.displayName||n.name;y&&(p=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+y+">.")}return p}}function tt(n,p){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var y=Sa(p);if(et[y])return;et[y]=!0;var L="";n&&n._owner&&n._owner!==Ie.current&&(L=" It was passed a child from "+K(n._owner.type)+"."),re(n),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',y,L),re(null)}}function at(n,p){{if(typeof n!="object")return;if(Ee(n))for(var y=0;y<n.length;y++){var L=n[y];je(L)&&tt(L,p)}else if(je(n))n._store&&(n._store.validated=!0);else if(n){var O=k(n);if(typeof O=="function"&&O!==n.entries)for(var A=O.call(n),P;!(P=A.next()).done;)je(P.value)&&tt(P.value,p)}}}function Ca(n){{var p=n.type;if(p==null||typeof p=="string")return;var y;if(typeof p=="function")y=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===u||p.$$typeof===m))y=p.propTypes;else return;if(y){var L=K(p);la(y,n.props,"prop",L,n)}else if(p.PropTypes!==void 0&&!Pe){Pe=!0;var O=K(p);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",O||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function La(n){{for(var p=Object.keys(n.props),y=0;y<p.length;y++){var L=p[y];if(L!=="children"&&L!=="key"){re(n),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",L),re(null);break}}n.ref!==null&&(re(n),T("Invalid attribute `ref` supplied to `React.Fragment`."),re(null))}}function st(n,p,y,L,O,A){{var P=W(n);if(!P){var E="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var U=ba(O);U?E+=U:E+=Ze();var H;n===null?H="null":Ee(n)?H="array":n!==void 0&&n.$$typeof===e?(H="<"+(K(n.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):H=typeof n,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",H,E)}var q=xa(n,p,y,O,A);if(q==null)return q;if(P){var z=p.children;if(z!==void 0)if(L)if(Ee(z)){for(var ie=0;ie<z.length;ie++)at(z[ie],n);Object.freeze&&Object.freeze(z)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else at(z,n)}return n===s?La(q):Ca(q),q}}function Ta(n,p,y){return st(n,p,y,!0)}function ka(n,p,y){return st(n,p,y,!1)}var Ra=ka,Ea=Ta;ce.Fragment=s,ce.jsx=Ra,ce.jsxs=Ea}()),ce}process.env.NODE_ENV==="production"?be.exports=it():be.exports=nt();var o=be.exports,ct=Object.defineProperty,lt=(i,e,t)=>e in i?ct(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,h=(i,e,t)=>(lt(i,typeof e!="symbol"?e+"":e,t),t),B=(i=>(i[i.mustache=0]="mustache",i[i.vue=1]="vue",i[i.react=2]="react",i[i.angular=3]="angular",i))(B||{});class ot{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.searchObject.itemsPerPage||0}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,c=t.find(l=>l.name===a);if(c){const l=c.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.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}}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.sessionId,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 J{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 c=e[r],l=t[r],u=this.isObject(c)&&this.isObject(l);if(u&&!this.deepEqual(c,l)||!u&&c!==l)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class N{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 Se{static getOrSetCookie(e){let t=this.getCookie(e);return t==null&&(t=this.makeid(25),this.setCookie(e,t,{secure:!0,"max-age":3600})),t}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=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));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 c in a){r+="; "+c;const l=a[c];l!==!0&&(r+="="+l)}document.cookie=r}}class X{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 ht{constructor(e){h(this,"$searchTermChange",new N("")),h(this,"$loadingChange",new N(!1)),h(this,"$searchResults",new N(null)),h(this,"$searchResultsMetadata",new N(null)),h(this,"$searchAutosuggest",new N(null)),h(this,"$searchFacets",new N(null)),h(this,"$searchFacetsCached",new N(null)),h(this,"$searchstaxConfig",new N(null)),h(this,"$autosuggestResults",new N(null)),h(this,"$searchObject",new N({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]})),h(this,"$searchRelatedSearches",new N(null)),h(this,"$searchInputConfig",new N(null)),h(this,"$searchExternalPromotions",new N(null)),h(this,"$facetsTemplateData",new N(null)),h(this,"$selectedFacetsTemplateData",new N(null)),h(this,"$paginationData",new N(null)),h(this,"$searchFeedbackData",new N(null)),h(this,"$searchSortingData",new N(null)),h(this,"$searchRelatedSearchesData",new N(null)),h(this,"$searchExternalPromotionsData",new N(null)),h(this,"$cookiesDisabled",new N(null)),h(this,"$answer",new N("")),h(this,"$language",new N("en")),h(this,"currentPageValue",1),h(this,"isAnswerWidgetCreatedValue",!1),h(this,"renderingEngineValue",B.mustache),h(this,"parsedData",new ot(this)),h(this,"sessionId"),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,this.cookieHandlingCallback(),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback()})}cookieHandlingCallback(){this.cookiesDisabled?(Se.deleteCookie(this.sessionId),Se.deleteCookie("ms_visitorid")):Se.getOrSetCookie(this.sessionId)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(X.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,(!J.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){J.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var t,s;let a=e;(s=(t=this.searchstaxConfig)==null?void 0:t.hooks)!=null&&s.beforeSearch&&a&&(a=this.searchstaxConfig.hooks.beforeSearch(a)),a&&(!J.deepEqual(a,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(a)}setSearchFacets(e){J.deepEqual(e,this.searchFacets??[])||(this.facetsWereSet=!0,this.$searchFacets.setValue(e))}setSearchFacetsCached(e){J.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){J.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){J.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)}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.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}}class le{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"")-1,a=parseInt(e.responseHeader.params.rows);return e.response.docs.forEach((r,c)=>{const l={custom:null,uniqueId:r[e.responseHeader.params.uniqueId]??"",position:s*a+1+c,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",r,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",r,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",r,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",r,e):null,promoted:r["[elevated]"]?r["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",r,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",r,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",r,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",r,e):null,unmappedFields:this.getUnmappedFields(r,e),allFields:this.getAllFields(r,e)};t.push(l)}),t}static extractFacets(e){const t=[];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 c=0;c<r.length;c+=2){const l={};l.value=r[c],l.parentName=a.name,l.count=r[c+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;let c="";return c=((r=(a=(s=(t=e==null?void 0:e.spellcheck)==null?void 0:t.suggestions)==null?void 0:s[0])==null?void 0:a.suggestion)==null?void 0:r[0])??"",typeof c!="string"&&(c=(c==null?void 0:c.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:c,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e)}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const r=s[a],c={};c.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(c.cDocTitle=this.getDataForAnalytics(r.title)),c.position=r.position,t.push(c)}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){const s=t.metadata.results.filter(r=>r.result_card==="").map(r=>r.name),a=[];for(const r of Object.keys(e))if(s.indexOf(r)!==-1){const c=Array.isArray(e[r])?e[r].join(", "):e[r];a.push({key:r,value:c,isImage:this.checkIfImage(e[r])})}return a}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){const a=s.metadata.results.find(c=>c.result_card===e);if(a===void 0)return null;const r=t[a.name];return r===void 0?null:typeof r=="string"?r:Array.isArray(r)?r.join(", "):null}}class Me{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 ut(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=document.title;this.titleParser&&(s=this.titleParser(e)),document.title=s,window.location.href!==t&&window.history.pushState({},s,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window.location.href)?window.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):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.location.href)){const a=this.queryStringHelper.urlToParams(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 c in e)if(c.startsWith(this.routeName+"[facets]")){const l=X.removeXSSRiskyTags((t=e[c].split(":"))==null?void 0:t[0]),u=X.removeXSSRiskyTags(decodeURIComponent((s=e[c].split(":"))==null?void 0:s[1])),d=X.removeXSSRiskyTags(decodeURIComponent((a=e[c].split(":"))==null?void 0:a[2]));r.push({type:l,name:u,value:d})}return r}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=X.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),c=isNaN(r)?1:r;return{query:X.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:c,itemsPerPage:t,order:X.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[]}}}class ut{constructor(e){h(this,"routeName",""),h(this,"stringify",(t,s)=>{const a=this.filterOutIgnoredKeys(t,s.ignoredKeys);return Object.keys(a).map(r=>{const c=a[r];return Array.isArray(c)?c.map(l=>`${r}=${l}`).join("&"):`${r}=${c}`}).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,c]=a.split("=");t[r]=c}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const te={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class dt{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 c=r.name+":"+r.value,l=decodeURIComponent(c).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 c=a[r],l=r;let u="";for(const d of c)u+=` ${l}:"${d}"`;s=s.concat("fq="+u.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(c=>c.json()).then(c=>{a(c)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:10,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=le.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,s=!1,a=!1){if(e.query&&e.query!=="undefined"&&e.itemsPerPage!==void 0){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.location.search),{get:(v,C)=>v.get(C)??""}),c=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let l=e.itemsPerPage,u=e.itemsPerPage*(e.page-1),d=e.order?`&sort=${e.order}`:"";const g=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+u+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(v=>v.type==="or"||v.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(v=>v.type==="and"||v.type==="tabs"),!1)+d+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!a}&rows=${l}&language=`+this.dataLayer.language+c,m={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete m.signal,fetch(g,m).then(v=>v.json()).then(v=>{this.dataLayer.setLoading(!1),t(v)}).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(te.questionURL+e),a=this.dataLayer;s.onmessage=function(r){if(r.data===te.question||r.data===te.notQuestion){a.setAnswerData("");return}if(r.data===te.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 oe{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.title,position:e.result.position,language:e.language};setTimeout(()=>{t.key&&this.msq.push(["trackClick",t])},0)}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(oe,"msq",window._msq||[]);/*!
|
|
27
|
+
Check the top-level render call using <`+y+">.")}return p}}function tt(n,p){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var y=Sa(p);if(et[y])return;et[y]=!0;var L="";n&&n._owner&&n._owner!==Ie.current&&(L=" It was passed a child from "+K(n._owner.type)+"."),re(n),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',y,L),re(null)}}function at(n,p){{if(typeof n!="object")return;if(Ee(n))for(var y=0;y<n.length;y++){var L=n[y];je(L)&&tt(L,p)}else if(je(n))n._store&&(n._store.validated=!0);else if(n){var O=k(n);if(typeof O=="function"&&O!==n.entries)for(var A=O.call(n),P;!(P=A.next()).done;)je(P.value)&&tt(P.value,p)}}}function Ca(n){{var p=n.type;if(p==null||typeof p=="string")return;var y;if(typeof p=="function")y=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===u||p.$$typeof===m))y=p.propTypes;else return;if(y){var L=K(p);la(y,n.props,"prop",L,n)}else if(p.PropTypes!==void 0&&!Pe){Pe=!0;var O=K(p);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",O||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function La(n){{for(var p=Object.keys(n.props),y=0;y<p.length;y++){var L=p[y];if(L!=="children"&&L!=="key"){re(n),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",L),re(null);break}}n.ref!==null&&(re(n),T("Invalid attribute `ref` supplied to `React.Fragment`."),re(null))}}function st(n,p,y,L,O,A){{var P=W(n);if(!P){var E="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var U=ba(O);U?E+=U:E+=Ze();var H;n===null?H="null":Ee(n)?H="array":n!==void 0&&n.$$typeof===e?(H="<"+(K(n.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):H=typeof n,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",H,E)}var q=xa(n,p,y,O,A);if(q==null)return q;if(P){var z=p.children;if(z!==void 0)if(L)if(Ee(z)){for(var ie=0;ie<z.length;ie++)at(z[ie],n);Object.freeze&&Object.freeze(z)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else at(z,n)}return n===s?La(q):Ca(q),q}}function Ta(n,p,y){return st(n,p,y,!0)}function ka(n,p,y){return st(n,p,y,!1)}var Ra=ka,Ea=Ta;ce.Fragment=s,ce.jsx=Ra,ce.jsxs=Ea}()),ce}process.env.NODE_ENV==="production"?be.exports=it():be.exports=nt();var o=be.exports,ct=Object.defineProperty,lt=(i,e,t)=>e in i?ct(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,h=(i,e,t)=>(lt(i,typeof e!="symbol"?e+"":e,t),t),B=(i=>(i[i.mustache=0]="mustache",i[i.vue=1]="vue",i[i.react=2]="react",i[i.angular=3]="angular",i))(B||{});class ot{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.searchObject.itemsPerPage||0}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,c=t.find(l=>l.name===a);if(c){const l=c.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.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}}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.sessionId,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 J{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 c=e[r],l=t[r],u=this.isObject(c)&&this.isObject(l);if(u&&!this.deepEqual(c,l)||!u&&c!==l)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class N{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 Se{static getOrSetCookie(e){let t=this.getCookie(e);return t==null&&(t=this.makeid(25),this.setCookie(e,t,{secure:!0,"max-age":3600})),t}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=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));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 c in a){r+="; "+c;const l=a[c];l!==!0&&(r+="="+l)}document.cookie=r}}class X{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 ht{constructor(e){h(this,"$searchTermChange",new N("")),h(this,"$loadingChange",new N(!1)),h(this,"$searchResults",new N(null)),h(this,"$searchResultsMetadata",new N(null)),h(this,"$searchAutosuggest",new N(null)),h(this,"$searchFacets",new N(null)),h(this,"$searchFacetsCached",new N(null)),h(this,"$searchstaxConfig",new N(null)),h(this,"$autosuggestResults",new N(null)),h(this,"$searchObject",new N({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]})),h(this,"$searchRelatedSearches",new N(null)),h(this,"$searchInputConfig",new N(null)),h(this,"$searchExternalPromotions",new N(null)),h(this,"$facetsTemplateData",new N(null)),h(this,"$selectedFacetsTemplateData",new N(null)),h(this,"$paginationData",new N(null)),h(this,"$searchFeedbackData",new N(null)),h(this,"$searchSortingData",new N(null)),h(this,"$searchRelatedSearchesData",new N(null)),h(this,"$searchExternalPromotionsData",new N(null)),h(this,"$cookiesDisabled",new N(null)),h(this,"$answer",new N("")),h(this,"$language",new N("en")),h(this,"currentPageValue",1),h(this,"isAnswerWidgetCreatedValue",!1),h(this,"renderingEngineValue",B.mustache),h(this,"parsedData",new ot(this)),h(this,"sessionId"),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,this.cookieHandlingCallback(),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback()})}cookieHandlingCallback(){this.cookiesDisabled?(Se.deleteCookie(this.sessionId),Se.deleteCookie("ms_visitorid")):Se.getOrSetCookie(this.sessionId)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(X.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,(!J.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){J.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var t,s;let a=e;(s=(t=this.searchstaxConfig)==null?void 0:t.hooks)!=null&&s.beforeSearch&&a&&(a=this.searchstaxConfig.hooks.beforeSearch(a)),a&&(!J.deepEqual(a,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(a)}setSearchFacets(e){this.facetsWereSet=!0,J.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){J.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){J.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){J.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)}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.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}}class le{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"")-1,a=parseInt(e.responseHeader.params.rows);return e.response.docs.forEach((r,c)=>{const l={custom:null,uniqueId:r[e.responseHeader.params.uniqueId]??"",position:s*a+1+c,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",r,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",r,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",r,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",r,e):null,promoted:r["[elevated]"]?r["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",r,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",r,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",r,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",r,e):null,unmappedFields:this.getUnmappedFields(r,e),allFields:this.getAllFields(r,e)};t.push(l)}),t}static extractFacets(e){const t=[];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 c=0;c<r.length;c+=2){const l={};l.value=r[c],l.parentName=a.name,l.count=r[c+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;let c="";return c=((r=(a=(s=(t=e==null?void 0:e.spellcheck)==null?void 0:t.suggestions)==null?void 0:s[0])==null?void 0:a.suggestion)==null?void 0:r[0])??"",typeof c!="string"&&(c=(c==null?void 0:c.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:c,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e)}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const r=s[a],c={};c.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(c.cDocTitle=this.getDataForAnalytics(r.title)),c.position=r.position,t.push(c)}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){const s=t.metadata.results.filter(r=>r.result_card==="").map(r=>r.name),a=[];for(const r of Object.keys(e))if(s.indexOf(r)!==-1){const c=Array.isArray(e[r])?e[r].join(", "):e[r];a.push({key:r,value:c,isImage:this.checkIfImage(e[r])})}return a}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){const a=s.metadata.results.find(c=>c.result_card===e);if(a===void 0)return null;const r=t[a.name];return r===void 0?null:typeof r=="string"?r:Array.isArray(r)?r.join(", "):null}}class Me{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 ut(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=document.title;this.titleParser&&(s=this.titleParser(e)),document.title=s,window.location.href!==t&&window.history.pushState({},s,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window.location.href)?window.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):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.location.href)){const a=this.queryStringHelper.urlToParams(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 c in e)if(c.startsWith(this.routeName+"[facets]")){const l=X.removeXSSRiskyTags((t=e[c].split(":"))==null?void 0:t[0]),u=X.removeXSSRiskyTags(decodeURIComponent((s=e[c].split(":"))==null?void 0:s[1])),d=X.removeXSSRiskyTags(decodeURIComponent((a=e[c].split(":"))==null?void 0:a[2]));r.push({type:l,name:u,value:d})}return r}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=X.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),c=isNaN(r)?1:r;return{query:X.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:c,itemsPerPage:t,order:X.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[]}}}class ut{constructor(e){h(this,"routeName",""),h(this,"stringify",(t,s)=>{const a=this.filterOutIgnoredKeys(t,s.ignoredKeys);return Object.keys(a).map(r=>{const c=a[r];return Array.isArray(c)?c.map(l=>`${r}=${l}`).join("&"):`${r}=${c}`}).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,c]=a.split("=");t[r]=c}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const te={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class dt{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 c=r.name+":"+r.value,l=decodeURIComponent(c).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 c=a[r],l=r;let u="";for(const d of c)u+=` ${l}:"${d}"`;s=s.concat("fq="+u.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(c=>c.json()).then(c=>{a(c)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:10,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=le.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,s=!1,a=!1){if(e.query&&e.query!=="undefined"&&e.itemsPerPage!==void 0){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.location.search),{get:(v,C)=>v.get(C)??""}),c=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let l=e.itemsPerPage,u=e.itemsPerPage*(e.page-1),d=e.order?`&sort=${e.order}`:"";const g=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+u+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(v=>v.type==="or"||v.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(v=>v.type==="and"||v.type==="tabs"),!1)+d+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!a}&rows=${l}&language=`+this.dataLayer.language+c,m={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete m.signal,fetch(g,m).then(v=>v.json()).then(v=>{this.dataLayer.setLoading(!1),t(v)}).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(te.questionURL+e),a=this.dataLayer;s.onmessage=function(r){if(r.data===te.question||r.data===te.notQuestion){a.setAnswerData("");return}if(r.data===te.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 oe{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.title,position:e.result.position,language:e.language};setTimeout(()=>{t.key&&this.msq.push(["trackClick",t])},0)}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(oe,"msq",window._msq||[]);/*!
|
|
28
28
|
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
29
29
|
* http://github.com/janl/mustache.js
|
|
30
30
|
*/var gt=Object.prototype.toString,ae=Array.isArray||function(i){return gt.call(i)==="[object Array]"};function Ce(i){return typeof i=="function"}function pt(i){return ae(i)?"array":typeof i}function Le(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Ae(i,e){return i!=null&&typeof i=="object"&&e in i}function mt(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var ft=RegExp.prototype.test;function vt(i,e){return ft.call(i,e)}var yt=/\S/;function xt(i){return!vt(yt,i)}var bt={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function St(i){return String(i).replace(/[&<>"'`=\/]/g,function(e){return bt[e]})}var Ct=/\s*/,Lt=/\s+/,De=/\s*=/,Tt=/\s*\}/,kt=/#|\^|\/|>|\{|&|=|!/;function Rt(i,e){if(!i)return[];var t=!1,s=[],a=[],r=[],c=!1,l=!1,u="",d=0;function g(){if(c&&!l)for(;r.length;)delete a[r.pop()];else r=[];c=!1,l=!1}var m,v,C;function M(S){if(typeof S=="string"&&(S=S.split(Lt,2)),!ae(S)||S.length!==2)throw new Error("Invalid tags: "+S);m=new RegExp(Le(S[0])+"\\s*"),v=new RegExp("\\s*"+Le(S[1])),C=new RegExp("\\s*"+Le("}"+S[1]))}M(e||j.tags);for(var R=new he(i),k,I,T,_,V,D;!R.eos();){if(k=R.pos,T=R.scanUntil(m),T)for(var Q=0,f=T.length;Q<f;++Q)_=T.charAt(Q),xt(_)?(r.push(a.length),u+=_):(l=!0,t=!0,u+=" "),a.push(["text",_,k,k+1]),k+=1,_===`
|
|
@@ -891,7 +891,7 @@ class $t {
|
|
|
891
891
|
(s = (t = this.searchstaxConfig) == null ? void 0 : t.hooks) != null && s.beforeSearch && a && (a = this.searchstaxConfig.hooks.beforeSearch(a)), a && (!J.deepEqual(a, this.searchObject ?? {}) || this.forceNotCorrect) && this.$searchObject.setValue(a);
|
|
892
892
|
}
|
|
893
893
|
setSearchFacets(e) {
|
|
894
|
-
J.deepEqual(e, this.searchFacets ?? []) ||
|
|
894
|
+
this.facetsWereSet = !0, J.deepEqual(e, this.searchFacets ?? []) || this.$searchFacets.setValue(e);
|
|
895
895
|
}
|
|
896
896
|
setSearchFacetsCached(e) {
|
|
897
897
|
J.deepEqual(e, this.searchFacetsCached ?? []) || this.$searchFacetsCached.setValue(e);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@searchstax-inc/searchstudio-ux-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.18",
|
|
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": "
|
|
25
|
+
"@searchstax-inc/searchstudio-ux-js": "npm:@searchstax-inc/searchstudio-ux-js@^0.5.30",
|
|
26
26
|
"react": "^18.2.0",
|
|
27
27
|
"react-dom": "^18.2.0"
|
|
28
28
|
},
|