@searchstax-inc/searchstudio-ux-js 4.2.2 → 4.2.10
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/CHANGELOG.md +8 -0
- package/README.md +2 -0
- package/dist/@searchstax-inc/searchstudio-ux-js.cjs +77 -74
- package/dist/@searchstax-inc/searchstudio-ux-js.d.mts +8 -1
- package/dist/@searchstax-inc/searchstudio-ux-js.d.ts +8 -1
- package/dist/@searchstax-inc/searchstudio-ux-js.iife.js +77 -74
- package/dist/@searchstax-inc/searchstudio-ux-js.mjs +57 -54
- package/dist/styles/mainTheme.css +47 -14
- package/dist/styles/mainTheme.css.map +1 -1
- package/dist/styles/scss/widgets/searchInput/style.scss +48 -13
- package/dist/templates.js +5 -3
- package/package.json +1 -1
|
@@ -1,72 +1,73 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
]`).replace("lheading",
|
|
3
|
-
`).map(
|
|
4
|
-
`)}var
|
|
5
|
-
`)}}}fences(
|
|
6
|
-
`)}}blockquote(
|
|
1
|
+
(function(Na){"use strict";var F=(i=>(i[i.mustache=0]="mustache",i[i.vue=1]="vue",i[i.react=2]="react",i[i.angular=3]="angular",i))(F||{});function Ft(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ee=Ft();function Pa(i){Ee=i}var Ke={exec:()=>null};function v(i,e=""){let t=typeof i=="string"?i:i.source;const a={replace:(s,n)=>{let r=typeof n=="string"?n:n.source;return r=r.replace(te.caret,"$1"),t=t.replace(s,r),a},getRegex:()=>new RegExp(t,e)};return a}var te={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:i=>new RegExp(`^( {0,3}${i})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}#`),htmlBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}<(?:[a-z].*>|!--)`,"i")},Ys=/^(?:[ \t]*(?:\n|$))+/,Js=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Gs=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Xe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Zs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,zt=/(?:[*+-]|\d{1,9}[.)])/,Oa=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_a=v(Oa).replace(/bull/g,zt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ks=v(Oa).replace(/bull/g,zt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),$t=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Xs=/^[^\n]+/,Bt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ei=v(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Bt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ti=v(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,zt).getRegex(),Lt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Vt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ai=v("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Vt).replace("tag",Lt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Fa=v($t).replace("hr",Xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Lt).getRegex(),si=v(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Fa).getRegex(),Ht={blockquote:si,code:Js,def:ei,fences:Gs,heading:Zs,hr:Xe,html:ai,lheading:_a,list:ti,newline:Ys,paragraph:Fa,table:Ke,text:Xs},za=v("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Lt).getRegex(),ii={...Ht,lheading:Ks,table:za,paragraph:v($t).replace("hr",Xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",za).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Lt).getRegex()},ni={...Ht,html:v(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Vt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ke,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:v($t).replace("hr",Xe).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",_a).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ri=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,oi=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$a=/^( {2,}|\\)\n(?!\s*$)/,li=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,yt=/[\p{P}\p{S}]/u,Ut=/[\s\p{P}\p{S}]/u,Ba=/[^\s\p{P}\p{S}]/u,ci=v(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ut).getRegex(),Va=/(?!~)[\p{P}\p{S}]/u,hi=/(?!~)[\s\p{P}\p{S}]/u,ui=/(?:[^\s\p{P}\p{S}]|~)/u,di=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Ha=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,gi=v(Ha,"u").replace(/punct/g,yt).getRegex(),pi=v(Ha,"u").replace(/punct/g,Va).getRegex(),Ua="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",fi=v(Ua,"gu").replace(/notPunctSpace/g,Ba).replace(/punctSpace/g,Ut).replace(/punct/g,yt).getRegex(),mi=v(Ua,"gu").replace(/notPunctSpace/g,ui).replace(/punctSpace/g,hi).replace(/punct/g,Va).getRegex(),Li=v("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ba).replace(/punctSpace/g,Ut).replace(/punct/g,yt).getRegex(),yi=v(/\\(punct)/,"gu").replace(/punct/g,yt).getRegex(),wi=v(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ci=v(Vt).replace("(?:-->|$)","-->").getRegex(),Mi=v("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ci).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),wt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,bi=v(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",wt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Qa=v(/^!?\[(label)\]\[(ref)\]/).replace("label",wt).replace("ref",Bt).getRegex(),qa=v(/^!?\[(ref)\](?:\[\])?/).replace("ref",Bt).getRegex(),Si=v("reflink|nolink(?!\\()","g").replace("reflink",Qa).replace("nolink",qa).getRegex(),Qt={_backpedal:Ke,anyPunctuation:yi,autolink:wi,blockSkip:di,br:$a,code:oi,del:Ke,emStrongLDelim:gi,emStrongRDelimAst:fi,emStrongRDelimUnd:Li,escape:ri,link:bi,nolink:qa,punctuation:ci,reflink:Qa,reflinkSearch:Si,tag:Mi,text:li,url:Ke},Ti={...Qt,link:v(/^!?\[(label)\]\((.*?)\)/).replace("label",wt).getRegex(),reflink:v(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",wt).getRegex()},qt={...Qt,emStrongRDelimAst:mi,emStrongLDelim:pi,url:v(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},xi={...qt,br:v($a).replace("{2,}","*").getRegex(),text:v(qt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ct={normal:Ht,gfm:ii,pedantic:ni},et={normal:Qt,gfm:qt,breaks:xi,pedantic:Ti},ki={"&":"&","<":"<",">":">",'"':""","'":"'"},Wa=i=>ki[i];function pe(i,e){if(e){if(te.escapeTest.test(i))return i.replace(te.escapeReplace,Wa)}else if(te.escapeTestNoEncode.test(i))return i.replace(te.escapeReplaceNoEncode,Wa);return i}function Ya(i){try{i=encodeURI(i).replace(te.percentDecode,"%")}catch{return null}return i}function Ja(i,e){const t=i.replace(te.findPipe,(n,r,o)=>{let c=!1,h=r;for(;--h>=0&&o[h]==="\\";)c=!c;return c?"|":" |"}),a=t.split(te.splitPipe);let s=0;if(a[0].trim()||a.shift(),a.length>0&&!a.at(-1)?.trim()&&a.pop(),e)if(a.length>e)a.splice(e);else for(;a.length<e;)a.push("");for(;s<a.length;s++)a[s]=a[s].trim().replace(te.slashPipe,"|");return a}function tt(i,e,t){const a=i.length;if(a===0)return"";let s=0;for(;s<a&&i.charAt(a-s-1)===e;)s++;return i.slice(0,a-s)}function Ai(i,e){if(i.indexOf(e[1])===-1)return-1;let t=0;for(let a=0;a<i.length;a++)if(i[a]==="\\")a++;else if(i[a]===e[0])t++;else if(i[a]===e[1]&&(t--,t<0))return a;return t>0?-2:-1}function Ga(i,e,t,a,s){const n=e.href,r=e.title||null,o=i[1].replace(s.other.outputLinkReplace,"$1");a.state.inLink=!0;const c={type:i[0].charAt(0)==="!"?"image":"link",raw:t,href:n,title:r,text:o,tokens:a.inlineTokens(o)};return a.state.inLink=!1,c}function Ei(i,e,t){const a=i.match(t.other.indentCodeCompensation);if(a===null)return e;const s=a[1];return e.split(`
|
|
3
|
+
`).map(n=>{const r=n.match(t.other.beginningSpace);if(r===null)return n;const[o]=r;return o.length>=s.length?n.slice(s.length):n}).join(`
|
|
4
|
+
`)}var Mt=class{options;rules;lexer;constructor(i){this.options=i||Ee}space(i){const e=this.rules.block.newline.exec(i);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(i){const e=this.rules.block.code.exec(i);if(e){const t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:tt(t,`
|
|
5
|
+
`)}}}fences(i){const e=this.rules.block.fences.exec(i);if(e){const t=e[0],a=Ei(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:a}}}heading(i){const e=this.rules.block.heading.exec(i);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){const a=tt(t,"#");(this.options.pedantic||!a||this.rules.other.endingSpaceChar.test(a))&&(t=a.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(i){const e=this.rules.block.hr.exec(i);if(e)return{type:"hr",raw:tt(e[0],`
|
|
6
|
+
`)}}blockquote(i){const e=this.rules.block.blockquote.exec(i);if(e){let t=tt(e[0],`
|
|
7
7
|
`).split(`
|
|
8
|
-
`),
|
|
8
|
+
`),a="",s="";const n=[];for(;t.length>0;){let r=!1;const o=[];let c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))o.push(t[c]),r=!0;else if(!r)o.push(t[c]);else break;t=t.slice(c);const h=o.join(`
|
|
9
9
|
`),d=h.replace(this.rules.other.blockquoteSetextReplace,`
|
|
10
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");
|
|
11
|
-
${h}`:h,
|
|
12
|
-
${d}`:d;const
|
|
10
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");a=a?`${a}
|
|
11
|
+
${h}`:h,s=s?`${s}
|
|
12
|
+
${d}`:d;const L=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,n,!0),this.lexer.state.top=L,t.length===0)break;const m=n.at(-1);if(m?.type==="code")break;if(m?.type==="blockquote"){const R=m,A=R.raw+`
|
|
13
13
|
`+t.join(`
|
|
14
|
-
`),
|
|
14
|
+
`),S=this.blockquote(A);n[n.length-1]=S,a=a.substring(0,a.length-R.raw.length)+S.raw,s=s.substring(0,s.length-R.text.length)+S.text;break}else if(m?.type==="list"){const R=m,A=R.raw+`
|
|
15
15
|
`+t.join(`
|
|
16
|
-
`),
|
|
17
|
-
`);continue}}return{type:"blockquote",raw:
|
|
18
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,
|
|
19
|
-
`,1)[0],
|
|
20
|
-
`,
|
|
21
|
-
`,1)[0];let
|
|
22
|
-
`+
|
|
23
|
-
`+
|
|
24
|
-
`,
|
|
25
|
-
`):[],
|
|
26
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(
|
|
27
|
-
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const
|
|
28
|
-
`:t.push(
|
|
29
|
-
`+
|
|
30
|
-
`+
|
|
31
|
-
`+
|
|
32
|
-
`+
|
|
33
|
-
`+
|
|
34
|
-
`+
|
|
35
|
-
`+
|
|
36
|
-
`+
|
|
37
|
-
`;return
|
|
38
|
-
`:"<pre><code>"+(t?
|
|
39
|
-
`}blockquote({tokens:
|
|
40
|
-
${this.parser.parse(
|
|
41
|
-
`}html({text:
|
|
42
|
-
`}hr(
|
|
43
|
-
`}list(
|
|
44
|
-
`+
|
|
45
|
-
`}listitem(
|
|
46
|
-
`}checkbox({checked:
|
|
47
|
-
`}table(
|
|
16
|
+
`),S=this.list(A);n[n.length-1]=S,a=a.substring(0,a.length-m.raw.length)+S.raw,s=s.substring(0,s.length-R.raw.length)+S.raw,t=A.substring(n.at(-1).raw.length).split(`
|
|
17
|
+
`);continue}}return{type:"blockquote",raw:a,tokens:n,text:s}}}list(i){let e=this.rules.block.list.exec(i);if(e){let t=e[1].trim();const a=t.length>1,s={type:"list",raw:"",ordered:a,start:a?+t.slice(0,-1):"",loose:!1,items:[]};t=a?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=a?t:"[*+-]");const n=this.rules.other.listItemRegex(t);let r=!1;for(;i;){let c=!1,h="",d="";if(!(e=n.exec(i))||this.rules.block.hr.test(i))break;h=e[0],i=i.substring(h.length);let L=e[2].split(`
|
|
18
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,j=>" ".repeat(3*j.length)),m=i.split(`
|
|
19
|
+
`,1)[0],R=!L.trim(),A=0;if(this.options.pedantic?(A=2,d=L.trimStart()):R?A=e[1].length+1:(A=e[2].search(this.rules.other.nonSpaceChar),A=A>4?1:A,d=L.slice(A),A+=e[1].length),R&&this.rules.other.blankLine.test(m)&&(h+=m+`
|
|
20
|
+
`,i=i.substring(m.length+1),c=!0),!c){const j=this.rules.other.nextBulletRegex(A),_=this.rules.other.hrRegex(A),le=this.rules.other.fencesBeginRegex(A),B=this.rules.other.headingBeginRegex(A),p=this.rules.other.htmlBeginRegex(A);for(;i;){const g=i.split(`
|
|
21
|
+
`,1)[0];let C;if(m=g,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),C=m):C=m.replace(this.rules.other.tabCharGlobal," "),le.test(m)||B.test(m)||p.test(m)||j.test(m)||_.test(m))break;if(C.search(this.rules.other.nonSpaceChar)>=A||!m.trim())d+=`
|
|
22
|
+
`+C.slice(A);else{if(R||L.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||le.test(L)||B.test(L)||_.test(L))break;d+=`
|
|
23
|
+
`+m}!R&&!m.trim()&&(R=!0),h+=g+`
|
|
24
|
+
`,i=i.substring(g.length+1),L=C.slice(A)}}s.loose||(r?s.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(r=!0));let S=null,$;this.options.gfm&&(S=this.rules.other.listIsTask.exec(d),S&&($=S[0]!=="[ ] ",d=d.replace(this.rules.other.listReplaceTask,""))),s.items.push({type:"list_item",raw:h,task:!!S,checked:$,loose:!1,text:d,tokens:[]}),s.raw+=h}const o=s.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let c=0;c<s.items.length;c++)if(this.lexer.state.top=!1,s.items[c].tokens=this.lexer.blockTokens(s.items[c].text,[]),!s.loose){const h=s.items[c].tokens.filter(L=>L.type==="space"),d=h.length>0&&h.some(L=>this.rules.other.anyLine.test(L.raw));s.loose=d}if(s.loose)for(let c=0;c<s.items.length;c++)s.items[c].loose=!0;return s}}html(i){const e=this.rules.block.html.exec(i);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(i){const e=this.rules.block.def.exec(i);if(e){const t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),a=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:a,title:s}}}table(i){const e=this.rules.block.table.exec(i);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const t=Ja(e[1]),a=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
25
|
+
`):[],n={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===a.length){for(const r of a)this.rules.other.tableAlignRight.test(r)?n.align.push("right"):this.rules.other.tableAlignCenter.test(r)?n.align.push("center"):this.rules.other.tableAlignLeft.test(r)?n.align.push("left"):n.align.push(null);for(let r=0;r<t.length;r++)n.header.push({text:t[r],tokens:this.lexer.inline(t[r]),header:!0,align:n.align[r]});for(const r of s)n.rows.push(Ja(r,n.header.length).map((o,c)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:n.align[c]})));return n}}lheading(i){const e=this.rules.block.lheading.exec(i);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(i){const e=this.rules.block.paragraph.exec(i);if(e){const t=e[1].charAt(e[1].length-1)===`
|
|
26
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(i){const e=this.rules.block.text.exec(i);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(i){const e=this.rules.inline.escape.exec(i);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(i){const e=this.rules.inline.tag.exec(i);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(i){const e=this.rules.inline.link.exec(i);if(e){const t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;const n=tt(t.slice(0,-1),"\\");if((t.length-n.length)%2===0)return}else{const n=Ai(e[2],"()");if(n===-2)return;if(n>-1){const o=(e[0].indexOf("!")===0?5:4)+e[1].length+n;e[2]=e[2].substring(0,n),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let a=e[2],s="";if(this.options.pedantic){const n=this.rules.other.pedanticHrefTitle.exec(a);n&&(a=n[1],s=n[3])}else s=e[3]?e[3].slice(1,-1):"";return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?a=a.slice(1):a=a.slice(1,-1)),Ga(e,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(i,e){let t;if((t=this.rules.inline.reflink.exec(i))||(t=this.rules.inline.nolink.exec(i))){const a=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[a.toLowerCase()];if(!s){const n=t[0].charAt(0);return{type:"text",raw:n,text:n}}return Ga(t,s,t[0],this.lexer,this.rules)}}emStrong(i,e,t=""){let a=this.rules.inline.emStrongLDelim.exec(i);if(!a||a[3]&&t.match(this.rules.other.unicodeAlphaNumeric))return;if(!(a[1]||a[2]||"")||!t||this.rules.inline.punctuation.exec(t)){const n=[...a[0]].length-1;let r,o,c=n,h=0;const d=a[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,e=e.slice(-1*i.length+n);(a=d.exec(e))!=null;){if(r=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!r)continue;if(o=[...r].length,a[3]||a[4]){c+=o;continue}else if((a[5]||a[6])&&n%3&&!((n+o)%3)){h+=o;continue}if(c-=o,c>0)continue;o=Math.min(o,o+c+h);const L=[...a[0]][0].length,m=i.slice(0,n+a.index+L+o);if(Math.min(n,o)%2){const A=m.slice(1,-1);return{type:"em",raw:m,text:A,tokens:this.lexer.inlineTokens(A)}}const R=m.slice(2,-2);return{type:"strong",raw:m,text:R,tokens:this.lexer.inlineTokens(R)}}}}codespan(i){const e=this.rules.inline.code.exec(i);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," ");const a=this.rules.other.nonSpaceChar.test(t),s=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return a&&s&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(i){const e=this.rules.inline.br.exec(i);if(e)return{type:"br",raw:e[0]}}del(i){const e=this.rules.inline.del.exec(i);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(i){const e=this.rules.inline.autolink.exec(i);if(e){let t,a;return e[2]==="@"?(t=e[1],a="mailto:"+t):(t=e[1],a=t),{type:"link",raw:e[0],text:t,href:a,tokens:[{type:"text",raw:t,text:t}]}}}url(i){let e;if(e=this.rules.inline.url.exec(i)){let t,a;if(e[2]==="@")t=e[0],a="mailto:"+t;else{let s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==e[0]);t=e[0],e[1]==="www."?a="http://"+e[0]:a=e[0]}return{type:"link",raw:e[0],text:t,href:a,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(i){const e=this.rules.inline.text.exec(i);if(e){const t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},Me=class ja{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ee,this.options.tokenizer=this.options.tokenizer||new Mt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={other:te,block:Ct.normal,inline:et.normal};this.options.pedantic?(t.block=Ct.pedantic,t.inline=et.pedantic):this.options.gfm&&(t.block=Ct.gfm,this.options.breaks?t.inline=et.breaks:t.inline=et.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ct,inline:et}}static lex(e,t){return new ja(t).lex(e)}static lexInline(e,t){return new ja(t).inlineTokens(e)}lex(e){e=e.replace(te.carriageReturn,`
|
|
27
|
+
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const a=this.inlineQueue[t];this.inlineTokens(a.src,a.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],a=!1){for(this.options.pedantic&&(e=e.replace(te.tabCharGlobal," ").replace(te.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(r=>(s=r.call({lexer:this},e,t))?(e=e.substring(s.raw.length),t.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);const r=t.at(-1);s.raw.length===1&&r!==void 0?r.raw+=`
|
|
28
|
+
`:t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);const r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=`
|
|
29
|
+
`+s.raw,r.text+=`
|
|
30
|
+
`+s.text,this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);const r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=`
|
|
31
|
+
`+s.raw,r.text+=`
|
|
32
|
+
`+s.raw,this.inlineQueue.at(-1).src=r.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),t.push(s);continue}let n=e;if(this.options.extensions?.startBlock){let r=1/0;const o=e.slice(1);let c;this.options.extensions.startBlock.forEach(h=>{c=h.call({lexer:this},o),typeof c=="number"&&c>=0&&(r=Math.min(r,c))}),r<1/0&&r>=0&&(n=e.substring(0,r+1))}if(this.state.top&&(s=this.tokenizer.paragraph(n))){const r=t.at(-1);a&&r?.type==="paragraph"?(r.raw+=`
|
|
33
|
+
`+s.raw,r.text+=`
|
|
34
|
+
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s),a=n.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);const r=t.at(-1);r?.type==="text"?(r.raw+=`
|
|
35
|
+
`+s.raw,r.text+=`
|
|
36
|
+
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if(e){const r="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(r);break}else throw new Error(r)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let a=e,s=null;if(this.tokens.links){const o=Object.keys(this.tokens.links);if(o.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)o.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,s.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(s=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let n=!1,r="";for(;e;){n||(r=""),n=!1;let o;if(this.options.extensions?.inline?.some(h=>(o=h.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);const h=t.at(-1);o.type==="text"&&h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,a,r)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let c=e;if(this.options.extensions?.startInline){let h=1/0;const d=e.slice(1);let L;this.options.extensions.startInline.forEach(m=>{L=m.call({lexer:this},d),typeof L=="number"&&L>=0&&(h=Math.min(h,L))}),h<1/0&&h>=0&&(c=e.substring(0,h+1))}if(o=this.tokenizer.inlineText(c)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(r=o.raw.slice(-1)),n=!0;const h=t.at(-1);h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(e){const h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return t}},bt=class{options;parser;constructor(i){this.options=i||Ee}space(i){return""}code({text:i,lang:e,escaped:t}){const a=(e||"").match(te.notSpaceStart)?.[0],s=i.replace(te.endingNewline,"")+`
|
|
37
|
+
`;return a?'<pre><code class="language-'+pe(a)+'">'+(t?s:pe(s,!0))+`</code></pre>
|
|
38
|
+
`:"<pre><code>"+(t?s:pe(s,!0))+`</code></pre>
|
|
39
|
+
`}blockquote({tokens:i}){return`<blockquote>
|
|
40
|
+
${this.parser.parse(i)}</blockquote>
|
|
41
|
+
`}html({text:i}){return i}heading({tokens:i,depth:e}){return`<h${e}>${this.parser.parseInline(i)}</h${e}>
|
|
42
|
+
`}hr(i){return`<hr>
|
|
43
|
+
`}list(i){const e=i.ordered,t=i.start;let a="";for(let r=0;r<i.items.length;r++){const o=i.items[r];a+=this.listitem(o)}const s=e?"ol":"ul",n=e&&t!==1?' start="'+t+'"':"";return"<"+s+n+`>
|
|
44
|
+
`+a+"</"+s+`>
|
|
45
|
+
`}listitem(i){let e="";if(i.task){const t=this.checkbox({checked:!!i.checked});i.loose?i.tokens[0]?.type==="paragraph"?(i.tokens[0].text=t+" "+i.tokens[0].text,i.tokens[0].tokens&&i.tokens[0].tokens.length>0&&i.tokens[0].tokens[0].type==="text"&&(i.tokens[0].tokens[0].text=t+" "+pe(i.tokens[0].tokens[0].text),i.tokens[0].tokens[0].escaped=!0)):i.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:!0}):e+=t+" "}return e+=this.parser.parse(i.tokens,!!i.loose),`<li>${e}</li>
|
|
46
|
+
`}checkbox({checked:i}){return"<input "+(i?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:i}){return`<p>${this.parser.parseInline(i)}</p>
|
|
47
|
+
`}table(i){let e="",t="";for(let s=0;s<i.header.length;s++)t+=this.tablecell(i.header[s]);e+=this.tablerow({text:t});let a="";for(let s=0;s<i.rows.length;s++){const n=i.rows[s];t="";for(let r=0;r<n.length;r++)t+=this.tablecell(n[r]);a+=this.tablerow({text:t})}return a&&(a=`<tbody>${a}</tbody>`),`<table>
|
|
48
48
|
<thead>
|
|
49
49
|
`+e+`</thead>
|
|
50
|
-
`+
|
|
51
|
-
`}tablerow({text:
|
|
52
|
-
${
|
|
53
|
-
`}tablecell(
|
|
54
|
-
`}strong({tokens:
|
|
55
|
-
`+this.renderer.text(o);t?
|
|
56
|
-
Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An error occurred:</p><pre>"+ge(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},xe=new Ti;function D(n,e){return xe.parse(n,e)}D.options=D.setOptions=function(n){return xe.setOptions(n),D.defaults=xe.defaults,ka(D.defaults),D},D.getDefaults=Rt,D.defaults=Se,D.use=function(...n){return xe.use(...n),D.defaults=xe.defaults,ka(D.defaults),D},D.walkTokens=function(n,e){return xe.walkTokens(n,e)},D.parseInline=xe.parseInline,D.Parser=Le,D.parser=Le.parse,D.Renderer=Lt,D.TextRenderer=Vt,D.Lexer=me,D.lexer=me.lex,D.Tokenizer=mt,D.Hooks=yt,D.parse=D,D.options,D.setOptions,D.use,D.walkTokens,D.parseInline,Le.parse,me.lex;const{entries:Ba,setPrototypeOf:Ha,isFrozen:Si,getPrototypeOf:xi,getOwnPropertyDescriptor:ki}=Object;let{freeze:X,seal:re,create:Ie}=Object,{apply:Bt,construct:Ht}=typeof Reflect<"u"&&Reflect;X||(X=function(e){return e}),re||(re=function(e){return e}),Bt||(Bt=function(e,t){for(var s=arguments.length,a=new Array(s>2?s-2:0),i=2;i<s;i++)a[i-2]=arguments[i];return e.apply(t,a)}),Ht||(Ht=function(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];return new e(...s)});const Ge=_(Array.prototype.forEach),Ai=_(Array.prototype.lastIndexOf),Ua=_(Array.prototype.pop),Ze=_(Array.prototype.push),Ei=_(Array.prototype.splice),ee=Array.isArray,Ke=_(String.prototype.toLowerCase),Ut=_(String.prototype.toString),Qa=_(String.prototype.match),Re=_(String.prototype.replace),qa=_(String.prototype.indexOf),vi=_(String.prototype.trim),Di=_(Number.prototype.toString),Ii=_(Boolean.prototype.toString),Wa=typeof BigInt>"u"?null:_(BigInt.prototype.toString),Ya=typeof Symbol>"u"?null:_(Symbol.prototype.toString),P=_(Object.prototype.hasOwnProperty),Xe=_(Object.prototype.toString),J=_(RegExp.prototype.test),wt=Ri(TypeError);function _(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,s=new Array(t>1?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];return Bt(n,e,s)}}function Ri(n){return function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return Ht(n,t)}}function b(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ke;if(Ha&&Ha(n,null),!ee(e))return n;let s=e.length;for(;s--;){let a=e[s];if(typeof a=="string"){const i=t(a);i!==a&&(Si(e)||(e[s]=i),a=i)}n[a]=!0}return n}function ji(n){for(let e=0;e<n.length;e++)P(n,e)||(n[e]=null);return n}function ae(n){const e=Ie(null);for(const[t,s]of Ba(n))P(n,t)&&(ee(s)?e[t]=ji(s):s&&typeof s=="object"&&s.constructor===Object?e[t]=ae(s):e[t]=s);return e}function Ni(n){switch(typeof n){case"string":return n;case"number":return Di(n);case"boolean":return Ii(n);case"bigint":return Wa?Wa(n):"0";case"symbol":return Ya?Ya(n):"Symbol()";case"undefined":return Xe(n);case"function":case"object":{if(n===null)return Xe(n);const e=n,t=je(e,"toString");if(typeof t=="function"){const s=t(e);return typeof s=="string"?s:Xe(s)}return Xe(n)}default:return Xe(n)}}function je(n,e){for(;n!==null;){const s=ki(n,e);if(s){if(s.get)return _(s.get);if(typeof s.value=="function")return _(s.value)}n=xi(n)}function t(){return null}return t}function Pi(n){try{return J(n,""),!0}catch{return!1}}const Ja=X(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Qt=X(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),qt=X(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Oi=X(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Wt=X(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),_i=X(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ga=X(["#text"]),Za=X(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Yt=X(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ka=X(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ct=X(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Fi=re(/\{\{[\w\W]*|[\w\W]*\}\}/gm),zi=re(/<%[\w\W]*|[\w\W]*%>/gm),$i=re(/\$\{[\w\W]*/gm),Vi=re(/^data-[\-\w.\u00B7-\uFFFF]+$/),Bi=re(/^aria-[\-\w]+$/),Xa=re(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Hi=re(/^(?:\w+script|data):/i),Ui=re(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),es=re(/^html$/i),Qi=re(/^[a-z][.\w]*(-[.\w]+)+$/i);var ts=Object.freeze({__proto__:null,ARIA_ATTR:Bi,ATTR_WHITESPACE:Ui,CUSTOM_ELEMENT:Qi,DATA_ATTR:Vi,DOCTYPE_NAME:es,ERB_EXPR:zi,IS_ALLOWED_URI:Xa,IS_SCRIPT_OR_DATA:Hi,MUSTACHE_EXPR:Fi,TMPLIT_EXPR:$i});const et={element:1,text:3,progressingInstruction:7,comment:8,document:9},qi=function(){return typeof window>"u"?null:window},Wi=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null;const a="data-tt-policy-suffix";t&&t.hasAttribute(a)&&(s=t.getAttribute(a));const i="dompurify"+(s?"#"+s:"");try{return e.createPolicy(i,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},as=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ss(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qi();const e=m=>ss(m);if(e.version="3.4.2",e.removed=[],!n||!n.document||n.document.nodeType!==et.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const s=t,a=s.currentScript,{DocumentFragment:i,HTMLTemplateElement:r,Node:o,Element:c,NodeFilter:h,NamedNodeMap:d=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:C,DOMParser:y,trustedTypes:I}=n,S=c.prototype,x=je(S,"cloneNode"),Q=je(S,"remove"),p=je(S,"nextSibling"),g=je(S,"childNodes"),w=je(S,"parentNode");if(typeof r=="function"){const m=t.createElement("template");m.content&&m.content.ownerDocument&&(t=m.content.ownerDocument)}let T,E="";const{implementation:F,createNodeIterator:he,createDocumentFragment:ne,getElementsByTagName:la}=t,{importNode:be}=s;let q=as();e.isSupported=typeof Ba=="function"&&typeof w=="function"&&F&&F.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:St,ERB_EXPR:xt,TMPLIT_EXPR:kt,DATA_ATTR:$n,ARIA_ATTR:Vn,IS_SCRIPT_OR_DATA:Bn,ATTR_WHITESPACE:Ls,CUSTOM_ELEMENT:Hn}=ts;let{IS_ALLOWED_URI:ys}=ts,W=null;const ws=b({},[...Ja,...Qt,...qt,...Wt,...Ga]);let G=null;const Cs=b({},[...Za,...Yt,...Ka,...Ct]);let O=Object.seal(Ie(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),lt=null,At=null;const Te=Object.seal(Ie(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ms=!0,ca=!0,bs=!1,Ts=!0,Ee=!1,ct=!0,ve=!1,ha=!1,ua=!1,Be=!1,Et=!1,vt=!1,Ss=!0,xs=!1;const ks="user-content-";let da=!0,ht=!1,He={},pe=null;const ga=b({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let As=null;const Es=b({},["audio","video","img","source","image","track"]);let pa=null;const vs=b({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Dt="http://www.w3.org/1998/Math/MathML",It="http://www.w3.org/2000/svg",fe="http://www.w3.org/1999/xhtml";let Ue=fe,fa=!1,ma=null;const Un=b({},[Dt,It,fe],Ut);let La=b({},["mi","mo","mn","ms","mtext"]),ya=b({},["annotation-xml"]);const Qn=b({},["title","style","font","a","script"]);let ut=null;const qn=["application/xhtml+xml","text/html"],Wn="text/html";let B=null,Qe=null;const Yn=t.createElement("form"),Ds=function(l){return l instanceof RegExp||l instanceof Function},wa=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Qe&&Qe===l)return;(!l||typeof l!="object")&&(l={}),l=ae(l),ut=qn.indexOf(l.PARSER_MEDIA_TYPE)===-1?Wn:l.PARSER_MEDIA_TYPE,B=ut==="application/xhtml+xml"?Ut:Ke,W=P(l,"ALLOWED_TAGS")&&ee(l.ALLOWED_TAGS)?b({},l.ALLOWED_TAGS,B):ws,G=P(l,"ALLOWED_ATTR")&&ee(l.ALLOWED_ATTR)?b({},l.ALLOWED_ATTR,B):Cs,ma=P(l,"ALLOWED_NAMESPACES")&&ee(l.ALLOWED_NAMESPACES)?b({},l.ALLOWED_NAMESPACES,Ut):Un,pa=P(l,"ADD_URI_SAFE_ATTR")&&ee(l.ADD_URI_SAFE_ATTR)?b(ae(vs),l.ADD_URI_SAFE_ATTR,B):vs,As=P(l,"ADD_DATA_URI_TAGS")&&ee(l.ADD_DATA_URI_TAGS)?b(ae(Es),l.ADD_DATA_URI_TAGS,B):Es,pe=P(l,"FORBID_CONTENTS")&&ee(l.FORBID_CONTENTS)?b({},l.FORBID_CONTENTS,B):ga,lt=P(l,"FORBID_TAGS")&&ee(l.FORBID_TAGS)?b({},l.FORBID_TAGS,B):ae({}),At=P(l,"FORBID_ATTR")&&ee(l.FORBID_ATTR)?b({},l.FORBID_ATTR,B):ae({}),He=P(l,"USE_PROFILES")?l.USE_PROFILES&&typeof l.USE_PROFILES=="object"?ae(l.USE_PROFILES):l.USE_PROFILES:!1,Ms=l.ALLOW_ARIA_ATTR!==!1,ca=l.ALLOW_DATA_ATTR!==!1,bs=l.ALLOW_UNKNOWN_PROTOCOLS||!1,Ts=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ee=l.SAFE_FOR_TEMPLATES||!1,ct=l.SAFE_FOR_XML!==!1,ve=l.WHOLE_DOCUMENT||!1,Be=l.RETURN_DOM||!1,Et=l.RETURN_DOM_FRAGMENT||!1,vt=l.RETURN_TRUSTED_TYPE||!1,ua=l.FORCE_BODY||!1,Ss=l.SANITIZE_DOM!==!1,xs=l.SANITIZE_NAMED_PROPS||!1,da=l.KEEP_CONTENT!==!1,ht=l.IN_PLACE||!1,ys=Pi(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:Xa,Ue=typeof l.NAMESPACE=="string"?l.NAMESPACE:fe,La=P(l,"MATHML_TEXT_INTEGRATION_POINTS")&&l.MATHML_TEXT_INTEGRATION_POINTS&&typeof l.MATHML_TEXT_INTEGRATION_POINTS=="object"?ae(l.MATHML_TEXT_INTEGRATION_POINTS):b({},["mi","mo","mn","ms","mtext"]),ya=P(l,"HTML_INTEGRATION_POINTS")&&l.HTML_INTEGRATION_POINTS&&typeof l.HTML_INTEGRATION_POINTS=="object"?ae(l.HTML_INTEGRATION_POINTS):b({},["annotation-xml"]);const u=P(l,"CUSTOM_ELEMENT_HANDLING")&&l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING=="object"?ae(l.CUSTOM_ELEMENT_HANDLING):Ie(null);if(O=Ie(null),P(u,"tagNameCheck")&&Ds(u.tagNameCheck)&&(O.tagNameCheck=u.tagNameCheck),P(u,"attributeNameCheck")&&Ds(u.attributeNameCheck)&&(O.attributeNameCheck=u.attributeNameCheck),P(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(O.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),Ee&&(ca=!1),Et&&(Be=!0),He&&(W=b({},Ga),G=Ie(null),He.html===!0&&(b(W,Ja),b(G,Za)),He.svg===!0&&(b(W,Qt),b(G,Yt),b(G,Ct)),He.svgFilters===!0&&(b(W,qt),b(G,Yt),b(G,Ct)),He.mathMl===!0&&(b(W,Wt),b(G,Ka),b(G,Ct))),Te.tagCheck=null,Te.attributeCheck=null,P(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?Te.tagCheck=l.ADD_TAGS:ee(l.ADD_TAGS)&&(W===ws&&(W=ae(W)),b(W,l.ADD_TAGS,B))),P(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?Te.attributeCheck=l.ADD_ATTR:ee(l.ADD_ATTR)&&(G===Cs&&(G=ae(G)),b(G,l.ADD_ATTR,B))),P(l,"ADD_URI_SAFE_ATTR")&&ee(l.ADD_URI_SAFE_ATTR)&&b(pa,l.ADD_URI_SAFE_ATTR,B),P(l,"FORBID_CONTENTS")&&ee(l.FORBID_CONTENTS)&&(pe===ga&&(pe=ae(pe)),b(pe,l.FORBID_CONTENTS,B)),P(l,"ADD_FORBID_CONTENTS")&&ee(l.ADD_FORBID_CONTENTS)&&(pe===ga&&(pe=ae(pe)),b(pe,l.ADD_FORBID_CONTENTS,B)),da&&(W["#text"]=!0),ve&&b(W,["html","head","body"]),W.table&&(b(W,["tbody"]),delete lt.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw wt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw wt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');T=l.TRUSTED_TYPES_POLICY,E=T.createHTML("")}else T===void 0&&(T=Wi(I,a)),T!==null&&typeof E=="string"&&(E=T.createHTML(""));X&&X(l),Qe=l},Is=b({},[...Qt,...qt,...Oi]),Rs=b({},[...Wt,..._i]),Jn=function(l){let u=w(l);(!u||!u.tagName)&&(u={namespaceURI:Ue,tagName:"template"});const f=Ke(l.tagName),R=Ke(u.tagName);return ma[l.namespaceURI]?l.namespaceURI===It?u.namespaceURI===fe?f==="svg":u.namespaceURI===Dt?f==="svg"&&(R==="annotation-xml"||La[R]):!!Is[f]:l.namespaceURI===Dt?u.namespaceURI===fe?f==="math":u.namespaceURI===It?f==="math"&&ya[R]:!!Rs[f]:l.namespaceURI===fe?u.namespaceURI===It&&!ya[R]||u.namespaceURI===Dt&&!La[R]?!1:!Rs[f]&&(Qn[f]||!Is[f]):!!(ut==="application/xhtml+xml"&&ma[l.namespaceURI]):!1},ue=function(l){Ze(e.removed,{element:l});try{w(l).removeChild(l)}catch{Q(l)}},De=function(l,u){try{Ze(e.removed,{attribute:u.getAttributeNode(l),from:u})}catch{Ze(e.removed,{attribute:null,from:u})}if(u.removeAttribute(l),l==="is")if(Be||Et)try{ue(u)}catch{}else try{u.setAttribute(l,"")}catch{}},js=function(l){let u=null,f=null;if(ua)l="<remove></remove>"+l;else{const z=Qa(l,/^[\r\n\t ]+/);f=z&&z[0]}ut==="application/xhtml+xml"&&Ue===fe&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");const R=T?T.createHTML(l):l;if(Ue===fe)try{u=new y().parseFromString(R,ut)}catch{}if(!u||!u.documentElement){u=F.createDocument(Ue,"template",null);try{u.documentElement.innerHTML=fa?E:R}catch{}}const Z=u.body||u.documentElement;return l&&f&&Z.insertBefore(t.createTextNode(f),Z.childNodes[0]||null),Ue===fe?la.call(u,ve?"html":"body")[0]:ve?u.documentElement:Z},Ns=function(l){return he.call(l.ownerDocument||l,l,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},Ca=function(l){return l instanceof C&&(typeof l.nodeName!="string"||typeof l.textContent!="string"||typeof l.removeChild!="function"||!(l.attributes instanceof d)||typeof l.removeAttribute!="function"||typeof l.setAttribute!="function"||typeof l.namespaceURI!="string"||typeof l.insertBefore!="function"||typeof l.hasChildNodes!="function")},Ma=function(l){return typeof o=="function"&&l instanceof o};function Ce(m,l,u){Ge(m,f=>{f.call(e,l,u,Qe)})}const Ps=function(l){let u=null;if(Ce(q.beforeSanitizeElements,l,null),Ca(l))return ue(l),!0;const f=B(l.nodeName);if(Ce(q.uponSanitizeElement,l,{tagName:f,allowedTags:W}),ct&&l.hasChildNodes()&&!Ma(l.firstElementChild)&&J(/<[/\w!]/g,l.innerHTML)&&J(/<[/\w!]/g,l.textContent)||ct&&l.namespaceURI===fe&&f==="style"&&Ma(l.firstElementChild)||l.nodeType===et.progressingInstruction||ct&&l.nodeType===et.comment&&J(/<[/\w]/g,l.data))return ue(l),!0;if(lt[f]||!(Te.tagCheck instanceof Function&&Te.tagCheck(f))&&!W[f]){if(!lt[f]&&_s(f)&&(O.tagNameCheck instanceof RegExp&&J(O.tagNameCheck,f)||O.tagNameCheck instanceof Function&&O.tagNameCheck(f)))return!1;if(da&&!pe[f]){const R=w(l)||l.parentNode,Z=g(l)||l.childNodes;if(Z&&R){const z=Z.length;for(let ie=z-1;ie>=0;--ie){const le=x(Z[ie],!0);R.insertBefore(le,p(l))}}}return ue(l),!0}return l instanceof c&&!Jn(l)||(f==="noscript"||f==="noembed"||f==="noframes")&&J(/<\/no(script|embed|frames)/i,l.innerHTML)?(ue(l),!0):(Ee&&l.nodeType===et.text&&(u=l.textContent,Ge([St,xt,kt],R=>{u=Re(u,R," ")}),l.textContent!==u&&(Ze(e.removed,{element:l.cloneNode()}),l.textContent=u)),Ce(q.afterSanitizeElements,l,null),!1)},Os=function(l,u,f){if(At[u]||Ss&&(u==="id"||u==="name")&&(f in t||f in Yn))return!1;const R=G[u]||Te.attributeCheck instanceof Function&&Te.attributeCheck(u,l);if(!(ca&&!At[u]&&J($n,u))){if(!(Ms&&J(Vn,u))){if(!R||At[u]){if(!(_s(l)&&(O.tagNameCheck instanceof RegExp&&J(O.tagNameCheck,l)||O.tagNameCheck instanceof Function&&O.tagNameCheck(l))&&(O.attributeNameCheck instanceof RegExp&&J(O.attributeNameCheck,u)||O.attributeNameCheck instanceof Function&&O.attributeNameCheck(u,l))||u==="is"&&O.allowCustomizedBuiltInElements&&(O.tagNameCheck instanceof RegExp&&J(O.tagNameCheck,f)||O.tagNameCheck instanceof Function&&O.tagNameCheck(f))))return!1}else if(!pa[u]){if(!J(ys,Re(f,Ls,""))){if(!((u==="src"||u==="xlink:href"||u==="href")&&l!=="script"&&qa(f,"data:")===0&&As[l])){if(!(bs&&!J(Bn,Re(f,Ls,"")))){if(f)return!1}}}}}}return!0},Gn=b({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),_s=function(l){return!Gn[Ke(l)]&&J(Hn,l)},Fs=function(l){Ce(q.beforeSanitizeAttributes,l,null);const{attributes:u}=l;if(!u||Ca(l))return;const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let R=u.length;for(;R--;){const Z=u[R],{name:z,namespaceURI:ie,value:le}=Z,de=B(z),ba=le;let Y=z==="value"?ba:vi(ba);if(f.attrName=de,f.attrValue=Y,f.keepAttr=!0,f.forceKeepAttr=void 0,Ce(q.uponSanitizeAttribute,l,f),Y=f.attrValue,xs&&(de==="id"||de==="name")&&qa(Y,ks)!==0&&(De(z,l),Y=ks+Y),ct&&J(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Y)){De(z,l);continue}if(de==="attributename"&&Qa(Y,"href")){De(z,l);continue}if(f.forceKeepAttr)continue;if(!f.keepAttr){De(z,l);continue}if(!Ts&&J(/\/>/i,Y)){De(z,l);continue}Ee&&Ge([St,xt,kt],Vs=>{Y=Re(Y,Vs," ")});const $s=B(l.nodeName);if(!Os($s,de,Y)){De(z,l);continue}if(T&&typeof I=="object"&&typeof I.getAttributeType=="function"&&!ie)switch(I.getAttributeType($s,de)){case"TrustedHTML":{Y=T.createHTML(Y);break}case"TrustedScriptURL":{Y=T.createScriptURL(Y);break}}if(Y!==ba)try{ie?l.setAttributeNS(ie,z,Y):l.setAttribute(z,Y),Ca(l)?ue(l):Ua(e.removed)}catch{De(z,l)}}Ce(q.afterSanitizeAttributes,l,null)},zs=function(l){let u=null;const f=Ns(l);for(Ce(q.beforeSanitizeShadowDOM,l,null);u=f.nextNode();)Ce(q.uponSanitizeShadowNode,u,null),Ps(u),Fs(u),u.content instanceof i&&zs(u.content);Ce(q.afterSanitizeShadowDOM,l,null)};return e.sanitize=function(m){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,f=null,R=null,Z=null;if(fa=!m,fa&&(m="<!-->"),typeof m!="string"&&!Ma(m)&&(m=Ni(m),typeof m!="string"))throw wt("dirty is not a string, aborting");if(!e.isSupported)return m;if(ha||wa(l),e.removed=[],typeof m=="string"&&(ht=!1),ht){const le=m.nodeName;if(typeof le=="string"){const de=B(le);if(!W[de]||lt[de])throw wt("root node is forbidden and cannot be sanitized in-place")}}else if(m instanceof o)u=js("<!---->"),f=u.ownerDocument.importNode(m,!0),f.nodeType===et.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?u=f:u.appendChild(f);else{if(!Be&&!Ee&&!ve&&m.indexOf("<")===-1)return T&&vt?T.createHTML(m):m;if(u=js(m),!u)return Be?null:vt?E:""}u&&ua&&ue(u.firstChild);const z=Ns(ht?m:u);for(;R=z.nextNode();)Ps(R),Fs(R),R.content instanceof i&&zs(R.content);if(ht)return m;if(Be){if(Ee){u.normalize();let le=u.innerHTML;Ge([St,xt,kt],de=>{le=Re(le,de," ")}),u.innerHTML=le}if(Et)for(Z=ne.call(u.ownerDocument);u.firstChild;)Z.appendChild(u.firstChild);else Z=u;return(G.shadowroot||G.shadowrootmode)&&(Z=be.call(s,Z,!0)),Z}let ie=ve?u.outerHTML:u.innerHTML;return ve&&W["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&J(es,u.ownerDocument.doctype.name)&&(ie="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
|
|
57
|
-
`+ie),Ee&&Ge([St,xt,kt],le=>{ie=Re(ie,le," ")}),T&&vt?T.createHTML(ie):ie},e.setConfig=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};wa(m),ha=!0},e.clearConfig=function(){Qe=null,ha=!1},e.isValidAttribute=function(m,l,u){Qe||wa({});const f=B(m),R=B(l);return Os(f,R,u)},e.addHook=function(m,l){typeof l=="function"&&Ze(q[m],l)},e.removeHook=function(m,l){if(l!==void 0){const u=Ai(q[m],l);return u===-1?void 0:Ei(q[m],u,1)[0]}return Ua(q[m])},e.removeHooks=function(m){q[m]=[]},e.removeAllHooks=function(){q=as()},e}var is=ss();class Yi{dataLayer;constructor(e){this.dataLayer=e}get answerWidgetShowMoreLimit(){return this.dataLayer.answerWidgetShowMoreLimit??100}get currentPage(){return this.dataLayer.searchObject?.page}get totalPages(){return this.resultsPerPage===0?0:Math.ceil(this.totalResults/this.resultsPerPage)}get totalResults(){return this.dataLayer.searchResultsMetadata?.totalResultsValue||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){return this.dataLayer.searchResultsMetadata?.sorting.options||[]}get selectedSortOption(){return this.dataLayer.searchResultsMetadata?.sorting.selectedSortOption||""}get startResultIndex(){return(this.dataLayer.searchObject?.page-1)*this.resultsPerPage+1}get endResultIndex(){const e=(this.dataLayer.searchObject?.page-1)*this.resultsPerPage+(this.resultsPerPage??0);return e>this.totalResults?this.totalResults:e}get isFirstPage(){return this.dataLayer.searchObject?.page===1}get isLastPage(){return this.dataLayer.searchObject?.page>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){return this.dataLayer.searchResultsMetadata?.autoCorrectedQuery||""}get originalQuery(){return this.dataLayer.searchObject?.query||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswerLoadMore(){return this.dataLayer.getAnswerData.split(" ").length>this.answerWidgetShowMoreLimit}get answerTruncated(){return this.dataLayer.getAnswerData.split(" ").slice(0,this.answerWidgetShowMoreLimit).join(" ")+"..."}get fullAnswerFormatted(){return is.sanitize(D.parse(this.dataLayer.getAnswerData)).replace(/<a /g,'<a target="_blank" class="searchstax-answer-link" rel="noopener noreferrer" ')}get answerLoading(){return this.dataLayer.answerLoading}get shouldShowAnswerError(){return this.dataLayer.answerError}get locationError(){return this.dataLayer.locationError}get shouldShowAnswer(){return(this.dataLayer.getAnswerData!==""||this.dataLayer.parsedData.answerLoading||this.shouldShowAnswerError)&&this.dataLayer.searchObject.query!=="*"}get searchTerm(){return this.dataLayer.searchResultsMetadata?.autoCorrectedQuery||this.dataLayer.searchObject?.query||""}get locationSearchEnabled(){return this.dataLayer.locationEnabled??!1}get locationSearchDistanceEnabled(){return(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationDistanceEnabled?this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationDistanceEnabled:this.dataLayer.searchResultsMetadata?.location?.filter?.enabled)??!1}get locationSearchDistanceValues(){const e=this.dataLayer.searchLocationConfig?.locationValuesOverride?.filterValues??this.dataLayer.searchResultsMetadata?.location?.filter?.values,t=this.dataLayer.searchLocationConfig?.locationValuesOverride?.filterUnit??this.dataLayer.searchResultsMetadata?.location?.unit;return!e||e.length===0?[]:e.map(a=>({label:a==="any"?"Any Distance":a+" "+(t??""),value:a,isSelected:a===this.dataLayer.searchRadius})).sort((a,i)=>{const r=a.value==="any"?0:parseFloat(a.value),o=i.value==="any"?0:parseFloat(i.value);return r-o})}get shouldShowLocationDistanceDropdown(){return this.locationSearchDistanceEnabled&&this.locationSearchDistanceValues.length>1}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get answerErrorMessage(){return is.sanitize(D.parse(this.dataLayer.answerErrorMessage)).replace("<br>","")}get searchExecuted(){return this.dataLayer.searchObject?.query!==void 0&&this.dataLayer.searchObject?.query!=="undefined"&&this.dataLayer.searchObject?.query!==""}get selectedFacets(){const e=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return e?(this.dataLayer.searchObject?.facets??[]).map(a=>{const i=a.name,r=a.value,o=e.find(c=>c.name===i);if(o){const c=o.values.find(h=>h.type==="range"?!1:h.type==="checkbox"?'"'+h.value+'"'===r:!1);if(c)return c}return null}).filter(a=>a!==null):[]}get cachedANDFacets(){let e="";for(const t of this.dataLayer.searchObject.facets)(t.type==="and"||t.type==="tabs")&&(e+=JSON.stringify(t));return e}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,totalPages:this.totalPages,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,answerTruncated:this.answerTruncated,fullAnswerFormatted:this.fullAnswerFormatted,shouldShowAnswerLoadMore:this.shouldShowAnswerLoadMore,answerLoading:this.answerLoading,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption,shouldShowAnswerError:this.shouldShowAnswerError,answerErrorMessage:this.answerErrorMessage,locationSearchEnabled:this.locationSearchEnabled,locationSearchDistanceEnabled:this.locationSearchDistanceEnabled,locationSearchDistanceValues:this.locationSearchDistanceValues,shouldShowLocationDistanceDropdown:this.shouldShowLocationDistanceDropdown,locationError:this.locationError}}get trackingData(){return{searchTerm:this.searchTerm,trackApiKey:this.dataLayer.searchstaxConfig?.trackApiKey??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:this.dataLayer.searchResultsMetadata?.recordsPerPageValue??0,totalResults:this.dataLayer.searchResultsMetadata?.totalResultsValue??0,currentPage:this.dataLayer.currentPage,latencyVal:this.dataLayer.searchResultsMetadata?.latency??0,...this.dataLayer.model?{model:this.dataLayer.model}:{}}}}class oe{static deepEqual(e,t){const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(const i of s){const r=e[i],o=t[i],c=this.isObject(r)&&this.isObject(o);if(c&&!this.deepEqual(r,o)||!c&&r!==o)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class M{value;observers={};constructor(e){this.value=e,this.observers={}}subscribe(e,t){const s=Math.random().toString(36).substring(2,15),a=t||s;return this.observers[a]=e,e(this.value),a}unsubscribe(e){this.observers[e]&&delete this.observers[e]}subscribeOnce(e){const t=Math.random().toString(36).substring(2,15),s=a=>{e(a),this.unsubscribe(t)};this.subscribe(s,t)}subscribeTwice(e){const t=Math.random().toString(36).substring(2,15);let s=0;const a=i=>{s++,e(i),s>=2&&this.unsubscribe(t)};this.subscribe(a,t)}subscribeUntil(e,t,s=6e3,a=!0){const i=Math.random().toString(36).substring(2,15),r=o=>{o===t&&(e(o),this.unsubscribe(i))};return this.value===t?(e(this.value),null):(this.subscribe(r,i),setTimeout(()=>{a&&this.observers[i]&&e(this.value),this.unsubscribe(i)},s),i)}subscribeUntilHasValue(e,t=6e3,s=!0){const a=Math.random().toString(36).substring(2,15),i=r=>{r!=null&&(e(r),this.unsubscribe(a))};return this.value!==null&&this.value!==void 0?(e(this.value),null):(this.subscribe(i,a),t>0&&setTimeout(()=>{s&&this.observers[a]&&e(this.value),this.unsubscribe(a)},t),i)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){for(const e in this.observers)if(Object.prototype.hasOwnProperty.call(this.observers,e)){const t=this.observers[e];typeof t=="function"&&t(this.value)}}}class Jt{static getOrSetCookie(e,t){let s=this.getCookie(e);return s==null&&(s=t??this.makeid(25),this.setCookie(e,s,{secure:!0,"max-age":3600})),s}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=s.length;for(let i=0;i<e;i++)t+=s.charAt(Math.floor(Math.random()*a));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,s){const a={path:"/",...s};s.expires instanceof Date&&(a.expires=s.expires.toUTCString());let i=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const r in a){i+="; "+r;const o=a[r];o!==!0&&(i+="="+o)}typeof document<"u"&&(document.cookie=i)}}class H{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 Ji{$searchTermChange=new M("");$searchLocationChange=new M("");$searchLocationCoordinatesDecoded=new M("");$searchLatChange=new M("");$searchLongChange=new M("");$searchRadiusChange=new M(void 0);$loadingChange=new M(!1);$locationError=new M(!1);$searchResults=new M(null);$searchResultsMetadata=new M(null);$searchAutosuggest=new M(null);$searchFacets=new M(null);$searchFacetsCached=new M(null);$searchFacetsCachedTabs=new M(null);$searchstaxConfig=new M(null);$autosuggestResults=new M(null);$itemsPerPage=new M(void 0);$searchObject=new M({query:"",itemsPerPage:void 0,page:99999999,order:"",facets:[],additionalProps:[],location:{term:void 0,radius:void 0,lat:void 0,lon:void 0},model:""});$searchRelatedSearches=new M(null);$searchInputConfig=new M(null);$searchLocationConfig=new M(null);$searchExternalPromotions=new M(null);$facetsTemplateData=new M(null);$selectedFacetsTemplateData=new M(null);$paginationData=new M(null);$answerData=new M(null);$searchFeedbackData=new M(null);$inputWidgetTemplateData=new M(null);$locationWidgetTemplateData=new M(null);$searchSortingData=new M(null);$searchRelatedSearchesData=new M(null);$searchExternalPromotionsData=new M(null);$cookiesDisabled=new M(null);$locationDecodingLoading=new M(!1);$answer=new M("");$language=new M("en");$model=new M("");$answerLoading=new M(!1);$locationEnabled=new M(null);$answerError=new M(!1);$answerErrorMessage=new M("");$isQuestion=new M(!1);$inputTemplateRendered=new M(!1);currentPageValue=1;isAnswerWidgetCreatedValue=!1;renderingEngineValue=N.mustache;parsedData=new Yi(this);sessionId;sessionIdValue=null;autoCorrect=!0;forceNotCorrect=!1;lastSearchValue="";turnAIAnswerGenerationOn=!1;questionURL="";isInfiniteScroll=!1;firstSearchHappened=!1;facetsWereSet=!1;answerWidgetShowMoreLimit=100;searchHelper;searchResultUnparsed;constructor(e,t){this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,Jt.deleteCookie(this.sessionId),Jt.deleteCookie("ms_visitorid")):this.sessionIdValue=Jt.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(H.removeXSSRiskyTags(e))}setSearchLocation(e){this.$searchLocationChange.setValue(H.removeXSSRiskyTags(e))}setSearchRadius(e){this.$searchRadiusChange.setValue(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,(!oe.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){oe.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){let t=e;t={...t,itemsPerPage:this.itemsPerPage,model:this.model},this.searchstaxConfig?.hooks?.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!oe.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&(this.searchObject.itemsPerPage!==t.itemsPerPage&&t.itemsPerPage!==void 0&&this.setItemsPerPage(t.itemsPerPage),this.$searchObject.setValue(t))}setSearchFacets(e){this.facetsWereSet=!0,oe.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){oe.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchFacetsCachedTabs(e){oe.deepEqual(e,this.searchFacetsCachedTabs??[])||this.$searchFacetsCachedTabs.setValue(e)}setSearchRelatedSearches(e){oe.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){oe.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setModel(e){this.$model.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setSearchLocationConfig(e){this.$searchLocationConfig.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)}setAnswerFullData(e){this.$answerData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}setAnswerLoading(e){this.$answerLoading.setValue(e)}setAnswerError(e){this.$answerError.setValue(e)}setIsQuestion(e){this.$isQuestion.setValue(e)}setAnswerErrorMessage(e){this.$answerErrorMessage.setValue(e)}setLocationDecodingLoading(e){this.$locationDecodingLoading.setValue(e)}setSearchLat(e){this.$searchLatChange.setValue(e)}setSearchLong(e){this.$searchLongChange.setValue(e)}setInputTemplateRendered(e){this.$inputTemplateRendered.setValue(e)}setLocationError(e){this.$locationError.setValue(e)}setInputWidgetTemplateData(e){this.$inputWidgetTemplateData.setValue(e)}setLocationWidgetTemplateData(e){this.$locationWidgetTemplateData.setValue(e)}setLocationCoordinatesDecoded(e){this.$searchLocationCoordinatesDecoded.setValue(H.removeXSSRiskyTags(e))}setLocationEnabled(e){this.$locationEnabled.setValue(e)}setSearchResultUnparsedData(e){this.searchResultUnparsed=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 searchFacetsCachedTabs(){return this.$searchFacetsCachedTabs.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCachedTabs.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get searchLocation(){return this.$searchLocationChange.getValue()}get searchRadius(){return this.$searchRadiusChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get model(){return this.$model.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get searchLocationConfig(){return this.$searchLocationConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}get answerFullData(){return this.$answerData.getValue()}get answerLoading(){return this.$answerLoading.getValue()}get isQuestion(){return this.$isQuestion.getValue()}get answerError(){return this.$answerError.getValue()}get answerErrorMessage(){return this.$answerErrorMessage.getValue()}get locationDecodingLoading(){return this.$locationDecodingLoading.getValue()}get searchLat(){return this.$searchLatChange.getValue()}get searchLong(){return this.$searchLongChange.getValue()}get inputTemplateRendered(){return this.$inputTemplateRendered.getValue()}get locationError(){return this.$locationError.getValue()}get inputWidgetTemplateData(){return this.$inputWidgetTemplateData.getValue()}get locationWidgetTemplateData(){return this.$locationWidgetTemplateData.getValue()}get searchLocationCoordinatesDecoded(){return this.$searchLocationCoordinatesDecoded.getValue()}get locationEnabled(){return this.$locationEnabled.getValue()}get searchResultUnparsedData(){return this.searchResultUnparsed}}class tt{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,i)=>{const r=a[e.responseHeader.params.uniqueId]??"",o={custom:null,uniqueId:r,position:s+1+i,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e,r):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e,r):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e,r):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,r):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,r,!0):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e,r):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e,r):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e,r):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e,r):null,distance:this.doesMapExist("distance",e)&&this.getValueByKey("distance",a,e,r)!=="Infinity"&&this.getValueByKey("distance",a,e,r)?Math.floor(this.getValueByKey("distance",a,e,r)):null,unit:e.metadata.locationSearch?.unit??"",unmappedFields:this.getUnmappedFields(a,e,r),allFields:this.getAllFields(a,e)};t.push(o)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const s of e.metadata.facets){let a={values:[]};if(a.name=s.name,a.label=s.label,s.name in e.facet_counts.facet_fields){const i=e.facet_counts.facet_fields[s.name];for(let r=0;r<i.length;r+=2){const o={};o.value=i[r],o.parentName=a.name,o.count=i[r+1],o.type="checkbox",a.values.push(o)}}a.values.length>0&&t.push(a)}return t}static extractSearchResultsMetadata(e){let t="",s={selectedSortOption:"",options:[]},a={enabled:!1,field:"",unit:"",filter:{enabled:!1,values:[],label:"",defaultValue:""}};if(e.metadata.locationSearch&&(a={enabled:e.metadata.locationSearch.enabled,field:e.metadata.locationSearch.field,unit:e.metadata.locationSearch.unit,filter:{enabled:e.metadata.locationSearch.filter?.enabled??!1,values:e.metadata.locationSearch.filter?.values??[],label:e.metadata.locationSearch.filter?.label??"",defaultValue:e.metadata.locationSearch.filter?.defaultValue??""}}),e.metadata.results.find(i=>i.result_card==="date")?.name,s.options=[],e.metadata.sorts?.length){const i=e.metadata.sorts.map(r=>({value:r.label,key:r.name+" "+r.order}));s.options=[{key:"",value:"Relevance"},...i]}return t=e?.spellcheck?.suggestions?.[1]?.suggestion?.[0]??"",typeof t!="string"&&(t=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,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:s,location:a,isLocationMapped:this.doesMapExist("distance",e)}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const i=s[a],r={};r.cDocId=this.getDataForAnalytics(i.uniqueId),i.title&&(r.cDocTitle=this.getDataForAnalytics(i.titleTracking)),r.position=i.position,t.push(r)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(s=>s.uniqueId===e)??null}static getUnmappedFields(e,t,s){const a=t.metadata.results.filter(r=>r.result_card==="").map(r=>r.name),i=[];for(const r of a)if(Object.keys(e).includes(r)){const o=Array.isArray(e[r])?this.getHighlightedResults(r,e[r].join(", "),s,t):this.getHighlightedResults(r,e[r]+"",s,t);i.push({key:r,value:o,isImage:this.checkIfImage(e[r])})}return i}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(i=>i.name),a=[];for(const i of Object.keys(e))s.indexOf(i)!==-1&&a.push({key:i,value:e[i],isImage:this.checkIfImage(e[i])});return a}static doesMapExist(e,t){return t.metadata.results.find(s=>s.result_card===e)!==void 0}static getValueByKey(e,t,s,a,i=!1){const r=s.metadata.results.find(c=>c.result_card===e);if(r===void 0)return null;const o=t[r.name];return o===void 0?null:typeof o=="string"?i?o:this.getHighlightedResults(r.name,o,a,s):typeof o=="number"?o:Array.isArray(o)?i?o.join(", "):this.getHighlightedResults(r.name,o.join(", "),a,s):null}static getHighlightedResults(e,t,s,a){if(a.highlighting&&s in a.highlighting){let i=a.highlighting[s];if(i&&e in i){let r=i[e];const o=this.cleanValue(r);if(o!=="")return o}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class ns{routeName="searchstax";ignoredKeys=[];queryStringHelper;titleParser;constructor(e){e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new Gi(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=typeof document<"u"?document?.title:"";this.titleParser&&(s=this.titleParser(e)),typeof document<"u"&&(document.title=s),window?.location.href!==t&&window?.history.replaceState(window.history.state,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.itemsPerPage&&e.itemsPerPage!==10&&(t[this.routeName+"[itemsPerPage]"]=e.itemsPerPage+""),e.location)for(const a in e.location){const i=e.location[a];i&&(t[this.routeName+`[location][${a}]`]=i)}if(e.facets)for(const a in e.facets){const i=e.facets[a].type+":"+encodeURIComponent(e.facets[a].name)+":"+encodeURIComponent(e.facets[a].value);t[this.routeName+`[facets][${a}]`]=i}if(e.model&&(t[this.routeName+"[model]"]=e.model),this.queryStringHelper.urlHasQueryParams(window?.location.href??"")){const a=this.queryStringHelper.urlToParams(window?.location.href??"");for(const i in a)i.startsWith(this.routeName)&&delete a[i];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){const t=[];for(const s in e)if(s.startsWith(this.routeName+"[facets]")){const a=H.removeXSSRiskyTags(e[s].split(":")?.[0]),i=H.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[1])),r=H.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[2]));t.push({type:a,name:i,value:r})}return t}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=H.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),i=parseInt(a),r=isNaN(i)?1:i;let o=parseInt(H.removeXSSRiskyTags(s[this.routeName+"[itemsPerPage]"]));return isNaN(o)&&(o=10),{query:H.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:r,itemsPerPage:t??o,order:H.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[],model:H.removeXSSRiskyTags(s[this.routeName+"[model]"])||"",location:{address:H.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][address]"]||"")),radius:H.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][radius]"]||"")),lat:H.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lat]"]||"")),lon:H.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lon]"]||""))}}}}class Gi{routeName="";constructor(e){this.routeName=e}stringify=(e,t)=>{const s=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(s).map(a=>{const i=s[a];return Array.isArray(i)?i.map(r=>`${a}=${r}`).join("&"):`${a}=${i}`}).join("&")};filterOutIgnoredKeys(e,t){const s=t||[],a={};return Object.keys(e).forEach(i=>{s.includes(i)||e[i]!==""&&(a[i]=e[i])}),a}urlToParams(e){const t={},s=e.split("?")[1];return s&&s.split("&").forEach(a=>{const[i,r]=a.split("=");t[i]=r}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const Ne={question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class rs extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const os=10,Zi=13,ke=32;function Gt(n){}function Ki(n){if(typeof n=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=Gt,onError:t=Gt,onRetry:s=Gt,onComment:a}=n,i=[];let r=!0,o,c="",h=0,d;function C(p){if(r&&(r=!1,p.charCodeAt(0)===239&&p.charCodeAt(1)===187&&p.charCodeAt(2)===191&&(p=p.slice(3))),i.length===0){const T=y(p);T!==""&&i.push(T);return}if(p.indexOf(`
|
|
58
|
-
`)===-1&&p.indexOf("\r")===-1){i.push(p);return}i.push(p);const g=i.join("");i.length=0;const w=y(g);w!==""&&i.push(w)}function y(p){let g=0;if(p.indexOf("\r")===-1){let w=p.indexOf(`
|
|
59
|
-
|
|
60
|
-
`,g);
|
|
61
|
-
`,g);continue}
|
|
62
|
-
|
|
63
|
-
`,
|
|
64
|
-
`,g)
|
|
65
|
-
|
|
66
|
-
${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.test(g)?s(parseInt(g,10)):t(new rs(`Invalid \`retry\` value: "${g}"`,{type:"invalid-retry",value:g,line:w}));break;default:t(new rs(`Unknown field "${p.length>20?`${p.slice(0,20)}…`:p}"`,{type:"unknown-field",field:p,value:g,line:w}));break}}function x(){h>0&&e({id:o,event:d,data:c}),o=void 0,c="",h=0,d=void 0}function Q(p={}){if(p.consume&&i.length>0){const g=i.join("");I(g,0,g.length)}r=!0,o=void 0,c="",h=0,d=void 0,i.length=0}return{feed:C,reset:Q}}function ls(n,e,t){return t===100&&n.charCodeAt(e+1)===97&&n.charCodeAt(e+2)===116&&n.charCodeAt(e+3)===97&&n.charCodeAt(e+4)===58}function cs(n,e,t){return t===101&&n.charCodeAt(e+1)===118&&n.charCodeAt(e+2)===101&&n.charCodeAt(e+3)===110&&n.charCodeAt(e+4)===116&&n.charCodeAt(e+5)===58}class hs extends Event{constructor(e,t){var s,a;super(e),this.code=(s=t?.code)!=null?s:void 0,this.message=(a=t?.message)!=null?a:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,t,s){return s(us(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(us(this),t)}}function Xi(n){const e=globalThis.DOMException;return typeof e=="function"?new e(n,"SyntaxError"):new SyntaxError(n)}function Zt(n){return n instanceof Error?"errors"in n&&Array.isArray(n.errors)?n.errors.map(Zt).join(", "):"cause"in n&&n.cause instanceof Error?`${n}: ${Zt(n.cause)}`:n.message:`${n}`}function us(n){return{type:n.type,message:n.message,code:n.code,defaultPrevented:n.defaultPrevented,cancelable:n.cancelable,timeStamp:n.timeStamp}}var ds=n=>{throw TypeError(n)},Kt=(n,e,t)=>e.has(n)||ds("Cannot "+t),k=(n,e,t)=>(Kt(n,e,"read from private field"),t?t.call(n):e.get(n)),$=(n,e,t)=>e.has(n)?ds("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),j=(n,e,t,s)=>(Kt(n,e,"write to private field"),e.set(n,t),t),ye=(n,e,t)=>(Kt(n,e,"access private method"),t),se,Ae,Pe,Mt,bt,at,Oe,st,Me,_e,Fe,ze,it,ce,Xt,ea,ta,gs,aa,sa,nt,ia,na;class Tt extends EventTarget{constructor(e,t){var s,a;super(),$(this,ce),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,$(this,se),$(this,Ae),$(this,Pe),$(this,Mt),$(this,bt),$(this,at),$(this,Oe),$(this,st,null),$(this,Me),$(this,_e),$(this,Fe,null),$(this,ze,null),$(this,it,null),$(this,ea,async i=>{var r;k(this,_e).reset();const{body:o,redirected:c,status:h,headers:d}=i;if(h===204){ye(this,ce,nt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?j(this,Pe,new URL(i.url)):j(this,Pe,void 0),h!==200){ye(this,ce,nt).call(this,`Non-200 status code (${h})`,h);return}if(!(d.get("content-type")||"").startsWith("text/event-stream")){ye(this,ce,nt).call(this,'Invalid content type, expected "text/event-stream"',h);return}if(k(this,se)===this.CLOSED)return;j(this,se,this.OPEN);const C=new Event("open");if((r=k(this,it))==null||r.call(this,C),this.dispatchEvent(C),typeof o!="object"||!o||!("getReader"in o)){ye(this,ce,nt).call(this,"Invalid response body, expected a web ReadableStream",h),this.close();return}const y=new TextDecoder,I=o.getReader();let S=!0;do{const{done:x,value:Q}=await I.read();Q&&k(this,_e).feed(y.decode(Q,{stream:!x})),x&&(S=!1,k(this,_e).reset(),ye(this,ce,ia).call(this))}while(S)}),$(this,ta,i=>{j(this,Me,void 0),!(i.name==="AbortError"||i.type==="aborted")&&ye(this,ce,ia).call(this,Zt(i))}),$(this,aa,i=>{typeof i.id=="string"&&j(this,st,i.id);const r=new MessageEvent(i.event||"message",{data:i.data,origin:k(this,Pe)?k(this,Pe).origin:k(this,Ae).origin,lastEventId:i.id||""});k(this,ze)&&(!i.event||i.event==="message")&&k(this,ze).call(this,r),this.dispatchEvent(r)}),$(this,sa,i=>{j(this,at,i)}),$(this,na,()=>{j(this,Oe,void 0),k(this,se)===this.CONNECTING&&ye(this,ce,Xt).call(this)});try{if(e instanceof URL)j(this,Ae,e);else if(typeof e=="string")j(this,Ae,new URL(e,en()));else throw new Error("Invalid URL")}catch{throw Xi("An invalid or illegal string was specified")}j(this,_e,Ki({onEvent:k(this,aa),onRetry:k(this,sa)})),j(this,se,this.CONNECTING),j(this,at,3e3),j(this,bt,(s=t?.fetch)!=null?s:globalThis.fetch),j(this,Mt,(a=t?.withCredentials)!=null?a:!1),ye(this,ce,Xt).call(this)}get readyState(){return k(this,se)}get url(){return k(this,Ae).href}get withCredentials(){return k(this,Mt)}get onerror(){return k(this,Fe)}set onerror(e){j(this,Fe,e)}get onmessage(){return k(this,ze)}set onmessage(e){j(this,ze,e)}get onopen(){return k(this,it)}set onopen(e){j(this,it,e)}addEventListener(e,t,s){const a=t;super.addEventListener(e,a,s)}removeEventListener(e,t,s){const a=t;super.removeEventListener(e,a,s)}close(){k(this,Oe)&&clearTimeout(k(this,Oe)),k(this,se)!==this.CLOSED&&(k(this,Me)&&k(this,Me).abort(),j(this,se,this.CLOSED),j(this,Me,void 0))}}se=new WeakMap,Ae=new WeakMap,Pe=new WeakMap,Mt=new WeakMap,bt=new WeakMap,at=new WeakMap,Oe=new WeakMap,st=new WeakMap,Me=new WeakMap,_e=new WeakMap,Fe=new WeakMap,ze=new WeakMap,it=new WeakMap,ce=new WeakSet,Xt=function(){j(this,se,this.CONNECTING),j(this,Me,new AbortController),k(this,bt)(k(this,Ae),ye(this,ce,gs).call(this)).then(k(this,ea)).catch(k(this,ta))},ea=new WeakMap,ta=new WeakMap,gs=function(){var n;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...k(this,st)?{"Last-Event-ID":k(this,st)}:void 0},cache:"no-store",signal:(n=k(this,Me))==null?void 0:n.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},aa=new WeakMap,sa=new WeakMap,nt=function(n,e){var t;k(this,se)!==this.CLOSED&&j(this,se,this.CLOSED);const s=new hs("error",{code:e,message:n});(t=k(this,Fe))==null||t.call(this,s),this.dispatchEvent(s)},ia=function(n,e){var t;if(k(this,se)===this.CLOSED)return;j(this,se,this.CONNECTING);const s=new hs("error",{code:e,message:n});(t=k(this,Fe))==null||t.call(this,s),this.dispatchEvent(s),j(this,Oe,setTimeout(k(this,na),k(this,at)))},na=new WeakMap,Tt.CONNECTING=0,Tt.OPEN=1,Tt.CLOSED=2;function en(){const n="document"in globalThis?globalThis.document:void 0;return n&&typeof n=="object"&&"baseURI"in n&&typeof n.baseURI=="string"?n.baseURI:void 0}class we{static subscribedToClickEvent=!1;static attachAnalyticsScript(e){window._msq=window._msq||[];const s=e||"https://static.searchstax.com/studio-js/v4/js/studio-analytics.js";if(!document.querySelector(`script[src="${s}"]`)){var i=document.createElement("script");i.type="text/javascript",i.src=s;var r=document.getElementsByTagName("script")[0];r.parentNode&&r.parentNode.insertBefore(i,r)}}static msq=()=>typeof window<"u"&&window?._msq?window?._msq:[];static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language,model:e.model};return new Promise((s,a)=>{const i=["trackClick",t];t.key?this.msq().push(i,(function(r,o){JSON.stringify(r)===JSON.stringify(t)&&o?s():a()}).bind(this)):a()})}static trackAnswerLinkClick(e){const t={key:e.trackApiKey,question:e.searchTerm,session:e.session,href:e.href,language:e.language,model:e.model,answer:e.answer};return new Promise((s,a)=>{const i=["answerSourceClick",t];t.key?this.msq().push(i,(function(r,o){JSON.stringify(r)===JSON.stringify(t)&&o?s():a()}).bind(this)):a()})}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,model:e.model,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:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches,language:e.language,model:e.model};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,latency:e.latencyVal,language:e.language,model:e.model,impressions:e.impressions,pageNo:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}static trackAnswerData(e){const t={session:e.session,key:e.trackApiKey,question:e.searchTerm,answer:e.answer,language:e.language,model:e.model,is_question:e.isQuestion+""};setTimeout(()=>{t.key&&this.msq().push(["trackquestionanswer",t])},0)}static trackFeedback(e){setTimeout(()=>{this.msq().push(["trackSearchSatisfaction",{key:e.trackApiKey,email:e.email,score:e.rating,comments:e.feedback,language:e.language,model:e.model}])},0)}}class tn{cachedQuery="";cachedANDFacets="";url="";relatedSearches="";suggester="";authHeader;authHeaderRelated;trackApiKey="";session="";searchAuthType;searchAuth="";controllerSearch;signalSearch;controllerSuggest;signalSuggest;_authToken="";resolveFn;dataLayer;constructor(e,t){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"),this._authToken=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`,this.authHeader.append("Authorization",this._authToken),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 i=a.name+':"'+a.value+'"';s=s.concat("fq="+decodeURIComponent(i).replace(" "," "))});else{const a={};e.forEach(function(r){const o=r.name+":"+r.value,c=decodeURIComponent(o).replace(" "," ").split(":");a[c[0]]?a[c[0]].push(c[1]):a[c[0]]=[c[1]]});let i="";for(const r in a)if(Object.prototype.hasOwnProperty.call(a,r)){const o=a[r],c=r;for(const h of o)i+=i===""?` ${c}:"${h}"`:` OR ${c}:"${h}"`}s=s.concat("fq="+i.trim())}return s=s.map(a=>a.replace(/&/g,"%26").replace(/\+/g,"%2B")),s.length?"&"+s.join("&"):""}generateLocationQuery(e){let t="";if(e.lat&&e.lon){const s=Math.floor(parseFloat(e.lat)*100)/100,a=Math.floor(parseFloat(e.lon)*100)/100;t+=`&pt=${s},${a}`}return e.radius&&t!==""&&e.radius!=="any"&&(t+=`&distanceFilter=${e.radius}`),t}getRelatedSearches(e,t,s,a){const i=new Headers;i.append("Accept","application/json"),i.append("Authorization",s),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:i,credentials:"same-origin"}).then(r=>r.json()).then(r=>{a(r)})}cacheFacets(e){return new Promise(t=>{if(this.resolveFn=t,this.dataLayer.searchObject.query!==this.cachedQuery||this.cachedANDFacets+e!==this.dataLayer.parsedData.cachedANDFacets+e){this.cachedANDFacets=this.dataLayer.parsedData.cachedANDFacets+e,this.cachedQuery=this.dataLayer.searchObject.query;const s=[this.dataLayer.searchObject.facets.filter(a=>e?!1:a.type==="and"||a.type==="tabs")].flat();this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:s,additionalProps:this.dataLayer.searchObject.additionalProps,location:this.dataLayer.searchObject.location,model:this.dataLayer.model},this.cacheFacetsCallback.bind(this),!0,!1,e)}else this.resolveFn()})}cacheFacetsCallback(e,t){let s=tt.extractFacets(e);t?this.dataLayer.setSearchFacetsCachedTabs(s):this.dataLayer.setSearchFacetsCached(s),this.resolveFn&&this.resolveFn()}search(e,t,s=!1,a=!1,i=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=this.url+this.generateQueryParams(e,a),o={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete o.signal,fetch(r,o).then(c=>c.json()).then(c=>{this.dataLayer.setLoading(!1),t(c,i)}).catch(()=>{this.dataLayer.setLoading(!1)})}}generateQueryParams(e,t){let s=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),a=e.order?`&sort=${e.order}`:"";const i=e.itemsPerPage!==void 0?`&rows=${e.itemsPerPage}`:"",r=new Proxy(new URLSearchParams(window?.location.search??""),{get:(h,d)=>h.get(d)??""}),o=r.languageVariant?"&fq=_language:"+r.languageVariant:"",c=e.model??this.dataLayer.model;return"?q="+encodeURIComponent(e.query.trim())+"&start="+s+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(h=>h.type==="or"||h.type==="showUnavailable"),!0)+this.generateLocationQuery(e.location)+this.generateFacetQuery(e.facets.filter(h=>h.type==="and"||h.type==="tabs"),!1)+a+i+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!t}`+(c?`&model=${c}`:"")+"&language="+this.dataLayer.language+o}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.searchObject.page!==1)return;const s=new Tt(this.dataLayer.questionURL+this.generateQueryParams(this.dataLayer.searchObject),{fetch:(i,r)=>fetch(i,{...r,headers:{...r?.headers,Authorization:this._authToken}})}),a=this.dataLayer;return s.onmessage=i=>{if(i.data===Ne.question||i.data===Ne.notQuestion){i.data===Ne.question?(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setIsQuestion(!0)):(a.setAnswerLoading(!1),this.dataLayer.setIsQuestion(!1)),a.setAnswerData("");return}if(i.data===Ne.close){we.trackAnswerData({...a.parsedData.trackingData,answer:a.$answer.getValue(),isQuestion:this.dataLayer.isQuestion}),a.setAnswerLoading(!1),s.close();return}if(i.data.indexOf("[!CAUTION]")!==-1){a.setAnswerError(!0),a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),s.close();return}if(i.data.indexOf("[comment]: <> ({")!==-1)try{const r=i.data.split("[comment]: <> ({");if(r.length<2){t(i.data);return}const o=r[1].split("})");if(o.length<2){t(i.data);return}const c=o[0],h=JSON.parse("{"+c+"}");this.dataLayer.answerWidgetShowMoreLimit=h.displayShowMoreAfter,h.showMoreEnabled||(this.dataLayer.answerWidgetShowMoreLimit=1e17);const d=o.slice(1).join("})");t(d)}catch{t(i.data)}else t(i.data)},s.addEventListener("error",i=>{(i.code===401||i.code===500)&&(a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),a.setAnswerError(!0))}),s.onerror=()=>{a.setAnswerLoading(!1),s.close()},s}suggest(e,t,s){if(this.controllerSuggest&&this.controllerSuggest.abort(),this.suggester.trim()==="")return;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(i=>i.json()).then(i=>{t(i)}).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("&")}}var an=Object.prototype.toString,$e=Array.isArray||function(e){return an.call(e)==="[object Array]"};function ra(n){return typeof n=="function"}function sn(n){return $e(n)?"array":typeof n}function oa(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function ps(n,e){return n!=null&&typeof n=="object"&&e in n}function nn(n,e){return n!=null&&typeof n!="object"&&n.hasOwnProperty&&n.hasOwnProperty(e)}var rn=RegExp.prototype.test;function on(n,e){return rn.call(n,e)}var ln=/\S/;function cn(n){return!on(ln,n)}var hn={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function un(n){return String(n).replace(/[&<>"'`=\/]/g,function(t){return hn[t]})}var dn=/\s*/,gn=/\s+/,fs=/\s*=/,pn=/\s*\}/,fn=/#|\^|\/|>|\{|&|=|!/;function mn(n,e){if(!n)return[];var t=!1,s=[],a=[],i=[],r=!1,o=!1,c="",h=0;function d(){if(r&&!o)for(;i.length;)delete a[i.pop()];else i=[];r=!1,o=!1}var C,y,I;function S(ne){if(typeof ne=="string"&&(ne=ne.split(gn,2)),!$e(ne)||ne.length!==2)throw new Error("Invalid tags: "+ne);C=new RegExp(oa(ne[0])+"\\s*"),y=new RegExp("\\s*"+oa(ne[1])),I=new RegExp("\\s*"+oa("}"+ne[1]))}S(e||A.tags);for(var x=new rt(n),Q,p,g,w,T,E;!x.eos();){if(Q=x.pos,g=x.scanUntil(C),g)for(var F=0,he=g.length;F<he;++F)w=g.charAt(F),cn(w)?(i.push(a.length),c+=w):(o=!0,t=!0,c+=" "),a.push(["text",w,Q,Q+1]),Q+=1,w===`
|
|
67
|
-
`&&(d(),c="",h=0,t=!1);if(!x.scan(C))break;if(r=!0,p=x.scan(fn)||"name",x.scan(dn),p==="="?(g=x.scanUntil(fs),x.scan(fs),x.scanUntil(y)):p==="{"?(g=x.scanUntil(I),x.scan(pn),x.scanUntil(y),p="&"):g=x.scanUntil(y),!x.scan(y))throw new Error("Unclosed tag at "+x.pos);if(p==">"?T=[p,g,Q,x.pos,c,h,t]:T=[p,g,Q,x.pos],h++,a.push(T),p==="#"||p==="^")s.push(T);else if(p==="/"){if(E=s.pop(),!E)throw new Error('Unopened section "'+g+'" at '+Q);if(E[1]!==g)throw new Error('Unclosed section "'+E[1]+'" at '+Q)}else p==="name"||p==="{"||p==="&"?o=!0:p==="="&&S(g)}if(d(),E=s.pop(),E)throw new Error('Unclosed section "'+E[1]+'" at '+x.pos);return yn(Ln(a))}function Ln(n){for(var e=[],t,s,a=0,i=n.length;a<i;++a)t=n[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 yn(n){for(var e=[],t=e,s=[],a,i,r=0,o=n.length;r<o;++r)switch(a=n[r],a[0]){case"#":case"^":t.push(a),s.push(a),t=a[4]=[];break;case"/":i=s.pop(),i[5]=a[2],t=s.length>0?s[s.length-1][4]:e;break;default:t.push(a)}return e}function rt(n){this.string=n,this.tail=n,this.pos=0}rt.prototype.eos=function(){return this.tail===""},rt.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},rt.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 Ve(n,e){this.view=n,this.cache={".":this.view},this.parent=e}Ve.prototype.push=function(e){return new Ve(e,this)},Ve.prototype.lookup=function(e){var t=this.cache,s;if(t.hasOwnProperty(e))s=t[e];else{for(var a=this,i,r,o,c=!1;a;){if(e.indexOf(".")>0)for(i=a.view,r=e.split("."),o=0;i!=null&&o<r.length;)o===r.length-1&&(c=ps(i,r[o])||nn(i,r[o])),i=i[r[o++]];else i=a.view[e],c=ps(a.view,e);if(c){s=i;break}a=a.parent}t[e]=s}return ra(s)&&(s=s.call(this.view)),s};function te(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}te.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()},te.prototype.parse=function(e,t){var s=this.templateCache,a=e+":"+(t||A.tags).join(":"),i=typeof s<"u",r=i?s.get(a):void 0;return r==null&&(r=mn(e,t),i&&s.set(a,r)),r},te.prototype.render=function(e,t,s,a){var i=this.getConfigTags(a),r=this.parse(e,i),o=t instanceof Ve?t:new Ve(t,void 0);return this.renderTokens(r,o,s,e,a)},te.prototype.renderTokens=function(e,t,s,a,i){for(var r="",o,c,h,d=0,C=e.length;d<C;++d)h=void 0,o=e[d],c=o[0],c==="#"?h=this.renderSection(o,t,s,a,i):c==="^"?h=this.renderInverted(o,t,s,a,i):c===">"?h=this.renderPartial(o,t,s,i):c==="&"?h=this.unescapedValue(o,t):c==="name"?h=this.escapedValue(o,t,i):c==="text"&&(h=this.rawValue(o)),h!==void 0&&(r+=h);return r},te.prototype.renderSection=function(e,t,s,a,i){var r=this,o="",c=t.lookup(e[1]);function h(y){return r.render(y,t,s,i)}if(c){if($e(c))for(var d=0,C=c.length;d<C;++d)o+=this.renderTokens(e[4],t.push(c[d]),s,a,i);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")o+=this.renderTokens(e[4],t.push(c),s,a,i);else if(ra(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]),h),c!=null&&(o+=c)}else o+=this.renderTokens(e[4],t,s,a,i);return o}},te.prototype.renderInverted=function(e,t,s,a,i){var r=t.lookup(e[1]);if(!r||$e(r)&&r.length===0)return this.renderTokens(e[4],t,s,a,i)},te.prototype.indentPartial=function(e,t,s){for(var a=t.replace(/[^ \t]/g,""),i=e.split(`
|
|
68
|
-
|
|
69
|
-
`)
|
|
50
|
+
`+a+`</table>
|
|
51
|
+
`}tablerow({text:i}){return`<tr>
|
|
52
|
+
${i}</tr>
|
|
53
|
+
`}tablecell(i){const e=this.parser.parseInline(i.tokens),t=i.header?"th":"td";return(i.align?`<${t} align="${i.align}">`:`<${t}>`)+e+`</${t}>
|
|
54
|
+
`}strong({tokens:i}){return`<strong>${this.parser.parseInline(i)}</strong>`}em({tokens:i}){return`<em>${this.parser.parseInline(i)}</em>`}codespan({text:i}){return`<code>${pe(i,!0)}</code>`}br(i){return"<br>"}del({tokens:i}){return`<del>${this.parser.parseInline(i)}</del>`}link({href:i,title:e,tokens:t}){const a=this.parser.parseInline(t),s=Ya(i);if(s===null)return a;i=s;let n='<a href="'+i+'"';return e&&(n+=' title="'+pe(e)+'"'),n+=">"+a+"</a>",n}image({href:i,title:e,text:t,tokens:a}){a&&(t=this.parser.parseInline(a,this.parser.textRenderer));const s=Ya(i);if(s===null)return pe(t);i=s;let n=`<img src="${i}" alt="${t}"`;return e&&(n+=` title="${pe(e)}"`),n+=">",n}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:pe(i.text)}},Wt=class{strong({text:i}){return i}em({text:i}){return i}codespan({text:i}){return i}del({text:i}){return i}html({text:i}){return i}text({text:i}){return i}link({text:i}){return""+i}image({text:i}){return""+i}br(){return""}},be=class Ra{options;renderer;textRenderer;constructor(e){this.options=e||Ee,this.options.renderer=this.options.renderer||new bt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Wt}static parse(e,t){return new Ra(t).parse(e)}static parseInline(e,t){return new Ra(t).parseInline(e)}parse(e,t=!0){let a="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions?.renderers?.[n.type]){const o=n,c=this.options.extensions.renderers[o.type].call({parser:this},o);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){a+=c||"";continue}}const r=n;switch(r.type){case"space":{a+=this.renderer.space(r);continue}case"hr":{a+=this.renderer.hr(r);continue}case"heading":{a+=this.renderer.heading(r);continue}case"code":{a+=this.renderer.code(r);continue}case"table":{a+=this.renderer.table(r);continue}case"blockquote":{a+=this.renderer.blockquote(r);continue}case"list":{a+=this.renderer.list(r);continue}case"html":{a+=this.renderer.html(r);continue}case"paragraph":{a+=this.renderer.paragraph(r);continue}case"text":{let o=r,c=this.renderer.text(o);for(;s+1<e.length&&e[s+1].type==="text";)o=e[++s],c+=`
|
|
55
|
+
`+this.renderer.text(o);t?a+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c,escaped:!0}]}):a+=c;continue}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return a}parseInline(e,t=this.renderer){let a="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions?.renderers?.[n.type]){const o=this.options.extensions.renderers[n.type].call({parser:this},n);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type)){a+=o||"";continue}}const r=n;switch(r.type){case"escape":{a+=t.text(r);break}case"html":{a+=t.html(r);break}case"link":{a+=t.link(r);break}case"image":{a+=t.image(r);break}case"strong":{a+=t.strong(r);break}case"em":{a+=t.em(r);break}case"codespan":{a+=t.codespan(r);break}case"br":{a+=t.br(r);break}case"del":{a+=t.del(r);break}case"text":{a+=t.text(r);break}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return a}},St=class{options;block;constructor(i){this.options=i||Ee}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(i){return i}postprocess(i){return i}processAllTokens(i){return i}provideLexer(){return this.block?Me.lex:Me.lexInline}provideParser(){return this.block?be.parse:be.parseInline}},vi=class{defaults=Ft();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=be;Renderer=bt;TextRenderer=Wt;Lexer=Me;Tokenizer=Mt;Hooks=St;constructor(...i){this.use(...i)}walkTokens(i,e){let t=[];for(const a of i)switch(t=t.concat(e.call(this,a)),a.type){case"table":{const s=a;for(const n of s.header)t=t.concat(this.walkTokens(n.tokens,e));for(const n of s.rows)for(const r of n)t=t.concat(this.walkTokens(r.tokens,e));break}case"list":{const s=a;t=t.concat(this.walkTokens(s.items,e));break}default:{const s=a;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(n=>{const r=s[n].flat(1/0);t=t.concat(this.walkTokens(r,e))}):s.tokens&&(t=t.concat(this.walkTokens(s.tokens,e)))}}return t}use(...i){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return i.forEach(t=>{const a={...t};if(a.async=this.defaults.async||a.async||!1,t.extensions&&(t.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){const n=e.renderers[s.name];n?e.renderers[s.name]=function(...r){let o=s.renderer.apply(this,r);return o===!1&&(o=n.apply(this,r)),o}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const n=e[s.level];n?n.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),a.extensions=e),t.renderer){const s=this.defaults.renderer||new bt(this.defaults);for(const n in t.renderer){if(!(n in s))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;const r=n,o=t.renderer[r],c=s[r];s[r]=(...h)=>{let d=o.apply(s,h);return d===!1&&(d=c.apply(s,h)),d||""}}a.renderer=s}if(t.tokenizer){const s=this.defaults.tokenizer||new Mt(this.defaults);for(const n in t.tokenizer){if(!(n in s))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const r=n,o=t.tokenizer[r],c=s[r];s[r]=(...h)=>{let d=o.apply(s,h);return d===!1&&(d=c.apply(s,h)),d}}a.tokenizer=s}if(t.hooks){const s=this.defaults.hooks||new St;for(const n in t.hooks){if(!(n in s))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;const r=n,o=t.hooks[r],c=s[r];St.passThroughHooks.has(n)?s[r]=h=>{if(this.defaults.async)return Promise.resolve(o.call(s,h)).then(L=>c.call(s,L));const d=o.call(s,h);return c.call(s,d)}:s[r]=(...h)=>{let d=o.apply(s,h);return d===!1&&(d=c.apply(s,h)),d}}a.hooks=s}if(t.walkTokens){const s=this.defaults.walkTokens,n=t.walkTokens;a.walkTokens=function(r){let o=[];return o.push(n.call(this,r)),s&&(o=o.concat(s.call(this,r))),o}}this.defaults={...this.defaults,...a}}),this}setOptions(i){return this.defaults={...this.defaults,...i},this}lexer(i,e){return Me.lex(i,e??this.defaults)}parser(i,e){return be.parse(i,e??this.defaults)}parseMarkdown(i){return(t,a)=>{const s={...a},n={...this.defaults,...s},r=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&s.async===!1)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return r(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));n.hooks&&(n.hooks.options=n,n.hooks.block=i);const o=n.hooks?n.hooks.provideLexer():i?Me.lex:Me.lexInline,c=n.hooks?n.hooks.provideParser():i?be.parse:be.parseInline;if(n.async)return Promise.resolve(n.hooks?n.hooks.preprocess(t):t).then(h=>o(h,n)).then(h=>n.hooks?n.hooks.processAllTokens(h):h).then(h=>n.walkTokens?Promise.all(this.walkTokens(h,n.walkTokens)).then(()=>h):h).then(h=>c(h,n)).then(h=>n.hooks?n.hooks.postprocess(h):h).catch(r);try{n.hooks&&(t=n.hooks.preprocess(t));let h=o(t,n);n.hooks&&(h=n.hooks.processAllTokens(h)),n.walkTokens&&this.walkTokens(h,n.walkTokens);let d=c(h,n);return n.hooks&&(d=n.hooks.postprocess(d)),d}catch(h){return r(h)}}}onError(i,e){return t=>{if(t.message+=`
|
|
56
|
+
Please report this to https://github.com/markedjs/marked.`,i){const a="<p>An error occurred:</p><pre>"+pe(t.message+"",!0)+"</pre>";return e?Promise.resolve(a):a}if(e)return Promise.reject(t);throw t}}},ve=new vi;function I(i,e){return ve.parse(i,e)}I.options=I.setOptions=function(i){return ve.setOptions(i),I.defaults=ve.defaults,Pa(I.defaults),I},I.getDefaults=Ft,I.defaults=Ee,I.use=function(...i){return ve.use(...i),I.defaults=ve.defaults,Pa(I.defaults),I},I.walkTokens=function(i,e){return ve.walkTokens(i,e)},I.parseInline=ve.parseInline,I.Parser=be,I.parser=be.parse,I.Renderer=bt,I.TextRenderer=Wt,I.Lexer=Me,I.lexer=Me.lex,I.Tokenizer=Mt,I.Hooks=St,I.parse=I,I.options,I.setOptions,I.use,I.walkTokens,I.parseInline,be.parse,Me.lex;function Za(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,a=Array(e);t<e;t++)a[t]=i[t];return a}function Ii(i){if(Array.isArray(i))return i}function Di(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var a,s,n,r,o=[],c=!0,h=!1;try{if(n=(t=t.call(i)).next,e!==0)for(;!(c=(a=n.call(t)).done)&&(o.push(a.value),o.length!==e);c=!0);}catch(d){h=!0,s=d}finally{try{if(!c&&t.return!=null&&(r=t.return(),Object(r)!==r))return}finally{if(h)throw s}}return o}}function ji(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
57
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ri(i,e){return Ii(i)||Di(i,e)||Ni(i,e)||ji()}function Ni(i,e){if(i){if(typeof i=="string")return Za(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Za(i,e):void 0}}const Ka=Object.entries,Xa=Object.setPrototypeOf,Pi=Object.isFrozen,Oi=Object.getPrototypeOf,_i=Object.getOwnPropertyDescriptor;let ae=Object.freeze,re=Object.seal,Pe=Object.create,es=typeof Reflect<"u"&&Reflect,Yt=es.apply,Jt=es.construct;ae||(ae=function(e){return e}),re||(re=function(e){return e}),Yt||(Yt=function(e,t){for(var a=arguments.length,s=new Array(a>2?a-2:0),n=2;n<a;n++)s[n-2]=arguments[n];return e.apply(t,s)}),Jt||(Jt=function(e){for(var t=arguments.length,a=new Array(t>1?t-1:0),s=1;s<t;s++)a[s-1]=arguments[s];return new e(...a)});const Oe=q(Array.prototype.forEach),Fi=q(Array.prototype.lastIndexOf),ts=q(Array.prototype.pop),_e=q(Array.prototype.push),zi=q(Array.prototype.splice),se=Array.isArray,at=q(String.prototype.toLowerCase),Gt=q(String.prototype.toString),as=q(String.prototype.match),Fe=q(String.prototype.replace),ss=q(String.prototype.indexOf),$i=q(String.prototype.trim),Bi=q(Number.prototype.toString),Vi=q(Boolean.prototype.toString),is=typeof BigInt>"u"?null:q(BigInt.prototype.toString),ns=typeof Symbol>"u"?null:q(Symbol.prototype.toString),z=q(Object.prototype.hasOwnProperty),st=q(Object.prototype.toString),X=q(RegExp.prototype.test),it=Hi(TypeError);function q(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,a=new Array(t>1?t-1:0),s=1;s<t;s++)a[s-1]=arguments[s];return Yt(i,e,a)}}function Hi(i){return function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return Jt(i,t)}}function b(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:at;if(Xa&&Xa(i,null),!se(e))return i;let a=e.length;for(;a--;){let s=e[a];if(typeof s=="string"){const n=t(s);n!==s&&(Pi(e)||(e[a]=n),s=n)}i[s]=!0}return i}function Ui(i){for(let e=0;e<i.length;e++)z(i,e)||(i[e]=null);return i}function ee(i){const e=Pe(null);for(const a of Ka(i)){var t=Ri(a,2);const s=t[0],n=t[1];z(i,s)&&(se(n)?e[s]=Ui(n):n&&typeof n=="object"&&n.constructor===Object?e[s]=ee(n):e[s]=n)}return e}function Qi(i){switch(typeof i){case"string":return i;case"number":return Bi(i);case"boolean":return Vi(i);case"bigint":return is?is(i):"0";case"symbol":return ns?ns(i):"Symbol()";case"undefined":return st(i);case"function":case"object":{if(i===null)return st(i);const e=i,t=fe(e,"toString");if(typeof t=="function"){const a=t(e);return typeof a=="string"?a:st(a)}return st(i)}default:return st(i)}}function fe(i,e){for(;i!==null;){const a=_i(i,e);if(a){if(a.get)return q(a.get);if(typeof a.value=="function")return q(a.value)}i=Oi(i)}function t(){return null}return t}function qi(i){try{return X(i,""),!0}catch{return!1}}const rs=ae(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Zt=ae(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Kt=ae(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Wi=ae(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Xt=ae(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Yi=ae(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),os=ae(["#text"]),ls=ae(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ea=ae(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),cs=ae(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Tt=ae(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ji=re(/{{[\w\W]*|^[\w\W]*}}/g),Gi=re(/<%[\w\W]*|^[\w\W]*%>/g),Zi=re(/\${[\w\W]*/g),Ki=re(/^data-[\-\w.\u00B7-\uFFFF]+$/),Xi=re(/^aria-[\-\w]+$/),hs=re(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),en=re(/^(?:\w+script|data):/i),tn=re(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),an=re(/^html$/i),sn=re(/^[a-z][.\w]*(-[.\w]+)+$/i),me={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},nn=function(){return typeof window>"u"?null:window},rn=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let a=null;const s="data-tt-policy-suffix";t&&t.hasAttribute(s)&&(a=t.getAttribute(s));const n="dompurify"+(a?"#"+a:"");try{return e.createPolicy(n,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+n+" could not be created."),null}},us=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ds(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:nn();const e=y=>ds(y);if(e.version="3.4.7",e.removed=[],!i||!i.document||i.document.nodeType!==me.document||!i.Element)return e.isSupported=!1,e;let t=i.document;const a=t,s=a.currentScript;i.DocumentFragment;const n=i.HTMLTemplateElement,r=i.Node,o=i.Element,c=i.NodeFilter,h=i.NamedNodeMap;h===void 0&&(i.NamedNodeMap||i.MozNamedAttrMap),i.HTMLFormElement;const d=i.DOMParser,L=i.trustedTypes,m=o.prototype,R=fe(m,"cloneNode"),A=fe(m,"remove"),S=fe(m,"nextSibling"),$=fe(m,"childNodes"),j=fe(m,"parentNode"),_=fe(m,"shadowRoot"),le=fe(m,"attributes"),B=r&&r.prototype?fe(r.prototype,"nodeType"):null,p=r&&r.prototype?fe(r.prototype,"nodeName"):null;if(typeof n=="function"){const y=t.createElement("template");y.content&&y.content.ownerDocument&&(t=y.content.ownerDocument)}let g,C="";const E=t,V=E.implementation,ue=E.createNodeIterator,fa=E.createDocumentFragment,ma=E.getElementsByTagName,La=a.importNode;let N=us();e.isSupported=typeof Ka=="function"&&typeof j=="function"&&V&&V.createHTMLDocument!==void 0;const je=Ji,Et=Gi,vt=Zi,Kn=Ki,Xn=Xi,er=en,xs=tn,tr=sn;let ks=hs,H=null;const ya=b({},[...rs,...Zt,...Kt,...Xt,...os]);let W=null;const wa=b({},[...ls,...ea,...cs,...Tt]);let U=Object.seal(Pe(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),dt=null,It=null;const ke=Object.seal(Pe(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let As=!0,Ca=!0,Es=!1,vs=!0,Ae=!1,gt=!0,Re=!1,Ma=!1,ba=!1,We=!1,Dt=!1,jt=!1,Is=!0,Ds=!1;const js="user-content-";let Sa=!0,pt=!1,Ye={},ye=null;const Ta=b({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Rs=null;const Ns=b({},["audio","video","img","source","image","track"]);let xa=null;const Ps=b({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Rt="http://www.w3.org/1998/Math/MathML",Nt="http://www.w3.org/2000/svg",we="http://www.w3.org/1999/xhtml";let Je=we,ka=!1,Aa=null;const ar=b({},[Rt,Nt,we],Gt);let Ea=b({},["mi","mo","mn","ms","mtext"]),va=b({},["annotation-xml"]);const sr=b({},["title","style","font","a","script"]);let ft=null;const ir=["application/xhtml+xml","text/html"],nr="text/html";let Q=null,Ge=null;const rr=t.createElement("form"),Os=function(l){return l instanceof RegExp||l instanceof Function},Ia=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ge&&Ge===l)return;(!l||typeof l!="object")&&(l={}),l=ee(l),ft=ir.indexOf(l.PARSER_MEDIA_TYPE)===-1?nr:l.PARSER_MEDIA_TYPE,Q=ft==="application/xhtml+xml"?Gt:at,H=z(l,"ALLOWED_TAGS")&&se(l.ALLOWED_TAGS)?b({},l.ALLOWED_TAGS,Q):ya,W=z(l,"ALLOWED_ATTR")&&se(l.ALLOWED_ATTR)?b({},l.ALLOWED_ATTR,Q):wa,Aa=z(l,"ALLOWED_NAMESPACES")&&se(l.ALLOWED_NAMESPACES)?b({},l.ALLOWED_NAMESPACES,Gt):ar,xa=z(l,"ADD_URI_SAFE_ATTR")&&se(l.ADD_URI_SAFE_ATTR)?b(ee(Ps),l.ADD_URI_SAFE_ATTR,Q):Ps,Rs=z(l,"ADD_DATA_URI_TAGS")&&se(l.ADD_DATA_URI_TAGS)?b(ee(Ns),l.ADD_DATA_URI_TAGS,Q):Ns,ye=z(l,"FORBID_CONTENTS")&&se(l.FORBID_CONTENTS)?b({},l.FORBID_CONTENTS,Q):Ta,dt=z(l,"FORBID_TAGS")&&se(l.FORBID_TAGS)?b({},l.FORBID_TAGS,Q):ee({}),It=z(l,"FORBID_ATTR")&&se(l.FORBID_ATTR)?b({},l.FORBID_ATTR,Q):ee({}),Ye=z(l,"USE_PROFILES")?l.USE_PROFILES&&typeof l.USE_PROFILES=="object"?ee(l.USE_PROFILES):l.USE_PROFILES:!1,As=l.ALLOW_ARIA_ATTR!==!1,Ca=l.ALLOW_DATA_ATTR!==!1,Es=l.ALLOW_UNKNOWN_PROTOCOLS||!1,vs=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ae=l.SAFE_FOR_TEMPLATES||!1,gt=l.SAFE_FOR_XML!==!1,Re=l.WHOLE_DOCUMENT||!1,We=l.RETURN_DOM||!1,Dt=l.RETURN_DOM_FRAGMENT||!1,jt=l.RETURN_TRUSTED_TYPE||!1,ba=l.FORCE_BODY||!1,Is=l.SANITIZE_DOM!==!1,Ds=l.SANITIZE_NAMED_PROPS||!1,Sa=l.KEEP_CONTENT!==!1,pt=l.IN_PLACE||!1,ks=qi(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:hs,Je=typeof l.NAMESPACE=="string"?l.NAMESPACE:we,Ea=z(l,"MATHML_TEXT_INTEGRATION_POINTS")&&l.MATHML_TEXT_INTEGRATION_POINTS&&typeof l.MATHML_TEXT_INTEGRATION_POINTS=="object"?ee(l.MATHML_TEXT_INTEGRATION_POINTS):b({},["mi","mo","mn","ms","mtext"]),va=z(l,"HTML_INTEGRATION_POINTS")&&l.HTML_INTEGRATION_POINTS&&typeof l.HTML_INTEGRATION_POINTS=="object"?ee(l.HTML_INTEGRATION_POINTS):b({},["annotation-xml"]);const u=z(l,"CUSTOM_ELEMENT_HANDLING")&&l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING=="object"?ee(l.CUSTOM_ELEMENT_HANDLING):Pe(null);if(U=Pe(null),z(u,"tagNameCheck")&&Os(u.tagNameCheck)&&(U.tagNameCheck=u.tagNameCheck),z(u,"attributeNameCheck")&&Os(u.attributeNameCheck)&&(U.attributeNameCheck=u.attributeNameCheck),z(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(U.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),Ae&&(Ca=!1),Dt&&(We=!0),Ye&&(H=b({},os),W=Pe(null),Ye.html===!0&&(b(H,rs),b(W,ls)),Ye.svg===!0&&(b(H,Zt),b(W,ea),b(W,Tt)),Ye.svgFilters===!0&&(b(H,Kt),b(W,ea),b(W,Tt)),Ye.mathMl===!0&&(b(H,Xt),b(W,cs),b(W,Tt))),ke.tagCheck=null,ke.attributeCheck=null,z(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?ke.tagCheck=l.ADD_TAGS:se(l.ADD_TAGS)&&(H===ya&&(H=ee(H)),b(H,l.ADD_TAGS,Q))),z(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?ke.attributeCheck=l.ADD_ATTR:se(l.ADD_ATTR)&&(W===wa&&(W=ee(W)),b(W,l.ADD_ATTR,Q))),z(l,"ADD_URI_SAFE_ATTR")&&se(l.ADD_URI_SAFE_ATTR)&&b(xa,l.ADD_URI_SAFE_ATTR,Q),z(l,"FORBID_CONTENTS")&&se(l.FORBID_CONTENTS)&&(ye===Ta&&(ye=ee(ye)),b(ye,l.FORBID_CONTENTS,Q)),z(l,"ADD_FORBID_CONTENTS")&&se(l.ADD_FORBID_CONTENTS)&&(ye===Ta&&(ye=ee(ye)),b(ye,l.ADD_FORBID_CONTENTS,Q)),Sa&&(H["#text"]=!0),Re&&b(H,["html","head","body"]),H.table&&(b(H,["tbody"]),delete dt.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw it('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw it('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');g=l.TRUSTED_TYPES_POLICY,C=g.createHTML("")}else g===void 0&&(g=rn(L,s)),g!==null&&typeof C=="string"&&(C=g.createHTML(""));(N.uponSanitizeElement.length>0||N.uponSanitizeAttribute.length>0)&&H===ya&&(H=ee(H)),N.uponSanitizeAttribute.length>0&&W===wa&&(W=ee(W)),ae&&ae(l),Ge=l},_s=b({},[...Zt,...Kt,...Wi]),Fs=b({},[...Xt,...Yi]),or=function(l){let u=j(l);(!u||!u.tagName)&&(u={namespaceURI:Je,tagName:"template"});const f=at(l.tagName),D=at(u.tagName);return Aa[l.namespaceURI]?l.namespaceURI===Nt?u.namespaceURI===we?f==="svg":u.namespaceURI===Rt?f==="svg"&&(D==="annotation-xml"||Ea[D]):!!_s[f]:l.namespaceURI===Rt?u.namespaceURI===we?f==="math":u.namespaceURI===Nt?f==="math"&&va[D]:!!Fs[f]:l.namespaceURI===we?u.namespaceURI===Nt&&!va[D]||u.namespaceURI===Rt&&!Ea[D]?!1:!Fs[f]&&(sr[f]||!_s[f]):!!(ft==="application/xhtml+xml"&&Aa[l.namespaceURI]):!1},de=function(l){_e(e.removed,{element:l});try{j(l).removeChild(l)}catch{A(l)}},Ne=function(l,u){try{_e(e.removed,{attribute:u.getAttributeNode(l),from:u})}catch{_e(e.removed,{attribute:null,from:u})}if(u.removeAttribute(l),l==="is")if(We||Dt)try{de(u)}catch{}else try{u.setAttribute(l,"")}catch{}},zs=function(l){let u=null,f=null;if(ba)l="<remove></remove>"+l;else{const P=as(l,/^[\r\n\t ]+/);f=P&&P[0]}ft==="application/xhtml+xml"&&Je===we&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");const D=g?g.createHTML(l):l;if(Je===we)try{u=new d().parseFromString(D,ft)}catch{}if(!u||!u.documentElement){u=V.createDocument(Je,"template",null);try{u.documentElement.innerHTML=ka?C:D}catch{}}const x=u.body||u.documentElement;return l&&f&&x.insertBefore(t.createTextNode(f),x.childNodes[0]||null),Je===we?ma.call(u,Re?"html":"body")[0]:Re?u.documentElement:x},$s=function(l){return ue.call(l.ownerDocument||l,l,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Bs=function(l){l.normalize();const u=ue.call(l.ownerDocument||l,l,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let f=u.nextNode();for(;f;){let D=f.data;Oe([je,Et,vt],x=>{D=Fe(D,x," ")}),f.data=D,f=u.nextNode()}},Pt=function(l){const u=p?p(l):null;return typeof u!="string"||Q(u)!=="form"?!1:typeof l.nodeName!="string"||typeof l.textContent!="string"||typeof l.removeChild!="function"||l.attributes!==le(l)||typeof l.removeAttribute!="function"||typeof l.setAttribute!="function"||typeof l.namespaceURI!="string"||typeof l.insertBefore!="function"||typeof l.hasChildNodes!="function"||l.nodeType!==B(l)||l.childNodes!==$(l)},mt=function(l){if(!B||typeof l!="object"||l===null)return!1;try{return B(l)===me.documentFragment}catch{return!1}},Ot=function(l){if(!B||typeof l!="object"||l===null)return!1;try{return typeof B(l)=="number"}catch{return!1}};function Te(y,l,u){Oe(y,f=>{f.call(e,l,u,Ge)})}const Vs=function(l){let u=null;if(Te(N.beforeSanitizeElements,l,null),Pt(l))return de(l),!0;const f=Q(l.nodeName);if(Te(N.uponSanitizeElement,l,{tagName:f,allowedTags:H}),gt&&l.hasChildNodes()&&!Ot(l.firstElementChild)&&X(/<[/\w!]/g,l.innerHTML)&&X(/<[/\w!]/g,l.textContent)||gt&&l.namespaceURI===we&&f==="style"&&Ot(l.firstElementChild)||l.nodeType===me.progressingInstruction||gt&&l.nodeType===me.comment&&X(/<[/\w]/g,l.data))return de(l),!0;if(dt[f]||!(ke.tagCheck instanceof Function&&ke.tagCheck(f))&&!H[f]){if(!dt[f]&&Us(f)&&(U.tagNameCheck instanceof RegExp&&X(U.tagNameCheck,f)||U.tagNameCheck instanceof Function&&U.tagNameCheck(f)))return!1;if(Sa&&!ye[f]){const x=j(l),P=$(l);if(P&&x){const ce=P.length;for(let Ce=ce-1;Ce>=0;--Ce){const ge=R(P[Ce],!0);x.insertBefore(ge,S(l))}}}return de(l),!0}return(B?B(l):l.nodeType)===me.element&&!or(l)||(f==="noscript"||f==="noembed"||f==="noframes")&&X(/<\/no(script|embed|frames)/i,l.innerHTML)?(de(l),!0):(Ae&&l.nodeType===me.text&&(u=l.textContent,Oe([je,Et,vt],x=>{u=Fe(u,x," ")}),l.textContent!==u&&(_e(e.removed,{element:l.cloneNode()}),l.textContent=u)),Te(N.afterSanitizeElements,l,null),!1)},Hs=function(l,u,f){if(It[u]||Is&&(u==="id"||u==="name")&&(f in t||f in rr))return!1;const D=W[u]||ke.attributeCheck instanceof Function&&ke.attributeCheck(u,l);if(!(Ca&&!It[u]&&X(Kn,u))){if(!(As&&X(Xn,u))){if(!D||It[u]){if(!(Us(l)&&(U.tagNameCheck instanceof RegExp&&X(U.tagNameCheck,l)||U.tagNameCheck instanceof Function&&U.tagNameCheck(l))&&(U.attributeNameCheck instanceof RegExp&&X(U.attributeNameCheck,u)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(u,l))||u==="is"&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&X(U.tagNameCheck,f)||U.tagNameCheck instanceof Function&&U.tagNameCheck(f))))return!1}else if(!xa[u]){if(!X(ks,Fe(f,xs,""))){if(!((u==="src"||u==="xlink:href"||u==="href")&&l!=="script"&&ss(f,"data:")===0&&Rs[l])){if(!(Es&&!X(er,Fe(f,xs,"")))){if(f)return!1}}}}}}return!0},lr=b({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Us=function(l){return!lr[at(l)]&&X(tr,l)},Qs=function(l){Te(N.beforeSanitizeAttributes,l,null);const u=l.attributes;if(!u||Pt(l))return;const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0};let D=u.length;for(;D--;){const x=u[D],P=x.name,ce=x.namespaceURI,Ce=x.value,ge=Q(P),Da=Ce;let K=P==="value"?Da:$i(Da);if(f.attrName=ge,f.attrValue=K,f.keepAttr=!0,f.forceKeepAttr=void 0,Te(N.uponSanitizeAttribute,l,f),K=f.attrValue,Ds&&(ge==="id"||ge==="name")&&ss(K,js)!==0&&(Ne(P,l),K=js+K),gt&&X(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,K)){Ne(P,l);continue}if(ge==="attributename"&&as(K,"href")){Ne(P,l);continue}if(f.forceKeepAttr)continue;if(!f.keepAttr){Ne(P,l);continue}if(!vs&&X(/\/>/i,K)){Ne(P,l);continue}Ae&&Oe([je,Et,vt],Ws=>{K=Fe(K,Ws," ")});const qs=Q(l.nodeName);if(!Hs(qs,ge,K)){Ne(P,l);continue}if(g&&typeof L=="object"&&typeof L.getAttributeType=="function"&&!ce)switch(L.getAttributeType(qs,ge)){case"TrustedHTML":{K=g.createHTML(K);break}case"TrustedScriptURL":{K=g.createScriptURL(K);break}}if(K!==Da)try{ce?l.setAttributeNS(ce,P,K):l.setAttribute(P,K),Pt(l)?de(l):ts(e.removed)}catch{Ne(P,l)}}Te(N.afterSanitizeAttributes,l,null)},_t=function(l){let u=null;const f=$s(l);for(Te(N.beforeSanitizeShadowDOM,l,null);u=f.nextNode();)if(Te(N.uponSanitizeShadowNode,u,null),Vs(u),Qs(u),mt(u.content)&&_t(u.content),(B?B(u):u.nodeType)===me.element){const x=_?_(u):u.shadowRoot;mt(x)&&(Ze(x),_t(x))}Te(N.afterSanitizeShadowDOM,l,null)},Ze=function(l){const u=B?B(l):l.nodeType;if(u===me.element){const x=_?_(l):l.shadowRoot;mt(x)&&(Ze(x),_t(x))}const f=$?$(l):l.childNodes;if(!f)return;const D=[];Oe(f,x=>{_e(D,x)});for(const x of D)Ze(x);if(u===me.element){const x=p?p(l):null;if(typeof x=="string"&&Q(x)==="template"){const P=l.content;mt(P)&&Ze(P)}}};return e.sanitize=function(y){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,f=null,D=null,x=null;if(ka=!y,ka&&(y="<!-->"),typeof y!="string"&&!Ot(y)&&(y=Qi(y),typeof y!="string"))throw it("dirty is not a string, aborting");if(!e.isSupported)return y;if(Ma||Ia(l),e.removed=[],typeof y=="string"&&(pt=!1),pt){const Ce=p?p(y):y.nodeName;if(typeof Ce=="string"){const ge=Q(Ce);if(!H[ge]||dt[ge])throw it("root node is forbidden and cannot be sanitized in-place")}if(Pt(y))throw it("root node is clobbered and cannot be sanitized in-place");Ze(y)}else if(Ot(y))u=zs("<!---->"),f=u.ownerDocument.importNode(y,!0),f.nodeType===me.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?u=f:u.appendChild(f),Ze(f);else{if(!We&&!Ae&&!Re&&y.indexOf("<")===-1)return g&&jt?g.createHTML(y):y;if(u=zs(y),!u)return We?null:jt?C:""}u&&ba&&de(u.firstChild);const P=$s(pt?y:u);for(;D=P.nextNode();)Vs(D),Qs(D),mt(D.content)&&_t(D.content);if(pt)return Ae&&Bs(y),y;if(We){if(Ae&&Bs(u),Dt)for(x=fa.call(u.ownerDocument);u.firstChild;)x.appendChild(u.firstChild);else x=u;return(W.shadowroot||W.shadowrootmode)&&(x=La.call(a,x,!0)),x}let ce=Re?u.outerHTML:u.innerHTML;return Re&&H["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&X(an,u.ownerDocument.doctype.name)&&(ce="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
|
|
58
|
+
`+ce),Ae&&Oe([je,Et,vt],Ce=>{ce=Fe(ce,Ce," ")}),g&&jt?g.createHTML(ce):ce},e.setConfig=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ia(y),Ma=!0},e.clearConfig=function(){Ge=null,Ma=!1},e.isValidAttribute=function(y,l,u){Ge||Ia({});const f=Q(y),D=Q(l);return Hs(f,D,u)},e.addHook=function(y,l){typeof l=="function"&&_e(N[y],l)},e.removeHook=function(y,l){if(l!==void 0){const u=Fi(N[y],l);return u===-1?void 0:zi(N[y],u,1)[0]}return ts(N[y])},e.removeHooks=function(y){N[y]=[]},e.removeAllHooks=function(){N=us()},e}var gs=ds();class on{dataLayer;constructor(e){this.dataLayer=e}get answerWidgetShowMoreLimit(){return this.dataLayer.answerWidgetShowMoreLimit??100}get currentPage(){return this.dataLayer.searchObject?.page}get totalPages(){return this.resultsPerPage===0?0:Math.ceil(this.totalResults/this.resultsPerPage)}get totalResults(){return this.dataLayer.searchResultsMetadata?.totalResultsValue||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){return this.dataLayer.searchResultsMetadata?.sorting.options||[]}get selectedSortOption(){return this.dataLayer.searchResultsMetadata?.sorting.selectedSortOption||""}get startResultIndex(){return(this.dataLayer.searchObject?.page-1)*this.resultsPerPage+1}get endResultIndex(){const e=(this.dataLayer.searchObject?.page-1)*this.resultsPerPage+(this.resultsPerPage??0);return e>this.totalResults?this.totalResults:e}get isFirstPage(){return this.dataLayer.searchObject?.page===1}get isLastPage(){return this.dataLayer.searchObject?.page>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){return this.dataLayer.searchResultsMetadata?.autoCorrectedQuery||""}get originalQuery(){return this.dataLayer.searchObject?.query||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswerLoadMore(){return this.dataLayer.getAnswerData.split(" ").length>this.answerWidgetShowMoreLimit}get answerTruncated(){return this.dataLayer.getAnswerData.split(" ").slice(0,this.answerWidgetShowMoreLimit).join(" ")+"..."}get fullAnswerFormatted(){return gs.sanitize(I.parse(this.dataLayer.getAnswerData)).replace(/<a /g,'<a target="_blank" class="searchstax-answer-link" rel="noopener noreferrer" ')}get answerLoading(){return this.dataLayer.answerLoading}get shouldShowAnswerError(){return this.dataLayer.answerError}get locationError(){return this.dataLayer.locationError}get shouldShowAnswer(){return(this.dataLayer.getAnswerData!==""||this.dataLayer.parsedData.answerLoading||this.shouldShowAnswerError)&&this.dataLayer.searchObject.query!=="*"}get searchTerm(){return this.dataLayer.searchResultsMetadata?.autoCorrectedQuery||this.dataLayer.searchObject?.query||""}get locationSearchEnabled(){return this.dataLayer.locationEnabled??!1}get locationSearchDistanceEnabled(){return(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationDistanceEnabled?this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationDistanceEnabled:this.dataLayer.searchResultsMetadata?.location?.filter?.enabled)??!1}get locationSearchDistanceValues(){const e=this.dataLayer.searchLocationConfig?.locationValuesOverride?.filterValues??this.dataLayer.searchResultsMetadata?.location?.filter?.values,t=this.dataLayer.searchLocationConfig?.locationValuesOverride?.filterUnit??this.dataLayer.searchResultsMetadata?.location?.unit;return!e||e.length===0?[]:e.map(s=>({label:s==="any"?"Any Distance":s+" "+(t??""),value:s,isSelected:s===this.dataLayer.searchRadius})).sort((s,n)=>{const r=s.value==="any"?0:parseFloat(s.value),o=n.value==="any"?0:parseFloat(n.value);return r-o})}get shouldShowLocationDistanceDropdown(){return this.locationSearchDistanceEnabled&&this.locationSearchDistanceValues.length>1}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get answerErrorMessage(){return gs.sanitize(I.parse(this.dataLayer.answerErrorMessage)).replace("<br>","")}get searchExecuted(){return this.dataLayer.searchObject?.query!==void 0&&this.dataLayer.searchObject?.query!=="undefined"&&this.dataLayer.searchObject?.query!==""}get selectedFacets(){const e=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return e?(this.dataLayer.searchObject?.facets??[]).map(s=>{const n=s.name,r=s.value,o=e.find(c=>c.name===n);if(o){const c=o.values.find(h=>h.type==="range"?!1:h.type==="checkbox"?'"'+h.value+'"'===r:!1);if(c)return c}return null}).filter(s=>s!==null):[]}get cachedANDFacets(){let e="";for(const t of this.dataLayer.searchObject.facets)(t.type==="and"||t.type==="tabs")&&(e+=JSON.stringify(t));return e}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,totalPages:this.totalPages,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,answerTruncated:this.answerTruncated,fullAnswerFormatted:this.fullAnswerFormatted,shouldShowAnswerLoadMore:this.shouldShowAnswerLoadMore,answerLoading:this.answerLoading,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption,shouldShowAnswerError:this.shouldShowAnswerError,answerErrorMessage:this.answerErrorMessage,locationSearchEnabled:this.locationSearchEnabled,locationSearchDistanceEnabled:this.locationSearchDistanceEnabled,locationSearchDistanceValues:this.locationSearchDistanceValues,shouldShowLocationDistanceDropdown:this.shouldShowLocationDistanceDropdown,locationError:this.locationError}}get trackingData(){return{searchTerm:this.searchTerm,trackApiKey:this.dataLayer.searchstaxConfig?.trackApiKey??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:this.dataLayer.searchResultsMetadata?.recordsPerPageValue??0,totalResults:this.dataLayer.searchResultsMetadata?.totalResultsValue??0,currentPage:this.dataLayer.currentPage,latencyVal:this.dataLayer.searchResultsMetadata?.latency??0,...this.dataLayer.model?{model:this.dataLayer.model}:{}}}}class oe{static deepEqual(e,t){const a=Object.keys(e),s=Object.keys(t);if(a.length!==s.length)return!1;for(const n of a){const r=e[n],o=t[n],c=this.isObject(r)&&this.isObject(o);if(c&&!this.deepEqual(r,o)||!c&&r!==o)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class M{value;observers={};constructor(e){this.value=e,this.observers={}}subscribe(e,t){const a=Math.random().toString(36).substring(2,15),s=t||a;return this.observers[s]=e,e(this.value),s}unsubscribe(e){this.observers[e]&&delete this.observers[e]}subscribeOnce(e){const t=Math.random().toString(36).substring(2,15),a=s=>{e(s),this.unsubscribe(t)};this.subscribe(a,t)}subscribeTwice(e){const t=Math.random().toString(36).substring(2,15);let a=0;const s=n=>{a++,e(n),a>=2&&this.unsubscribe(t)};this.subscribe(s,t)}subscribeUntil(e,t,a=6e3,s=!0){const n=Math.random().toString(36).substring(2,15),r=o=>{o===t&&(e(o),this.unsubscribe(n))};return this.value===t?(e(this.value),null):(this.subscribe(r,n),setTimeout(()=>{s&&this.observers[n]&&e(this.value),this.unsubscribe(n)},a),n)}subscribeUntilHasValue(e,t=6e3,a=!0){const s=Math.random().toString(36).substring(2,15),n=r=>{r!=null&&(e(r),this.unsubscribe(s))};return this.value!==null&&this.value!==void 0?(e(this.value),null):(this.subscribe(n,s),t>0&&setTimeout(()=>{a&&this.observers[s]&&e(this.value),this.unsubscribe(s)},t),n)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){for(const e in this.observers)if(Object.prototype.hasOwnProperty.call(this.observers,e)){const t=this.observers[e];typeof t=="function"&&t(this.value)}}}class ta{static getOrSetCookie(e,t){let a=this.getCookie(e);return a==null&&(a=t??this.makeid(25),this.setCookie(e,a,{secure:!0,"max-age":3600})),a}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=a.length;for(let n=0;n<e;n++)t+=a.charAt(Math.floor(Math.random()*s));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,a){const s={path:"/",...a};a.expires instanceof Date&&(s.expires=a.expires.toUTCString());let n=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const r in s){n+="; "+r;const o=s[r];o!==!0&&(n+="="+o)}typeof document<"u"&&(document.cookie=n)}}class G{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",a=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(a,""):""}}class ln{$searchTermChange=new M("");$searchLocationChange=new M("");$searchLocationCoordinatesDecoded=new M("");$searchLatChange=new M("");$searchLongChange=new M("");$searchRadiusChange=new M(void 0);$loadingChange=new M(!1);$locationError=new M(!1);$searchResults=new M(null);$searchResultsMetadata=new M(null);$searchAutosuggest=new M(null);$searchFacets=new M(null);$searchFacetsCached=new M(null);$searchFacetsCachedTabs=new M(null);$searchstaxConfig=new M(null);$autosuggestResults=new M(null);$itemsPerPage=new M(void 0);$searchObject=new M({query:"",itemsPerPage:void 0,page:99999999,order:"",facets:[],additionalProps:[],location:{term:void 0,radius:void 0,lat:void 0,lon:void 0},model:""});$searchRelatedSearches=new M(null);$searchInputConfig=new M(null);$searchLocationConfig=new M(null);$searchExternalPromotions=new M(null);$facetsTemplateData=new M(null);$selectedFacetsTemplateData=new M(null);$paginationData=new M(null);$answerData=new M(null);$searchFeedbackData=new M(null);$inputWidgetTemplateData=new M(null);$locationWidgetTemplateData=new M(null);$searchSortingData=new M(null);$searchRelatedSearchesData=new M(null);$searchExternalPromotionsData=new M(null);$cookiesDisabled=new M(null);$locationDecodingLoading=new M(!1);$answer=new M("");$language=new M("en");$model=new M("");$answerLoading=new M(!1);$locationEnabled=new M(null);$answerError=new M(!1);$answerErrorMessage=new M("");$isQuestion=new M(!1);$inputTemplateRendered=new M(!1);currentPageValue=1;isAnswerWidgetCreatedValue=!1;renderingEngineValue=F.mustache;parsedData=new on(this);sessionId;sessionIdValue=null;autoCorrect=!0;forceNotCorrect=!1;lastSearchValue="";turnAIAnswerGenerationOn=!1;questionURL="";isInfiniteScroll=!1;firstSearchHappened=!1;facetsWereSet=!1;answerWidgetShowMoreLimit=100;searchHelper;searchResultUnparsed;constructor(e,t){this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,ta.deleteCookie(this.sessionId),ta.deleteCookie("ms_visitorid")):this.sessionIdValue=ta.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(G.removeXSSRiskyTags(e))}setSearchLocation(e){this.$searchLocationChange.setValue(G.removeXSSRiskyTags(e))}setSearchRadius(e){this.$searchRadiusChange.setValue(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,(!oe.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){oe.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){let t=e;t={...t,itemsPerPage:this.itemsPerPage,model:this.model},this.searchstaxConfig?.hooks?.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!oe.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&(this.searchObject.itemsPerPage!==t.itemsPerPage&&t.itemsPerPage!==void 0&&this.setItemsPerPage(t.itemsPerPage),this.$searchObject.setValue(t))}setSearchFacets(e){this.facetsWereSet=!0,oe.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){oe.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchFacetsCachedTabs(e){oe.deepEqual(e,this.searchFacetsCachedTabs??[])||this.$searchFacetsCachedTabs.setValue(e)}setSearchRelatedSearches(e){oe.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){oe.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setModel(e){this.$model.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setSearchLocationConfig(e){this.$searchLocationConfig.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)}setAnswerFullData(e){this.$answerData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}setAnswerLoading(e){this.$answerLoading.setValue(e)}setAnswerError(e){this.$answerError.setValue(e)}setIsQuestion(e){this.$isQuestion.setValue(e)}setAnswerErrorMessage(e){this.$answerErrorMessage.setValue(e)}setLocationDecodingLoading(e){this.$locationDecodingLoading.setValue(e)}setSearchLat(e){this.$searchLatChange.setValue(e)}setSearchLong(e){this.$searchLongChange.setValue(e)}setInputTemplateRendered(e){this.$inputTemplateRendered.setValue(e)}setLocationError(e){this.$locationError.setValue(e)}setInputWidgetTemplateData(e){this.$inputWidgetTemplateData.setValue(e)}setLocationWidgetTemplateData(e){this.$locationWidgetTemplateData.setValue(e)}setLocationCoordinatesDecoded(e){this.$searchLocationCoordinatesDecoded.setValue(G.removeXSSRiskyTags(e))}setLocationEnabled(e){this.$locationEnabled.setValue(e)}setSearchResultUnparsedData(e){this.searchResultUnparsed=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 searchFacetsCachedTabs(){return this.$searchFacetsCachedTabs.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCachedTabs.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get searchLocation(){return this.$searchLocationChange.getValue()}get searchRadius(){return this.$searchRadiusChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get model(){return this.$model.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get searchLocationConfig(){return this.$searchLocationConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}get answerFullData(){return this.$answerData.getValue()}get answerLoading(){return this.$answerLoading.getValue()}get isQuestion(){return this.$isQuestion.getValue()}get answerError(){return this.$answerError.getValue()}get answerErrorMessage(){return this.$answerErrorMessage.getValue()}get locationDecodingLoading(){return this.$locationDecodingLoading.getValue()}get searchLat(){return this.$searchLatChange.getValue()}get searchLong(){return this.$searchLongChange.getValue()}get inputTemplateRendered(){return this.$inputTemplateRendered.getValue()}get locationError(){return this.$locationError.getValue()}get inputWidgetTemplateData(){return this.$inputWidgetTemplateData.getValue()}get locationWidgetTemplateData(){return this.$locationWidgetTemplateData.getValue()}get searchLocationCoordinatesDecoded(){return this.$searchLocationCoordinatesDecoded.getValue()}get locationEnabled(){return this.$locationEnabled.getValue()}get searchResultUnparsedData(){return this.searchResultUnparsed}}class nt{static combineResultsWithMetadata(e){const t=[],a=parseInt(e.response.start+"");return e.response.docs.forEach((s,n)=>{const r=s[e.responseHeader.params.uniqueId]??"",o={custom:null,uniqueId:r,position:a+1+n,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",s,e,r):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",s,e,r):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",s,e,r):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,r):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,r,!0):null,promoted:s["[elevated]"]?s["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",s,e,r):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",s,e,r):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",s,e,r):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",s,e,r):null,distance:this.doesMapExist("distance",e)&&this.getValueByKey("distance",s,e,r)!=="Infinity"&&this.getValueByKey("distance",s,e,r)?Math.floor(this.getValueByKey("distance",s,e,r)):null,unit:e.metadata.locationSearch?.unit??"",unmappedFields:this.getUnmappedFields(s,e,r),allFields:this.getAllFields(s,e)};t.push(o)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const a of e.metadata.facets){let s={values:[]};if(s.name=a.name,s.label=a.label,a.name in e.facet_counts.facet_fields){const n=e.facet_counts.facet_fields[a.name];for(let r=0;r<n.length;r+=2){const o={};o.value=n[r],o.parentName=s.name,o.count=n[r+1],o.type="checkbox",s.values.push(o)}}s.values.length>0&&t.push(s)}return t}static extractSearchResultsMetadata(e){let t="",a={selectedSortOption:"",options:[]},s={enabled:!1,field:"",unit:"",filter:{enabled:!1,values:[],label:"",defaultValue:""}};if(e.metadata.locationSearch&&(s={enabled:e.metadata.locationSearch.enabled,field:e.metadata.locationSearch.field,unit:e.metadata.locationSearch.unit,filter:{enabled:e.metadata.locationSearch.filter?.enabled??!1,values:e.metadata.locationSearch.filter?.values??[],label:e.metadata.locationSearch.filter?.label??"",defaultValue:e.metadata.locationSearch.filter?.defaultValue??""}}),e.metadata.results.find(n=>n.result_card==="date")?.name,a.options=[],e.metadata.sorts?.length){const n=e.metadata.sorts.map(r=>({value:r.label,key:r.name+" "+r.order}));a.options=[{key:"",value:"Relevance"},...n]}return t=e?.spellcheck?.suggestions?.[1]?.suggestion?.[0]??"",typeof t!="string"&&(t=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,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:a,location:s,isLocationMapped:this.doesMapExist("distance",e)}}static getImpressions(e){const t=[],a=this.combineResultsWithMetadata(e);for(const s in a){const n=a[s],r={};r.cDocId=this.getDataForAnalytics(n.uniqueId),n.title&&(r.cDocTitle=this.getDataForAnalytics(n.titleTracking)),r.position=n.position,t.push(r)}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(a=>a.uniqueId===e)??null}static getUnmappedFields(e,t,a){const s=t.metadata.results.filter(r=>r.result_card==="").map(r=>r.name),n=[];for(const r of s)if(Object.keys(e).includes(r)){const o=Array.isArray(e[r])?this.getHighlightedResults(r,e[r].join(", "),a,t):this.getHighlightedResults(r,e[r]+"",a,t);n.push({key:r,value:o,isImage:this.checkIfImage(e[r])})}return n}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 a=t.metadata.results.map(n=>n.name),s=[];for(const n of Object.keys(e))a.indexOf(n)!==-1&&s.push({key:n,value:e[n],isImage:this.checkIfImage(e[n])});return s}static doesMapExist(e,t){return t.metadata.results.find(a=>a.result_card===e)!==void 0}static getValueByKey(e,t,a,s,n=!1){const r=a.metadata.results.find(c=>c.result_card===e);if(r===void 0)return null;const o=t[r.name];return o===void 0?null:typeof o=="string"?n?o:this.getHighlightedResults(r.name,o,s,a):typeof o=="number"?o:Array.isArray(o)?n?o.join(", "):this.getHighlightedResults(r.name,o.join(", "),s,a):null}static getHighlightedResults(e,t,a,s){if(s.highlighting&&a in s.highlighting){let n=s.highlighting[a];if(n&&e in n){let r=n[e];const o=this.cleanValue(r);if(o!=="")return o}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class ps{routeName="searchstax";ignoredKeys=[];queryStringHelper;titleParser;constructor(e){e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new cn(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let a=typeof document<"u"?document?.title:"";this.titleParser&&(a=this.titleParser(e)),typeof document<"u"&&(document.title=a),window?.location.href!==t&&window?.history.replaceState(window.history.state,a,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={},a=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=a+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.itemsPerPage&&e.itemsPerPage!==10&&(t[this.routeName+"[itemsPerPage]"]=e.itemsPerPage+""),e.location)for(const s in e.location){const n=e.location[s];n&&(t[this.routeName+`[location][${s}]`]=n)}if(e.facets)for(const s in e.facets){const n=e.facets[s].type+":"+encodeURIComponent(e.facets[s].name)+":"+encodeURIComponent(e.facets[s].value);t[this.routeName+`[facets][${s}]`]=n}if(e.model&&(t[this.routeName+"[model]"]=e.model),this.queryStringHelper.urlHasQueryParams(window?.location.href??"")){const s=this.queryStringHelper.urlToParams(window?.location.href??"");for(const n in s)n.startsWith(this.routeName)&&delete s[n];return{...s,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const a in e)a.startsWith(this.routeName)||(t[a]=e[a]);return t}extractArrayOfFacetsFromQueryParameters(e){const t=[];for(const a in e)if(a.startsWith(this.routeName+"[facets]")){const s=G.removeXSSRiskyTags(e[a].split(":")?.[0]),n=G.removeXSSRiskyTags(decodeURIComponent(e[a].split(":")?.[1])),r=G.removeXSSRiskyTags(decodeURIComponent(e[a].split(":")?.[2]));t.push({type:s,name:n,value:r})}return t}urlToSearchObject(e,t){const a=this.queryStringHelper.urlToParams(e),s=G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[page]"])),n=parseInt(s),r=isNaN(n)?1:n;let o=parseInt(G.removeXSSRiskyTags(a[this.routeName+"[itemsPerPage]"]));return isNaN(o)&&(o=10),{query:G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[query]"]))||"",page:r,itemsPerPage:t??o,order:G.removeXSSRiskyTags(a[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(a)||[],model:G.removeXSSRiskyTags(a[this.routeName+"[model]"])||"",location:{address:G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[location][address]"]||"")),radius:G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[location][radius]"]||"")),lat:G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[location][lat]"]||"")),lon:G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[location][lon]"]||""))}}}}class cn{routeName="";constructor(e){this.routeName=e}stringify=(e,t)=>{const a=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(a).map(s=>{const n=a[s];return Array.isArray(n)?n.map(r=>`${s}=${r}`).join("&"):`${s}=${n}`}).join("&")};filterOutIgnoredKeys(e,t){const a=t||[],s={};return Object.keys(e).forEach(n=>{a.includes(n)||e[n]!==""&&(s[n]=e[n])}),s}urlToParams(e){const t={},a=e.split("?")[1];return a&&a.split("&").forEach(s=>{const[n,r]=s.split("=");t[n]=r}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const ze={question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class aa extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const fs=10,hn=13,Ie=32;function sa(i){}function un(i){if(typeof i=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=sa,onError:t=sa,onRetry:a=sa,onComment:s,maxBufferSize:n}=i,r=[];let o=0,c=!0,h,d="",L=0,m,R=!1;function A(p){if(R)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,p.charCodeAt(0)===239&&p.charCodeAt(1)===187&&p.charCodeAt(2)===191&&(p=p.slice(3))),r.length===0){const E=$(p);E!==""&&(r.push(E),o=E.length),S();return}if(p.indexOf(`
|
|
59
|
+
`)===-1&&p.indexOf("\r")===-1){r.push(p),o+=p.length,S();return}r.push(p);const g=r.join("");r.length=0,o=0;const C=$(g);C!==""&&(r.push(C),o=C.length),S()}function S(){n!==void 0&&(o+d.length<=n||(R=!0,r.length=0,o=0,h=void 0,d="",L=0,m=void 0,t(new aa(`Buffered data exceeded max buffer size of ${n} characters`,{type:"max-buffer-size-exceeded"}))))}function $(p){let g=0;if(p.indexOf("\r")===-1){let C=p.indexOf(`
|
|
60
|
+
`,g);for(;C!==-1;){if(g===C){L>0&&e({id:h,event:m,data:d}),h=void 0,d="",L=0,m=void 0,g=C+1,C=p.indexOf(`
|
|
61
|
+
`,g);continue}const E=p.charCodeAt(g);if(ms(p,g,E)){const V=p.charCodeAt(g+5)===Ie?g+6:g+5,ue=p.slice(V,C);if(L===0&&p.charCodeAt(C+1)===fs){e({id:h,event:m,data:ue}),h=void 0,d="",m=void 0,g=C+2,C=p.indexOf(`
|
|
62
|
+
`,g);continue}d=L===0?ue:`${d}
|
|
63
|
+
${ue}`,L++}else Ls(p,g,E)?m=p.slice(p.charCodeAt(g+6)===Ie?g+7:g+6,C)||void 0:j(p,g,C);g=C+1,C=p.indexOf(`
|
|
64
|
+
`,g)}return p.slice(g)}for(;g<p.length;){const C=p.indexOf("\r",g),E=p.indexOf(`
|
|
65
|
+
`,g);let V=-1;if(C!==-1&&E!==-1?V=C<E?C:E:C!==-1?C===p.length-1?V=-1:V=C:E!==-1&&(V=E),V===-1)break;j(p,g,V),g=V+1,p.charCodeAt(g-1)===hn&&p.charCodeAt(g)===fs&&g++}return p.slice(g)}function j(p,g,C){if(g===C){le();return}const E=p.charCodeAt(g);if(ms(p,g,E)){const N=p.charCodeAt(g+5)===Ie?g+6:g+5,je=p.slice(N,C);d=L===0?je:`${d}
|
|
66
|
+
${je}`,L++;return}if(Ls(p,g,E)){m=p.slice(p.charCodeAt(g+6)===Ie?g+7:g+6,C)||void 0;return}if(E===105&&p.charCodeAt(g+1)===100&&p.charCodeAt(g+2)===58){const N=p.slice(p.charCodeAt(g+3)===Ie?g+4:g+3,C);h=N.includes("\0")?void 0:N;return}if(E===58){if(s){const N=p.slice(g,C);s(N.slice(p.charCodeAt(g+1)===Ie?2:1))}return}const V=p.slice(g,C),ue=V.indexOf(":");if(ue===-1){_(V,"",V);return}const fa=V.slice(0,ue),ma=V.charCodeAt(ue+1)===Ie?2:1,La=V.slice(ue+ma);_(fa,La,V)}function _(p,g,C){switch(p){case"event":m=g||void 0;break;case"data":d=L===0?g:`${d}
|
|
67
|
+
${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.test(g)?a(parseInt(g,10)):t(new aa(`Invalid \`retry\` value: "${g}"`,{type:"invalid-retry",value:g,line:C}));break;default:t(new aa(`Unknown field "${p.length>20?`${p.slice(0,20)}…`:p}"`,{type:"unknown-field",field:p,value:g,line:C}));break}}function le(){L>0&&e({id:h,event:m,data:d}),h=void 0,d="",L=0,m=void 0}function B(p={}){if(p.consume&&r.length>0){const g=r.join("");j(g,0,g.length)}c=!0,h=void 0,d="",L=0,m=void 0,r.length=0,o=0,R=!1}return{feed:A,reset:B}}function ms(i,e,t){return t===100&&i.charCodeAt(e+1)===97&&i.charCodeAt(e+2)===116&&i.charCodeAt(e+3)===97&&i.charCodeAt(e+4)===58}function Ls(i,e,t){return t===101&&i.charCodeAt(e+1)===118&&i.charCodeAt(e+2)===101&&i.charCodeAt(e+3)===110&&i.charCodeAt(e+4)===116&&i.charCodeAt(e+5)===58}class ys extends Event{constructor(e,t){var a,s;super(e),this.code=(a=t?.code)!=null?a:void 0,this.message=(s=t?.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,t,a){return a(ws(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(ws(this),t)}}function dn(i){const e=globalThis.DOMException;return typeof e=="function"?new e(i,"SyntaxError"):new SyntaxError(i)}function ia(i){return i instanceof Error?"errors"in i&&Array.isArray(i.errors)?i.errors.map(ia).join(", "):"cause"in i&&i.cause instanceof Error?`${i}: ${ia(i.cause)}`:i.message:`${i}`}function ws(i){return{type:i.type,message:i.message,code:i.code,defaultPrevented:i.defaultPrevented,cancelable:i.cancelable,timeStamp:i.timeStamp}}var Cs=i=>{throw TypeError(i)},na=(i,e,t)=>e.has(i)||Cs("Cannot "+t),T=(i,e,t)=>(na(i,e,"read from private field"),t?t.call(i):e.get(i)),Y=(i,e,t)=>e.has(i)?Cs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),O=(i,e,t,a)=>(na(i,e,"write to private field"),e.set(i,t),t),Se=(i,e,t)=>(na(i,e,"access private method"),t),ne,De,$e,xt,kt,rt,Be,ot,xe,Ve,He,Ue,lt,he,ra,oa,la,Ms,ca,ha,ct,ua,da;class At extends EventTarget{constructor(e,t){var a,s;super(),Y(this,he),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Y(this,ne),Y(this,De),Y(this,$e),Y(this,xt),Y(this,kt),Y(this,rt),Y(this,Be),Y(this,ot,null),Y(this,xe),Y(this,Ve),Y(this,He,null),Y(this,Ue,null),Y(this,lt,null),Y(this,oa,async n=>{var r;T(this,Ve).reset();const{body:o,redirected:c,status:h,headers:d}=n;if(h===204){Se(this,he,ct).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?O(this,$e,new URL(n.url)):O(this,$e,void 0),h!==200){Se(this,he,ct).call(this,`Non-200 status code (${h})`,h);return}if(!(d.get("content-type")||"").startsWith("text/event-stream")){Se(this,he,ct).call(this,'Invalid content type, expected "text/event-stream"',h);return}if(T(this,ne)===this.CLOSED)return;O(this,ne,this.OPEN);const L=new Event("open");if((r=T(this,lt))==null||r.call(this,L),this.dispatchEvent(L),typeof o!="object"||!o||!("getReader"in o)){Se(this,he,ct).call(this,"Invalid response body, expected a web ReadableStream",h),this.close();return}const m=new TextDecoder,R=o.getReader();let A=!0;do{const{done:S,value:$}=await R.read();$&&T(this,Ve).feed(m.decode($,{stream:!S})),S&&(A=!1,T(this,Ve).reset(),Se(this,he,ua).call(this))}while(A)}),Y(this,la,n=>{O(this,xe,void 0),!(n.name==="AbortError"||n.type==="aborted")&&Se(this,he,ua).call(this,ia(n))}),Y(this,ca,n=>{typeof n.id=="string"&&O(this,ot,n.id);const r=new MessageEvent(n.event||"message",{data:n.data,origin:T(this,$e)?T(this,$e).origin:T(this,De).origin,lastEventId:n.id||""});T(this,Ue)&&(!n.event||n.event==="message")&&T(this,Ue).call(this,r),this.dispatchEvent(r)}),Y(this,ha,n=>{O(this,rt,n)}),Y(this,da,()=>{O(this,Be,void 0),T(this,ne)===this.CONNECTING&&Se(this,he,ra).call(this)});try{if(e instanceof URL)O(this,De,e);else if(typeof e=="string")O(this,De,new URL(e,gn()));else throw new Error("Invalid URL")}catch{throw dn("An invalid or illegal string was specified")}O(this,Ve,un({onEvent:T(this,ca),onRetry:T(this,ha)})),O(this,ne,this.CONNECTING),O(this,rt,3e3),O(this,kt,(a=t?.fetch)!=null?a:globalThis.fetch),O(this,xt,(s=t?.withCredentials)!=null?s:!1),Se(this,he,ra).call(this)}get readyState(){return T(this,ne)}get url(){return T(this,De).href}get withCredentials(){return T(this,xt)}get onerror(){return T(this,He)}set onerror(e){O(this,He,e)}get onmessage(){return T(this,Ue)}set onmessage(e){O(this,Ue,e)}get onopen(){return T(this,lt)}set onopen(e){O(this,lt,e)}addEventListener(e,t,a){const s=t;super.addEventListener(e,s,a)}removeEventListener(e,t,a){const s=t;super.removeEventListener(e,s,a)}close(){T(this,Be)&&clearTimeout(T(this,Be)),T(this,ne)!==this.CLOSED&&(T(this,xe)&&T(this,xe).abort(),O(this,ne,this.CLOSED),O(this,xe,void 0))}}ne=new WeakMap,De=new WeakMap,$e=new WeakMap,xt=new WeakMap,kt=new WeakMap,rt=new WeakMap,Be=new WeakMap,ot=new WeakMap,xe=new WeakMap,Ve=new WeakMap,He=new WeakMap,Ue=new WeakMap,lt=new WeakMap,he=new WeakSet,ra=function(){O(this,ne,this.CONNECTING),O(this,xe,new AbortController),T(this,kt)(T(this,De),Se(this,he,Ms).call(this)).then(T(this,oa)).catch(T(this,la))},oa=new WeakMap,la=new WeakMap,Ms=function(){var i;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...T(this,ot)?{"Last-Event-ID":T(this,ot)}:void 0},cache:"no-store",signal:(i=T(this,xe))==null?void 0:i.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},ca=new WeakMap,ha=new WeakMap,ct=function(i,e){var t;T(this,ne)!==this.CLOSED&&O(this,ne,this.CLOSED);const a=new ys("error",{code:e,message:i});(t=T(this,He))==null||t.call(this,a),this.dispatchEvent(a)},ua=function(i,e){var t;if(T(this,ne)===this.CLOSED)return;O(this,ne,this.CONNECTING);const a=new ys("error",{code:e,message:i});(t=T(this,He))==null||t.call(this,a),this.dispatchEvent(a),O(this,Be,setTimeout(T(this,da),T(this,rt)))},da=new WeakMap,At.CONNECTING=0,At.OPEN=1,At.CLOSED=2;function gn(){const i="document"in globalThis?globalThis.document:void 0;return i&&typeof i=="object"&&"baseURI"in i&&typeof i.baseURI=="string"?i.baseURI:void 0}class Le{static subscribedToClickEvent=!1;static attachAnalyticsScript(e){window._msq=window._msq||[];const a=e||"https://static.searchstax.com/studio-js/v4/js/studio-analytics.js";if(!document.querySelector(`script[src="${a}"]`)){var n=document.createElement("script");n.type="text/javascript",n.src=a;var r=document.getElementsByTagName("script")[0];r.parentNode&&r.parentNode.insertBefore(n,r)}}static msq=()=>typeof window<"u"&&window?._msq?window?._msq:[];static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language,model:e.model};return new Promise((a,s)=>{const n=["trackClick",t];t.key?this.msq().push(n,(function(r,o){JSON.stringify(r)===JSON.stringify(t)&&o?a():s()}).bind(this)):s()})}static trackAnswerLinkClick(e){const t={key:e.trackApiKey,question:e.searchTerm,session:e.session,href:e.href,language:e.language,model:e.model,answer:e.answer};return new Promise((a,s)=>{const n=["answerSourceClick",t];t.key?this.msq().push(n,(function(r,o){JSON.stringify(r)===JSON.stringify(t)&&o?a():s()}).bind(this)):s()})}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,model:e.model,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:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches,language:e.language,model:e.model};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,latency:e.latencyVal,language:e.language,model:e.model,impressions:e.impressions,pageNo:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}static trackAnswerData(e){const t={session:e.session,key:e.trackApiKey,question:e.searchTerm,answer:e.answer,language:e.language,model:e.model,is_question:e.isQuestion+"",has_show_more:e.hasShowMore};setTimeout(()=>{t.key&&this.msq().push(["trackquestionanswer",t])},0)}static trackShowMoreClick(e){const t={session:e.session,key:e.trackApiKey,language:e.language,model:e.model,question:e.searchTerm};setTimeout(()=>{t.key&&this.msq().push(["answershowmoreclick",t])},0)}static trackFeedback(e){setTimeout(()=>{this.msq().push(["trackSearchSatisfaction",{key:e.trackApiKey,email:e.email,score:e.rating,comments:e.feedback,language:e.language,model:e.model}])},0)}}class pn{cachedQuery="";cachedANDFacets="";url="";relatedSearches="";suggester="";authHeader;authHeaderRelated;trackApiKey="";session="";searchAuthType;searchAuth="";controllerSearch;signalSearch;controllerSuggest;signalSuggest;_authToken="";resolveFn;dataLayer;constructor(e,t){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"),this._authToken=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`,this.authHeader.append("Authorization",this._authToken),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let a=[];if(!t)e.forEach(function(s){const n=s.name+':"'+s.value+'"';a=a.concat("fq="+decodeURIComponent(n).replace(" "," "))});else{const s={};e.forEach(function(r){const o=r.name+":"+r.value,c=decodeURIComponent(o).replace(" "," ").split(":");s[c[0]]?s[c[0]].push(c[1]):s[c[0]]=[c[1]]});let n="";for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){const o=s[r],c=r;for(const h of o)n+=n===""?` ${c}:"${h}"`:` OR ${c}:"${h}"`}a=a.concat("fq="+n.trim())}return a=a.map(s=>s.replace(/&/g,"%26").replace(/\+/g,"%2B")),a.length?"&"+a.join("&"):""}generateLocationQuery(e){let t="";if(e.lat&&e.lon){const a=Math.floor(parseFloat(e.lat)*100)/100,s=Math.floor(parseFloat(e.lon)*100)/100;t+=`&pt=${a},${s}`}return e.radius&&t!==""&&e.radius!=="any"&&(t+=`&distanceFilter=${e.radius}`),t}getRelatedSearches(e,t,a,s){const n=new Headers;n.append("Accept","application/json"),n.append("Authorization",a),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:n,credentials:"same-origin"}).then(r=>r.json()).then(r=>{s(r)})}cacheFacets(e){return new Promise(t=>{if(this.resolveFn=t,this.dataLayer.searchObject.query!==this.cachedQuery||this.cachedANDFacets+e!==this.dataLayer.parsedData.cachedANDFacets+e){this.cachedANDFacets=this.dataLayer.parsedData.cachedANDFacets+e,this.cachedQuery=this.dataLayer.searchObject.query;const a=[this.dataLayer.searchObject.facets.filter(s=>e?!1:s.type==="and"||s.type==="tabs")].flat();this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:a,additionalProps:this.dataLayer.searchObject.additionalProps,location:this.dataLayer.searchObject.location,model:this.dataLayer.model},this.cacheFacetsCallback.bind(this),!0,!1,e)}else this.resolveFn()})}cacheFacetsCallback(e,t){let a=nt.extractFacets(e);t?this.dataLayer.setSearchFacetsCachedTabs(a):this.dataLayer.setSearchFacetsCached(a),this.resolveFn&&this.resolveFn()}search(e,t,a=!1,s=!1,n=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=this.url+this.generateQueryParams(e,s),o={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};a&&delete o.signal,fetch(r,o).then(c=>c.json()).then(c=>{this.dataLayer.setLoading(!1),t(c,n)}).catch(()=>{this.dataLayer.setLoading(!1)})}}generateQueryParams(e,t){let a=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),s=e.order?`&sort=${e.order}`:"";const n=e.itemsPerPage!==void 0?`&rows=${e.itemsPerPage}`:"",r=new Proxy(new URLSearchParams(window?.location.search??""),{get:(h,d)=>h.get(d)??""}),o=r.languageVariant?"&fq=_language:"+r.languageVariant:"",c=e.model??this.dataLayer.model;return"?q="+encodeURIComponent(e.query.trim())+"&start="+a+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(h=>h.type==="or"||h.type==="showUnavailable"),!0)+this.generateLocationQuery(e.location)+this.generateFacetQuery(e.facets.filter(h=>h.type==="and"||h.type==="tabs"),!1)+s+n+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!t}`+(c?`&model=${c}`:"")+"&language="+this.dataLayer.language+o}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.searchObject.page!==1)return;const a=this.dataLayer;a.setAnswerLoading(!1),a.setAnswerErrorMessage(""),a.setAnswerError(!1);const s=new At(this.dataLayer.questionURL+this.generateQueryParams(this.dataLayer.searchObject),{fetch:(n,r)=>fetch(n,{...r,headers:{...r?.headers,Authorization:this._authToken}})});return s.onmessage=n=>{if(n.data===ze.question||n.data===ze.notQuestion){n.data===ze.question?(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setIsQuestion(!0)):(a.setAnswerLoading(!1),this.dataLayer.setIsQuestion(!1)),a.setAnswerData("");return}if(n.data===ze.close){Le.trackAnswerData({...a.parsedData.trackingData,answer:a.$answer.getValue(),isQuestion:this.dataLayer.isQuestion,hasShowMore:this.dataLayer.parsedData.shouldShowAnswerLoadMore}),a.setAnswerLoading(!1),s.close();return}if(n.data.indexOf("[!CAUTION]")!==-1){a.setAnswerError(!0),a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),s.close();return}if(n.data.indexOf("[comment]: <> ({")!==-1)try{const r=n.data.split("[comment]: <> ({");if(r.length<2){t(n.data);return}const o=r[1].split("})");if(o.length<2){t(n.data);return}const c=o[0],h=JSON.parse("{"+c+"}");this.dataLayer.answerWidgetShowMoreLimit=h.displayShowMoreAfter,h.showMoreEnabled||(this.dataLayer.answerWidgetShowMoreLimit=1e17);const d=o.slice(1).join("})");t(d)}catch{t(n.data)}else t(n.data)},s.addEventListener("error",n=>{(n.code===401||n.code===500)&&(a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),a.setAnswerError(!0))}),s.onerror=()=>{a.setAnswerLoading(!1),s.close()},s}suggest(e,t,a){if(this.controllerSuggest&&this.controllerSuggest.abort(),this.suggester.trim()==="")return;this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const s=this.suggester+"?q="+e.trim()+this.toQueryString(a)+"&language="+this.dataLayer.language;fetch(s,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(n=>n.json()).then(n=>{t(n)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const a of e)t.push(encodeURIComponent(a.key)+"="+encodeURIComponent(a.value));return"&"+t.join("&")}}var fn=Object.prototype.toString,Qe=Array.isArray||function(e){return fn.call(e)==="[object Array]"};function ga(i){return typeof i=="function"}function mn(i){return Qe(i)?"array":typeof i}function pa(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function bs(i,e){return i!=null&&typeof i=="object"&&e in i}function Ln(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var yn=RegExp.prototype.test;function wn(i,e){return yn.call(i,e)}var Cn=/\S/;function Mn(i){return!wn(Cn,i)}var bn={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function Sn(i){return String(i).replace(/[&<>"'`=\/]/g,function(t){return bn[t]})}var Tn=/\s*/,xn=/\s+/,Ss=/\s*=/,kn=/\s*\}/,An=/#|\^|\/|>|\{|&|=|!/;function En(i,e){if(!i)return[];var t=!1,a=[],s=[],n=[],r=!1,o=!1,c="",h=0;function d(){if(r&&!o)for(;n.length;)delete s[n.pop()];else n=[];r=!1,o=!1}var L,m,R;function A(E){if(typeof E=="string"&&(E=E.split(xn,2)),!Qe(E)||E.length!==2)throw new Error("Invalid tags: "+E);L=new RegExp(pa(E[0])+"\\s*"),m=new RegExp("\\s*"+pa(E[1])),R=new RegExp("\\s*"+pa("}"+E[1]))}A(e||k.tags);for(var S=new ht(i),$,j,_,le,B,p;!S.eos();){if($=S.pos,_=S.scanUntil(L),_)for(var g=0,C=_.length;g<C;++g)le=_.charAt(g),Mn(le)?(n.push(s.length),c+=le):(o=!0,t=!0,c+=" "),s.push(["text",le,$,$+1]),$+=1,le===`
|
|
68
|
+
`&&(d(),c="",h=0,t=!1);if(!S.scan(L))break;if(r=!0,j=S.scan(An)||"name",S.scan(Tn),j==="="?(_=S.scanUntil(Ss),S.scan(Ss),S.scanUntil(m)):j==="{"?(_=S.scanUntil(R),S.scan(kn),S.scanUntil(m),j="&"):_=S.scanUntil(m),!S.scan(m))throw new Error("Unclosed tag at "+S.pos);if(j==">"?B=[j,_,$,S.pos,c,h,t]:B=[j,_,$,S.pos],h++,s.push(B),j==="#"||j==="^")a.push(B);else if(j==="/"){if(p=a.pop(),!p)throw new Error('Unopened section "'+_+'" at '+$);if(p[1]!==_)throw new Error('Unclosed section "'+p[1]+'" at '+$)}else j==="name"||j==="{"||j==="&"?o=!0:j==="="&&A(_)}if(d(),p=a.pop(),p)throw new Error('Unclosed section "'+p[1]+'" at '+S.pos);return In(vn(s))}function vn(i){for(var e=[],t,a,s=0,n=i.length;s<n;++s)t=i[s],t&&(t[0]==="text"&&a&&a[0]==="text"?(a[1]+=t[1],a[3]=t[3]):(e.push(t),a=t));return e}function In(i){for(var e=[],t=e,a=[],s,n,r=0,o=i.length;r<o;++r)switch(s=i[r],s[0]){case"#":case"^":t.push(s),a.push(s),t=s[4]=[];break;case"/":n=a.pop(),n[5]=s[2],t=a.length>0?a[a.length-1][4]:e;break;default:t.push(s)}return e}function ht(i){this.string=i,this.tail=i,this.pos=0}ht.prototype.eos=function(){return this.tail===""},ht.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return"";var a=t[0];return this.tail=this.tail.substring(a.length),this.pos+=a.length,a},ht.prototype.scanUntil=function(e){var t=this.tail.search(e),a;switch(t){case-1:a=this.tail,this.tail="";break;case 0:a="";break;default:a=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=a.length,a};function qe(i,e){this.view=i,this.cache={".":this.view},this.parent=e}qe.prototype.push=function(e){return new qe(e,this)},qe.prototype.lookup=function(e){var t=this.cache,a;if(t.hasOwnProperty(e))a=t[e];else{for(var s=this,n,r,o,c=!1;s;){if(e.indexOf(".")>0)for(n=s.view,r=e.split("."),o=0;n!=null&&o<r.length;)o===r.length-1&&(c=bs(n,r[o])||Ln(n,r[o])),n=n[r[o++]];else n=s.view[e],c=bs(s.view,e);if(c){a=n;break}s=s.parent}t[e]=a}return ga(a)&&(a=a.call(this.view)),a};function ie(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}ie.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()},ie.prototype.parse=function(e,t){var a=this.templateCache,s=e+":"+(t||k.tags).join(":"),n=typeof a<"u",r=n?a.get(s):void 0;return r==null&&(r=En(e,t),n&&a.set(s,r)),r},ie.prototype.render=function(e,t,a,s){var n=this.getConfigTags(s),r=this.parse(e,n),o=t instanceof qe?t:new qe(t,void 0);return this.renderTokens(r,o,a,e,s)},ie.prototype.renderTokens=function(e,t,a,s,n){for(var r="",o,c,h,d=0,L=e.length;d<L;++d)h=void 0,o=e[d],c=o[0],c==="#"?h=this.renderSection(o,t,a,s,n):c==="^"?h=this.renderInverted(o,t,a,s,n):c===">"?h=this.renderPartial(o,t,a,n):c==="&"?h=this.unescapedValue(o,t):c==="name"?h=this.escapedValue(o,t,n):c==="text"&&(h=this.rawValue(o)),h!==void 0&&(r+=h);return r},ie.prototype.renderSection=function(e,t,a,s,n){var r=this,o="",c=t.lookup(e[1]);function h(m){return r.render(m,t,a,n)}if(c){if(Qe(c))for(var d=0,L=c.length;d<L;++d)o+=this.renderTokens(e[4],t.push(c[d]),a,s,n);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")o+=this.renderTokens(e[4],t.push(c),a,s,n);else if(ga(c)){if(typeof s!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(t.view,s.slice(e[3],e[5]),h),c!=null&&(o+=c)}else o+=this.renderTokens(e[4],t,a,s,n);return o}},ie.prototype.renderInverted=function(e,t,a,s,n){var r=t.lookup(e[1]);if(!r||Qe(r)&&r.length===0)return this.renderTokens(e[4],t,a,s,n)},ie.prototype.indentPartial=function(e,t,a){for(var s=t.replace(/[^ \t]/g,""),n=e.split(`
|
|
69
|
+
`),r=0;r<n.length;r++)n[r].length&&(r>0||!a)&&(n[r]=s+n[r]);return n.join(`
|
|
70
|
+
`)},ie.prototype.renderPartial=function(e,t,a,s){if(a){var n=this.getConfigTags(s),r=ga(a)?a(e[1]):a[e[1]];if(r!=null){var o=e[6],c=e[5],h=e[4],d=r;c==0&&h&&(d=this.indentPartial(r,h,o));var L=this.parse(d,n);return this.renderTokens(L,t,a,d,s)}}},ie.prototype.unescapedValue=function(e,t){var a=t.lookup(e[1]);if(a!=null)return a},ie.prototype.escapedValue=function(e,t,a){var s=this.getConfigEscape(a)||k.escape,n=t.lookup(e[1]);if(n!=null)return typeof n=="number"&&s===k.escape?String(n):s(n)},ie.prototype.rawValue=function(e){return e[1]},ie.prototype.getConfigTags=function(e){return Qe(e)?e:e&&typeof e=="object"?e.tags:void 0},ie.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!Qe(e))return e.escape};var k={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){ut.templateCache=i},get templateCache(){return ut.templateCache}},ut=new ie;k.clearCache=function(){return ut.clearCache()},k.parse=function(e,t){return ut.parse(e,t)},k.render=function(e,t,a,s){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+mn(e)+'" was given as the first argument for mustache#render(template, view, partials)');return ut.render(e,t,a,s)},k.escape=Sn,k.Scanner=ht,k.Context=qe,k.Writer=ie;const Dn={main:{template:`
|
|
70
71
|
{{#shouldShowAnswer}}
|
|
71
72
|
<div class="searchstax-answer-wrap">
|
|
72
73
|
<div class="searchstax-answer-icon"></div>
|
|
@@ -103,7 +104,7 @@ ${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
|
|
|
103
104
|
</div>
|
|
104
105
|
</div>
|
|
105
106
|
{{/shouldShowAnswer}}
|
|
106
|
-
`}},
|
|
107
|
+
`}},jn={mainTemplate:{template:`
|
|
107
108
|
{{#hasExternalPromotions}}
|
|
108
109
|
<div class="searchstax-external-promotions-container" id="searchstax-external-promotions-container" data-test-id="searchstax-external-promotions-container">
|
|
109
110
|
External promotions go here
|
|
@@ -129,7 +130,7 @@ ${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
|
|
|
129
130
|
</p>
|
|
130
131
|
{{/url}}
|
|
131
132
|
</div>
|
|
132
|
-
`}},
|
|
133
|
+
`}},Rn={mainTemplateDesktop:{template:`
|
|
133
134
|
{{#hasResultsOrExternalPromotions}}
|
|
134
135
|
<div class="searchstax-facets-container-desktop"></div>
|
|
135
136
|
{{/hasResultsOrExternalPromotions}}
|
|
@@ -187,7 +188,7 @@ ${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
|
|
|
187
188
|
<div class="searchstax-facets-pill-label">{{value}} ({{count}})</div>
|
|
188
189
|
<div class="searchstax-facets-pill-icon-close"></div>
|
|
189
190
|
</div>
|
|
190
|
-
`,containerClass:"searchstax-facets-pill-facets"}},
|
|
191
|
+
`,containerClass:"searchstax-facets-pill-facets"}},Nn={mainTemplate:{template:`
|
|
191
192
|
{{#results.length}}
|
|
192
193
|
<div class="searchstax-pagination-container" data-test-id="searchstax-pagination-container">
|
|
193
194
|
<div class="searchstax-pagination-content">
|
|
@@ -205,7 +206,7 @@ ${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
|
|
|
205
206
|
<a class="searchstax-pagination-load-more" data-test-id="searchstax-pagination-load-more" tabindex="0">Show More</a>
|
|
206
207
|
{{/isLastPage}}
|
|
207
208
|
{{/results.length}}
|
|
208
|
-
`,loadMoreButtonClass:"searchstax-pagination-load-more"}},
|
|
209
|
+
`,loadMoreButtonClass:"searchstax-pagination-load-more"}},Pn={main:{template:`
|
|
209
210
|
{{#hasRelatedSearches}}
|
|
210
211
|
<div class="searchstax-related-searches-container" data-test-id="searchstax-related-searches-container" id="searchstax-related-searches-container">
|
|
211
212
|
Related searches: <span id="searchstax-related-searches"></span>
|
|
@@ -220,7 +221,7 @@ ${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
|
|
|
220
221
|
<span role="link" class="searchstax-related-search searchstax-related-search-item" data-test-id="searchstax-related-search-item" aria-label="Related search: {{related_search}}" tabindex="0">
|
|
221
222
|
{{ related_search }}{{^last}}<span>,</span>{{/last}}
|
|
222
223
|
</span>
|
|
223
|
-
`,relatedSearchContainerClass:"searchstax-related-search-item"}},
|
|
224
|
+
`,relatedSearchContainerClass:"searchstax-related-search-item"}},On={main:{template:`
|
|
224
225
|
{{#searchExecuted}}
|
|
225
226
|
<a href="#searchstax-search-results" data-test-id="searchstax-skip" class="searchstax-skip">Skip to results section</a>
|
|
226
227
|
<h4 class="searchstax-feedback-container" data-test-id="searchstax-feedback-container">
|
|
@@ -234,17 +235,19 @@ ${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
|
|
|
234
235
|
{{/hasResults}}
|
|
235
236
|
</h4>
|
|
236
237
|
{{/searchExecuted}}
|
|
237
|
-
`,originalQueryClass:"searchstax-feedback-original-query"}},
|
|
238
|
+
`,originalQueryClass:"searchstax-feedback-original-query"}},_n={mainTemplate:{template:`
|
|
238
239
|
<div class="searchstax-search-input-container searchstax-search-input-container-new {{#locationEnabled}}searchstax-alternative-render{{/locationEnabled}}">
|
|
239
240
|
<div class="searchstax-search-input-wrapper">
|
|
240
241
|
<input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." aria-label="Search" />
|
|
242
|
+
<button id="searchstax-clear-input-action-button" class="searchstax-cross-icon hidden" aria-label="clear input" role="button"></button>
|
|
243
|
+
<span id="searchstax-separator-icon" class="searchstax-separator hidden"></span>
|
|
241
244
|
</div>
|
|
242
245
|
<div id="searchstax-location-container" class="searchstax-location-container"></div>
|
|
243
246
|
<button class="searchstax-spinner-icon" id="searchstax-search-input-action-button" aria-label="search" role="button"></button>
|
|
244
247
|
</div>
|
|
245
248
|
`,searchInputId:"searchstax-search-input"},autosuggestItemTemplate:{template:`
|
|
246
249
|
<div class="searchstax-autosuggest-item-term-container">{{{term}}}</div>
|
|
247
|
-
`}},
|
|
250
|
+
`}},Fn={mainTemplate:{template:`
|
|
248
251
|
<div class="searchstax-location-input-container" data-test-id="searchstax-location-input-container">
|
|
249
252
|
<div class="searchstax-location-input-wrapper">
|
|
250
253
|
<span class="searchstax-location-input-label">NEAR</span>
|
|
@@ -262,7 +265,7 @@ ${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
|
|
|
262
265
|
{{/shouldShowLocationDistanceDropdown}}
|
|
263
266
|
</div>
|
|
264
267
|
</div>
|
|
265
|
-
`,locationInputId:"searchstax-location-input",radiusInputId:"searchstax-location-radius-select",currentLocationActionButtonId:"searchstax-location-get-current-location"}},
|
|
268
|
+
`,locationInputId:"searchstax-location-input",radiusInputId:"searchstax-location-radius-select",currentLocationActionButtonId:"searchstax-location-get-current-location"}},zn={mainTemplate:{template:`
|
|
266
269
|
<section aria-label="search results container" tabindex="0">
|
|
267
270
|
<div class="searchstax-search-results-container" id="searchstax-search-results-container" data-test-id="searchstax-search-results-container">
|
|
268
271
|
<div class="searchstax-search-results" id="searchstax-search-results"></div>
|
|
@@ -334,7 +337,7 @@ ${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
|
|
|
334
337
|
</ul>
|
|
335
338
|
</div>
|
|
336
339
|
{{/searchExecuted}}
|
|
337
|
-
`}}
|
|
340
|
+
`}},$n={main:{template:`
|
|
338
341
|
{{#searchExecuted}}
|
|
339
342
|
{{#hasResultsOrExternalPromotions}}
|
|
340
343
|
{{#sortOptions.length}}
|
|
@@ -351,7 +354,7 @@ ${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
|
|
|
351
354
|
{{/sortOptions.length}}
|
|
352
355
|
{{/hasResultsOrExternalPromotions}}
|
|
353
356
|
{{/searchExecuted}}
|
|
354
|
-
`,selectId:"searchstax-search-order-select"}},
|
|
357
|
+
`,selectId:"searchstax-search-order-select"}},Z={mainTemplate:{template:`
|
|
355
358
|
<div class="sf-widget-container">
|
|
356
359
|
<div id="sf-widget" class="sf-main">
|
|
357
360
|
<a role="button" href="#" id="searchstax-open-feedback" class="sf-open-feedback" tabindex="0" aria-label="Open Search Feedback">[ - ] Search Feedback</a>
|
|
@@ -434,4 +437,4 @@ ${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
|
|
|
434
437
|
|
|
435
438
|
</div>
|
|
436
439
|
</div>
|
|
437
|
-
`,thumbsUpButtonClass:"searchstax-lightweight-widget-thumbs-up",thumbsDownButtonClass:"searchstax-lightweight-widget-thumbs-down"}};class L{static answer=wn;static externalPromotions=Cn;static facets=Mn;static pagination=bn;static relatedSearches=Tn;static searchFeedback=Sn;static searchInput=xn;static location=kn;static searchResults=An;static sorting=En;static feedback=U}class vn{dataLayer;config;containerId;externalPromotionsContainerId;searchExternalPromotionsMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.externalPromotionsContainerId=this.config.templates?.mainTemplate?.externalPromotionsContainerId||L.externalPromotions.mainTemplate.externalPromotionsContainerId,typeof document<"u"&&(this.searchExternalPromotionsMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}initializeSubscriptions(){this.dataLayer.$searchExternalPromotions.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data,externalPromotions:this.dataLayer.parsedData.externalPromotions};return this.dataLayer.setExternalPromotionsData(e),e}addExternalSearch(e){const t=typeof document<"u"?document?.getElementById(this.externalPromotionsContainerId):null;if(t){const s=this.config?.templates?.externalPromotion?.template||L.externalPromotions.externalPromotion?.template;if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-external-promotion"),a.addEventListener("click",i=>{this.trackClick(e,i)}),a.innerHTML=A.render(s,e),t.appendChild(a)}}}trackClick(e,t){t.stopPropagation(),t.preventDefault(),window?.open(e.url,"_blank")}renderMainTemplate(e){const t=this.config?.templates?.mainTemplate?.template||L.externalPromotions.mainTemplate?.template;if(this.dataLayer.renderingEngine===N.mustache){this.searchExternalPromotionsMainContainer.innerHTML=A.render(t,e);const s=typeof document<"u"?document?.getElementById(this.externalPromotionsContainerId):null;s&&(s.innerHTML="");for(const a of e.externalPromotions)this.addExternalSearch(a)}}}class V{static addAccessibilityNotificationContainerToBody(){if(!document.getElementById("searchAccessibilityContainer")){const t=document.createElement("div");t.setAttribute("aria-live","polite"),t.setAttribute("id","searchAccessibilityContainer"),document.body.appendChild(t)}}static setAccessibilityText(e,t,s){this.addAccessibilityNotificationContainerToBody();const a=s??"searchAccessibility",i=document.getElementById(a);i&&i.remove();const r=document.createElement("span");r.setAttribute("id",a),r.innerHTML=e;const o=document.getElementById("searchAccessibilityContainer");o&&setTimeout(()=>{o.appendChild(r)},t??100)}}class Dn{dataLayer;config;containerId;routerHelper;cachedPhrase="";cachedANDFacets="";isCached=!1;overlayOpened=!1;facetPaginationStep;facetPaginationStepMobile;searchFacetsMainContainer=null;searchFacetsMobileContainer=null;searchFacetsDesktopContainer=null;facetLimits={};facetLimitsMobile={};deactivatedFacets={};focusedElement=null;cachedData=null;cacheFacets;constructor(e,t){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.routerHelper=e.routerHelper,this.cacheFacets=t,this.facetPaginationStep=this.config.itemsPerPageDesktop,this.facetPaginationStepMobile=this.config.itemsPerPageMobile,typeof document<"u"&&(this.searchFacetsMainContainer=document?.getElementById(this.containerId)),this.needCache&&t(this.config.facetingType==="tabs"),this.initializeSubscriptions()}get needCache(){return this.config.facetingType==="showUnavailable"||this.config.facetingType==="or"||this.config.facetingType==="tabs"}get needDisabling(){return this.config.facetingType==="showUnavailable"}initializeSubscriptions(){this.needCache&&(this.dataLayer.$searchFacetsCached.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$searchFacetsCachedTabs.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())})),this.dataLayer.$searchResults.subscribe(e=>{e&&(this.needCache&&!this.isCached&&(this.dataLayer.searchFacets&&!this.dataLayer.searchFacetsCached&&this.dataLayer.setSearchFacetsCached(this.dataLayer.searchFacets),this.cacheFacets(this.config.facetingType==="tabs")),this.renderMainTemplate(this.generateTemplateData()))}),this.dataLayer.$searchObject.subscribe(e=>{this.cachedPhrase!==e.query||this.cachedANDFacets!==this.dataLayer.parsedData.cachedANDFacets?(this.cachedANDFacets=this.dataLayer.parsedData.cachedANDFacets,this.cachedPhrase=e.query,this.isCached=!1):this.isCached=!0})}extractFacetValue(e){return{type:this.config.facetingType,name:e.parentName,value:e.value}}applyFacetLimits(e,t){const s=t?this.facetPaginationStepMobile:this.facetPaginationStep,a=t?this.facetLimits:this.facetLimitsMobile;return e.forEach(i=>{a[i.name]||(a[i.name]=s)}),e.map(i=>({...i,values:i.values.slice(0,a[i.name]),showingAllFacets:i.values.length<=a[i.name],hasMoreFacets:i.values.length>s}))}generateTemplateData(e){if(this.generateSelectedFacetsData(),this.dataLayer.searchFacets){let t=this.dataLayer.searchFacets;this.config.hooks?.beforeFacetsRender&&(t=this.config.hooks.beforeFacetsRender(t)),this.needCache&&this.dataLayer.searchFacetsCached&&(t=this.dataLayer.searchFacetsCached,this.config.facetingType==="tabs"&&this.dataLayer.searchFacetsCachedTabs&&(t=this.dataLayer.searchFacetsCachedTabs),this.needDisabling&&(t=t.map(a=>{const i=this.dataLayer.searchFacets?.find(r=>r.name===a.name);return i?{...a,values:a.values.map(o=>{const c=i.values.find(h=>o.type==="range"?!1:o.type==="checkbox"?h.value===o.value:!1);return{...o,disabled:!c,isMobile:e}})}:{...a,values:a.values.map(o=>({...o,disabled:!0})),isMobile:e}}))),this.config.specificFacets&&(t=t.filter(a=>this.config.specificFacets?.includes(a.name)));const s={facets:this.applyFacetLimits(t,e),...this.dataLayer.parsedData.data,isMobile:e};return this.dataLayer.setFacetsTemplateData(s),s}else{const t={facets:[],...this.dataLayer.parsedData.data,isMobile:e};return this.dataLayer.setFacetsTemplateData(t),t}}createFacetItem(e,t,s){if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-facet-container"),this.deactivatedFacets[e.name]||a.classList.add("active");const i=this.config?.templates?.facetItemContainerTemplate?.template||L.facets.facetItemContainerTemplate?.template;a.innerHTML=A.render(i,e),t.appendChild(a);const r=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerClass||L.facets.facetItemContainerTemplate?.facetListTitleContainerClass));r?.addEventListener("click",()=>{a.classList.toggle("active");const c=a.classList.contains("active"),h=r.querySelector(".searchstax-facet-title");h&&h.setAttribute("aria-expanded",String(c))}),r?.querySelector("."+this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerInner)?.addEventListener("keydown",c=>{if(c.code==="Enter"||c.code==="Space"){c.preventDefault(),a.classList.toggle("active");const h=a.classList.contains("active"),d=r.querySelector(".searchstax-facet-title");d&&d.setAttribute("aria-expanded",String(h))}});const o=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListContainerClass||L.facets.facetItemContainerTemplate?.facetListContainerClass));o&&(e.values.forEach(c=>{this.createFacetListItem(c,o,e.name)}),e.hasMoreFacets&&this.createHasMoreComponent(e,o,s))}}isChecked(e){return!!this.dataLayer.searchObject.facets?.find(t=>oe.deepEqual(t,this.extractFacetValue(e)))}createFacetListItem(e,t,s){if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-facet-value-container"),e.disabled&&a.classList.add("searchstax-facet-value-disabled");const i=this.isChecked(e),r=this.config?.templates?.facetItemTemplate?.template||L.facets.facetItemTemplate?.template;a.innerHTML=A.render(r,{...e,isChecked:i});let o=L.facets.facetItemTemplate?.checkTriggerClasses;o=this.config?.templates?.facetItemTemplate?.checkTriggerClasses||o,o.forEach(h=>{a.querySelector("."+h)?.addEventListener("click",C=>{this.onFacetSelect(C,e,a)})});const c=a.querySelector("."+(this.config?.templates?.facetItemTemplate?.inputCheckboxClass||L.facets.facetItemTemplate?.inputCheckboxClass));c?.addEventListener("click",h=>{this.onFacetSelect(h,e,a,!0)}),c&&c?.setAttribute("data-test-value",`${encodeURIComponent(s)}:"${encodeURIComponent(e.value)}"`),t.appendChild(a)}}onFacetSelect=(e,t,s,a,i)=>{if(e.stopPropagation(),!t.disabled){const r=s.querySelector("input");let o=a?r.checked:!r.checked;i!==void 0&&(o=!i),r.checked=o;const c=this.dataLayer.searchObject;let h=[...c.facets];const d=this.extractFacetValue(t);o?h.find(y=>oe.deepEqual(y,d)?y:!1)||(this.config.facetingType==="tabs"&&(h=h.filter(y=>y.name!==d.name)),h.push(d)):h=h.filter(C=>!oe.deepEqual(C,d)),setTimeout(()=>{this.dataLayer.setSearchObject({...c,facets:h,page:1}),this.config.facetingType==="tabs"&&this.renderMainTemplate(this.generateTemplateData(),!0)},0)}};createHasMoreComponent(e,t,s){if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-facet-show-more-container");const i=this.config?.templates?.showMoreButtonContainerTemplate?.template||L.facets.showMoreButtonContainerTemplate?.template;a.innerHTML=A.render(i,{...e,focusId:`moreLess${e?.values?.[0]?.value}`});const r=a.querySelector("."+(this.config?.templates?.showMoreButtonContainerTemplate?.showMoreButtonClass||L.facets.showMoreButtonContainerTemplate?.showMoreButtonClass));r&&(this.attachOnclickToShowMore(e,r,s),t&&t.appendChild(r))}}attachOnclickToShowMore(e,t,s){t.addEventListener("click",a=>{this.onShowMoreLessClick(a,e,s)}),t.addEventListener("keydown",a=>{a.code==="Space"&&a.preventDefault()}),t.addEventListener("keyup",a=>{(a.code==="Space"||a.code==="Enter")&&(a.preventDefault(),this.onShowMoreLessClick(a,e,s))})}onShowMoreLessClick(e,t,s){e.preventDefault();const a=s?this.facetPaginationStepMobile:this.facetPaginationStep,i=s?this.facetLimits:this.facetLimitsMobile;i[t.name]===void 0?i[t.name]=a*2:i[t.name]<=t.values.length?(V.setAccessibilityText(`More Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),i[t.name]=i[t.name]+a):(V.setAccessibilityText(`Less Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),i[t.name]=a),this.generateTemplateData(s),this.renderMainTemplate(this.generateTemplateData())}renderMainTemplate(e,t){if(e&&(!oe.deepEqual(this.cachedData??{},e)||t)){this.cachedData=e;const s=this.config?.templates?.mainTemplateDesktop?.template||L.facets.mainTemplateDesktop?.template;if(this.dataLayer.renderingEngine===N.mustache&&this.searchFacetsMainContainer){const a=document.activeElement;a instanceof HTMLInputElement&&a.type==="checkbox"||a?.classList.contains("searchstax-facet-show-more-button")||a?.classList.contains("searchstax-facet-show-less-button")?this.focusedElement=a:this.focusedElement=null,this.searchFacetsMainContainer.innerHTML=A.render(s,{...e});const i=this.searchFacetsMainContainer?.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.facetsContainerClass||L.facets.mainTemplateDesktop.facetsContainerClass));if(i){i.innerHTML="";for(const r of e.facets)this.createFacetItem(r,i);if(this.searchFacetsMainContainer){const r=this.searchFacetsMainContainer.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.selectedFacetsContainerClass||L.facets.mainTemplateDesktop.selectedFacetsContainerClass));r&&(this.createSelectedFacetsComponents(r),this.createClearFacetsComponents(r))}if(this.focusedElement){if(this.focusedElement.classList.contains("searchstax-facet-show-more-button")||this.focusedElement.classList.contains("searchstax-facet-show-less-button")){const c=this.focusedElement.getAttribute("data-focus"),h=this.searchFacetsMainContainer.querySelector(`[data-focus="${c}"]`);h instanceof HTMLElement&&h.focus(),this.focusedElement=null;return}const r=this.focusedElement.getAttribute("data-test-value"),o=this.searchFacetsMainContainer.querySelector(`[data-test-value="${r}"]`);o instanceof HTMLInputElement&&o.focus(),this.focusedElement=null}}}setTimeout(()=>{document.querySelectorAll(".searchstax-facet-title").forEach(i=>{i.setAttribute("aria-expanded",String(!0)),i.setAttribute("tabindex","0"),i.setAttribute("role","button")})},100),this.renderMobileTemplate(this.generateTemplateData(!0))}else this.generateSelectedFacetsData()}generateSelectedFacetsData(){const e=[],t=this.dataLayer.searchObject.facets;for(const s of t){const a=decodeURIComponent(s.name),i=decodeURIComponent(s.value);if(this.dataLayer.searchFacets){const o=(this.needCache?this.dataLayer.searchFacetsCached:this.dataLayer.searchFacets)?.find(c=>c.name===a);if(o){const c=o.values.find(h=>h.type==="range"?!1:h.type==="checkbox"?`"${h.value}"`==`"${i}"`:!1);c&&e.push(c)}}}this.dataLayer.setSelectedFacetsTemplateData(e)}createSelectedFacetsComponents(e){this.generateSelectedFacetsData(),this.dataLayer.selectedFacetsTemplateData?.forEach(t=>{this.createSelectedFacetsComponent(e,t)})}createClearFacetsComponents(e){if(typeof document<"u"){const t=this.dataLayer.searchObject,s=this.config?.templates?.clearFacetsTemplate?.template||L.facets.clearFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=A.render(s,{shouldShow:t.facets.length>0});const i=a.querySelector("."+(this.config?.templates?.clearFacetsTemplate?.containerClass||L.facets.clearFacetsTemplate?.containerClass));i&&(i.addEventListener("click",()=>{this.removeSelectedFacets()}),i.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.removeSelectedFacets()}),e.appendChild(i))}}createSelectedFacetsComponent(e,t){if(typeof document<"u"){const s=this.config?.templates?.selectedFacetsTemplate?.template||L.facets.selectedFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=A.render(s,t);const i=a.querySelector("."+(this.config?.templates?.selectedFacetsTemplate?.containerClass||L.facets.selectedFacetsTemplate?.containerClass));i&&(i.addEventListener("click",()=>{this.unselectFacet(t)}),i.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.unselectFacet(t)}),e.appendChild(i))}}unselectFacet(e){const t=this.dataLayer.searchObject;let s=[...t.facets];e.type==="checkbox"&&(s=s.filter(a=>JSON.stringify(a)!==JSON.stringify(this.extractFacetValue(e)))),setTimeout(()=>{this.dataLayer.setSearchObject({...t,facets:s}),this.generateSelectedFacetsData()},0)}removeSelectedFacets(){const e=this.dataLayer.searchObject;this.dataLayer.setSearchObject({...e,facets:[]})}createFilterByComponent(e){if(typeof document<"u"){const t=this.config?.templates?.filterByTemplate?.template||L.facets.filterByTemplate?.template,s=document?.createElement("div");s.innerHTML=A.render(t,{});const a=s.querySelector("."+(this.config?.templates?.filterByTemplate?.containerClass||L.facets.filterByTemplate?.containerClass));a&&(e.prepend(a),a.addEventListener("click",this.openOverlay.bind(this)),a.addEventListener("keyup",i=>{(i.code==="Space"||i.code==="Enter")&&this.openOverlay()}))}}openOverlay(){V.setAccessibilityText("Facet overlay opened. Tab to select facets."),this.overlayOpened=!0,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.add("searchstax-show"))}closeOverlay(){V.setAccessibilityText("Facet overlay closed"),this.overlayOpened=!1,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.remove("searchstax-show"))}renderMobileTemplate(e){if(e&&typeof document<"u"){const t=document?.createElement("div");t.classList.add("searchstax-facets-container-mobile");const s=this.config?.templates?.mainTemplateMobile?.template||L.facets.mainTemplateMobile?.template;if(this.dataLayer.renderingEngine===N.mustache){if(t.innerHTML=A.render(s,{...e,overlayOpened:this.overlayOpened}),this.searchFacetsMainContainer?.appendChild(t),this.config?.templates?.mainTemplateMobile)for(const o of this.config?.templates?.mainTemplateMobile?.closeOverlayTriggerClasses||[]){const c=t.querySelector("."+o);c&&(c.addEventListener("click",this.closeOverlay.bind(this)),c.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}else for(const o of L.facets.mainTemplateMobile.closeOverlayTriggerClasses){const c=t.querySelector("."+o);c&&(c.addEventListener("click",this.closeOverlay.bind(this)),c.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}const a=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.filterByContainerClass||L.facets.mainTemplateMobile.filterByContainerClass));a&&this.createFilterByComponent(a);const i=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.selectedFacetsContainerClass||L.facets.mainTemplateMobile.selectedFacetsContainerClass));i&&(this.createSelectedFacetsComponents(i),this.createClearFacetsComponents(i));const r=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.facetsContainerClass||L.facets.mainTemplateMobile.facetsContainerClass));if(r){r.innerHTML="";for(const o of e.facets)this.createFacetItem(o,r,!0)}}}}}class In{dataLayer;config;containerId;previousButtonClass;nextButtonClass;loadMoreButtonClass;routerHelper;searchPaginationMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.routerHelper=e.routerHelper,this.previousButtonClass=this.config?.templates?.mainTemplate?.previousButtonClass??L.pagination.mainTemplate.previousButtonClass,this.nextButtonClass=this.config?.templates?.mainTemplate?.nextButtonClass??L.pagination.mainTemplate.nextButtonClass,this.loadMoreButtonClass=this.config?.templates?.infiniteScrollTemplate?.loadMoreButtonClass??L.pagination.infiniteScrollTemplate.loadMoreButtonClass,typeof document<"u"&&(this.searchPaginationMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}get isFirstPage(){return this.dataLayer.searchObject?.page===1}get isLastPage(){return this.dataLayer.parsedData.data.isLastPage}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data,previousPageLink:this.routerHelper?.searchObjectToUrl({...this.dataLayer.searchObject,page:this.dataLayer.searchObject?.page-1}),nextPageLink:this.routerHelper?.searchObjectToUrl({...this.dataLayer.searchObject,page:this.dataLayer.searchObject?.page+1})};return this.dataLayer.setPaginationData(e),e}goToPage(e,t){const s=this.dataLayer.searchObject;s&&(s.page=e,this.dataLayer.setSearchObject(s));const a=document.querySelector(".searchstax-page-layout-result-container");if(a instanceof HTMLElement){const i=a.querySelector('[tabindex="0"]');i instanceof HTMLElement&&i.focus()}else document.body.tabIndex=-1,document.body.focus();t||(a instanceof HTMLElement?a.scrollIntoView({block:"start",behavior:"auto"}):window?.scrollTo(0,0))}nextPage(e){e?.preventDefault(),e?.stopPropagation(),this.isLastPage||this.goToPage(this.dataLayer.searchObject?.page+1,this.dataLayer.isInfiniteScroll)}previousPage(e){e?.preventDefault(),e?.stopPropagation(),this.isFirstPage||this.goToPage(this.dataLayer.searchObject?.page-1)}overridePaginationEvents(){if(this.searchPaginationMainContainer){const e=this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass),t=this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass),s=this.searchPaginationMainContainer.querySelector("."+this.loadMoreButtonClass);e&&(e.addEventListener("click",this.previousPage.bind(this)),e.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.previousPage(a)})),t&&(t.addEventListener("click",this.nextPage.bind(this)),t.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.nextPage(a)})),s&&(s.addEventListener("click",this.nextPage.bind(this)),s.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.nextPage(a)}))}}renderMainTemplate(e){this.searchPaginationMainContainer&&(this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass)?.removeEventListener("click",this.previousPage),this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass)?.removeEventListener("click",this.nextPage));let t=this.config?.templates?.mainTemplate?.template||L.pagination.mainTemplate?.template;this.dataLayer.isInfiniteScroll&&(t=this.config?.templates?.infiniteScrollTemplate?.template||L.pagination.infiniteScrollTemplate?.template),this.dataLayer.renderingEngine===N.mustache&&(this.searchPaginationMainContainer.innerHTML=A.render(t,e),setTimeout(()=>{this.overridePaginationEvents()},0))}}class Rn{dataLayer;config;containerId;relatedSearchesContainerClass;searchRelatedSearchesMainContainer=null;track;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.relatedSearchesContainerClass=this.config.templates?.main?.relatedSearchesContainerClass||L.relatedSearches.main.relatedSearchesContainerClass,typeof document<"u"&&(this.searchRelatedSearchesMainContainer=document?.getElementById(this.containerId)),this.track=e.trackRelatedSearchClick,this.initializeSubscriptions()}initializeSubscriptions(){this.dataLayer.$searchRelatedSearches.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setRelatedSearchesData(e),e}addRelatedSearchComponent(e,t){if(typeof document<"u"){const s=document?.createElement("div"),a=this.config?.templates?.relatedSearch?.template||L.relatedSearches.relatedSearch.template;if(this.dataLayer.renderingEngine===N.mustache){s.innerHTML=A.render(a,e);const i=s.querySelector("."+(this.config.templates?.relatedSearch?.relatedSearchContainerClass||L.relatedSearches.relatedSearch.relatedSearchContainerClass));i&&(t.appendChild(i),i.addEventListener("click",()=>{this.executeSearch(e)}),i.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.executeSearch(e)}))}}}executeSearch(e){const t=this.dataLayer.searchObject;t.query=e.related_search,this.dataLayer.setSearchObject(t),this.track(e)}renderMainTemplate(e){const t=this.config?.templates?.main?.template||L.relatedSearches.main.template;if(this.dataLayer.renderingEngine===N.mustache&&this.searchRelatedSearchesMainContainer){this.searchRelatedSearchesMainContainer.innerHTML="",this.searchRelatedSearchesMainContainer.innerHTML=A.render(t,e);const s=this.searchRelatedSearchesMainContainer?.querySelector(`.${this.relatedSearchesContainerClass}`);if(s)for(const a of e.relatedSearches)this.addRelatedSearchComponent(a,s)}}}class jn{dataLayer;config;containerId;searchFeedbackMainContainer=null;searchTrigger;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.searchTrigger=e.searchTrigger,typeof document<"u"&&(this.searchFeedbackMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions()}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setSearchFeedbackData(e),e}onOriginalQueryClick(e){e.stopPropagation(),e.preventDefault();const t=e.target?.innerHTML;this.searchTrigger(t,!0)}attachClick(){const e=this.searchFeedbackMainContainer?.querySelector("."+(this.config?.templates?.main?.originalQueryClass||L.searchFeedback.main?.originalQueryClass));e&&e.addEventListener("click",this.onOriginalQueryClick.bind(this))}renderMainTemplate(e){const t=this.config?.templates?.main?.template||L.searchFeedback.main.template;this.dataLayer.renderingEngine===N.mustache&&(this.searchFeedbackMainContainer.innerHTML=A.render(t,e),setTimeout(()=>{this.attachClick()},0))}}class Nn{searchHelper;dataLayer;config;suggestAfterMinChars;containerId;currentInputValue="";autosuggestResults;searchInput;actionButton;autosuggestContainer;buttonState="search";selectedAutosuggestItem=-1;suggestTrigger;searchTrigger;constructor(e){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.suggestAfterMinChars===void 0&&this.getSuggestAfterValue(),this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())},200)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||L.searchInput.mainTemplate.template,s={...this.dataLayer.parsedData.data,locationEnabled:!!this.dataLayer.locationEnabled};if(this.dataLayer.setInputWidgetTemplateData(s),this.dataLayer.renderingEngine===N.mustache){const r=A.render(t,s);e.innerHTML=r,this.dataLayer.setInputTemplateRendered(!0)}const a=this.config.templates?.mainTemplate?.searchInputId||L.searchInput.mainTemplate.searchInputId,i=document?.querySelector(`#${a}`);if(i)this.searchInput=i,i.addEventListener("keyup",this.inputKeyupEvent.bind(this)),i.addEventListener("blur",this.hideAutosuggest.bind(this)),i.addEventListener("paste",this.inputPasteEvent.bind(this));else throw new Error("Input not found")}}createAutosuggestContainer(){this.dataLayer.renderingEngine===N.mustache&&typeof document<"u"&&(this.autosuggestContainer=document?.createElement("div"),this.autosuggestContainer.classList.add("searchstax-autosuggest-container"),this.autosuggestContainer.addEventListener("mouseleave",()=>{this.resetAutosuggestSelection(),this.markActiveAutosuggestItem()}),this.searchInput?.after(this.autosuggestContainer))}getSuggestAfterValue(){this.dataLayer.searchHelper&&this.dataLayer.searchHelper.suggest("*",e=>{this.suggestAfterMinChars=e.metadata.minPrefixChars},[])}actionButtonInit(){typeof document<"u"&&(this.actionButton=document?.getElementById("searchstax-search-input-action-button"),this.actionButton&&this.actionButton.addEventListener("click",()=>{this.executeSearch(this.searchInput?.value??"")}))}attachSubscriptions(){this.dataLayer.$searchTermChange.subscribe(()=>{this.handleSearchTermChange()}),this.dataLayer.$loadingChange.subscribe(()=>{this.handleLoadingChange()}),this.dataLayer.$searchAutosuggest.subscribe(e=>{e&&this.appendSuggestions(e)}),this.dataLayer.$searchObject.subscribe(e=>{e.query!=="undefined"&&e.query!==void 0&&e.query!=="*"&&this.searchInput&&(this.searchInput.value=this.cleanSuggestionTerm(e.query??""))})}handleLoadingChange(){this.dataLayer.loading?this.updateActionButtonState("loading"):this.handleSearchTermChange()}handleSearchTermChange(){this.updateActionButtonState("search")}updateActionButtonState(e){if(this.buttonState=e,this.actionButton)switch(this.actionButton.classList.remove("searchstax-spinner-icon"),this.actionButton.classList.remove("searchstax-search-icon"),e){case"loading":this.actionButton.classList.add("searchstax-spinner-icon");break;case"search":this.actionButton.classList.add("searchstax-search-icon"),this.actionButton.setAttribute("aria-label","search");break}}selectPreviousAutosuggestItem(e){this.selectedAutosuggestItem>0?this.selectedAutosuggestItem--:this.selectedAutosuggestItem===0?(this.selectedAutosuggestItem=-1,e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),V.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=this.autosuggestResults.suggestions.length-1,this.markActiveAutosuggestItem()}selectNextAutosuggestItem(){this.selectedAutosuggestItem<this.autosuggestResults.suggestions.length-1?this.selectedAutosuggestItem++:this.selectedAutosuggestItem===this.autosuggestResults.suggestions.length-1?(this.selectedAutosuggestItem=-1,V.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=0,this.markActiveAutosuggestItem()}resetAutosuggestSelection(){this.selectedAutosuggestItem=-1,this.markActiveAutosuggestItem()}markActiveAutosuggestItem(){if(typeof document<"u"){const e=document?.getElementsByClassName("searchstax-autosuggest-item");for(let t=0;t<e.length;t++){const s=e[t];t===this.selectedAutosuggestItem?(s.classList.add("active"),V.setAccessibilityText(`Selected suggestion: ${s.innerText}`)):s.classList.remove("active")}}}inputKeyupEvent(e){const t=e.key;this.currentInputValue=e.target.value,t==="Enter"?this.suggestionChosen():t==="Escape"?this.hideAutosuggest(e.target):t==="ArrowUp"?this.selectPreviousAutosuggestItem(e.target):t==="ArrowDown"?this.selectNextAutosuggestItem():this.autosuggestHandling(e),this.handleSearchTermChange()}autosuggestHandling(e){this.suggestAfterMinChars&&e.target&&e.target.value.length>=this.suggestAfterMinChars?this.executeSuggest(e.target.value):this.hideAutosuggest()}inputPasteEvent(e){setTimeout(()=>{this.autosuggestHandling(e),this.handleSearchTermChange()},0)}executeSuggest(e){this.suggestTrigger(e)}executeSearch(e){this.hideAutosuggest(),this.searchTrigger(e===""?"*":e)}suggestionChosen(){this.selectedAutosuggestItem>-1?this.autosuggestItemClicked(this.autosuggestResults.suggestions[this.selectedAutosuggestItem]):this.executeSearch(this.currentInputValue)}hideAutosuggest(e){setTimeout(()=>{this.dataLayer.setAutosuggestResults({numFound:0,suggestions:[]}),this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.add("hidden")),this.resetAutosuggestSelection(),e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),V.setAccessibilityText("No Suggestion selected")},200)}cleanSuggestionTerm(e){return H.removeXSSRiskyTags(e.replace(/(<([^>]+)>)/gi,"")).trim()}autosuggestItemClicked(e){this.searchInput.value=this.cleanSuggestionTerm(e.term??""),this.executeSearch(this.cleanSuggestionTerm(e.term))}createAutosuggestItem(e){const t=document?.createElement("div");t.classList.add("searchstax-autosuggest-item"),t.addEventListener("click",()=>{this.autosuggestItemClicked(e)}),t.addEventListener("mouseenter",()=>{this.onSuggestionEnter(e)});const s=this.config.templates?.autosuggestItemTemplate?.template||L.searchInput.autosuggestItemTemplate?.template;return t.innerHTML=A.render(s,e),t}onSuggestionEnter(e){this.selectedAutosuggestItem=this.autosuggestResults?.suggestions.indexOf(e)||0,this.markActiveAutosuggestItem()}appendSuggestions(e){this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.remove("hidden"));for(const t in e.suggest)if(Object.prototype.hasOwnProperty.call(e.suggest,t)){const s=e.suggest[t];for(const a in s)if(Object.prototype.hasOwnProperty.call(s,a)){const i=s[a];i.numFound?V.setAccessibilityText("Suggestions are available. Use up and down arrows to navigate while focusing input. Use Escape key to escape out of the suggestions",2e3):V.setAccessibilityText("",0),this.autosuggestResults=i,this.dataLayer.setAutosuggestResults(i),i.numFound>0?i.suggestions.forEach(r=>{this.autosuggestContainer&&typeof document<"u"&&this.autosuggestContainer.appendChild(this.createAutosuggestItem(r))}):this.autosuggestContainer&&this.autosuggestContainer.classList.add("hidden")}}}}class Pn{dataLayer;config;linkClickCallback;searchCallback;containerId;searchResultsMainContainer;searchResultsContainer;searchResultLinks=[];constructor(e){this.linkClickCallback=e.linkClickCallback,this.searchCallback=e.searchTrigger,this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId;const t=document?.getElementById(this.containerId);if(t)this.searchResultsMainContainer=t;else throw new Error(`Search Results Main Container with id ${this.containerId} not found`);this.dataLayer.setIsInfiniteScroll(e.config.renderMethod==="infiniteScroll"),this.initializeSubscriptions(),this.renderMainTemplate()}initializeSubscriptions(){this.dataLayer.$searchObject.subscribe(()=>{V.setAccessibilityText("Searching...")}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.searchResultsContainer&&this.renderResults(e)})}changeTemplate(){this.dataLayer.searchResults&&this.renderResults(this.dataLayer.searchResults)}renderNoResultsTemplate(){const e=this.config?.templates?.noSearchResultTemplate?.template||L.searchResults.noSearchResultTemplate?.template,t=this.dataLayer.searchResultsMetadata?.spellingSuggestion??"";if(this.dataLayer.renderingEngine===N.mustache&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=A.render(e,{spellingSuggestion:t,...this.dataLayer.parsedData.data,searchCallback:this.searchCallback.bind(this)})),t&&this.searchResultsContainer){const s=this.searchResultsContainer.querySelector("a");s&&s.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.searchCallback(t)})}}renderResults(e){if(this.dataLayer.renderingEngine===N.mustache&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)V.setAccessibilityText("Search has no results"),this.renderNoResultsTemplate();else{V.setAccessibilityText(`Showing ${this.dataLayer.parsedData.startResultIndex} through ${this.dataLayer.parsedData.endResultIndex} results from ${this.dataLayer.parsedData.totalResults}. Press tab to navigate through results`);const t=this.config?.templates?.searchResultTemplate?.template||L.searchResults.searchResultTemplate?.template,s=e.map(a=>A.render(t,a));this.config?.renderMethod==="infiniteScroll"&&this.dataLayer.searchObject.page>1?this.searchResultsContainer.innerHTML+=s.join(""):this.searchResultsContainer.innerHTML=s.join(""),this.searchResultLinks=Array.from(this.searchResultsContainer.querySelectorAll(`[${this.uniqueIdAttribute}]`)),this.attachLinkClickEvents()}}removeLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.removeEventListener("click",()=>{}),e.removeEventListener("keydown",()=>{})})}get uniqueIdAttribute(){return this.config?.templates?.searchResultTemplate?.searchResultUniqueIdAttribute||L.searchResults.searchResultTemplate?.searchResultUniqueIdAttribute}attachLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const s=e.getAttribute(this.uniqueIdAttribute)??"";s&&this.linkClickCallback(s)}),e.addEventListener("keydown",t=>{if(t.code==="Space"||t.code==="Enter"){const s=e.getAttribute(this.uniqueIdAttribute)??"";s&&this.linkClickCallback(s)}})})}renderMainTemplate(){const e=this.config?.templates?.mainTemplate?.template||L.searchResults.mainTemplate?.template;this.dataLayer.renderingEngine===N.mustache&&(this.searchResultsMainContainer.innerHTML=A.render(e,{}),setTimeout(()=>{const t=this.config?.templates?.mainTemplate?.searchResultsContainerId?this.config?.templates?.mainTemplate?.searchResultsContainerId:L.searchResults.mainTemplate?.searchResultsContainerId,s=document?.getElementById(t);if(s)this.searchResultsContainer=s;else throw new Error(`Search Results Container with id ${t} not found`)},0))}}class On{dataLayer;config;containerId;selectId;searchSortingMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.selectId=this.config.templates?.main?.selectId||L.sorting.main.selectId,this.searchSortingMainContainer=document?.getElementById(this.containerId),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setSearchSortingData(e),e}setOrderQuery(e){const t=this.dataLayer.searchObject;t&&(t.order=e,this.dataLayer.setSearchObject(t))}markOptionSelected(){const e=document?.getElementById(this.selectId);if(e){const t=e.querySelector(`option[value="${decodeURIComponent(this.dataLayer.searchObject.order)}"]`);t&&(t.selected=!0)}}renderMainTemplate(e){const t=this.config?.templates?.main?.template||L.sorting.main.template;if(this.dataLayer.renderingEngine===N.mustache){this.searchSortingMainContainer.innerHTML=A.render(t,e),this.markOptionSelected();const s=document?.getElementById(this.selectId);s&&s.addEventListener("change",a=>{this.setOrderQuery(a.target.value)})}}}class _n{analyticsKey;containerId;mainContainer;isLightweight;emailOverride;feedbackTextAreaOverride;mainTemplateOverride;lightweightTemplateOverride;focusedElement=null;focusTrapListener=null;lastFocusedElementBeforeModal=null;templateData={feedbackOpen:!1,ratings:[{index:1,isSelected:!1},{index:2,isSelected:!1},{index:3,isSelected:!1},{index:4,isSelected:!1},{index:5,isSelected:!1},{index:6,isSelected:!1},{index:7,isSelected:!1},{index:8,isSelected:!1},{index:9,isSelected:!1},{index:10,isSelected:!1}],emailInput:"",feedbackTextArea:"",charactersLeft:2e3,maxLength:2e3,errors:{rating:!1,email:!1},submitted:!1,thumbsUpActive:!1,thumbsDownActive:!1};thumbsUpValue=10;thumbsDownValue=1;ratedQuestion="";language="";model="";analyticsSrc="";constructor(e){this.analyticsKey=e.analyticsKey,this.containerId=e.containerId??"sf-feedback",this.isLightweight=e.lightweight??!1,this.isLightweight&&this.templateData.ratings.unshift({index:0,isSelected:!1}),this.thumbsUpValue=e.thumbsUpValue??10,this.thumbsDownValue=e.thumbsDownValue??1,this.emailOverride=e.emailOverride,this.feedbackTextAreaOverride=e.feedbackTextAreaOverride,this.mainTemplateOverride=e.mainTemplateOverride,this.lightweightTemplateOverride=e.lightweightTemplateOverride,this.mainContainer=document.getElementById(this.containerId),this.language=e.language??"",this.model=e.model??"",this.analyticsSrc=e.analyticsSrc??"",this.init()}init(){we.attachAnalyticsScript(this.analyticsSrc),this.renderMainTemplate(this.generateTemplateData())}generateTemplateData(){return this.templateData}renderMainTemplate(e){const t=document.activeElement;(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLAnchorElement)&&(t.type==="radio"||t.type==="button"||t.type==="textarea"||t instanceof HTMLAnchorElement)?this.focusedElement=t:this.focusedElement=null,this.mainContainer;let s=U?.mainTemplate?.template;if(this.mainTemplateOverride&&(s=this.mainTemplateOverride),this.isLightweight&&(s=U.lightweightTemplate?.template,this.lightweightTemplateOverride&&(s=this.lightweightTemplateOverride)),this.mainContainer.innerHTML=A.render(s,e),this.focusedElement&&this.mainContainer){const a=this.focusedElement.type==="radio"?this.focusedElement.getAttribute("id"):this.focusedElement.getAttribute("class"),i=this.focusedElement.type==="radio"?"id":"class",r=this.mainContainer.querySelector(`[${i}="${a}"]`);(r instanceof HTMLInputElement||r instanceof HTMLButtonElement||r instanceof HTMLTextAreaElement||r instanceof HTMLAnchorElement)&&r.focus(),this.focusedElement=null}this.attachEvents()}attachEvents(){this.isLightweight?this.attachLightweightEvents():(this.attachOpenModalEvent(),this.closeModalEvent(),this.attachRatingEvents(),this.attachTextAreaEvents(),this.attachEmailInputEvents(),this.attachSubmitButtonEvents())}attachFocusTrap(){this.focusTrapListener&&document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=e=>{if(!this.templateData.feedbackOpen)return;const t=this.getModalElement();if(!t)return;const s=this.getFocusableElements(t);if(s.length===0)return;const a=s[0],i=s[s.length-1];e.key==="Tab"&&(e.shiftKey?(document.activeElement===a||!t.contains(document.activeElement))&&(e.preventDefault(),i?.focus()):(document.activeElement===i||!t.contains(document.activeElement))&&(e.preventDefault(),a?.focus())),e.key==="Escape"&&(e.preventDefault(),this.closeFeedbackModal())},document.addEventListener("keydown",this.focusTrapListener)}getFocusableElements(e){const t=["button:not([disabled])","input:not([disabled])","textarea:not([disabled])","select:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(e.querySelectorAll(t))}getModalElement(){const e=U.mainTemplate?.modalContainerClass;return this.mainContainer?.querySelector(`.${e}`)||null}attachLightweightEvents(){const e=U.lightweightTemplate?.thumbsUpButtonClass,t=U.lightweightTemplate?.thumbsDownButtonClass,s=this.mainContainer?.querySelector("."+e),a=this.mainContainer?.querySelector("."+t);s&&s.addEventListener("click",()=>{const i=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[this.templateData.ratings.length-1].isSelected&&this.ratedQuestion===i||(this.templateData.thumbsUpActive=!0,this.templateData.thumbsDownActive=!1,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsUpValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=i,this.submit())}),a&&a.addEventListener("click",()=>{const i=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[0].isSelected&&this.ratedQuestion===i||(this.templateData.thumbsUpActive=!1,this.templateData.thumbsDownActive=!0,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsDownValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=i,this.submit())})}attachSubmitButtonEvents(){const e=U.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.checkIfValid()})}checkIfValid(){const e=this.mainContainer?.querySelector("#"+U.mainTemplate?.emailInputId);this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,V.setAccessibilityText("Please enter a valid email address.")),this.templateData.ratings.some(a=>a.isSelected)?this.templateData.errors.rating=!1:(this.templateData.errors.rating=!0,V.setAccessibilityText("Please Rate your experience.")),this.templateData.errors.rating||this.templateData.errors.email?this.renderMainTemplate(this.generateTemplateData()):this.submit()}submit(){this.templateData.submitted=!0;const e=this.templateData.ratings.find(t=>t.isSelected)?.index;e!==void 0&&(we.trackFeedback({trackApiKey:this.analyticsKey,email:this.emailOverride&&this.isLightweight?this.emailOverride():this.templateData.emailInput,rating:e,feedback:this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea,model:this.model?this.model:void 0,language:this.language?this.language:void 0}),this.showCheckmarkAnimation(),V.setAccessibilityText("Feedback has been sent.",1e3),this.mainContainer?.querySelector("."+U.mainTemplate?.checkmarkClass)?setTimeout(()=>{this.closeFeedbackModal(),this.renderMainTemplate(this.generateTemplateData())},2e3):(setTimeout(()=>{this.closeFeedbackModal()},500),this.renderMainTemplate(this.generateTemplateData())))}validateEmail(e){return e===""?!0:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}attachEmailInputEvents(){const e=this.mainContainer?.querySelector("#"+U.mainTemplate?.emailInputId);e&&(e.addEventListener("input",()=>{this.templateData.emailInput=e.value}),e.addEventListener("blur",()=>{setTimeout(()=>{this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,V.setAccessibilityText("Please enter a valid email address.")),this.renderMainTemplate(this.generateTemplateData())},300)}))}attachTextAreaEvents(){const e=this.mainContainer?.querySelector("#"+U.mainTemplate?.feedbackTextAreaId);e&&e.addEventListener("input",()=>{this.templateData.feedbackTextArea=e.value,this.templateData.charactersLeft=this.templateData.maxLength-e.value.length;const t=this.mainContainer?.querySelector("."+U.mainTemplate?.charactersRemainingContainerclass);t&&(t.innerText=this.templateData.charactersLeft+"")})}attachRatingEvents(){const e=U.mainTemplate?.ratingInputclass,t=this.mainContainer?.querySelectorAll("."+e);t&&t.forEach(s=>{s.addEventListener("click",a=>{const i=a.target.value;this.templateData.ratings.forEach(r=>{r.isSelected=r.index+""===i}),this.templateData.errors.rating=!1,this.renderMainTemplate(this.generateTemplateData())})})}attachOpenModalEvent(){const e=U.mainTemplate?.openModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",s=>{s.preventDefault(),this.toggleModal()})}toggleModal(){this.templateData.feedbackOpen?this.closeFeedbackModal():this.openFeedbackModal()}closeModalEvent(){const e=U.mainTemplate?.closeModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.closeFeedbackModal()})}openFeedbackModal(){this.lastFocusedElementBeforeModal=document.activeElement,this.templateData.feedbackOpen=!0,this.renderMainTemplate(this.generateTemplateData()),setTimeout(()=>{const e=this.getModalElement();if(e){const t=this.getFocusableElements(e);t.length>0&&t[0].focus()}this.attachFocusTrap()},0),V.setAccessibilityText("Feedback form opened",1e3)}closeFeedbackModal(){this.templateData.feedbackOpen=!1,this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null),this.renderMainTemplate(this.generateTemplateData()),this.lastFocusedElementBeforeModal&&(this.lastFocusedElementBeforeModal.focus(),this.lastFocusedElementBeforeModal=null),V.setAccessibilityText("Feedback form closed",1e3)}showCheckmarkAnimation(){const e=U.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&(t.disabled=!0);const s=U.mainTemplate?.checkmarkClass,a=this.mainContainer?.querySelector("."+s);a&&a.classList.remove("hidden");const i=U.mainTemplate?.submitButtonTextClass,r=this.mainContainer?.querySelector("."+i);r&&r.classList.add("visibility"),setTimeout(()=>{a&&a.classList.add("hidden"),r&&r.classList.remove("visibility"),t&&(t.disabled=!1)},2e3)}destroy(){this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null)}}class Fn{dataLayer;config;containerId;answerContainer=null;showMoreVisible=!1;renderFeedbackWidget=!1;clicked=!1;renderedWithShowMore=!1;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.renderFeedbackWidget=this.config.feedbackwidget?.renderFeedbackWidget||!1,this.config.showMoreAfterWordCount&&(this.dataLayer.answerWidgetShowMoreLimit=this.config.showMoreAfterWordCount),typeof document<"u"&&(this.answerContainer=document?.getElementById(this.containerId)),this.config.testString?(this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())):this.initializeSubscriptions(),this.dataLayer.setIsAnswerWidgetCreated(!0)}initializeSubscriptions(){this.dataLayer.$answer.subscribe(()=>{this.clicked?this.showMoreVisible=!1:this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerLoading.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerError.subscribe(e=>{e&&setTimeout(()=>{this.renderMainTemplate(this.generateTemplateData())},100)}),this.dataLayer.$searchObject.subscribe(()=>{this.clicked=!1,this.renderedWithShowMore=!1,this.showMoreVisible=!1}),this.dataLayer.$paginationData.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answer.subscribe(e=>{e&&setTimeout(()=>{this.initializeWidget()},600)}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.$answer.getValue()&&setTimeout(()=>{this.initializeWidget()},600)})}searchstaxFeedbackTextAreaOverride(){return"Question: "+(this.dataLayer.searchObject.query==="undefined"?"":this.dataLayer.searchObject.query)+" Answer: "+this.dataLayer.parsedData.getAnswerData}initializeWidget(){this.renderFeedbackWidget&&document.getElementById("feedbackWidgetContainer")&&!this.dataLayer.answerLoading&&new _n({analyticsKey:this.dataLayer.parsedData.trackingData.trackApiKey,containerId:"feedbackWidgetContainer",lightweight:!0,model:this.dataLayer.parsedData.trackingData.model,language:this.dataLayer.parsedData.trackingData.language,emailOverride:this.config.feedbackwidget?.emailOverride,feedbackTextAreaOverride:this.config.feedbackwidget?.searchstaxFeedbackTextAreaOverride??this.searchstaxFeedbackTextAreaOverride.bind(this),thumbsUpValue:this.config.feedbackwidget?.thumbsUpValue??10,thumbsDownValue:this.config.feedbackwidget?.thumbsDownValue??0,lightweightTemplateOverride:this.config.feedbackwidget?.lightweightTemplateOverride})}showMore(e){e.preventDefault(),this.clicked=!0,this.showMoreVisible=!1,this.renderMainTemplate(this.generateTemplateData()),this.config.testString||setTimeout(()=>{this.initializeWidget()},600)}attachClickEventToShowMore(){const e=document.querySelector(".searchstax-answer-load-more-button");e&&e.addEventListener("click",this.showMore.bind(this))}trackLinkClick(e){e.preventDefault(),e.stopPropagation();const s=e.target.getAttribute("href");we.trackAnswerLinkClick({href:s,answer:this.dataLayer.parsedData.getAnswerData,...this.dataLayer.parsedData.trackingData}).then(()=>{window.open(s,"_blank")}).catch(()=>{window.open(s,"_blank")})}attachLinkTracking(){document.querySelectorAll(".searchstax-answer-link").forEach(t=>{t.getAttribute("listener")!=="true"&&(t.setAttribute("listener","true"),t.addEventListener("click",this.trackLinkClick.bind(this)))})}renderMainTemplate(e){const t=this.config?.templates?.main?.template||L.answer.main.template;this.dataLayer.renderingEngine===N.mustache?(!this.renderedWithShowMore||!e.answerLoading||this.clicked)&&(e.showMoreButtonVisible&&(this.renderedWithShowMore=!0),this.answerContainer.innerHTML=A.render(t,e),setTimeout(()=>{this.attachClickEventToShowMore(),this.attachLinkTracking()},100)):setTimeout(()=>{this.attachLinkTracking()},500)}generateTemplateData(){this.config.testString&&this.dataLayer.setAnswerData(this.config.testString??"");const e={...this.dataLayer.parsedData.data,showMoreButtonVisible:this.showMoreVisible};return this.config.testString&&(e.searchExecuted=!0),this.dataLayer.setAnswerFullData(e),e}}class ms{dataLayer;config;containerId;currentSelectValue="";locationInput;radiusInput;locationDecode;locationDecodeCoordinatesToAddress;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.locationDecode=e.config.hooks?.locationDecode,this.locationDecodeCoordinatesToAddress=e.config.hooks?.locationDecodeCoordinatesToAddress,this.dataLayer.locationEnabled&&this.dataLayer.$inputTemplateRendered.subscribeUntil(()=>{this.renderMainTemplate(),this.attachSubscriptions()},!0,500)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||L.location.mainTemplate.template,s={...this.dataLayer.parsedData.data};if(this.dataLayer.setLocationWidgetTemplateData(s),this.dataLayer.renderingEngine===N.mustache){const a=A.render(t,s);e.innerHTML=a;const i=this.config.templates?.mainTemplate?.locationInputId||L.location.mainTemplate.locationInputId,r=document?.querySelector(`#${i}`);if(r)this.locationInput=r,r.addEventListener("blur",this.blurEvent.bind(this)),r.addEventListener("focus",this.focusEvent.bind(this));else throw new Error("Input not found");const o=this.config.templates?.mainTemplate?.radiusInputId||L.location.mainTemplate.radiusInputId,c=document?.querySelector(`#${o}`);c instanceof HTMLSelectElement&&(this.radiusInput=c,c.addEventListener("change",this.radiusSelectChangeEvent.bind(this)));const h=this.config.templates?.mainTemplate?.currentLocationActionButtonId||L.location.mainTemplate.currentLocationActionButtonId,d=document?.querySelector(`#${h}`);d&&d.addEventListener("click",this.getCurrentLocation.bind(this))}}}setCurrentLocationFields(e){this.dataLayer.setLocationCoordinatesDecoded(e),this.dataLayer.setSearchLocation(this.dataLayer.searchLocationCoordinatesDecoded),this.dataLayer.renderingEngine===N.mustache&&this.locationInput&&(this.locationInput.value=this.dataLayer.searchLocationCoordinatesDecoded)}getCurrentLocation(){navigator.geolocation?navigator.geolocation.getCurrentPosition(e=>{const t=e.coords.latitude.toString(),s=e.coords.longitude.toString(),a=Math.floor(parseFloat(t)*100)/100,i=Math.floor(parseFloat(s)*100)/100;this.dataLayer.setSearchLat(a+""),this.dataLayer.setSearchLong(i+"");const r=this.locationDecodeCoordinatesToAddress;r?r(a+"",i+"").then(o=>{this.setCurrentLocationFields(o.address||"Current Location")}).catch(()=>{this.setCurrentLocationFields("Current Location")}):this.setCurrentLocationFields("Current Location")},()=>{console.error("Unable to retrieve your location")}):console.error("Geolocation is not supported by this browser.")}setRadiusValue(e){this.dataLayer.setSearchRadius(e)}radiusSelectChangeEvent(e){this.currentSelectValue=e.target.value,this.setRadiusValue(this.currentSelectValue)}attachSubscriptions(){this.dataLayer.$searchObject.subscribe(e=>{this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(e.location.address??"")),this.radiusInput&&e.location.radius&&(this.radiusInput.value=e.location.radius||"")})}cleanSuggestionTerm(e){return H.removeXSSRiskyTags(e.replace(/(<([^>]+)>)/gi,"")).trim()}triggerGeocoder(e){const t=this.locationDecode;this.dataLayer.setLocationDecodingLoading(!0),e&&this.dataLayer.searchLocation!==e&&e!==this.dataLayer.searchLocationCoordinatesDecoded?t(e).then(s=>{this.dataLayer.setSearchLocation(s.address||""),this.dataLayer.setSearchLat(s.lat||""),this.dataLayer.setSearchLong(s.lon||""),this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(s.address||"")),this.dataLayer.renderingEngine===N.mustache&&s.error&&this.locationInput&&this.locationInput.classList.add("searchstax-input-location-error"),s.error?this.dataLayer.setLocationError(!0):this.dataLayer.setLocationError(!1),this.dataLayer.setLocationDecodingLoading(!1)}).catch(()=>{this.dataLayer.setLocationDecodingLoading(!1)}):e===""&&(this.dataLayer.setSearchLocation(void 0),this.dataLayer.setSearchLat(void 0),this.dataLayer.setSearchLong(void 0),this.dataLayer.setLocationDecodingLoading(!1))}focusEvent(e){e.target.classList.remove("searchstax-input-location-error"),this.dataLayer.setLocationError(!1)}blurEvent(e){const s=e.target.value;this.triggerGeocoder(s)}}class zn{routerEnabled=!1;cachedQuery="";routerHelper;searchHelper;searchResultsConfig;searchPaginationConfig;searchFeedbackConfig;searchSortingConfig;searchFacetsConfig;relatedSearchesConfig;externalPromotionsConfig;searchInputWidget;searchLocationWidget;searchResultsWidget;searchFacetsWidget;searchPaginationWidget;searchFeedbackWidget;searchSortingWidget;relatedSearchesWidget;externalPromotionsWidget;answerWidget;locationObserver=null;dataLayer;firstRequest=!0;previousQuery="";eventSource=null;renderEngine=N.mustache;constructor(e=N.mustache){e&&(this.renderEngine=e)}setRenderingEngine(e=N.mustache){this.dataLayer.setRenderingEngine(e)}handleHooks(){this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&this.dataLayer.$searchResults.subscribe(e=>{this.dataLayer.searchstaxConfig.hooks.afterSearch(e,this.dataLayer.searchResultUnparsedData)}),setTimeout(()=>{this.dataLayer.$searchObject.subscribe(e=>{e.query!==this.previousQuery&&this.dataLayer.setAnswerData(""),e.query!==""&&e.query!==void 0&&e.query!=="undefined"?(this.search(e),e.query!==this.previousQuery&&this.startSSE(e.query)):this.dataLayer.searchLocationConfig?.locationSearchEnabled&&!this.dataLayer.searchLocationConfig?.locationValuesOverride?this.getMetadata(e):this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue),this.previousQuery=e.query})},10),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&we.trackSearch({...this.dataLayer.parsedData.trackingData,impressions:this.dataLayer.searchResultsMetadata.impressions})})}startSSE(e){this.eventSource&&(this.eventSource?.close(),this.dataLayer.setAnswerData("")),this.dataLayer.turnAIAnswerGenerationOn===!0&&this.dataLayer.questionURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&(this.eventSource=this.searchHelper?.startSSE(e,this.parseAnswerResultsResponse.bind(this)))}attachAnalyticsScript(e){we.attachAnalyticsScript(e)}initialize(e){if(this.dataLayer=new Ji("searchstax_session_id",e.sessionId),this.renderEngine&&this.dataLayer.setRenderingEngine(this.renderEngine),this.handleHooks(),e.questionURL&&(this.dataLayer.questionURL=e.questionURL),e.analyticsBaseUrl&&typeof window<"u"&&(window.analyticsBaseUrl=e.analyticsBaseUrl,window._msq=e._msq||[],this.attachAnalyticsScript(e.analyticsSrc)),e.autoCorrect===!1&&(this.dataLayer.autoCorrect=!1),e.language&&this.dataLayer.setLanguage(e.language),e.model&&this.dataLayer.setModel(e.model),this.dataLayer.searchstaxConfig||(this.dataLayer.setSearchstaxConfig(e),this.searchHelper=new tn({...e,sessionId:this.dataLayer.sessionId},this.dataLayer),this.dataLayer.searchHelper=this.searchHelper),e.router?.enabled===void 0||e.router?.enabled===!0){this.routerEnabled=!0,this.routerHelper=new ns(e.router?e.router:{enabled:!0});const t=this.routerHelper.urlToSearchObject(window?.location.href??"");this.dataLayer.searchObject.itemsPerPage?t.itemsPerPage=this.dataLayer.searchObject.itemsPerPage:t.itemsPerPage&&this.dataLayer.setItemsPerPage(t.itemsPerPage),t.model&&this.dataLayer.setModel(t.model),t.location&&(t.location.address&&this.dataLayer.setSearchLocation(t.location.address),t.location.lat&&this.dataLayer.setSearchLat(t.location.lat),t.location.lon&&this.dataLayer.setSearchLong(t.location.lon),t.location.radius&&this.dataLayer.setSearchRadius(t.location.radius)),this.dataLayer.setSearchObject(t),addEventListener("popstate",()=>{this.routerHelper&&this.dataLayer.setSearchObject(this.routerHelper.urlToSearchObject(window?.location.href??"",this.dataLayer.searchObject.itemsPerPage))})}else this.routerHelper=new ns({})}getMetadata(e){this.searchHelper&&(e.query==="undefined"||e.query===void 0)&&this.dataLayer.setSearchObject({...e,query:"*"})}search(e){if(this.searchHelper){const t=this.dataLayer.forceNotCorrect;this.searchHelper.url&&(this.searchHelper.search(e,this.parseSearchResultsResponse.bind(this),this.firstRequest,t),this.firstRequest=!1),this.getRelatedSearches()}}getRelatedSearches(){this.searchHelper&&this.relatedSearchesConfig&&this.relatedSearchesConfig?.relatedSearchesURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&this.searchHelper.getRelatedSearches(this.dataLayer.searchObject,this.relatedSearchesConfig.relatedSearchesURL,this.relatedSearchesConfig.relatedSearchesAPIKey,this.parseRelatedSearchesResponse.bind(this))}parseRelatedSearchesResponse(e){const s=(e.response?.docs??[]).map((i,r)=>({...i,position:r+1})),a=[];for(const i of s)a.push({relatedSearch:i.related_search,position:i.position});this.dataLayer.setSearchRelatedSearches(s),this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&a.length&&we.trackRelatedSearches({...this.dataLayer.parsedData.trackingData,impressions:a,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}handleRouter(){if(this.routerEnabled){const e={...this.dataLayer.searchObject};this.dataLayer.isInfiniteScroll&&delete e.page,this.routerHelper.updateUrl(e)}}parseSearchResultsResponseMetadata(e){const t=tt.extractSearchResultsMetadata(e),s=this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue??t.location?.filter?.defaultValue;!this.dataLayer.searchRadius&&s&&this.dataLayer.setSearchRadius(s),this.dataLayer.setSearchResultsMetadata(t)}parseSearchResultsResponse(e){this.handleRouter(),this.dataLayer.setItemsPerPage(parseInt(e.responseHeader.params.rows)),this.dataLayer.setModel(e.responseHeader.params.model);let t=tt.combineResultsWithMetadata(e),s=tt.extractFacets(e);this.dataLayer.setSearchFacets(s),this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&(t=this.dataLayer.searchstaxConfig.hooks.afterSearch(t,e)),this.dataLayer.setSearchExternalPromotions(e.externalLinks??[]),this.parseSearchResultsResponseMetadata(e),this.dataLayer.setSearchResultUnparsedData(e),this.dataLayer.setSearchResults(t)}parseAnswerResultsResponse(e){this.handleRouter(),e!==Ne.question&&e!==Ne.notQuestion&&(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setAnswerData(this.dataLayer.getAnswerData+e))}cacheFacets(e){e?this.searchHelper?.cacheFacets(!0).then(()=>{}):this.searchHelper?.cacheFacets().then(()=>{})}parseSuggestSuggestResponse(e){let t=e;this.dataLayer.searchInputConfig?.hooks?.afterAutosuggest&&(t=this.dataLayer.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.dataLayer.setLanguage(e)}addSearchInputWidget(e,t){this.dataLayer.searchInputConfig||this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.dataLayer.setSearchInputConfig(t),this.searchInputWidget=new Nn({containerId:e,config:t,searchTrigger:this.executeSearch.bind(this),suggestTrigger:this.executeSuggest.bind(this),dataLayer:this.dataLayer})},200)}addSearchLocationWidget(e,t){this.dataLayer.searchLocationConfig||(t.locationSearchEnabled?(this.dataLayer.setLocationEnabled(!0),this.dataLayer.setSearchLocationConfig(t),t.locationValuesOverride?(this.searchLocationWidget=new ms({containerId:e,config:t,dataLayer:this.dataLayer}),t?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(t?.locationValuesOverride?.locationFilterDefaultValue)):this.dataLayer.$searchResultsMetadata.subscribeUntilHasValue(()=>{this.searchLocationWidget=new ms({containerId:e,config:t,dataLayer:this.dataLayer})},0)):this.dataLayer.setLocationEnabled(!1))}addAnswerWidget(e,t){this.dataLayer.turnAIAnswerGenerationOn=!0,t.testString||this.startSSE(this.dataLayer.searchObject.query),this.dataLayer.setAnswerData(t.testString??""),this.answerWidget=new Fn({containerId:e,config:t,dataLayer:this.dataLayer})}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new Pn({containerId:e,linkClickCallback:this.executeLinkClick.bind(this),searchTrigger:this.executeSearch.bind(this),config:t,dataLayer:this.dataLayer}))}addPaginationWidget(e,t){this.searchPaginationConfig=t,this.searchPaginationWidget=new In({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper})}addSearchFeedbackWidget(e,t){this.searchFeedbackConfig=t,this.searchFeedbackWidget=new jn({containerId:e,config:t,dataLayer:this.dataLayer,searchTrigger:this.executeSearch.bind(this)})}addSearchSortingWidget(e,t){this.searchSortingConfig=t,this.searchSortingWidget=new On({containerId:e,config:t,dataLayer:this.dataLayer})}addRelatedSearchesWidget(e,t){this.relatedSearchesConfig=t,this.relatedSearchesWidget=new Rn({containerId:e,config:t,dataLayer:this.dataLayer,trackRelatedSearchClick:this.trackRelatedSearchClick.bind(this)}),setTimeout(()=>{this.getRelatedSearches()},0)}addExternalPromotionsWidget(e,t){this.externalPromotionsConfig=t,this.externalPromotionsWidget=new vn({containerId:e,config:t,dataLayer:this.dataLayer})}addFacetsWidget(e,t){this.searchFacetsConfig=t,this.searchFacetsWidget=new Dn({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper},this.cacheFacets.bind(this))}executeSearch(e,t){const s={...this.dataLayer.searchObject};s.query=H.removeXSSRiskyTags(e),s.page=1,s.facets=[],s.location={...s.location},this.locationObserver&&this.dataLayer.$locationDecodingLoading.unsubscribe(this.locationObserver),this.locationObserver=this.dataLayer.$locationDecodingLoading.subscribeUntil(()=>{s.location.address=this.dataLayer.searchLocation,s.location.radius=this.dataLayer.searchRadius,s.location.lat=this.dataLayer.searchLat,s.location.lon=this.dataLayer.searchLong,this.dataLayer.forceNotCorrect=!!t;let a=this.routerHelper?.searchObjectToParams(s);a&&(a=this.routerHelper?.extractParamsThatDoNotStartWithRouteName(a)),a&&(s.additionalProps=Object.keys(a).map(i=>a?{key:i,value:a[i]}:{key:"",value:""})),this.dataLayer.setSearchObject(s),this.dataLayer.lastSearchValue=s.query},!1)}executeSuggest(e){let t={term:e,queryParams:[]};this.dataLayer.searchInputConfig?.hooks?.beforeAutosuggest&&(t=this.dataLayer.searchInputConfig.hooks.beforeAutosuggest(t)),t&&t.term!==void 0&&t.queryParams!==void 0&&this.suggest(t.term,t.queryParams)}trackRelatedSearchClick(e){this.dataLayer.searchResultsMetadata&&this.dataLayer.searchRelatedSearches&&!this.dataLayer.cookiesDisabled&&we.trackRelatedSearchClick({...this.dataLayer.parsedData.trackingData,relatedSearch:e,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}executeLinkClick(e){let t=tt.findResultByUniqueId(e,this.dataLayer.searchResults??[]);t&&(this.searchResultsConfig?.hooks?.afterLinkClick&&(t=this.searchResultsConfig.hooks.afterLinkClick(t)),t&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&we.trackClick({result:t,...this.dataLayer.parsedData.trackingData}).then(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}).catch(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}))}setPage(e){this.searchPaginationWidget?.goToPage(e)}setCookiesDisabled(e){this.dataLayer.setCookiesDisabled(e)}changeResultTemplate(e){this.searchResultsConfig&&(this.searchResultsConfig.templates=this.searchResultsConfig?.templates?{...this.searchResultsConfig?.templates,...e}:e,this.searchResultsWidget?.changeTemplate())}}xa.Searchstax=zn,Object.defineProperty(xa,Symbol.toStringTag,{value:"Module"})})(this["@searchstaxInc/searchstudioUxJs"]=this["@searchstaxInc/searchstudioUxJs"]||{});
|
|
440
|
+
`,thumbsUpButtonClass:"searchstax-lightweight-widget-thumbs-up",thumbsDownButtonClass:"searchstax-lightweight-widget-thumbs-down"}};class w{static answer=Dn;static externalPromotions=jn;static facets=Rn;static pagination=Nn;static relatedSearches=Pn;static searchFeedback=On;static searchInput=_n;static location=Fn;static searchResults=zn;static sorting=$n;static feedback=Z}class Bn{dataLayer;config;containerId;externalPromotionsContainerId;searchExternalPromotionsMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.externalPromotionsContainerId=this.config.templates?.mainTemplate?.externalPromotionsContainerId||w.externalPromotions.mainTemplate.externalPromotionsContainerId,typeof document<"u"&&(this.searchExternalPromotionsMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}initializeSubscriptions(){this.dataLayer.$searchExternalPromotions.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data,externalPromotions:this.dataLayer.parsedData.externalPromotions};return this.dataLayer.setExternalPromotionsData(e),e}addExternalSearch(e){const t=typeof document<"u"?document?.getElementById(this.externalPromotionsContainerId):null;if(t){const a=this.config?.templates?.externalPromotion?.template||w.externalPromotions.externalPromotion?.template;if(typeof document<"u"){const s=document?.createElement("div");s.classList.add("searchstax-external-promotion"),s.addEventListener("click",n=>{this.trackClick(e,n)}),s.innerHTML=k.render(a,e),t.appendChild(s)}}}trackClick(e,t){t.stopPropagation(),t.preventDefault(),window?.open(e.url,"_blank")}renderMainTemplate(e){const t=this.config?.templates?.mainTemplate?.template||w.externalPromotions.mainTemplate?.template;if(this.dataLayer.renderingEngine===F.mustache){this.searchExternalPromotionsMainContainer.innerHTML=k.render(t,e);const a=typeof document<"u"?document?.getElementById(this.externalPromotionsContainerId):null;a&&(a.innerHTML="");for(const s of e.externalPromotions)this.addExternalSearch(s)}}}class J{static addAccessibilityNotificationContainerToBody(){if(!document.getElementById("searchAccessibilityContainer")){const t=document.createElement("div");t.setAttribute("aria-live","polite"),t.setAttribute("id","searchAccessibilityContainer"),document.body.appendChild(t)}}static setAccessibilityText(e,t,a){this.addAccessibilityNotificationContainerToBody();const s=a??"searchAccessibility",n=document.getElementById(s);n&&n.remove();const r=document.createElement("span");r.setAttribute("id",s),r.innerHTML=e;const o=document.getElementById("searchAccessibilityContainer");o&&setTimeout(()=>{o.appendChild(r)},t??100)}}class Vn{dataLayer;config;containerId;routerHelper;cachedPhrase="";cachedANDFacets="";isCached=!1;overlayOpened=!1;facetPaginationStep;facetPaginationStepMobile;searchFacetsMainContainer=null;searchFacetsMobileContainer=null;searchFacetsDesktopContainer=null;facetLimits={};facetLimitsMobile={};deactivatedFacets={};focusedElement=null;cachedData=null;cacheFacets;constructor(e,t){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.routerHelper=e.routerHelper,this.cacheFacets=t,this.facetPaginationStep=this.config.itemsPerPageDesktop,this.facetPaginationStepMobile=this.config.itemsPerPageMobile,typeof document<"u"&&(this.searchFacetsMainContainer=document?.getElementById(this.containerId)),this.needCache&&t(this.config.facetingType==="tabs"),this.initializeSubscriptions()}get needCache(){return this.config.facetingType==="showUnavailable"||this.config.facetingType==="or"||this.config.facetingType==="tabs"}get needDisabling(){return this.config.facetingType==="showUnavailable"}initializeSubscriptions(){this.needCache&&(this.dataLayer.$searchFacetsCached.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$searchFacetsCachedTabs.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())})),this.dataLayer.$searchResults.subscribe(e=>{e&&(this.needCache&&!this.isCached&&(this.dataLayer.searchFacets&&!this.dataLayer.searchFacetsCached&&this.dataLayer.setSearchFacetsCached(this.dataLayer.searchFacets),this.cacheFacets(this.config.facetingType==="tabs")),this.renderMainTemplate(this.generateTemplateData()))}),this.dataLayer.$searchObject.subscribe(e=>{this.cachedPhrase!==e.query||this.cachedANDFacets!==this.dataLayer.parsedData.cachedANDFacets?(this.cachedANDFacets=this.dataLayer.parsedData.cachedANDFacets,this.cachedPhrase=e.query,this.isCached=!1):this.isCached=!0})}extractFacetValue(e){return{type:this.config.facetingType,name:e.parentName,value:e.value}}applyFacetLimits(e,t){const a=t?this.facetPaginationStepMobile:this.facetPaginationStep,s=t?this.facetLimits:this.facetLimitsMobile;return e.forEach(n=>{s[n.name]||(s[n.name]=a)}),e.map(n=>({...n,values:n.values.slice(0,s[n.name]),showingAllFacets:n.values.length<=s[n.name],hasMoreFacets:n.values.length>a}))}generateTemplateData(e){if(this.generateSelectedFacetsData(),this.dataLayer.searchFacets){let t=this.dataLayer.searchFacets;this.config.hooks?.beforeFacetsRender&&(t=this.config.hooks.beforeFacetsRender(t)),this.needCache&&this.dataLayer.searchFacetsCached&&(t=this.dataLayer.searchFacetsCached,this.config.facetingType==="tabs"&&this.dataLayer.searchFacetsCachedTabs&&(t=this.dataLayer.searchFacetsCachedTabs),this.needDisabling&&(t=t.map(s=>{const n=this.dataLayer.searchFacets?.find(r=>r.name===s.name);return n?{...s,values:s.values.map(o=>{const c=n.values.find(h=>o.type==="range"?!1:o.type==="checkbox"?h.value===o.value:!1);return{...o,disabled:!c,isMobile:e}})}:{...s,values:s.values.map(o=>({...o,disabled:!0})),isMobile:e}}))),this.config.specificFacets&&(t=t.filter(s=>this.config.specificFacets?.includes(s.name)));const a={facets:this.applyFacetLimits(t,e),...this.dataLayer.parsedData.data,isMobile:e};return this.dataLayer.setFacetsTemplateData(a),a}else{const t={facets:[],...this.dataLayer.parsedData.data,isMobile:e};return this.dataLayer.setFacetsTemplateData(t),t}}createFacetItem(e,t,a){if(typeof document<"u"){const s=document?.createElement("div");s.classList.add("searchstax-facet-container"),this.deactivatedFacets[e.name]||s.classList.add("active");const n=this.config?.templates?.facetItemContainerTemplate?.template||w.facets.facetItemContainerTemplate?.template;s.innerHTML=k.render(n,e),t.appendChild(s);const r=s.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerClass||w.facets.facetItemContainerTemplate?.facetListTitleContainerClass));r?.addEventListener("click",()=>{s.classList.toggle("active");const c=s.classList.contains("active"),h=r.querySelector(".searchstax-facet-title");h&&h.setAttribute("aria-expanded",String(c))}),r?.querySelector("."+this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerInner)?.addEventListener("keydown",c=>{if(c.code==="Enter"||c.code==="Space"){c.preventDefault(),s.classList.toggle("active");const h=s.classList.contains("active"),d=r.querySelector(".searchstax-facet-title");d&&d.setAttribute("aria-expanded",String(h))}});const o=s.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListContainerClass||w.facets.facetItemContainerTemplate?.facetListContainerClass));o&&(e.values.forEach(c=>{this.createFacetListItem(c,o,e.name)}),e.hasMoreFacets&&this.createHasMoreComponent(e,o,a))}}isChecked(e){return!!this.dataLayer.searchObject.facets?.find(t=>oe.deepEqual(t,this.extractFacetValue(e)))}createFacetListItem(e,t,a){if(typeof document<"u"){const s=document?.createElement("div");s.classList.add("searchstax-facet-value-container"),e.disabled&&s.classList.add("searchstax-facet-value-disabled");const n=this.isChecked(e),r=this.config?.templates?.facetItemTemplate?.template||w.facets.facetItemTemplate?.template;s.innerHTML=k.render(r,{...e,isChecked:n});let o=w.facets.facetItemTemplate?.checkTriggerClasses;o=this.config?.templates?.facetItemTemplate?.checkTriggerClasses||o,o.forEach(h=>{s.querySelector("."+h)?.addEventListener("click",L=>{this.onFacetSelect(L,e,s)})});const c=s.querySelector("."+(this.config?.templates?.facetItemTemplate?.inputCheckboxClass||w.facets.facetItemTemplate?.inputCheckboxClass));c?.addEventListener("click",h=>{this.onFacetSelect(h,e,s,!0)}),c&&c?.setAttribute("data-test-value",`${encodeURIComponent(a)}:"${encodeURIComponent(e.value)}"`),t.appendChild(s)}}onFacetSelect=(e,t,a,s,n)=>{if(e.stopPropagation(),!t.disabled){const r=a.querySelector("input");let o=s?r.checked:!r.checked;n!==void 0&&(o=!n),r.checked=o;const c=this.dataLayer.searchObject;let h=[...c.facets];const d=this.extractFacetValue(t);o?h.find(m=>oe.deepEqual(m,d)?m:!1)||(this.config.facetingType==="tabs"&&(h=h.filter(m=>m.name!==d.name)),h.push(d)):h=h.filter(L=>!oe.deepEqual(L,d)),setTimeout(()=>{this.dataLayer.setSearchObject({...c,facets:h,page:1}),this.config.facetingType==="tabs"&&this.renderMainTemplate(this.generateTemplateData(),!0)},0)}};createHasMoreComponent(e,t,a){if(typeof document<"u"){const s=document?.createElement("div");s.classList.add("searchstax-facet-show-more-container");const n=this.config?.templates?.showMoreButtonContainerTemplate?.template||w.facets.showMoreButtonContainerTemplate?.template;s.innerHTML=k.render(n,{...e,focusId:`moreLess${e?.values?.[0]?.value}`});const r=s.querySelector("."+(this.config?.templates?.showMoreButtonContainerTemplate?.showMoreButtonClass||w.facets.showMoreButtonContainerTemplate?.showMoreButtonClass));r&&(this.attachOnclickToShowMore(e,r,a),t&&t.appendChild(r))}}attachOnclickToShowMore(e,t,a){t.addEventListener("click",s=>{this.onShowMoreLessClick(s,e,a)}),t.addEventListener("keydown",s=>{s.code==="Space"&&s.preventDefault()}),t.addEventListener("keyup",s=>{(s.code==="Space"||s.code==="Enter")&&(s.preventDefault(),this.onShowMoreLessClick(s,e,a))})}onShowMoreLessClick(e,t,a){e.preventDefault();const s=a?this.facetPaginationStepMobile:this.facetPaginationStep,n=a?this.facetLimits:this.facetLimitsMobile;n[t.name]===void 0?n[t.name]=s*2:n[t.name]<=t.values.length?(J.setAccessibilityText(`More Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),n[t.name]=n[t.name]+s):(J.setAccessibilityText(`Less Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),n[t.name]=s),this.generateTemplateData(a),this.renderMainTemplate(this.generateTemplateData())}renderMainTemplate(e,t){if(e&&(!oe.deepEqual(this.cachedData??{},e)||t)){this.cachedData=e;const a=this.config?.templates?.mainTemplateDesktop?.template||w.facets.mainTemplateDesktop?.template;if(this.dataLayer.renderingEngine===F.mustache&&this.searchFacetsMainContainer){const s=document.activeElement;s instanceof HTMLInputElement&&s.type==="checkbox"||s?.classList.contains("searchstax-facet-show-more-button")||s?.classList.contains("searchstax-facet-show-less-button")?this.focusedElement=s:this.focusedElement=null,this.searchFacetsMainContainer.innerHTML=k.render(a,{...e});const n=this.searchFacetsMainContainer?.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.facetsContainerClass||w.facets.mainTemplateDesktop.facetsContainerClass));if(n){n.innerHTML="";for(const r of e.facets)this.createFacetItem(r,n);if(this.searchFacetsMainContainer){const r=this.searchFacetsMainContainer.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.selectedFacetsContainerClass||w.facets.mainTemplateDesktop.selectedFacetsContainerClass));r&&(this.createSelectedFacetsComponents(r),this.createClearFacetsComponents(r))}if(this.focusedElement){if(this.focusedElement.classList.contains("searchstax-facet-show-more-button")||this.focusedElement.classList.contains("searchstax-facet-show-less-button")){const c=this.focusedElement.getAttribute("data-focus"),h=this.searchFacetsMainContainer.querySelector(`[data-focus="${c}"]`);h instanceof HTMLElement&&h.focus(),this.focusedElement=null;return}const r=this.focusedElement.getAttribute("data-test-value"),o=this.searchFacetsMainContainer.querySelector(`[data-test-value="${r}"]`);o instanceof HTMLInputElement&&o.focus(),this.focusedElement=null}}}setTimeout(()=>{document.querySelectorAll(".searchstax-facet-title").forEach(n=>{n.setAttribute("aria-expanded",String(!0)),n.setAttribute("tabindex","0"),n.setAttribute("role","button")})},100),this.renderMobileTemplate(this.generateTemplateData(!0))}else this.generateSelectedFacetsData()}generateSelectedFacetsData(){const e=[],t=this.dataLayer.searchObject.facets;for(const a of t){const s=decodeURIComponent(a.name),n=decodeURIComponent(a.value);if(this.dataLayer.searchFacets){const o=(this.needCache?this.dataLayer.searchFacetsCached:this.dataLayer.searchFacets)?.find(c=>c.name===s);if(o){const c=o.values.find(h=>h.type==="range"?!1:h.type==="checkbox"?`"${h.value}"`==`"${n}"`:!1);c&&e.push(c)}}}this.dataLayer.setSelectedFacetsTemplateData(e)}createSelectedFacetsComponents(e){this.generateSelectedFacetsData(),this.dataLayer.selectedFacetsTemplateData?.forEach(t=>{this.createSelectedFacetsComponent(e,t)})}createClearFacetsComponents(e){if(typeof document<"u"){const t=this.dataLayer.searchObject,a=this.config?.templates?.clearFacetsTemplate?.template||w.facets.clearFacetsTemplate?.template,s=document?.createElement("div");s.innerHTML=k.render(a,{shouldShow:t.facets.length>0});const n=s.querySelector("."+(this.config?.templates?.clearFacetsTemplate?.containerClass||w.facets.clearFacetsTemplate?.containerClass));n&&(n.addEventListener("click",()=>{this.removeSelectedFacets()}),n.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.removeSelectedFacets()}),e.appendChild(n))}}createSelectedFacetsComponent(e,t){if(typeof document<"u"){const a=this.config?.templates?.selectedFacetsTemplate?.template||w.facets.selectedFacetsTemplate?.template,s=document?.createElement("div");s.innerHTML=k.render(a,t);const n=s.querySelector("."+(this.config?.templates?.selectedFacetsTemplate?.containerClass||w.facets.selectedFacetsTemplate?.containerClass));n&&(n.addEventListener("click",()=>{this.unselectFacet(t)}),n.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.unselectFacet(t)}),e.appendChild(n))}}unselectFacet(e){const t=this.dataLayer.searchObject;let a=[...t.facets];e.type==="checkbox"&&(a=a.filter(s=>JSON.stringify(s)!==JSON.stringify(this.extractFacetValue(e)))),setTimeout(()=>{this.dataLayer.setSearchObject({...t,facets:a}),this.generateSelectedFacetsData()},0)}removeSelectedFacets(){const e=this.dataLayer.searchObject;this.dataLayer.setSearchObject({...e,facets:[]})}createFilterByComponent(e){if(typeof document<"u"){const t=this.config?.templates?.filterByTemplate?.template||w.facets.filterByTemplate?.template,a=document?.createElement("div");a.innerHTML=k.render(t,{});const s=a.querySelector("."+(this.config?.templates?.filterByTemplate?.containerClass||w.facets.filterByTemplate?.containerClass));s&&(e.prepend(s),s.addEventListener("click",this.openOverlay.bind(this)),s.addEventListener("keyup",n=>{(n.code==="Space"||n.code==="Enter")&&this.openOverlay()}))}}openOverlay(){J.setAccessibilityText("Facet overlay opened. Tab to select facets."),this.overlayOpened=!0,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.add("searchstax-show"))}closeOverlay(){J.setAccessibilityText("Facet overlay closed"),this.overlayOpened=!1,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.remove("searchstax-show"))}renderMobileTemplate(e){if(e&&typeof document<"u"){const t=document?.createElement("div");t.classList.add("searchstax-facets-container-mobile");const a=this.config?.templates?.mainTemplateMobile?.template||w.facets.mainTemplateMobile?.template;if(this.dataLayer.renderingEngine===F.mustache){if(t.innerHTML=k.render(a,{...e,overlayOpened:this.overlayOpened}),this.searchFacetsMainContainer?.appendChild(t),this.config?.templates?.mainTemplateMobile)for(const o of this.config?.templates?.mainTemplateMobile?.closeOverlayTriggerClasses||[]){const c=t.querySelector("."+o);c&&(c.addEventListener("click",this.closeOverlay.bind(this)),c.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}else for(const o of w.facets.mainTemplateMobile.closeOverlayTriggerClasses){const c=t.querySelector("."+o);c&&(c.addEventListener("click",this.closeOverlay.bind(this)),c.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}const s=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.filterByContainerClass||w.facets.mainTemplateMobile.filterByContainerClass));s&&this.createFilterByComponent(s);const n=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.selectedFacetsContainerClass||w.facets.mainTemplateMobile.selectedFacetsContainerClass));n&&(this.createSelectedFacetsComponents(n),this.createClearFacetsComponents(n));const r=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.facetsContainerClass||w.facets.mainTemplateMobile.facetsContainerClass));if(r){r.innerHTML="";for(const o of e.facets)this.createFacetItem(o,r,!0)}}}}}class Hn{dataLayer;config;containerId;previousButtonClass;nextButtonClass;loadMoreButtonClass;routerHelper;searchPaginationMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.routerHelper=e.routerHelper,this.previousButtonClass=this.config?.templates?.mainTemplate?.previousButtonClass??w.pagination.mainTemplate.previousButtonClass,this.nextButtonClass=this.config?.templates?.mainTemplate?.nextButtonClass??w.pagination.mainTemplate.nextButtonClass,this.loadMoreButtonClass=this.config?.templates?.infiniteScrollTemplate?.loadMoreButtonClass??w.pagination.infiniteScrollTemplate.loadMoreButtonClass,typeof document<"u"&&(this.searchPaginationMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}get isFirstPage(){return this.dataLayer.searchObject?.page===1}get isLastPage(){return this.dataLayer.parsedData.data.isLastPage}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data,previousPageLink:this.routerHelper?.searchObjectToUrl({...this.dataLayer.searchObject,page:this.dataLayer.searchObject?.page-1}),nextPageLink:this.routerHelper?.searchObjectToUrl({...this.dataLayer.searchObject,page:this.dataLayer.searchObject?.page+1})};return this.dataLayer.setPaginationData(e),e}goToPage(e,t){const a=this.dataLayer.searchObject;a&&(a.page=e,this.dataLayer.setSearchObject(a));const s=document.querySelector(".searchstax-page-layout-result-container");if(s instanceof HTMLElement){const n=s.querySelector('[tabindex="0"]');n instanceof HTMLElement&&n.focus()}else document.body.tabIndex=-1,document.body.focus();t||(s instanceof HTMLElement?s.scrollIntoView({block:"start",behavior:"auto"}):window?.scrollTo(0,0))}nextPage(e){e?.preventDefault(),e?.stopPropagation(),this.isLastPage||this.goToPage(this.dataLayer.searchObject?.page+1,this.dataLayer.isInfiniteScroll)}previousPage(e){e?.preventDefault(),e?.stopPropagation(),this.isFirstPage||this.goToPage(this.dataLayer.searchObject?.page-1)}overridePaginationEvents(){if(this.searchPaginationMainContainer){const e=this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass),t=this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass),a=this.searchPaginationMainContainer.querySelector("."+this.loadMoreButtonClass);e&&(e.addEventListener("click",this.previousPage.bind(this)),e.addEventListener("keydown",s=>{(s.code==="Space"||s.code==="Enter")&&this.previousPage(s)})),t&&(t.addEventListener("click",this.nextPage.bind(this)),t.addEventListener("keydown",s=>{(s.code==="Space"||s.code==="Enter")&&this.nextPage(s)})),a&&(a.addEventListener("click",this.nextPage.bind(this)),a.addEventListener("keydown",s=>{(s.code==="Space"||s.code==="Enter")&&this.nextPage(s)}))}}renderMainTemplate(e){this.searchPaginationMainContainer&&(this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass)?.removeEventListener("click",this.previousPage),this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass)?.removeEventListener("click",this.nextPage));let t=this.config?.templates?.mainTemplate?.template||w.pagination.mainTemplate?.template;this.dataLayer.isInfiniteScroll&&(t=this.config?.templates?.infiniteScrollTemplate?.template||w.pagination.infiniteScrollTemplate?.template),this.dataLayer.renderingEngine===F.mustache&&(this.searchPaginationMainContainer.innerHTML=k.render(t,e),setTimeout(()=>{this.overridePaginationEvents()},0))}}class Un{dataLayer;config;containerId;relatedSearchesContainerClass;searchRelatedSearchesMainContainer=null;track;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.relatedSearchesContainerClass=this.config.templates?.main?.relatedSearchesContainerClass||w.relatedSearches.main.relatedSearchesContainerClass,typeof document<"u"&&(this.searchRelatedSearchesMainContainer=document?.getElementById(this.containerId)),this.track=e.trackRelatedSearchClick,this.initializeSubscriptions()}initializeSubscriptions(){this.dataLayer.$searchRelatedSearches.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setRelatedSearchesData(e),e}addRelatedSearchComponent(e,t){if(typeof document<"u"){const a=document?.createElement("div"),s=this.config?.templates?.relatedSearch?.template||w.relatedSearches.relatedSearch.template;if(this.dataLayer.renderingEngine===F.mustache){a.innerHTML=k.render(s,e);const n=a.querySelector("."+(this.config.templates?.relatedSearch?.relatedSearchContainerClass||w.relatedSearches.relatedSearch.relatedSearchContainerClass));n&&(t.appendChild(n),n.addEventListener("click",()=>{this.executeSearch(e)}),n.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.executeSearch(e)}))}}}executeSearch(e){const t=this.dataLayer.searchObject;t.query=e.related_search,this.dataLayer.setSearchObject(t),this.track(e)}renderMainTemplate(e){const t=this.config?.templates?.main?.template||w.relatedSearches.main.template;if(this.dataLayer.renderingEngine===F.mustache&&this.searchRelatedSearchesMainContainer){this.searchRelatedSearchesMainContainer.innerHTML="",this.searchRelatedSearchesMainContainer.innerHTML=k.render(t,e);const a=this.searchRelatedSearchesMainContainer?.querySelector(`.${this.relatedSearchesContainerClass}`);if(a)for(const s of e.relatedSearches)this.addRelatedSearchComponent(s,a)}}}class Qn{dataLayer;config;containerId;searchFeedbackMainContainer=null;searchTrigger;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.searchTrigger=e.searchTrigger,typeof document<"u"&&(this.searchFeedbackMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions()}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setSearchFeedbackData(e),e}onOriginalQueryClick(e){e.stopPropagation(),e.preventDefault();const t=e.target?.innerHTML;this.searchTrigger(t,!0)}attachClick(){const e=this.searchFeedbackMainContainer?.querySelector("."+(this.config?.templates?.main?.originalQueryClass||w.searchFeedback.main?.originalQueryClass));e&&e.addEventListener("click",this.onOriginalQueryClick.bind(this))}renderMainTemplate(e){const t=this.config?.templates?.main?.template||w.searchFeedback.main.template;this.dataLayer.renderingEngine===F.mustache&&(this.searchFeedbackMainContainer.innerHTML=k.render(t,e),setTimeout(()=>{this.attachClick()},0))}}class qn{searchHelper;dataLayer;config;suggestAfterMinChars;containerId;currentInputValue="";autosuggestResults;suppressNextEnter=!1;searchInput;actionButton;autosuggestContainer;clearButton;separatorIcon;buttonState="search";selectedAutosuggestItem=-1;suggestTrigger;searchTrigger;constructor(e){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.suggestAfterMinChars===void 0&&this.getSuggestAfterValue(),this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())},200)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||w.searchInput.mainTemplate.template,a={...this.dataLayer.parsedData.data,locationEnabled:!!this.dataLayer.locationEnabled,hasInputValue:!1};if(this.dataLayer.setInputWidgetTemplateData(a),this.dataLayer.renderingEngine===F.mustache){const r=k.render(t,a);e.innerHTML=r,this.dataLayer.setInputTemplateRendered(!0)}const s=this.config.templates?.mainTemplate?.searchInputId||w.searchInput.mainTemplate.searchInputId,n=document?.querySelector(`#${s}`);if(n)this.searchInput=n,n.addEventListener("keyup",this.inputKeyupEvent.bind(this)),n.addEventListener("blur",this.hideAutosuggest.bind(this)),n.addEventListener("paste",this.inputPasteEvent.bind(this));else throw new Error("Input not found")}}createAutosuggestContainer(){this.dataLayer.renderingEngine===F.mustache&&typeof document<"u"&&(this.autosuggestContainer=document?.createElement("div"),this.autosuggestContainer.classList.add("searchstax-autosuggest-container"),this.autosuggestContainer.addEventListener("mouseleave",()=>{this.resetAutosuggestSelection(),this.markActiveAutosuggestItem()}),this.searchInput?.after(this.autosuggestContainer))}getSuggestAfterValue(){this.dataLayer.searchHelper&&this.dataLayer.searchHelper.suggest("*",e=>{this.suggestAfterMinChars=e.metadata.minPrefixChars},[])}actionButtonInit(){typeof document<"u"&&(this.actionButton=document?.getElementById("searchstax-search-input-action-button"),this.actionButton&&this.actionButton.addEventListener("click",()=>{this.executeSearch(this.searchInput?.value??"")}),this.clearButton=document?.getElementById("searchstax-clear-input-action-button"),this.separatorIcon=document?.getElementById("searchstax-separator-icon"),this.clearButton&&this.clearButton.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.clearInput()}))}updateClearButtonVisibility(e){const t=e.length>0;t?(this.clearButton?.classList.remove("hidden"),this.separatorIcon?.classList.remove("hidden")):(this.clearButton?.classList.add("hidden"),this.separatorIcon?.classList.add("hidden"));const a=this.dataLayer.inputWidgetTemplateData;a&&this.dataLayer.setInputWidgetTemplateData({...a,hasInputValue:t})}attachSubscriptions(){this.dataLayer.$searchTermChange.subscribe(()=>{this.handleSearchTermChange()}),this.dataLayer.$loadingChange.subscribe(()=>{this.handleLoadingChange()}),this.dataLayer.$searchAutosuggest.subscribe(e=>{e&&this.appendSuggestions(e)}),this.dataLayer.$searchObject.subscribe(e=>{e.query!=="undefined"&&e.query!==void 0&&e.query!=="*"&&this.searchInput&&(this.searchInput.value=this.cleanSuggestionTerm(e.query??""),this.updateClearButtonVisibility(this.searchInput.value))})}handleLoadingChange(){this.dataLayer.loading?this.updateActionButtonState("loading"):this.handleSearchTermChange()}handleSearchTermChange(){this.updateActionButtonState("search")}updateActionButtonState(e){if(this.buttonState=e,this.actionButton)switch(this.actionButton.classList.remove("searchstax-spinner-icon"),this.actionButton.classList.remove("searchstax-search-icon"),e){case"loading":this.actionButton.classList.add("searchstax-spinner-icon");break;case"search":this.actionButton.classList.add("searchstax-search-icon"),this.actionButton.setAttribute("aria-label","search");break}}selectPreviousAutosuggestItem(e){this.selectedAutosuggestItem>0?this.selectedAutosuggestItem--:this.selectedAutosuggestItem===0?(this.selectedAutosuggestItem=-1,e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),J.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=this.autosuggestResults.suggestions.length-1,this.markActiveAutosuggestItem()}selectNextAutosuggestItem(){this.selectedAutosuggestItem<this.autosuggestResults.suggestions.length-1?this.selectedAutosuggestItem++:this.selectedAutosuggestItem===this.autosuggestResults.suggestions.length-1?(this.selectedAutosuggestItem=-1,J.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=0,this.markActiveAutosuggestItem()}resetAutosuggestSelection(){this.selectedAutosuggestItem=-1,this.markActiveAutosuggestItem()}clearInput(){this.suppressNextEnter=!0,this.searchInput&&(this.searchInput.value="",this.currentInputValue=""),this.updateClearButtonVisibility(""),this.hideAutosuggest(),this.searchInput?.focus()}markActiveAutosuggestItem(){if(typeof document<"u"){const e=document?.getElementsByClassName("searchstax-autosuggest-item");for(let t=0;t<e.length;t++){const a=e[t];t===this.selectedAutosuggestItem?(a.classList.add("active"),J.setAccessibilityText(`Selected suggestion: ${a.innerText}`)):a.classList.remove("active")}}}inputKeyupEvent(e){const t=e.key;if(this.currentInputValue=e.target.value,t==="Enter"){if(this.suppressNextEnter){this.suppressNextEnter=!1;return}this.suggestionChosen()}else this.suppressNextEnter=!1,t==="Escape"?this.hideAutosuggest(e.target):t==="ArrowUp"?this.selectPreviousAutosuggestItem(e.target):t==="ArrowDown"?this.selectNextAutosuggestItem():this.autosuggestHandling(e);this.handleSearchTermChange(),this.updateClearButtonVisibility(this.currentInputValue)}autosuggestHandling(e){this.suggestAfterMinChars&&e.target&&e.target.value.length>=this.suggestAfterMinChars?this.executeSuggest(e.target.value):this.hideAutosuggest()}inputPasteEvent(e){setTimeout(()=>{this.autosuggestHandling(e),this.handleSearchTermChange(),this.updateClearButtonVisibility(e.target.value)},0)}executeSuggest(e){this.suggestTrigger(e)}executeSearch(e){this.hideAutosuggest(),this.searchTrigger(e===""?"*":e)}suggestionChosen(){this.selectedAutosuggestItem>-1?this.autosuggestItemClicked(this.autosuggestResults.suggestions[this.selectedAutosuggestItem]):this.executeSearch(this.currentInputValue)}hideAutosuggest(e){setTimeout(()=>{this.dataLayer.setAutosuggestResults({numFound:0,suggestions:[]}),this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.add("hidden")),this.resetAutosuggestSelection(),e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),J.setAccessibilityText("No Suggestion selected")},200)}cleanSuggestionTerm(e){return G.removeXSSRiskyTags(e.replace(/(<([^>]+)>)/gi,"")).trim()}autosuggestItemClicked(e){this.searchInput.value=this.cleanSuggestionTerm(e.term??""),this.executeSearch(this.cleanSuggestionTerm(e.term))}createAutosuggestItem(e){const t=document?.createElement("div");t.classList.add("searchstax-autosuggest-item"),t.addEventListener("click",()=>{this.autosuggestItemClicked(e)}),t.addEventListener("mouseenter",()=>{this.onSuggestionEnter(e)});const a=this.config.templates?.autosuggestItemTemplate?.template||w.searchInput.autosuggestItemTemplate?.template;return t.innerHTML=k.render(a,e),t}onSuggestionEnter(e){this.selectedAutosuggestItem=this.autosuggestResults?.suggestions.indexOf(e)||0,this.markActiveAutosuggestItem()}appendSuggestions(e){this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.remove("hidden"));for(const t in e.suggest)if(Object.prototype.hasOwnProperty.call(e.suggest,t)){const a=e.suggest[t];for(const s in a)if(Object.prototype.hasOwnProperty.call(a,s)){const n=a[s];n.numFound?J.setAccessibilityText("Suggestions are available. Use up and down arrows to navigate while focusing input. Use Escape key to escape out of the suggestions",2e3):J.setAccessibilityText("",0),this.autosuggestResults=n,this.dataLayer.setAutosuggestResults(n),n.numFound>0?n.suggestions.forEach(r=>{this.autosuggestContainer&&typeof document<"u"&&this.autosuggestContainer.appendChild(this.createAutosuggestItem(r))}):this.autosuggestContainer&&this.autosuggestContainer.classList.add("hidden")}}}}class Wn{dataLayer;config;linkClickCallback;searchCallback;containerId;searchResultsMainContainer;searchResultsContainer;searchResultLinks=[];constructor(e){this.linkClickCallback=e.linkClickCallback,this.searchCallback=e.searchTrigger,this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId;const t=document?.getElementById(this.containerId);if(t)this.searchResultsMainContainer=t;else throw new Error(`Search Results Main Container with id ${this.containerId} not found`);this.dataLayer.setIsInfiniteScroll(e.config.renderMethod==="infiniteScroll"),this.initializeSubscriptions(),this.renderMainTemplate()}initializeSubscriptions(){this.dataLayer.$searchObject.subscribe(()=>{J.setAccessibilityText("Searching...")}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.searchResultsContainer&&this.renderResults(e)})}changeTemplate(){this.dataLayer.searchResults&&this.renderResults(this.dataLayer.searchResults)}renderNoResultsTemplate(){const e=this.config?.templates?.noSearchResultTemplate?.template||w.searchResults.noSearchResultTemplate?.template,t=this.dataLayer.searchResultsMetadata?.spellingSuggestion??"";if(this.dataLayer.renderingEngine===F.mustache&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=k.render(e,{spellingSuggestion:t,...this.dataLayer.parsedData.data,searchCallback:this.searchCallback.bind(this)})),t&&this.searchResultsContainer){const a=this.searchResultsContainer.querySelector("a");a&&a.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.searchCallback(t)})}}renderResults(e){if(this.dataLayer.renderingEngine===F.mustache&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)J.setAccessibilityText("Search has no results"),this.renderNoResultsTemplate();else{J.setAccessibilityText(`Showing ${this.dataLayer.parsedData.startResultIndex} through ${this.dataLayer.parsedData.endResultIndex} results from ${this.dataLayer.parsedData.totalResults}. Press tab to navigate through results`);const t=this.config?.templates?.searchResultTemplate?.template||w.searchResults.searchResultTemplate?.template,a=e.map(s=>k.render(t,s));this.config?.renderMethod==="infiniteScroll"&&this.dataLayer.searchObject.page>1?this.searchResultsContainer.innerHTML+=a.join(""):this.searchResultsContainer.innerHTML=a.join(""),this.searchResultLinks=Array.from(this.searchResultsContainer.querySelectorAll(`[${this.uniqueIdAttribute}]`)),this.attachLinkClickEvents()}}removeLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.removeEventListener("click",()=>{}),e.removeEventListener("keydown",()=>{})})}get uniqueIdAttribute(){return this.config?.templates?.searchResultTemplate?.searchResultUniqueIdAttribute||w.searchResults.searchResultTemplate?.searchResultUniqueIdAttribute}attachLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const a=e.getAttribute(this.uniqueIdAttribute)??"";a&&this.linkClickCallback(a)}),e.addEventListener("keydown",t=>{if(t.code==="Space"||t.code==="Enter"){const a=e.getAttribute(this.uniqueIdAttribute)??"";a&&this.linkClickCallback(a)}})})}renderMainTemplate(){const e=this.config?.templates?.mainTemplate?.template||w.searchResults.mainTemplate?.template;this.dataLayer.renderingEngine===F.mustache&&(this.searchResultsMainContainer.innerHTML=k.render(e,{}),setTimeout(()=>{const t=this.config?.templates?.mainTemplate?.searchResultsContainerId?this.config?.templates?.mainTemplate?.searchResultsContainerId:w.searchResults.mainTemplate?.searchResultsContainerId,a=document?.getElementById(t);if(a)this.searchResultsContainer=a;else throw new Error(`Search Results Container with id ${t} not found`)},0))}}class Yn{dataLayer;config;containerId;selectId;searchSortingMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.selectId=this.config.templates?.main?.selectId||w.sorting.main.selectId,this.searchSortingMainContainer=document?.getElementById(this.containerId),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setSearchSortingData(e),e}setOrderQuery(e){const t=this.dataLayer.searchObject;t&&(t.order=e,this.dataLayer.setSearchObject(t))}markOptionSelected(){const e=document?.getElementById(this.selectId);if(e){const t=e.querySelector(`option[value="${decodeURIComponent(this.dataLayer.searchObject.order)}"]`);t&&(t.selected=!0)}}renderMainTemplate(e){const t=this.config?.templates?.main?.template||w.sorting.main.template;if(this.dataLayer.renderingEngine===F.mustache){this.searchSortingMainContainer.innerHTML=k.render(t,e),this.markOptionSelected();const a=document?.getElementById(this.selectId);a&&a.addEventListener("change",s=>{this.setOrderQuery(s.target.value)})}}}class Jn{analyticsKey;containerId;mainContainer;isLightweight;emailOverride;feedbackTextAreaOverride;mainTemplateOverride;lightweightTemplateOverride;focusedElement=null;focusTrapListener=null;lastFocusedElementBeforeModal=null;templateData={feedbackOpen:!1,ratings:[{index:1,isSelected:!1},{index:2,isSelected:!1},{index:3,isSelected:!1},{index:4,isSelected:!1},{index:5,isSelected:!1},{index:6,isSelected:!1},{index:7,isSelected:!1},{index:8,isSelected:!1},{index:9,isSelected:!1},{index:10,isSelected:!1}],emailInput:"",feedbackTextArea:"",charactersLeft:2e3,maxLength:2e3,errors:{rating:!1,email:!1},submitted:!1,thumbsUpActive:!1,thumbsDownActive:!1};thumbsUpValue=10;thumbsDownValue=1;ratedQuestion="";language="";model="";analyticsSrc="";constructor(e){this.analyticsKey=e.analyticsKey,this.containerId=e.containerId??"sf-feedback",this.isLightweight=e.lightweight??!1,this.isLightweight&&this.templateData.ratings.unshift({index:0,isSelected:!1}),this.thumbsUpValue=e.thumbsUpValue??10,this.thumbsDownValue=e.thumbsDownValue??1,this.emailOverride=e.emailOverride,this.feedbackTextAreaOverride=e.feedbackTextAreaOverride,this.mainTemplateOverride=e.mainTemplateOverride,this.lightweightTemplateOverride=e.lightweightTemplateOverride,this.mainContainer=document.getElementById(this.containerId),this.language=e.language??"",this.model=e.model??"",this.analyticsSrc=e.analyticsSrc??"",this.init()}init(){Le.attachAnalyticsScript(this.analyticsSrc),this.renderMainTemplate(this.generateTemplateData())}generateTemplateData(){return this.templateData}renderMainTemplate(e){const t=document.activeElement;(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLAnchorElement)&&(t.type==="radio"||t.type==="button"||t.type==="textarea"||t instanceof HTMLAnchorElement)?this.focusedElement=t:this.focusedElement=null,this.mainContainer;let a=Z?.mainTemplate?.template;if(this.mainTemplateOverride&&(a=this.mainTemplateOverride),this.isLightweight&&(a=Z.lightweightTemplate?.template,this.lightweightTemplateOverride&&(a=this.lightweightTemplateOverride)),this.mainContainer.innerHTML=k.render(a,e),this.focusedElement&&this.mainContainer){const s=this.focusedElement.type==="radio"?this.focusedElement.getAttribute("id"):this.focusedElement.getAttribute("class"),n=this.focusedElement.type==="radio"?"id":"class",r=this.mainContainer.querySelector(`[${n}="${s}"]`);(r instanceof HTMLInputElement||r instanceof HTMLButtonElement||r instanceof HTMLTextAreaElement||r instanceof HTMLAnchorElement)&&r.focus(),this.focusedElement=null}this.attachEvents()}attachEvents(){this.isLightweight?this.attachLightweightEvents():(this.attachOpenModalEvent(),this.closeModalEvent(),this.attachRatingEvents(),this.attachTextAreaEvents(),this.attachEmailInputEvents(),this.attachSubmitButtonEvents())}attachFocusTrap(){this.focusTrapListener&&document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=e=>{if(!this.templateData.feedbackOpen)return;const t=this.getModalElement();if(!t)return;const a=this.getFocusableElements(t);if(a.length===0)return;const s=a[0],n=a[a.length-1];e.key==="Tab"&&(e.shiftKey?(document.activeElement===s||!t.contains(document.activeElement))&&(e.preventDefault(),n?.focus()):(document.activeElement===n||!t.contains(document.activeElement))&&(e.preventDefault(),s?.focus())),e.key==="Escape"&&(e.preventDefault(),this.closeFeedbackModal())},document.addEventListener("keydown",this.focusTrapListener)}getFocusableElements(e){const t=["button:not([disabled])","input:not([disabled])","textarea:not([disabled])","select:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(e.querySelectorAll(t))}getModalElement(){const e=Z.mainTemplate?.modalContainerClass;return this.mainContainer?.querySelector(`.${e}`)||null}attachLightweightEvents(){const e=Z.lightweightTemplate?.thumbsUpButtonClass,t=Z.lightweightTemplate?.thumbsDownButtonClass,a=this.mainContainer?.querySelector("."+e),s=this.mainContainer?.querySelector("."+t);a&&a.addEventListener("click",()=>{const n=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[this.templateData.ratings.length-1].isSelected&&this.ratedQuestion===n||(this.templateData.thumbsUpActive=!0,this.templateData.thumbsDownActive=!1,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsUpValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=n,this.submit())}),s&&s.addEventListener("click",()=>{const n=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[0].isSelected&&this.ratedQuestion===n||(this.templateData.thumbsUpActive=!1,this.templateData.thumbsDownActive=!0,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsDownValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=n,this.submit())})}attachSubmitButtonEvents(){const e=Z.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.checkIfValid()})}checkIfValid(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.emailInputId);this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,J.setAccessibilityText("Please enter a valid email address.")),this.templateData.ratings.some(s=>s.isSelected)?this.templateData.errors.rating=!1:(this.templateData.errors.rating=!0,J.setAccessibilityText("Please Rate your experience.")),this.templateData.errors.rating||this.templateData.errors.email?this.renderMainTemplate(this.generateTemplateData()):this.submit()}submit(){this.templateData.submitted=!0;const e=this.templateData.ratings.find(t=>t.isSelected)?.index;e!==void 0&&(Le.trackFeedback({trackApiKey:this.analyticsKey,email:this.emailOverride&&this.isLightweight?this.emailOverride():this.templateData.emailInput,rating:e,feedback:this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea,model:this.model?this.model:void 0,language:this.language?this.language:void 0}),this.showCheckmarkAnimation(),J.setAccessibilityText("Feedback has been sent.",1e3),this.mainContainer?.querySelector("."+Z.mainTemplate?.checkmarkClass)?setTimeout(()=>{this.closeFeedbackModal(),this.renderMainTemplate(this.generateTemplateData())},2e3):(setTimeout(()=>{this.closeFeedbackModal()},500),this.renderMainTemplate(this.generateTemplateData())))}validateEmail(e){return e===""?!0:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}attachEmailInputEvents(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.emailInputId);e&&(e.addEventListener("input",()=>{this.templateData.emailInput=e.value}),e.addEventListener("blur",()=>{setTimeout(()=>{this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,J.setAccessibilityText("Please enter a valid email address.")),this.renderMainTemplate(this.generateTemplateData())},300)}))}attachTextAreaEvents(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.feedbackTextAreaId);e&&e.addEventListener("input",()=>{this.templateData.feedbackTextArea=e.value,this.templateData.charactersLeft=this.templateData.maxLength-e.value.length;const t=this.mainContainer?.querySelector("."+Z.mainTemplate?.charactersRemainingContainerclass);t&&(t.innerText=this.templateData.charactersLeft+"")})}attachRatingEvents(){const e=Z.mainTemplate?.ratingInputclass,t=this.mainContainer?.querySelectorAll("."+e);t&&t.forEach(a=>{a.addEventListener("click",s=>{const n=s.target.value;this.templateData.ratings.forEach(r=>{r.isSelected=r.index+""===n}),this.templateData.errors.rating=!1,this.renderMainTemplate(this.generateTemplateData())})})}attachOpenModalEvent(){const e=Z.mainTemplate?.openModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",a=>{a.preventDefault(),this.toggleModal()})}toggleModal(){this.templateData.feedbackOpen?this.closeFeedbackModal():this.openFeedbackModal()}closeModalEvent(){const e=Z.mainTemplate?.closeModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.closeFeedbackModal()})}openFeedbackModal(){this.lastFocusedElementBeforeModal=document.activeElement,this.templateData.feedbackOpen=!0,this.renderMainTemplate(this.generateTemplateData()),setTimeout(()=>{const e=this.getModalElement();if(e){const t=this.getFocusableElements(e);t.length>0&&t[0].focus()}this.attachFocusTrap()},0),J.setAccessibilityText("Feedback form opened",1e3)}closeFeedbackModal(){this.templateData.feedbackOpen=!1,this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null),this.renderMainTemplate(this.generateTemplateData()),this.lastFocusedElementBeforeModal&&(this.lastFocusedElementBeforeModal.focus(),this.lastFocusedElementBeforeModal=null),J.setAccessibilityText("Feedback form closed",1e3)}showCheckmarkAnimation(){const e=Z.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&(t.disabled=!0);const a=Z.mainTemplate?.checkmarkClass,s=this.mainContainer?.querySelector("."+a);s&&s.classList.remove("hidden");const n=Z.mainTemplate?.submitButtonTextClass,r=this.mainContainer?.querySelector("."+n);r&&r.classList.add("visibility"),setTimeout(()=>{s&&s.classList.add("hidden"),r&&r.classList.remove("visibility"),t&&(t.disabled=!1)},2e3)}destroy(){this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null)}}class Gn{dataLayer;config;containerId;answerContainer=null;showMoreVisible=!1;renderFeedbackWidget=!1;clicked=!1;renderedWithShowMore=!1;showMoreListenerAttached=!1;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.renderFeedbackWidget=this.config.feedbackwidget?.renderFeedbackWidget||!1,this.config.showMoreAfterWordCount&&(this.dataLayer.answerWidgetShowMoreLimit=this.config.showMoreAfterWordCount),typeof document<"u"&&(this.answerContainer=document?.getElementById(this.containerId),this.attachShowMoreClickListener()),this.config.testString?(this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())):this.initializeSubscriptions(),this.dataLayer.setIsAnswerWidgetCreated(!0)}initializeSubscriptions(){this.dataLayer.$answer.subscribe(()=>{this.clicked?this.showMoreVisible=!1:this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerLoading.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerError.subscribe(e=>{e&&setTimeout(()=>{this.renderMainTemplate(this.generateTemplateData())},100)}),this.dataLayer.$searchObject.subscribe(()=>{this.clicked=!1,this.renderedWithShowMore=!1,this.showMoreVisible=!1}),this.dataLayer.$paginationData.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answer.subscribe(e=>{e&&setTimeout(()=>{this.initializeWidget()},600)}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.$answer.getValue()&&setTimeout(()=>{this.initializeWidget()},600)})}searchstaxFeedbackTextAreaOverride(){return"Question: "+(this.dataLayer.searchObject.query==="undefined"?"":this.dataLayer.searchObject.query)+" Answer: "+this.dataLayer.parsedData.getAnswerData}initializeWidget(){this.renderFeedbackWidget&&document.getElementById("feedbackWidgetContainer")&&!this.dataLayer.answerLoading&&new Jn({analyticsKey:this.dataLayer.parsedData.trackingData.trackApiKey,containerId:"feedbackWidgetContainer",lightweight:!0,model:this.dataLayer.parsedData.trackingData.model,language:this.dataLayer.parsedData.trackingData.language,emailOverride:this.config.feedbackwidget?.emailOverride,feedbackTextAreaOverride:this.config.feedbackwidget?.searchstaxFeedbackTextAreaOverride??this.searchstaxFeedbackTextAreaOverride.bind(this),thumbsUpValue:this.config.feedbackwidget?.thumbsUpValue??10,thumbsDownValue:this.config.feedbackwidget?.thumbsDownValue??0,lightweightTemplateOverride:this.config.feedbackwidget?.lightweightTemplateOverride})}showMore(e){e.preventDefault(),this.clicked=!0,this.showMoreVisible=!1,Le.trackShowMoreClick({...this.dataLayer.parsedData.trackingData}),this.renderMainTemplate(this.generateTemplateData()),this.config.testString||setTimeout(()=>{this.initializeWidget()},600)}attachShowMoreClickListener(){!this.answerContainer||this.showMoreListenerAttached||(this.showMoreListenerAttached=!0,this.answerContainer.addEventListener("click",e=>{e.target?.closest?.(".searchstax-answer-load-more-button")&&this.showMore(e)}))}trackLinkClick(e){e.preventDefault(),e.stopPropagation();const a=e.target.getAttribute("href");Le.trackAnswerLinkClick({href:a,answer:this.dataLayer.parsedData.getAnswerData,...this.dataLayer.parsedData.trackingData}).then(()=>{window.open(a,"_blank")}).catch(()=>{window.open(a,"_blank")})}attachLinkTracking(){document.querySelectorAll(".searchstax-answer-link").forEach(t=>{t.getAttribute("listener")!=="true"&&(t.setAttribute("listener","true"),t.addEventListener("click",this.trackLinkClick.bind(this)))})}renderMainTemplate(e){const t=this.config?.templates?.main?.template||w.answer.main.template;this.dataLayer.renderingEngine===F.mustache?(!this.renderedWithShowMore||!e.answerLoading||this.clicked)&&(e.showMoreButtonVisible&&(this.renderedWithShowMore=!0),this.answerContainer.innerHTML=k.render(t,e),setTimeout(()=>{this.attachLinkTracking()},100)):setTimeout(()=>{this.attachLinkTracking()},500)}generateTemplateData(){this.config.testString&&this.dataLayer.setAnswerData(this.config.testString??"");const e={...this.dataLayer.parsedData.data,showMoreButtonVisible:this.showMoreVisible};return this.config.testString&&(e.searchExecuted=!0),this.dataLayer.setAnswerFullData(e),e}}class Ts{dataLayer;config;containerId;currentSelectValue="";locationInput;radiusInput;locationDecode;locationDecodeCoordinatesToAddress;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.locationDecode=e.config.hooks?.locationDecode,this.locationDecodeCoordinatesToAddress=e.config.hooks?.locationDecodeCoordinatesToAddress,this.dataLayer.locationEnabled&&this.dataLayer.$inputTemplateRendered.subscribeUntil(()=>{this.renderMainTemplate(),this.attachSubscriptions()},!0,500)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||w.location.mainTemplate.template,a={...this.dataLayer.parsedData.data};if(this.dataLayer.setLocationWidgetTemplateData(a),this.dataLayer.renderingEngine===F.mustache){const s=k.render(t,a);e.innerHTML=s;const n=this.config.templates?.mainTemplate?.locationInputId||w.location.mainTemplate.locationInputId,r=document?.querySelector(`#${n}`);if(r)this.locationInput=r,r.addEventListener("blur",this.blurEvent.bind(this)),r.addEventListener("focus",this.focusEvent.bind(this));else throw new Error("Input not found");const o=this.config.templates?.mainTemplate?.radiusInputId||w.location.mainTemplate.radiusInputId,c=document?.querySelector(`#${o}`);c instanceof HTMLSelectElement&&(this.radiusInput=c,c.addEventListener("change",this.radiusSelectChangeEvent.bind(this)));const h=this.config.templates?.mainTemplate?.currentLocationActionButtonId||w.location.mainTemplate.currentLocationActionButtonId,d=document?.querySelector(`#${h}`);d&&d.addEventListener("click",this.getCurrentLocation.bind(this))}}}setCurrentLocationFields(e){this.dataLayer.setLocationCoordinatesDecoded(e),this.dataLayer.setSearchLocation(this.dataLayer.searchLocationCoordinatesDecoded),this.dataLayer.renderingEngine===F.mustache&&this.locationInput&&(this.locationInput.value=this.dataLayer.searchLocationCoordinatesDecoded)}getCurrentLocation(){navigator.geolocation?navigator.geolocation.getCurrentPosition(e=>{const t=e.coords.latitude.toString(),a=e.coords.longitude.toString(),s=Math.floor(parseFloat(t)*100)/100,n=Math.floor(parseFloat(a)*100)/100;this.dataLayer.setSearchLat(s+""),this.dataLayer.setSearchLong(n+"");const r=this.locationDecodeCoordinatesToAddress;r?r(s+"",n+"").then(o=>{this.setCurrentLocationFields(o.address||"Current Location")}).catch(()=>{this.setCurrentLocationFields("Current Location")}):this.setCurrentLocationFields("Current Location")},()=>{console.error("Unable to retrieve your location")}):console.error("Geolocation is not supported by this browser.")}setRadiusValue(e){this.dataLayer.setSearchRadius(e)}radiusSelectChangeEvent(e){this.currentSelectValue=e.target.value,this.setRadiusValue(this.currentSelectValue)}attachSubscriptions(){this.dataLayer.$searchObject.subscribe(e=>{this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(e.location.address??"")),this.radiusInput&&e.location.radius&&(this.radiusInput.value=e.location.radius||"")})}cleanSuggestionTerm(e){return G.removeXSSRiskyTags(e.replace(/(<([^>]+)>)/gi,"")).trim()}triggerGeocoder(e){const t=this.locationDecode;this.dataLayer.setLocationDecodingLoading(!0),e&&this.dataLayer.searchLocation!==e&&e!==this.dataLayer.searchLocationCoordinatesDecoded?t(e).then(a=>{this.dataLayer.setSearchLocation(a.address||""),this.dataLayer.setSearchLat(a.lat||""),this.dataLayer.setSearchLong(a.lon||""),this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(a.address||"")),this.dataLayer.renderingEngine===F.mustache&&a.error&&this.locationInput&&this.locationInput.classList.add("searchstax-input-location-error"),a.error?this.dataLayer.setLocationError(!0):this.dataLayer.setLocationError(!1),this.dataLayer.setLocationDecodingLoading(!1)}).catch(()=>{this.dataLayer.setLocationDecodingLoading(!1)}):e===""&&(this.dataLayer.setSearchLocation(void 0),this.dataLayer.setSearchLat(void 0),this.dataLayer.setSearchLong(void 0),this.dataLayer.setLocationDecodingLoading(!1))}focusEvent(e){e.target.classList.remove("searchstax-input-location-error"),this.dataLayer.setLocationError(!1)}blurEvent(e){const a=e.target.value;this.triggerGeocoder(a)}}class Zn{routerEnabled=!1;cachedQuery="";routerHelper;searchHelper;searchResultsConfig;searchPaginationConfig;searchFeedbackConfig;searchSortingConfig;searchFacetsConfig;relatedSearchesConfig;externalPromotionsConfig;searchInputWidget;searchLocationWidget;searchResultsWidget;searchFacetsWidget;searchPaginationWidget;searchFeedbackWidget;searchSortingWidget;relatedSearchesWidget;externalPromotionsWidget;answerWidget;locationObserver=null;dataLayer;firstRequest=!0;previousQuery="";eventSource=null;renderEngine=F.mustache;constructor(e=F.mustache){e&&(this.renderEngine=e)}setRenderingEngine(e=F.mustache){this.dataLayer.setRenderingEngine(e)}handleHooks(){this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&this.dataLayer.$searchResults.subscribe(e=>{this.dataLayer.searchstaxConfig.hooks.afterSearch(e,this.dataLayer.searchResultUnparsedData)}),setTimeout(()=>{this.dataLayer.$searchObject.subscribe(e=>{e.query!==this.previousQuery&&this.dataLayer.setAnswerData(""),e.query!==""&&e.query!==void 0&&e.query!=="undefined"?(this.search(e),e.query!==this.previousQuery&&this.startSSE(e.query)):this.dataLayer.searchLocationConfig?.locationSearchEnabled&&!this.dataLayer.searchLocationConfig?.locationValuesOverride?this.getMetadata(e):this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue),this.previousQuery=e.query})},10),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&Le.trackSearch({...this.dataLayer.parsedData.trackingData,impressions:this.dataLayer.searchResultsMetadata.impressions})})}startSSE(e){this.eventSource&&(this.eventSource?.close(),this.dataLayer.setAnswerData("")),this.dataLayer.turnAIAnswerGenerationOn===!0&&this.dataLayer.questionURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&(this.eventSource=this.searchHelper?.startSSE(e,this.parseAnswerResultsResponse.bind(this)))}attachAnalyticsScript(e){Le.attachAnalyticsScript(e)}initialize(e){if(this.dataLayer=new ln("searchstax_session_id",e.sessionId),this.renderEngine&&this.dataLayer.setRenderingEngine(this.renderEngine),this.handleHooks(),e.questionURL&&(this.dataLayer.questionURL=e.questionURL),e.analyticsBaseUrl&&typeof window<"u"&&(window.analyticsBaseUrl=e.analyticsBaseUrl,window._msq=e._msq||[],this.attachAnalyticsScript(e.analyticsSrc)),e.autoCorrect===!1&&(this.dataLayer.autoCorrect=!1),e.language&&this.dataLayer.setLanguage(e.language),e.model&&this.dataLayer.setModel(e.model),this.dataLayer.searchstaxConfig||(this.dataLayer.setSearchstaxConfig(e),this.searchHelper=new pn({...e,sessionId:this.dataLayer.sessionId},this.dataLayer),this.dataLayer.searchHelper=this.searchHelper),e.router?.enabled===void 0||e.router?.enabled===!0){this.routerEnabled=!0,this.routerHelper=new ps(e.router?e.router:{enabled:!0});const t=this.routerHelper.urlToSearchObject(window?.location.href??"");this.dataLayer.searchObject.itemsPerPage?t.itemsPerPage=this.dataLayer.searchObject.itemsPerPage:t.itemsPerPage&&this.dataLayer.setItemsPerPage(t.itemsPerPage),t.model&&this.dataLayer.setModel(t.model),t.location&&(t.location.address&&this.dataLayer.setSearchLocation(t.location.address),t.location.lat&&this.dataLayer.setSearchLat(t.location.lat),t.location.lon&&this.dataLayer.setSearchLong(t.location.lon),t.location.radius&&this.dataLayer.setSearchRadius(t.location.radius)),this.dataLayer.setSearchObject(t),addEventListener("popstate",()=>{this.routerHelper&&this.dataLayer.setSearchObject(this.routerHelper.urlToSearchObject(window?.location.href??"",this.dataLayer.searchObject.itemsPerPage))})}else this.routerHelper=new ps({})}getMetadata(e){this.searchHelper&&(e.query==="undefined"||e.query===void 0)&&this.dataLayer.setSearchObject({...e,query:"*"})}search(e){if(this.searchHelper){const t=this.dataLayer.forceNotCorrect;this.searchHelper.url&&(this.searchHelper.search(e,this.parseSearchResultsResponse.bind(this),this.firstRequest,t),this.firstRequest=!1),this.getRelatedSearches()}}getRelatedSearches(){this.searchHelper&&this.relatedSearchesConfig&&this.relatedSearchesConfig?.relatedSearchesURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&this.searchHelper.getRelatedSearches(this.dataLayer.searchObject,this.relatedSearchesConfig.relatedSearchesURL,this.relatedSearchesConfig.relatedSearchesAPIKey,this.parseRelatedSearchesResponse.bind(this))}parseRelatedSearchesResponse(e){const a=(e.response?.docs??[]).map((n,r)=>({...n,position:r+1})),s=[];for(const n of a)s.push({relatedSearch:n.related_search,position:n.position});this.dataLayer.setSearchRelatedSearches(a),this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&s.length&&Le.trackRelatedSearches({...this.dataLayer.parsedData.trackingData,impressions:s,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}handleRouter(){if(this.routerEnabled){const e={...this.dataLayer.searchObject};this.dataLayer.isInfiniteScroll&&delete e.page,this.routerHelper.updateUrl(e)}}parseSearchResultsResponseMetadata(e){const t=nt.extractSearchResultsMetadata(e),a=this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue??t.location?.filter?.defaultValue;!this.dataLayer.searchRadius&&a&&this.dataLayer.setSearchRadius(a),this.dataLayer.setSearchResultsMetadata(t)}parseSearchResultsResponse(e){this.handleRouter(),this.dataLayer.setItemsPerPage(parseInt(e.responseHeader.params.rows)),this.dataLayer.setModel(e.responseHeader.params.model);let t=nt.combineResultsWithMetadata(e),a=nt.extractFacets(e);this.dataLayer.setSearchFacets(a),this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&(t=this.dataLayer.searchstaxConfig.hooks.afterSearch(t,e)),this.dataLayer.setSearchExternalPromotions(e.externalLinks??[]),this.parseSearchResultsResponseMetadata(e),this.dataLayer.setSearchResultUnparsedData(e),this.dataLayer.setSearchResults(t)}parseAnswerResultsResponse(e){this.handleRouter(),e!==ze.question&&e!==ze.notQuestion&&(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setAnswerData(this.dataLayer.getAnswerData+e))}cacheFacets(e){e?this.searchHelper?.cacheFacets(!0).then(()=>{}):this.searchHelper?.cacheFacets().then(()=>{})}parseSuggestSuggestResponse(e){let t=e;this.dataLayer.searchInputConfig?.hooks?.afterAutosuggest&&(t=this.dataLayer.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.dataLayer.setLanguage(e)}addSearchInputWidget(e,t){this.dataLayer.searchInputConfig||this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.dataLayer.setSearchInputConfig(t),this.searchInputWidget=new qn({containerId:e,config:t,searchTrigger:this.executeSearch.bind(this),suggestTrigger:this.executeSuggest.bind(this),dataLayer:this.dataLayer})},200)}addSearchLocationWidget(e,t){this.dataLayer.searchLocationConfig||(t.locationSearchEnabled?(this.dataLayer.setLocationEnabled(!0),this.dataLayer.setSearchLocationConfig(t),t.locationValuesOverride?(this.searchLocationWidget=new Ts({containerId:e,config:t,dataLayer:this.dataLayer}),t?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(t?.locationValuesOverride?.locationFilterDefaultValue)):this.dataLayer.$searchResultsMetadata.subscribeUntilHasValue(()=>{this.searchLocationWidget=new Ts({containerId:e,config:t,dataLayer:this.dataLayer})},0)):this.dataLayer.setLocationEnabled(!1))}addAnswerWidget(e,t){this.dataLayer.turnAIAnswerGenerationOn=!0,t.testString||this.startSSE(this.dataLayer.searchObject.query),this.dataLayer.setAnswerData(t.testString??""),this.answerWidget=new Gn({containerId:e,config:t,dataLayer:this.dataLayer})}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new Wn({containerId:e,linkClickCallback:this.executeLinkClick.bind(this),searchTrigger:this.executeSearch.bind(this),config:t,dataLayer:this.dataLayer}))}addPaginationWidget(e,t){this.searchPaginationConfig=t,this.searchPaginationWidget=new Hn({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper})}addSearchFeedbackWidget(e,t){this.searchFeedbackConfig=t,this.searchFeedbackWidget=new Qn({containerId:e,config:t,dataLayer:this.dataLayer,searchTrigger:this.executeSearch.bind(this)})}addSearchSortingWidget(e,t){this.searchSortingConfig=t,this.searchSortingWidget=new Yn({containerId:e,config:t,dataLayer:this.dataLayer})}addRelatedSearchesWidget(e,t){this.relatedSearchesConfig=t,this.relatedSearchesWidget=new Un({containerId:e,config:t,dataLayer:this.dataLayer,trackRelatedSearchClick:this.trackRelatedSearchClick.bind(this)}),setTimeout(()=>{this.getRelatedSearches()},0)}addExternalPromotionsWidget(e,t){this.externalPromotionsConfig=t,this.externalPromotionsWidget=new Bn({containerId:e,config:t,dataLayer:this.dataLayer})}addFacetsWidget(e,t){this.searchFacetsConfig=t,this.searchFacetsWidget=new Vn({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper},this.cacheFacets.bind(this))}executeSearch(e,t){const a={...this.dataLayer.searchObject};a.query=G.removeXSSRiskyTags(e),a.page=1,a.facets=[],a.location={...a.location},this.locationObserver&&this.dataLayer.$locationDecodingLoading.unsubscribe(this.locationObserver),this.locationObserver=this.dataLayer.$locationDecodingLoading.subscribeUntil(()=>{a.location.address=this.dataLayer.searchLocation,a.location.radius=this.dataLayer.searchRadius,a.location.lat=this.dataLayer.searchLat,a.location.lon=this.dataLayer.searchLong,this.dataLayer.forceNotCorrect=!!t;let s=this.routerHelper?.searchObjectToParams(a);s&&(s=this.routerHelper?.extractParamsThatDoNotStartWithRouteName(s)),s&&(a.additionalProps=Object.keys(s).map(n=>s?{key:n,value:s[n]}:{key:"",value:""})),this.dataLayer.setSearchObject(a),this.dataLayer.lastSearchValue=a.query},!1)}executeSuggest(e){let t={term:e,queryParams:[]};this.dataLayer.searchInputConfig?.hooks?.beforeAutosuggest&&(t=this.dataLayer.searchInputConfig.hooks.beforeAutosuggest(t)),t&&t.term!==void 0&&t.queryParams!==void 0&&this.suggest(t.term,t.queryParams)}trackRelatedSearchClick(e){this.dataLayer.searchResultsMetadata&&this.dataLayer.searchRelatedSearches&&!this.dataLayer.cookiesDisabled&&Le.trackRelatedSearchClick({...this.dataLayer.parsedData.trackingData,relatedSearch:e,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}executeLinkClick(e){let t=nt.findResultByUniqueId(e,this.dataLayer.searchResults??[]);t&&(this.searchResultsConfig?.hooks?.afterLinkClick&&(t=this.searchResultsConfig.hooks.afterLinkClick(t)),t&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&Le.trackClick({result:t,...this.dataLayer.parsedData.trackingData}).then(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}).catch(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}))}setPage(e){this.searchPaginationWidget?.goToPage(e)}setCookiesDisabled(e){this.dataLayer.setCookiesDisabled(e)}changeResultTemplate(e){this.searchResultsConfig&&(this.searchResultsConfig.templates=this.searchResultsConfig?.templates?{...this.searchResultsConfig?.templates,...e}:e,this.searchResultsWidget?.changeTemplate())}}Na.Searchstax=Zn,Object.defineProperty(Na,Symbol.toStringTag,{value:"Module"})})(this["@searchstaxInc/searchstudioUxJs"]=this["@searchstaxInc/searchstudioUxJs"]||{});
|