@searchstax-inc/searchstudio-ux-js 0.0.6 → 0.0.8
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
|
@@ -28,7 +28,25 @@ After importing Searchstax class a new instance needs to be created:
|
|
|
28
28
|
```const searchstax = new Searchstax();```
|
|
29
29
|
|
|
30
30
|
## Initialization
|
|
31
|
+
Initialization object
|
|
31
32
|
|
|
33
|
+
{
|
|
34
|
+
|
|
35
|
+
`language: string;` - language code. Example: 'en'
|
|
36
|
+
|
|
37
|
+
`searchURL: string;` - SeachStudio select endpoint
|
|
38
|
+
|
|
39
|
+
`suggesterURL: string;` - SeachStudio suggest endpoint
|
|
40
|
+
|
|
41
|
+
`trackApiKey: string;` - Api key used for tracking events
|
|
42
|
+
|
|
43
|
+
`searchAuth: string;` - Authentication value. based on authType it's either a token value or basic auth value
|
|
44
|
+
|
|
45
|
+
`authType: 'token' | 'basic';` - Type of authentication
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Initialization example
|
|
32
50
|
```
|
|
33
51
|
searchstax.initialize({
|
|
34
52
|
language: "en",
|
|
@@ -42,17 +60,46 @@ searchstax.initialize({
|
|
|
42
60
|
```
|
|
43
61
|
|
|
44
62
|
## Input widget
|
|
63
|
+
Initialization properties
|
|
64
|
+
|
|
65
|
+
a. id of container where widget will be rendered
|
|
66
|
+
|
|
67
|
+
b. {
|
|
68
|
+
|
|
69
|
+
`suggestAfterMinChars: number;` - controls how many characters the UI should accept at the minimum before showing suggestions
|
|
70
|
+
|
|
71
|
+
`templates?: {` - optional object that defines template override options
|
|
72
|
+
|
|
73
|
+
`mainTemplate?: string;` - main template in Mustache templating language
|
|
74
|
+
|
|
75
|
+
`searchInputId?: string;` - id of search input within the mainTemplate
|
|
76
|
+
|
|
77
|
+
`autosuggestItemTemplate?: string;` - autosuggest item template in Mustache
|
|
78
|
+
|
|
79
|
+
`};`
|
|
80
|
+
|
|
81
|
+
`hooks?: {` - optional object that provides various hook options
|
|
82
|
+
|
|
83
|
+
`beforeSearch?: (props: ISearchstaxSearchProps) => ISearchstaxSearchProps | null;` - this function gets called before firing search. searchProps are being passed as a property and can be modified, if passed along further search will execute with modified properties, if null is returned then event gets canceled and search never fires.
|
|
84
|
+
|
|
85
|
+
`afterSearch?: (results: ISearchstaxParsedResult[]) => ISearchstaxParsedResult[];` - this function gets called after firing search and before rendering. It needs to return array of results that are either modified or untouched.
|
|
86
|
+
|
|
87
|
+
`beforeAutosuggest?: (props: ISearchstaxSuggestProps) => ISearchstaxSuggestProps | null;` - this function gets called before firing autosuggest. autosuggestProps are being passed as a property and can be modified, if passed along further search will execute with modified properties, if null is returned then event gets canceled and search never fires.
|
|
88
|
+
|
|
89
|
+
`afterAutosuggest?: (result: ISearchstaxSuggestResponse) => ISearchstaxSuggestResponse;`- this function gets called after autosuggest has values but before rendering. It needs to return same type of data but it can be modified.
|
|
90
|
+
|
|
91
|
+
`};`
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
45
96
|
example of input widget initialization with various options
|
|
46
97
|
```
|
|
47
98
|
searchstax.addSearchInputWidget("searchstax-input-container", {
|
|
48
99
|
suggestAfterMinChars: 3,
|
|
49
|
-
hideBranding: true,
|
|
50
100
|
hooks: {
|
|
51
101
|
beforeSearch: function (props: ISearchstaxSearchProps) {
|
|
52
|
-
// gets searchProps, if passed along further search will execute, if null then event gets canceled
|
|
53
|
-
// props can be modified and passed along
|
|
54
102
|
const propsCopy = { ...props };
|
|
55
|
-
// propsCopy.term = propsCopy.term;
|
|
56
103
|
return propsCopy;
|
|
57
104
|
},
|
|
58
105
|
afterSearch: function (results: ISearchstaxParsedResult[]) {
|
|
@@ -86,12 +133,36 @@ example of input widget initialization with various options
|
|
|
86
133
|
});
|
|
87
134
|
```
|
|
88
135
|
## Result widget
|
|
136
|
+
Initialization properties
|
|
137
|
+
|
|
138
|
+
a. id of container where widget will be rendered
|
|
139
|
+
|
|
140
|
+
b. {
|
|
141
|
+
|
|
142
|
+
`searchResultsContainerId?: string;` - this is needed only if mainTemplate is overridden. It points to an element in the template where results need to be rendered
|
|
143
|
+
|
|
144
|
+
`searchResultUniqueIdAttribute?: string;` - this is needed only if searchResultTemplate is overridden. searchResultTemplate needs to have unique result id property. Default is data-searchstax-unique-result-id="{{uniqueId}}". see example below on how it is used
|
|
145
|
+
|
|
146
|
+
`templates?: {` - optional object that defines template override options
|
|
147
|
+
|
|
148
|
+
`mainTemplate?: string;` - main template in Mustache templating language.
|
|
149
|
+
|
|
150
|
+
`searchResultTemplate?: string;` - result template using Mustache. ISearchstaxParsedResult is passed to the template and all its properties are available to be used when rendering
|
|
151
|
+
|
|
152
|
+
`noSearchResultTemplate?: string;` - Mustache template for no results section override. spellingSuggestion and searchTerm are values available in the template
|
|
153
|
+
|
|
154
|
+
`};`
|
|
155
|
+
|
|
156
|
+
`hooks?: {` - optional object that provides various hook options
|
|
157
|
+
|
|
158
|
+
`afterLinkClick?: (resultClicked: ISearchstaxParsedResult) => ISearchstaxParsedResult | null;` - function is called after user clicks result and passes that result as a property. when result is passed along tracking will execute and user will be navigated if null is returned events are canceled and nothing happens.
|
|
89
159
|
|
|
160
|
+
`};`
|
|
161
|
+
}
|
|
90
162
|
|
|
91
163
|
example of result widget initialization with various options
|
|
92
164
|
```
|
|
93
165
|
searchstax.addSearchResultsWidget("searchstax-results-container", {
|
|
94
|
-
hideUniqueKey: true,
|
|
95
166
|
// searchResultUniqueIdAttribute: ' data-searchstax-unique-result-id', if custom result template is used
|
|
96
167
|
// points to an attribute that will be used to identify a result
|
|
97
168
|
searchResultsContainerId: "searchstax-result-container", // if main template is over ridden this points to an
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty;var K=(i,e,t)=>e in i?U(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var u=(i,e,t)=>(K(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class A{constructor(e){u(this,"value");u(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 j{constructor(){u(this,"searchTermChangeObservable",new A(""));u(this,"loadingChangeObservable",new A(!1));u(this,"searchResultsObservable",new A(null));u(this,"searchResultsMetadataObservable",new A(null));u(this,"searchAutosuggestObservable",new A(null));u(this,"currentPage",1);u(this,"renderingEngine","mustache")}setSearchTerm(e){this.searchTermChangeObservable.setValue(e)}setRenderingEngine(e){this.renderingEngine=e}setCurrentPage(e){this.currentPage=e}setLoading(e){this.loadingChangeObservable.setValue(e)}setSearchResults(e){this.searchResultsObservable.setValue(e)}setSearchResultsMetadata(e){this.searchResultsMetadataObservable.setValue(e)}setSearchAutosuggest(e){this.searchAutosuggestObservable.setValue(e)}get searchResultsValue(){return this.searchResultsObservable.getValue()}get searchTermValue(){return this.searchTermChangeObservable.getValue()}get loadingValue(){return this.loadingChangeObservable.getValue()}get searchAutosuggestValue(){return this.searchAutosuggestObservable.getValue()}get searchResultsMetadataValue(){return this.searchResultsMetadataObservable.getValue()}get currentPageValue(){return this.currentPage}get renderingEngineValue(){return this.renderingEngine}}class E{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,r)=>{const n={custom:null,uniqueId:this.getValueByKey(e.responseHeader.params.uniqueId,a,e)??"",position:s+r+1,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e):null,unmappedFields:this.getUnmappedFields(a,e),allFields:this.getAllFields(a,e)};t.push(n)}),t}static extractSearchResultsMetadata(e){var s,a,r,n;let t="";return t=((n=(r=(a=(s=e==null?void 0:e.spellcheck)==null?void 0:s.suggestions)==null?void 0:a[0])==null?void 0:r.suggestion)==null?void 0:n[0])??"",typeof t!="string"&&(t=(t==null?void 0:t.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:t}}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 n=Array.isArray(e[r])?e[r].join(", "):e[r];a.push({key:r,value:n,isImage:this.checkIfImage(e[r])})}return a}static checkIfImage(e){return e===void 0||typeof e!="string"?!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(n=>n.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 W{constructor(e,t){u(this,"url","");u(this,"relatedSearches","");u(this,"suggester","");u(this,"authHeader");u(this,"authHeaderRelated");u(this,"language","en");u(this,"trackApiKey","");u(this,"session","");u(this,"
|
|
1
|
+
"use strict";var U=Object.defineProperty;var K=(i,e,t)=>e in i?U(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var u=(i,e,t)=>(K(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class A{constructor(e){u(this,"value");u(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 j{constructor(){u(this,"searchTermChangeObservable",new A(""));u(this,"loadingChangeObservable",new A(!1));u(this,"searchResultsObservable",new A(null));u(this,"searchResultsMetadataObservable",new A(null));u(this,"searchAutosuggestObservable",new A(null));u(this,"currentPage",1);u(this,"renderingEngine","mustache")}setSearchTerm(e){this.searchTermChangeObservable.setValue(e)}setRenderingEngine(e){this.renderingEngine=e}setCurrentPage(e){this.currentPage=e}setLoading(e){this.loadingChangeObservable.setValue(e)}setSearchResults(e){this.searchResultsObservable.setValue(e)}setSearchResultsMetadata(e){this.searchResultsMetadataObservable.setValue(e)}setSearchAutosuggest(e){this.searchAutosuggestObservable.setValue(e)}get searchResultsValue(){return this.searchResultsObservable.getValue()}get searchTermValue(){return this.searchTermChangeObservable.getValue()}get loadingValue(){return this.loadingChangeObservable.getValue()}get searchAutosuggestValue(){return this.searchAutosuggestObservable.getValue()}get searchResultsMetadataValue(){return this.searchResultsMetadataObservable.getValue()}get currentPageValue(){return this.currentPage}get renderingEngineValue(){return this.renderingEngine}}class E{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,r)=>{const n={custom:null,uniqueId:this.getValueByKey(e.responseHeader.params.uniqueId,a,e)??"",position:s+r+1,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e):null,unmappedFields:this.getUnmappedFields(a,e),allFields:this.getAllFields(a,e)};t.push(n)}),t}static extractSearchResultsMetadata(e){var s,a,r,n;let t="";return t=((n=(r=(a=(s=e==null?void 0:e.spellcheck)==null?void 0:s.suggestions)==null?void 0:a[0])==null?void 0:r.suggestion)==null?void 0:n[0])??"",typeof t!="string"&&(t=(t==null?void 0:t.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:t}}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 n=Array.isArray(e[r])?e[r].join(", "):e[r];a.push({key:r,value:n,isImage:this.checkIfImage(e[r])})}return a}static checkIfImage(e){return e===void 0||typeof e!="string"?!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(n=>n.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 W{constructor(e,t){u(this,"url","");u(this,"relatedSearches","");u(this,"suggester","");u(this,"authHeader");u(this,"authHeaderRelated");u(this,"language","en");u(this,"trackApiKey","");u(this,"session","");u(this,"searchAuthType");u(this,"controllerSearch");u(this,"signalSearch");u(this,"controllerSuggest");u(this,"signalSuggest");u(this,"dataLayer");this.dataLayer=t,this.url=e.searchURL,this.language=e.language,this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,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)}search(e,t,s){this.dataLayer.setSearchTerm(e),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const a=new Proxy(new URLSearchParams(window.location.search),{get:(h,c)=>h.get(c)??""}),r=a.languageVariant?"&fq=_language:"+a.languageVariant:"",n=this.url+"?q="+encodeURIComponent(e.trim())+this.toQueryString(s)+"&language="+this.language+r;fetch(n,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch}).then(h=>h.json()).then(h=>{this.dataLayer.setLoading(!1),t(h)}).catch(h=>{this.dataLayer.setLoading(!1),console.log(h)})}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.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(r=>r.json()).then(r=>{t(r)}).catch(r=>console.log(r))}fields(){return this.fields}toQueryString(e){return"&"+e.join("&")}}class F{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 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 n in a){r+="; "+n;const h=a[n];h!==!0&&(r+="="+h)}document.cookie=r}}class D{static trackClick(e){const t={key:e.trackApiKey,query:e.searchTermValue,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};_msq.push(["trackClick",t])}}/*!
|
|
2
2
|
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
3
3
|
* http://github.com/janl/mustache.js
|
|
4
|
-
*/var _=Object.prototype.toString,S=Array.isArray||function(e){return _.call(e)==="[object Array]"};function M(i){return typeof i=="function"}function $(i){return S(i)?"array":typeof i}function V(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function O(i,e){return i!=null&&typeof i=="object"&&e in i}function N(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var z=RegExp.prototype.test;function Q(i,e){return z.call(i,e)}var G=/\S/;function X(i){return!Q(G,i)}var J={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function Y(i){return String(i).replace(/[&<>"'`=\/]/g,function(t){return J[t]})}var Z=/\s*/,ee=/\s+/,B=/\s*=/,te=/\s*\}/,se=/#|\^|\/|>|\{|&|=|!/;function ae(i,e){if(!i)return[];var t=!1,s=[],a=[],r=[],n=!1,h=!1,c="",l=0;function p(){if(n&&!h)for(;r.length;)delete a[r.pop()];else r=[];n=!1,h=!1}var
|
|
5
|
-
`&&(p(),c="",l=0,t=!1);if(!o.scan(
|
|
4
|
+
*/var _=Object.prototype.toString,S=Array.isArray||function(e){return _.call(e)==="[object Array]"};function M(i){return typeof i=="function"}function $(i){return S(i)?"array":typeof i}function V(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function O(i,e){return i!=null&&typeof i=="object"&&e in i}function N(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var z=RegExp.prototype.test;function Q(i,e){return z.call(i,e)}var G=/\S/;function X(i){return!Q(G,i)}var J={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function Y(i){return String(i).replace(/[&<>"'`=\/]/g,function(t){return J[t]})}var Z=/\s*/,ee=/\s+/,B=/\s*=/,te=/\s*\}/,se=/#|\^|\/|>|\{|&|=|!/;function ae(i,e){if(!i)return[];var t=!1,s=[],a=[],r=[],n=!1,h=!1,c="",l=0;function p(){if(n&&!h)for(;r.length;)delete a[r.pop()];else r=[];n=!1,h=!1}var v,C,P;function H(y){if(typeof y=="string"&&(y=y.split(ee,2)),!S(y)||y.length!==2)throw new Error("Invalid tags: "+y);v=new RegExp(V(y[0])+"\\s*"),C=new RegExp("\\s*"+V(y[1])),P=new RegExp("\\s*"+V("}"+y[1]))}H(e||g.tags);for(var o=new x(i),b,f,m,R,T,I;!o.eos();){if(b=o.pos,m=o.scanUntil(v),m)for(var w=0,q=m.length;w<q;++w)R=m.charAt(w),X(R)?(r.push(a.length),c+=R):(h=!0,t=!0,c+=" "),a.push(["text",R,b,b+1]),b+=1,R===`
|
|
5
|
+
`&&(p(),c="",l=0,t=!1);if(!o.scan(v))break;if(n=!0,f=o.scan(se)||"name",o.scan(Z),f==="="?(m=o.scanUntil(B),o.scan(B),o.scanUntil(C)):f==="{"?(m=o.scanUntil(P),o.scan(te),o.scanUntil(C),f="&"):m=o.scanUntil(C),!o.scan(C))throw new Error("Unclosed tag at "+o.pos);if(f==">"?T=[f,m,b,o.pos,c,l,t]:T=[f,m,b,o.pos],l++,a.push(T),f==="#"||f==="^")s.push(T);else if(f==="/"){if(I=s.pop(),!I)throw new Error('Unopened section "'+m+'" at '+b);if(I[1]!==m)throw new Error('Unclosed section "'+I[1]+'" at '+b)}else f==="name"||f==="{"||f==="&"?h=!0:f==="="&&H(m)}if(p(),I=s.pop(),I)throw new Error('Unclosed section "'+I[1]+'" at '+o.pos);return ie(re(a))}function re(i){for(var e=[],t,s,a=0,r=i.length;a<r;++a)t=i[a],t&&(t[0]==="text"&&s&&s[0]==="text"?(s[1]+=t[1],s[3]=t[3]):(e.push(t),s=t));return e}function ie(i){for(var e=[],t=e,s=[],a,r,n=0,h=i.length;n<h;++n)switch(a=i[n],a[0]){case"#":case"^":t.push(a),s.push(a),t=a[4]=[];break;case"/":r=s.pop(),r[5]=a[2],t=s.length>0?s[s.length-1][4]:e;break;default:t.push(a)}return e}function x(i){this.string=i,this.tail=i,this.pos=0}x.prototype.eos=function(){return this.tail===""};x.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return"";var s=t[0];return this.tail=this.tail.substring(s.length),this.pos+=s.length,s};x.prototype.scanUntil=function(e){var t=this.tail.search(e),s;switch(t){case-1:s=this.tail,this.tail="";break;case 0:s="";break;default:s=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=s.length,s};function k(i,e){this.view=i,this.cache={".":this.view},this.parent=e}k.prototype.push=function(e){return new k(e,this)};k.prototype.lookup=function(e){var t=this.cache,s;if(t.hasOwnProperty(e))s=t[e];else{for(var a=this,r,n,h,c=!1;a;){if(e.indexOf(".")>0)for(r=a.view,n=e.split("."),h=0;r!=null&&h<n.length;)h===n.length-1&&(c=O(r,n[h])||N(r,n[h])),r=r[n[h++]];else r=a.view[e],c=O(a.view,e);if(c){s=r;break}a=a.parent}t[e]=s}return M(s)&&(s=s.call(this.view)),s};function d(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}d.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};d.prototype.parse=function(e,t){var s=this.templateCache,a=e+":"+(t||g.tags).join(":"),r=typeof s<"u",n=r?s.get(a):void 0;return n==null&&(n=ae(e,t),r&&s.set(a,n)),n};d.prototype.render=function(e,t,s,a){var r=this.getConfigTags(a),n=this.parse(e,r),h=t instanceof k?t:new k(t,void 0);return this.renderTokens(n,h,s,e,a)};d.prototype.renderTokens=function(e,t,s,a,r){for(var n="",h,c,l,p=0,v=e.length;p<v;++p)l=void 0,h=e[p],c=h[0],c==="#"?l=this.renderSection(h,t,s,a,r):c==="^"?l=this.renderInverted(h,t,s,a,r):c===">"?l=this.renderPartial(h,t,s,r):c==="&"?l=this.unescapedValue(h,t):c==="name"?l=this.escapedValue(h,t,r):c==="text"&&(l=this.rawValue(h)),l!==void 0&&(n+=l);return n};d.prototype.renderSection=function(e,t,s,a,r){var n=this,h="",c=t.lookup(e[1]);function l(C){return n.render(C,t,s,r)}if(c){if(S(c))for(var p=0,v=c.length;p<v;++p)h+=this.renderTokens(e[4],t.push(c[p]),s,a,r);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")h+=this.renderTokens(e[4],t.push(c),s,a,r);else if(M(c)){if(typeof a!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(t.view,a.slice(e[3],e[5]),l),c!=null&&(h+=c)}else h+=this.renderTokens(e[4],t,s,a,r);return h}};d.prototype.renderInverted=function(e,t,s,a,r){var n=t.lookup(e[1]);if(!n||S(n)&&n.length===0)return this.renderTokens(e[4],t,s,a,r)};d.prototype.indentPartial=function(e,t,s){for(var a=t.replace(/[^ \t]/g,""),r=e.split(`
|
|
6
6
|
`),n=0;n<r.length;n++)r[n].length&&(n>0||!s)&&(r[n]=a+r[n]);return r.join(`
|
|
7
|
-
`)};d.prototype.renderPartial=function(e,t,s,a){if(s){var r=this.getConfigTags(a),n=M(s)?s(e[1]):s[e[1]];if(n!=null){var h=e[6],c=e[5],l=e[4],p=n;c==0&&l&&(p=this.indentPartial(n,l,h));var
|
|
7
|
+
`)};d.prototype.renderPartial=function(e,t,s,a){if(s){var r=this.getConfigTags(a),n=M(s)?s(e[1]):s[e[1]];if(n!=null){var h=e[6],c=e[5],l=e[4],p=n;c==0&&l&&(p=this.indentPartial(n,l,h));var v=this.parse(p,r);return this.renderTokens(v,t,s,p,a)}}};d.prototype.unescapedValue=function(e,t){var s=t.lookup(e[1]);if(s!=null)return s};d.prototype.escapedValue=function(e,t,s){var a=this.getConfigEscape(s)||g.escape,r=t.lookup(e[1]);if(r!=null)return typeof r=="number"&&a===g.escape?String(r):a(r)};d.prototype.rawValue=function(e){return e[1]};d.prototype.getConfigTags=function(e){return S(e)?e:e&&typeof e=="object"?e.tags:void 0};d.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!S(e))return e.escape};var g={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(i){L.templateCache=i},get templateCache(){return L.templateCache}},L=new d;g.clearCache=function(){return L.clearCache()};g.parse=function(e,t){return L.parse(e,t)};g.render=function(e,t,s,a){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+$(e)+'" was given as the first argument for mustache#render(template, view, partials)');return L.render(e,t,s,a)};g.escape=Y;g.Scanner=x;g.Context=k;g.Writer=d;class ne{constructor(e){u(this,"dataLayer");u(this,"config");u(this,"suggestAfterMinChars");u(this,"containerId");u(this,"currentInputValue","");u(this,"autosuggestResults");u(this,"searchInput");u(this,"actionButton");u(this,"autosuggestContainer");u(this,"buttonState","search");u(this,"selectedAutosuggestItem",-1);u(this,"suggestTrigger");u(this,"searchTrigger");this.dataLayer=e.dataLayer,this.config=e.config,this.searchTrigger=e.searchTrigger,this.suggestTrigger=e.suggestTrigger,this.containerId=e.containerId,this.suggestAfterMinChars=e.config.suggestAfterMinChars,this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())}renderMainTemplate(){var r,n;const e=document.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=((r=this.config.templates)==null?void 0:r.mainTemplate)||`
|
|
8
8
|
<div class="searchstax-search-input-container">
|
|
9
9
|
<div class="searchstax-search-input-wrapper">
|
|
10
10
|
<input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." />
|
|
@@ -92,12 +92,9 @@ export interface ISearchstaxConfig {
|
|
|
92
92
|
language: string;
|
|
93
93
|
searchURL: string;
|
|
94
94
|
suggesterURL: string;
|
|
95
|
-
authenticationValue: string;
|
|
96
95
|
trackApiKey: string;
|
|
97
|
-
|
|
96
|
+
searchAuth: string;
|
|
98
97
|
authType: "token" | "basic";
|
|
99
|
-
searchToken?: string;
|
|
100
|
-
suggesterToken?: string;
|
|
101
98
|
}
|
|
102
99
|
export interface ISearchstaxSearchProps {
|
|
103
100
|
term: string;
|
|
@@ -108,9 +105,7 @@ export interface ISearchstaxSuggestProps {
|
|
|
108
105
|
queryParams: string[];
|
|
109
106
|
}
|
|
110
107
|
export interface ISearchstaxSearchInputConfig {
|
|
111
|
-
searchAdditionalArgs?: string;
|
|
112
108
|
suggestAfterMinChars: number;
|
|
113
|
-
hideBranding: boolean;
|
|
114
109
|
templates?: {
|
|
115
110
|
mainTemplate?: string;
|
|
116
111
|
searchInputId?: string;
|
|
@@ -124,7 +119,6 @@ export interface ISearchstaxSearchInputConfig {
|
|
|
124
119
|
};
|
|
125
120
|
}
|
|
126
121
|
export interface ISearchstaxSearcResultsConfig {
|
|
127
|
-
hideUniqueKey: boolean;
|
|
128
122
|
searchResultsContainerId?: string;
|
|
129
123
|
searchResultUniqueIdAttribute?: string;
|
|
130
124
|
templates?: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var he=Object.defineProperty;var ce=(C,
|
|
1
|
+
var he=Object.defineProperty;var ce=(C,m,k)=>m in C?he(C,m,{enumerable:!0,configurable:!0,writable:!0,value:k}):C[m]=k;var u=(C,m,k)=>(ce(C,typeof m!="symbol"?m+"":m,k),k);(function(C){"use strict";class m{constructor(e){u(this,"value");u(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 k{constructor(){u(this,"searchTermChangeObservable",new m(""));u(this,"loadingChangeObservable",new m(!1));u(this,"searchResultsObservable",new m(null));u(this,"searchResultsMetadataObservable",new m(null));u(this,"searchAutosuggestObservable",new m(null));u(this,"currentPage",1);u(this,"renderingEngine","mustache")}setSearchTerm(e){this.searchTermChangeObservable.setValue(e)}setRenderingEngine(e){this.renderingEngine=e}setCurrentPage(e){this.currentPage=e}setLoading(e){this.loadingChangeObservable.setValue(e)}setSearchResults(e){this.searchResultsObservable.setValue(e)}setSearchResultsMetadata(e){this.searchResultsMetadataObservable.setValue(e)}setSearchAutosuggest(e){this.searchAutosuggestObservable.setValue(e)}get searchResultsValue(){return this.searchResultsObservable.getValue()}get searchTermValue(){return this.searchTermChangeObservable.getValue()}get loadingValue(){return this.loadingChangeObservable.getValue()}get searchAutosuggestValue(){return this.searchAutosuggestObservable.getValue()}get searchResultsMetadataValue(){return this.searchResultsMetadataObservable.getValue()}get currentPageValue(){return this.currentPage}get renderingEngineValue(){return this.renderingEngine}}class V{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,r)=>{const n={custom:null,uniqueId:this.getValueByKey(e.responseHeader.params.uniqueId,a,e)??"",position:s+r+1,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e):null,unmappedFields:this.getUnmappedFields(a,e),allFields:this.getAllFields(a,e)};t.push(n)}),t}static extractSearchResultsMetadata(e){var s,a,r,n;let t="";return t=((n=(r=(a=(s=e==null?void 0:e.spellcheck)==null?void 0:s.suggestions)==null?void 0:a[0])==null?void 0:r.suggestion)==null?void 0:n[0])??"",typeof t!="string"&&(t=(t==null?void 0:t.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:t}}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 n=Array.isArray(e[r])?e[r].join(", "):e[r];a.push({key:r,value:n,isImage:this.checkIfImage(e[r])})}return a}static checkIfImage(e){return e===void 0||typeof e!="string"?!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(n=>n.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 K{constructor(e,t){u(this,"url","");u(this,"relatedSearches","");u(this,"suggester","");u(this,"authHeader");u(this,"authHeaderRelated");u(this,"language","en");u(this,"trackApiKey","");u(this,"session","");u(this,"searchAuthType");u(this,"controllerSearch");u(this,"signalSearch");u(this,"controllerSuggest");u(this,"signalSuggest");u(this,"dataLayer");this.dataLayer=t,this.url=e.searchURL,this.language=e.language,this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,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)}search(e,t,s){this.dataLayer.setSearchTerm(e),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const a=new Proxy(new URLSearchParams(window.location.search),{get:(h,c)=>h.get(c)??""}),r=a.languageVariant?"&fq=_language:"+a.languageVariant:"",n=this.url+"?q="+encodeURIComponent(e.trim())+this.toQueryString(s)+"&language="+this.language+r;fetch(n,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch}).then(h=>h.json()).then(h=>{this.dataLayer.setLoading(!1),t(h)}).catch(h=>{this.dataLayer.setLoading(!1),console.log(h)})}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.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(r=>r.json()).then(r=>{t(r)}).catch(r=>console.log(r))}fields(){return this.fields}toQueryString(e){return"&"+e.join("&")}}class j{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 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 n in a){r+="; "+n;const h=a[n];h!==!0&&(r+="="+h)}document.cookie=r}}class W{static trackClick(e){const t={key:e.trackApiKey,query:e.searchTermValue,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};_msq.push(["trackClick",t])}}/*!
|
|
2
2
|
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
3
3
|
* http://github.com/janl/mustache.js
|
|
4
|
-
*/var F=Object.prototype.toString,A=Array.isArray||function(e){return F.call(e)==="[object Array]"};function M(i){return typeof i=="function"}function D(i){return A(i)?"array":typeof i}function P(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function O(i,e){return i!=null&&typeof i=="object"&&e in i}function _(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var $=RegExp.prototype.test;function N(i,e){return $.call(i,e)}var z=/\S/;function Q(i){return!N(z,i)}var G={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function J(i){return String(i).replace(/[&<>"'`=\/]/g,function(t){return G[t]})}var X=/\s*/,Y=/\s+/,B=/\s*=/,Z=/\s*\}/,ee=/#|\^|\/|>|\{|&|=|!/;function te(i,e){if(!i)return[];var t=!1,s=[],a=[],r=[],n=!1,h=!1,c="",l=0;function p(){if(n&&!h)for(;r.length;)delete a[r.pop()];else r=[];n=!1,h=!1}var y,S,q;function U(b){if(typeof b=="string"&&(b=b.split(Y,2)),!A(b)||b.length!==2)throw new Error("Invalid tags: "+b);y=new RegExp(P(b[0])+"\\s*"),S=new RegExp("\\s*"+P(b[1])),q=new RegExp("\\s*"+P("}"+b[1]))}U(e||g.tags);for(var o=new
|
|
5
|
-
`&&(p(),c="",l=0,t=!1);if(!o.scan(y))break;if(n=!0,f=o.scan(ee)||"name",o.scan(X),f==="="?(
|
|
4
|
+
*/var F=Object.prototype.toString,A=Array.isArray||function(e){return F.call(e)==="[object Array]"};function M(i){return typeof i=="function"}function D(i){return A(i)?"array":typeof i}function P(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function O(i,e){return i!=null&&typeof i=="object"&&e in i}function _(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var $=RegExp.prototype.test;function N(i,e){return $.call(i,e)}var z=/\S/;function Q(i){return!N(z,i)}var G={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function J(i){return String(i).replace(/[&<>"'`=\/]/g,function(t){return G[t]})}var X=/\s*/,Y=/\s+/,B=/\s*=/,Z=/\s*\}/,ee=/#|\^|\/|>|\{|&|=|!/;function te(i,e){if(!i)return[];var t=!1,s=[],a=[],r=[],n=!1,h=!1,c="",l=0;function p(){if(n&&!h)for(;r.length;)delete a[r.pop()];else r=[];n=!1,h=!1}var y,S,q;function U(b){if(typeof b=="string"&&(b=b.split(Y,2)),!A(b)||b.length!==2)throw new Error("Invalid tags: "+b);y=new RegExp(P(b[0])+"\\s*"),S=new RegExp("\\s*"+P(b[1])),q=new RegExp("\\s*"+P("}"+b[1]))}U(e||g.tags);for(var o=new x(i),I,f,v,w,E,R;!o.eos();){if(I=o.pos,v=o.scanUntil(y),v)for(var H=0,ue=v.length;H<ue;++H)w=v.charAt(H),Q(w)?(r.push(a.length),c+=w):(h=!0,t=!0,c+=" "),a.push(["text",w,I,I+1]),I+=1,w===`
|
|
5
|
+
`&&(p(),c="",l=0,t=!1);if(!o.scan(y))break;if(n=!0,f=o.scan(ee)||"name",o.scan(X),f==="="?(v=o.scanUntil(B),o.scan(B),o.scanUntil(S)):f==="{"?(v=o.scanUntil(q),o.scan(Z),o.scanUntil(S),f="&"):v=o.scanUntil(S),!o.scan(S))throw new Error("Unclosed tag at "+o.pos);if(f==">"?E=[f,v,I,o.pos,c,l,t]:E=[f,v,I,o.pos],l++,a.push(E),f==="#"||f==="^")s.push(E);else if(f==="/"){if(R=s.pop(),!R)throw new Error('Unopened section "'+v+'" at '+I);if(R[1]!==v)throw new Error('Unclosed section "'+R[1]+'" at '+I)}else f==="name"||f==="{"||f==="&"?h=!0:f==="="&&U(v)}if(p(),R=s.pop(),R)throw new Error('Unclosed section "'+R[1]+'" at '+o.pos);return ae(se(a))}function se(i){for(var e=[],t,s,a=0,r=i.length;a<r;++a)t=i[a],t&&(t[0]==="text"&&s&&s[0]==="text"?(s[1]+=t[1],s[3]=t[3]):(e.push(t),s=t));return e}function ae(i){for(var e=[],t=e,s=[],a,r,n=0,h=i.length;n<h;++n)switch(a=i[n],a[0]){case"#":case"^":t.push(a),s.push(a),t=a[4]=[];break;case"/":r=s.pop(),r[5]=a[2],t=s.length>0?s[s.length-1][4]:e;break;default:t.push(a)}return e}function x(i){this.string=i,this.tail=i,this.pos=0}x.prototype.eos=function(){return this.tail===""},x.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return"";var s=t[0];return this.tail=this.tail.substring(s.length),this.pos+=s.length,s},x.prototype.scanUntil=function(e){var t=this.tail.search(e),s;switch(t){case-1:s=this.tail,this.tail="";break;case 0:s="";break;default:s=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=s.length,s};function L(i,e){this.view=i,this.cache={".":this.view},this.parent=e}L.prototype.push=function(e){return new L(e,this)},L.prototype.lookup=function(e){var t=this.cache,s;if(t.hasOwnProperty(e))s=t[e];else{for(var a=this,r,n,h,c=!1;a;){if(e.indexOf(".")>0)for(r=a.view,n=e.split("."),h=0;r!=null&&h<n.length;)h===n.length-1&&(c=O(r,n[h])||_(r,n[h])),r=r[n[h++]];else r=a.view[e],c=O(a.view,e);if(c){s=r;break}a=a.parent}t[e]=s}return M(s)&&(s=s.call(this.view)),s};function d(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}d.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()},d.prototype.parse=function(e,t){var s=this.templateCache,a=e+":"+(t||g.tags).join(":"),r=typeof s<"u",n=r?s.get(a):void 0;return n==null&&(n=te(e,t),r&&s.set(a,n)),n},d.prototype.render=function(e,t,s,a){var r=this.getConfigTags(a),n=this.parse(e,r),h=t instanceof L?t:new L(t,void 0);return this.renderTokens(n,h,s,e,a)},d.prototype.renderTokens=function(e,t,s,a,r){for(var n="",h,c,l,p=0,y=e.length;p<y;++p)l=void 0,h=e[p],c=h[0],c==="#"?l=this.renderSection(h,t,s,a,r):c==="^"?l=this.renderInverted(h,t,s,a,r):c===">"?l=this.renderPartial(h,t,s,r):c==="&"?l=this.unescapedValue(h,t):c==="name"?l=this.escapedValue(h,t,r):c==="text"&&(l=this.rawValue(h)),l!==void 0&&(n+=l);return n},d.prototype.renderSection=function(e,t,s,a,r){var n=this,h="",c=t.lookup(e[1]);function l(S){return n.render(S,t,s,r)}if(c){if(A(c))for(var p=0,y=c.length;p<y;++p)h+=this.renderTokens(e[4],t.push(c[p]),s,a,r);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")h+=this.renderTokens(e[4],t.push(c),s,a,r);else if(M(c)){if(typeof a!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(t.view,a.slice(e[3],e[5]),l),c!=null&&(h+=c)}else h+=this.renderTokens(e[4],t,s,a,r);return h}},d.prototype.renderInverted=function(e,t,s,a,r){var n=t.lookup(e[1]);if(!n||A(n)&&n.length===0)return this.renderTokens(e[4],t,s,a,r)},d.prototype.indentPartial=function(e,t,s){for(var a=t.replace(/[^ \t]/g,""),r=e.split(`
|
|
6
6
|
`),n=0;n<r.length;n++)r[n].length&&(n>0||!s)&&(r[n]=a+r[n]);return r.join(`
|
|
7
|
-
`)},d.prototype.renderPartial=function(e,t,s,a){if(s){var r=this.getConfigTags(a),n=M(s)?s(e[1]):s[e[1]];if(n!=null){var h=e[6],c=e[5],l=e[4],p=n;c==0&&l&&(p=this.indentPartial(n,l,h));var y=this.parse(p,r);return this.renderTokens(y,t,s,p,a)}}},d.prototype.unescapedValue=function(e,t){var s=t.lookup(e[1]);if(s!=null)return s},d.prototype.escapedValue=function(e,t,s){var a=this.getConfigEscape(s)||g.escape,r=t.lookup(e[1]);if(r!=null)return typeof r=="number"&&a===g.escape?String(r):a(r)},d.prototype.rawValue=function(e){return e[1]},d.prototype.getConfigTags=function(e){return A(e)?e:e&&typeof e=="object"?e.tags:void 0},d.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!A(e))return e.escape};var g={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(i){
|
|
7
|
+
`)},d.prototype.renderPartial=function(e,t,s,a){if(s){var r=this.getConfigTags(a),n=M(s)?s(e[1]):s[e[1]];if(n!=null){var h=e[6],c=e[5],l=e[4],p=n;c==0&&l&&(p=this.indentPartial(n,l,h));var y=this.parse(p,r);return this.renderTokens(y,t,s,p,a)}}},d.prototype.unescapedValue=function(e,t){var s=t.lookup(e[1]);if(s!=null)return s},d.prototype.escapedValue=function(e,t,s){var a=this.getConfigEscape(s)||g.escape,r=t.lookup(e[1]);if(r!=null)return typeof r=="number"&&a===g.escape?String(r):a(r)},d.prototype.rawValue=function(e){return e[1]},d.prototype.getConfigTags=function(e){return A(e)?e:e&&typeof e=="object"?e.tags:void 0},d.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!A(e))return e.escape};var g={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(i){T.templateCache=i},get templateCache(){return T.templateCache}},T=new d;g.clearCache=function(){return T.clearCache()},g.parse=function(e,t){return T.parse(e,t)},g.render=function(e,t,s,a){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+D(e)+'" was given as the first argument for mustache#render(template, view, partials)');return T.render(e,t,s,a)},g.escape=J,g.Scanner=x,g.Context=L,g.Writer=d;class re{constructor(e){u(this,"dataLayer");u(this,"config");u(this,"suggestAfterMinChars");u(this,"containerId");u(this,"currentInputValue","");u(this,"autosuggestResults");u(this,"searchInput");u(this,"actionButton");u(this,"autosuggestContainer");u(this,"buttonState","search");u(this,"selectedAutosuggestItem",-1);u(this,"suggestTrigger");u(this,"searchTrigger");this.dataLayer=e.dataLayer,this.config=e.config,this.searchTrigger=e.searchTrigger,this.suggestTrigger=e.suggestTrigger,this.containerId=e.containerId,this.suggestAfterMinChars=e.config.suggestAfterMinChars,this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())}renderMainTemplate(){var r,n;const e=document.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=((r=this.config.templates)==null?void 0:r.mainTemplate)||`
|
|
8
8
|
<div class="searchstax-search-input-container">
|
|
9
9
|
<div class="searchstax-search-input-wrapper">
|
|
10
10
|
<input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." />
|
|
@@ -66,4 +66,4 @@ var he=Object.defineProperty;var ce=(C,v,I)=>v in C?he(C,v,{enumerable:!0,config
|
|
|
66
66
|
<div class="searchstax-search-results-container">
|
|
67
67
|
<div class="searchstax-search-results"></div>
|
|
68
68
|
</div>
|
|
69
|
-
`;this.dataLayer.renderingEngineValue==="mustache"&&(this.searchResultsMainContainer.innerHTML=g.render(e,{})),setTimeout(()=>{var n,h;const a=(n=this.config)!=null&&n.searchResultsContainerId?(h=this.config)==null?void 0:h.searchResultsContainerId:"searchstax-search-results",r=document.getElementById(a);if(r)this.searchResultsContainer=r;else throw new Error(`Search Results Container with id ${a} not found`)},0)}}class ne{constructor(e="mustache"){u(this,"sessionId");u(this,"searchstaxConfig");u(this,"searchHelper");u(this,"searchInputConfig");u(this,"searchResultsConfig");u(this,"searchInputWidget");u(this,"searchResultsWidget");u(this,"dataLayer",new
|
|
69
|
+
`;this.dataLayer.renderingEngineValue==="mustache"&&(this.searchResultsMainContainer.innerHTML=g.render(e,{})),setTimeout(()=>{var n,h;const a=(n=this.config)!=null&&n.searchResultsContainerId?(h=this.config)==null?void 0:h.searchResultsContainerId:"searchstax-search-results",r=document.getElementById(a);if(r)this.searchResultsContainer=r;else throw new Error(`Search Results Container with id ${a} not found`)},0)}}class ne{constructor(e="mustache"){u(this,"sessionId");u(this,"searchstaxConfig");u(this,"searchHelper");u(this,"searchInputConfig");u(this,"searchResultsConfig");u(this,"searchInputWidget");u(this,"searchResultsWidget");u(this,"dataLayer",new k);e&&this.dataLayer.setRenderingEngine(e),this.sessionId=j.getOrSetCookie("searchstax_session_id"),this.handleHooks()}setRenderingEngine(e="mustache"){this.dataLayer.setRenderingEngine(e)}handleHooks(){var e,t;(t=(e=this.searchInputConfig)==null?void 0:e.hooks)!=null&&t.afterSearch&&this.dataLayer.searchResultsObservable.subscribe(s=>{this.searchInputConfig.hooks.afterSearch(s)})}initialize(e){this.searchstaxConfig||(this.searchstaxConfig=e,this.searchHelper=new K({...e,sessionId:this.sessionId},this.dataLayer))}search(e,t){this.searchHelper&&this.searchHelper.search(e,this.parseSearchResultsResponse.bind(this),t)}parseSearchResultsResponse(e){var s,a;let t=V.combineResultsWithMetadata(e);(a=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&a.afterSearch&&(t=this.searchInputConfig.hooks.afterSearch(t)),this.dataLayer.setSearchResults(t),this.dataLayer.setSearchResultsMetadata(V.extractSearchResultsMetadata(e))}parseSuggestSuggestResponse(e){var s,a;let t=e;(a=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&a.afterAutosuggest&&(t=this.searchInputConfig.hooks.afterAutosuggest(e)),this.dataLayer.setSearchAutosuggest(t)}suggest(e,t){this.searchHelper&&this.searchHelper.suggest(e,this.parseSuggestSuggestResponse.bind(this),t)}changeLanguage(e){this.searchHelper&&(this.searchHelper.language=e)}addSearchInputWidget(e,t){this.searchInputConfig||(this.searchInputConfig=t,this.searchInputWidget=new re({containerId:e,config:t,searchTrigger:this.executeSearch.bind(this),suggestTrigger:this.executeSuggest.bind(this),dataLayer:this.dataLayer}))}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new ie({containerId:e,linkClickCallback:this.executeLinkClick.bind(this),searchTrigger:this.executeSearch.bind(this),config:t,dataLayer:this.dataLayer}))}executeSearch(e){var s,a;let t={term:e,queryParams:[]};(a=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&a.beforeSearch&&(t=this.searchInputConfig.hooks.beforeSearch(t)),t&&t.term!==void 0&&t.queryParams!==void 0&&this.search(t.term,t.queryParams)}executeSuggest(e){var s,a;let t={term:e,queryParams:[]};(a=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&a.beforeAutosuggest&&(t=this.searchInputConfig.hooks.beforeAutosuggest(t)),t&&t.term!==void 0&&t.queryParams!==void 0&&this.suggest(t.term,t.queryParams)}executeLinkClick(e){var s,a,r,n;let t=V.findResultByUniqueId(e,this.dataLayer.searchResultsValue??[]);t&&((a=(s=this.searchResultsConfig)==null?void 0:s.hooks)!=null&&a.afterLinkClick&&(t=this.searchResultsConfig.hooks.afterLinkClick(t)),t&&(console.log("foundResult",t),this.dataLayer.searchResultsMetadataValue&&W.trackClick({result:t,searchTermValue:this.dataLayer.searchTermValue,trackApiKey:((r=this.searchstaxConfig)==null?void 0:r.trackApiKey)??"",session:this.sessionId,language:((n=this.searchHelper)==null?void 0:n.language)??"",recordsPerPage:this.dataLayer.searchResultsMetadataValue.recordsPerPageValue,totalResults:this.dataLayer.searchResultsMetadataValue.totalResultsValue,currentPage:this.dataLayer.currentPageValue,latencyVal:this.dataLayer.searchResultsMetadataValue.latency})))}}C.Searchstax=ne,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})})(this["@searchstaxInc/searchstudioUxJs"]=this["@searchstaxInc/searchstudioUxJs"]||{});
|
|
@@ -169,18 +169,15 @@ class W {
|
|
|
169
169
|
u(this, "language", "en");
|
|
170
170
|
u(this, "trackApiKey", "");
|
|
171
171
|
u(this, "session", "");
|
|
172
|
-
u(this, "searchAdditionalArgs", "");
|
|
173
172
|
u(this, "searchAuthType");
|
|
174
|
-
u(this, "selectAuthToken");
|
|
175
|
-
u(this, "suggesterAuthToken");
|
|
176
173
|
u(this, "controllerSearch");
|
|
177
174
|
u(this, "signalSearch");
|
|
178
175
|
u(this, "controllerSuggest");
|
|
179
176
|
u(this, "signalSuggest");
|
|
180
177
|
u(this, "dataLayer");
|
|
181
|
-
this.dataLayer = t, this.url = e.searchURL, this.language = e.language, this.suggester = e.suggesterURL, this.trackApiKey = e.trackApiKey, this.session = e.sessionId, this.searchAuthType = e.authType, this.
|
|
182
|
-
const s = this.searchAuthType === "token" ? `Token ${
|
|
183
|
-
this.authHeader.append("Authorization", s), this.authHeaderRelated = new Headers(), this.authHeaderRelated.append("Accept", "application/json"), this.authHeaderRelated.append("Authorization", e.
|
|
178
|
+
this.dataLayer = t, this.url = e.searchURL, this.language = e.language, this.suggester = e.suggesterURL, this.trackApiKey = e.trackApiKey, this.session = e.sessionId, this.searchAuthType = e.authType, this.authHeader = new Headers(), this.authHeader.append("Accept", "application/json");
|
|
179
|
+
const s = this.searchAuthType === "token" ? `Token ${e.searchAuth}` : `Basic ${e.searchAuth}`;
|
|
180
|
+
this.authHeader.append("Authorization", s), this.authHeaderRelated = new Headers(), this.authHeaderRelated.append("Accept", "application/json"), this.authHeaderRelated.append("Authorization", e.searchAuth);
|
|
184
181
|
}
|
|
185
182
|
search(e, t, s) {
|
|
186
183
|
this.dataLayer.setSearchTerm(e), this.dataLayer.setLoading(!0), this.controllerSearch && this.controllerSearch.abort(), this.controllerSearch = new AbortController(), this.signalSearch = this.controllerSearch.signal;
|
|
@@ -192,7 +189,7 @@ class W {
|
|
|
192
189
|
), r = a.languageVariant ? (
|
|
193
190
|
//@ts-expect-error - this is a hack to get around the fact that the urlQueryParams is a proxy
|
|
194
191
|
"&fq=_language:" + a.languageVariant
|
|
195
|
-
) : "", n = this.url + "?q=" + encodeURIComponent(e.trim()) + this.toQueryString(s) +
|
|
192
|
+
) : "", n = this.url + "?q=" + encodeURIComponent(e.trim()) + this.toQueryString(s) + "&language=" + this.language + r;
|
|
196
193
|
fetch(n, {
|
|
197
194
|
method: "GET",
|
|
198
195
|
headers: this.authHeader,
|
|
@@ -292,7 +289,7 @@ function $(i) {
|
|
|
292
289
|
function V(i) {
|
|
293
290
|
return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|
294
291
|
}
|
|
295
|
-
function
|
|
292
|
+
function O(i, e) {
|
|
296
293
|
return i != null && typeof i == "object" && e in i;
|
|
297
294
|
}
|
|
298
295
|
function N(i, e) {
|
|
@@ -321,7 +318,7 @@ function Y(i) {
|
|
|
321
318
|
return J[t];
|
|
322
319
|
});
|
|
323
320
|
}
|
|
324
|
-
var Z = /\s*/, ee = /\s+/,
|
|
321
|
+
var Z = /\s*/, ee = /\s+/, B = /\s*=/, te = /\s*\}/, se = /#|\^|\/|>|\{|&|=|!/;
|
|
325
322
|
function ae(i, e) {
|
|
326
323
|
if (!i)
|
|
327
324
|
return [];
|
|
@@ -334,34 +331,34 @@ function ae(i, e) {
|
|
|
334
331
|
r = [];
|
|
335
332
|
n = !1, h = !1;
|
|
336
333
|
}
|
|
337
|
-
var
|
|
334
|
+
var v, C, H;
|
|
338
335
|
function P(y) {
|
|
339
336
|
if (typeof y == "string" && (y = y.split(ee, 2)), !R(y) || y.length !== 2)
|
|
340
337
|
throw new Error("Invalid tags: " + y);
|
|
341
|
-
|
|
338
|
+
v = new RegExp(V(y[0]) + "\\s*"), C = new RegExp("\\s*" + V(y[1])), H = new RegExp("\\s*" + V("}" + y[1]));
|
|
342
339
|
}
|
|
343
340
|
P(e || g.tags);
|
|
344
|
-
for (var o = new
|
|
345
|
-
if (b = o.pos,
|
|
346
|
-
for (var w = 0, q =
|
|
347
|
-
S =
|
|
341
|
+
for (var o = new x(i), b, f, m, S, T, I; !o.eos(); ) {
|
|
342
|
+
if (b = o.pos, m = o.scanUntil(v), m)
|
|
343
|
+
for (var w = 0, q = m.length; w < q; ++w)
|
|
344
|
+
S = m.charAt(w), X(S) ? (r.push(a.length), c += S) : (h = !0, t = !0, c += " "), a.push(["text", S, b, b + 1]), b += 1, S === `
|
|
348
345
|
` && (p(), c = "", l = 0, t = !1);
|
|
349
|
-
if (!o.scan(
|
|
346
|
+
if (!o.scan(v))
|
|
350
347
|
break;
|
|
351
|
-
if (n = !0, f = o.scan(se) || "name", o.scan(Z), f === "=" ? (
|
|
348
|
+
if (n = !0, f = o.scan(se) || "name", o.scan(Z), f === "=" ? (m = o.scanUntil(B), o.scan(B), o.scanUntil(C)) : f === "{" ? (m = o.scanUntil(H), o.scan(te), o.scanUntil(C), f = "&") : m = o.scanUntil(C), !o.scan(C))
|
|
352
349
|
throw new Error("Unclosed tag at " + o.pos);
|
|
353
|
-
if (f == ">" ?
|
|
354
|
-
s.push(
|
|
350
|
+
if (f == ">" ? T = [f, m, b, o.pos, c, l, t] : T = [f, m, b, o.pos], l++, a.push(T), f === "#" || f === "^")
|
|
351
|
+
s.push(T);
|
|
355
352
|
else if (f === "/") {
|
|
356
|
-
if (
|
|
357
|
-
throw new Error('Unopened section "' +
|
|
358
|
-
if (
|
|
359
|
-
throw new Error('Unclosed section "' +
|
|
353
|
+
if (I = s.pop(), !I)
|
|
354
|
+
throw new Error('Unopened section "' + m + '" at ' + b);
|
|
355
|
+
if (I[1] !== m)
|
|
356
|
+
throw new Error('Unclosed section "' + I[1] + '" at ' + b);
|
|
360
357
|
} else
|
|
361
|
-
f === "name" || f === "{" || f === "&" ? h = !0 : f === "=" && P(
|
|
358
|
+
f === "name" || f === "{" || f === "&" ? h = !0 : f === "=" && P(m);
|
|
362
359
|
}
|
|
363
|
-
if (p(),
|
|
364
|
-
throw new Error('Unclosed section "' +
|
|
360
|
+
if (p(), I = s.pop(), I)
|
|
361
|
+
throw new Error('Unclosed section "' + I[1] + '" at ' + o.pos);
|
|
365
362
|
return ie(re(a));
|
|
366
363
|
}
|
|
367
364
|
function re(i) {
|
|
@@ -384,20 +381,20 @@ function ie(i) {
|
|
|
384
381
|
}
|
|
385
382
|
return e;
|
|
386
383
|
}
|
|
387
|
-
function
|
|
384
|
+
function x(i) {
|
|
388
385
|
this.string = i, this.tail = i, this.pos = 0;
|
|
389
386
|
}
|
|
390
|
-
|
|
387
|
+
x.prototype.eos = function() {
|
|
391
388
|
return this.tail === "";
|
|
392
389
|
};
|
|
393
|
-
|
|
390
|
+
x.prototype.scan = function(e) {
|
|
394
391
|
var t = this.tail.match(e);
|
|
395
392
|
if (!t || t.index !== 0)
|
|
396
393
|
return "";
|
|
397
394
|
var s = t[0];
|
|
398
395
|
return this.tail = this.tail.substring(s.length), this.pos += s.length, s;
|
|
399
396
|
};
|
|
400
|
-
|
|
397
|
+
x.prototype.scanUntil = function(e) {
|
|
401
398
|
var t = this.tail.search(e), s;
|
|
402
399
|
switch (t) {
|
|
403
400
|
case -1:
|
|
@@ -411,13 +408,13 @@ T.prototype.scanUntil = function(e) {
|
|
|
411
408
|
}
|
|
412
409
|
return this.pos += s.length, s;
|
|
413
410
|
};
|
|
414
|
-
function
|
|
411
|
+
function k(i, e) {
|
|
415
412
|
this.view = i, this.cache = { ".": this.view }, this.parent = e;
|
|
416
413
|
}
|
|
417
|
-
|
|
418
|
-
return new
|
|
414
|
+
k.prototype.push = function(e) {
|
|
415
|
+
return new k(e, this);
|
|
419
416
|
};
|
|
420
|
-
|
|
417
|
+
k.prototype.lookup = function(e) {
|
|
421
418
|
var t = this.cache, s;
|
|
422
419
|
if (t.hasOwnProperty(e))
|
|
423
420
|
s = t[e];
|
|
@@ -425,9 +422,9 @@ I.prototype.lookup = function(e) {
|
|
|
425
422
|
for (var a = this, r, n, h, c = !1; a; ) {
|
|
426
423
|
if (e.indexOf(".") > 0)
|
|
427
424
|
for (r = a.view, n = e.split("."), h = 0; r != null && h < n.length; )
|
|
428
|
-
h === n.length - 1 && (c =
|
|
425
|
+
h === n.length - 1 && (c = O(r, n[h]) || N(r, n[h])), r = r[n[h++]];
|
|
429
426
|
else
|
|
430
|
-
r = a.view[e], c =
|
|
427
|
+
r = a.view[e], c = O(a.view, e);
|
|
431
428
|
if (c) {
|
|
432
429
|
s = r;
|
|
433
430
|
break;
|
|
@@ -460,11 +457,11 @@ d.prototype.parse = function(e, t) {
|
|
|
460
457
|
return n == null && (n = ae(e, t), r && s.set(a, n)), n;
|
|
461
458
|
};
|
|
462
459
|
d.prototype.render = function(e, t, s, a) {
|
|
463
|
-
var r = this.getConfigTags(a), n = this.parse(e, r), h = t instanceof
|
|
460
|
+
var r = this.getConfigTags(a), n = this.parse(e, r), h = t instanceof k ? t : new k(t, void 0);
|
|
464
461
|
return this.renderTokens(n, h, s, e, a);
|
|
465
462
|
};
|
|
466
463
|
d.prototype.renderTokens = function(e, t, s, a, r) {
|
|
467
|
-
for (var n = "", h, c, l, p = 0,
|
|
464
|
+
for (var n = "", h, c, l, p = 0, v = e.length; p < v; ++p)
|
|
468
465
|
l = void 0, h = e[p], c = h[0], c === "#" ? l = this.renderSection(h, t, s, a, r) : c === "^" ? l = this.renderInverted(h, t, s, a, r) : c === ">" ? l = this.renderPartial(h, t, s, r) : c === "&" ? l = this.unescapedValue(h, t) : c === "name" ? l = this.escapedValue(h, t, r) : c === "text" && (l = this.rawValue(h)), l !== void 0 && (n += l);
|
|
469
466
|
return n;
|
|
470
467
|
};
|
|
@@ -475,7 +472,7 @@ d.prototype.renderSection = function(e, t, s, a, r) {
|
|
|
475
472
|
}
|
|
476
473
|
if (c) {
|
|
477
474
|
if (R(c))
|
|
478
|
-
for (var p = 0,
|
|
475
|
+
for (var p = 0, v = c.length; p < v; ++p)
|
|
479
476
|
h += this.renderTokens(e[4], t.push(c[p]), s, a, r);
|
|
480
477
|
else if (typeof c == "object" || typeof c == "string" || typeof c == "number")
|
|
481
478
|
h += this.renderTokens(e[4], t.push(c), s, a, r);
|
|
@@ -506,8 +503,8 @@ d.prototype.renderPartial = function(e, t, s, a) {
|
|
|
506
503
|
if (n != null) {
|
|
507
504
|
var h = e[6], c = e[5], l = e[4], p = n;
|
|
508
505
|
c == 0 && l && (p = this.indentPartial(n, l, h));
|
|
509
|
-
var
|
|
510
|
-
return this.renderTokens(
|
|
506
|
+
var v = this.parse(p, r);
|
|
507
|
+
return this.renderTokens(v, t, s, p, a);
|
|
511
508
|
}
|
|
512
509
|
}
|
|
513
510
|
};
|
|
@@ -569,15 +566,14 @@ g.render = function(e, t, s, a) {
|
|
|
569
566
|
return L.render(e, t, s, a);
|
|
570
567
|
};
|
|
571
568
|
g.escape = Y;
|
|
572
|
-
g.Scanner =
|
|
573
|
-
g.Context =
|
|
569
|
+
g.Scanner = x;
|
|
570
|
+
g.Context = k;
|
|
574
571
|
g.Writer = d;
|
|
575
572
|
class ne {
|
|
576
573
|
constructor(e) {
|
|
577
574
|
u(this, "dataLayer");
|
|
578
575
|
u(this, "config");
|
|
579
576
|
u(this, "suggestAfterMinChars");
|
|
580
|
-
u(this, "hideBranding");
|
|
581
577
|
u(this, "containerId");
|
|
582
578
|
u(this, "currentInputValue", "");
|
|
583
579
|
u(this, "autosuggestResults");
|
|
@@ -588,7 +584,7 @@ class ne {
|
|
|
588
584
|
u(this, "selectedAutosuggestItem", -1);
|
|
589
585
|
u(this, "suggestTrigger");
|
|
590
586
|
u(this, "searchTrigger");
|
|
591
|
-
this.dataLayer = e.dataLayer, this.config = e.config, this.searchTrigger = e.searchTrigger, this.suggestTrigger = e.suggestTrigger, this.containerId = e.containerId, this.suggestAfterMinChars = e.config.suggestAfterMinChars, this.
|
|
587
|
+
this.dataLayer = e.dataLayer, this.config = e.config, this.searchTrigger = e.searchTrigger, this.suggestTrigger = e.suggestTrigger, this.containerId = e.containerId, this.suggestAfterMinChars = e.config.suggestAfterMinChars, this.renderMainTemplate(), this.actionButtonInit(), this.updateActionButtonState("search"), this.searchInput && (this.createAutosuggestContainer(), this.attachSubscriptions());
|
|
592
588
|
}
|
|
593
589
|
renderMainTemplate() {
|
|
594
590
|
var r, n;
|