@searchstax-inc/searchstudio-ux-js 4.2.10 → 4.2.13
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 +5 -0
- package/dist/@searchstax-inc/searchstudio-ux-js.cjs +67 -67
- package/dist/@searchstax-inc/searchstudio-ux-js.d.mts +48 -45
- package/dist/@searchstax-inc/searchstudio-ux-js.d.ts +48 -45
- package/dist/@searchstax-inc/searchstudio-ux-js.iife.js +66 -66
- package/dist/@searchstax-inc/searchstudio-ux-js.mjs +64 -64
- package/package.json +1 -1
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
var
|
|
2
|
-
]`).replace("lheading",
|
|
3
|
-
`).map(
|
|
4
|
-
`)}var Dt=class{options;rules;lexer;constructor(
|
|
5
|
-
`)}}}fences(
|
|
6
|
-
`)}}blockquote(
|
|
1
|
+
var B=(r=>(r[r.mustache=0]="mustache",r[r.vue=1]="vue",r[r.react=2]="react",r[r.angular=3]="angular",r))(B||{});function sa(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Oe=sa();function ls(r){Oe=r}var it={exec:()=>null};function E(r,e=""){let t=typeof r=="string"?r:r.source;const s={replace:(a,i)=>{let n=typeof i=="string"?i:i.source;return n=n.replace(ae.caret,"$1"),t=t.replace(a,n),s},getRegex:()=>new RegExp(t,e)};return s}var ae={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:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}#`),htmlBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}<(?:[a-z].*>|!--)`,"i")},Tr=/^(?:[ \t]*(?:\n|$))+/,vr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ar=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,nt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Er=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ra=/(?:[*+-]|\d{1,9}[.)])/,hs=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,us=E(hs).replace(/bull/g,ra).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(),Ir=E(hs).replace(/bull/g,ra).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(),ia=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,jr=/^[^\n]+/,na=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Dr=E(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",na).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Rr=E(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ra).getRegex(),At="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",oa=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Nr=E("^ {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",oa).replace("tag",At).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ds=E(ia).replace("hr",nt).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",At).getRegex(),Or=E(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ds).getRegex(),ca={blockquote:Or,code:vr,def:Dr,fences:Ar,heading:Er,hr:nt,html:Nr,lheading:us,list:Rr,newline:Tr,paragraph:ds,table:it,text:jr},gs=E("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",nt).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",At).getRegex(),Pr={...ca,lheading:Ir,table:gs,paragraph:E(ia).replace("hr",nt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",gs).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",At).getRegex()},Fr={...ca,html:E(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",oa).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:it,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:E(ia).replace("hr",nt).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",us).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},zr=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,$r=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ps=/^( {2,}|\\)\n(?!\s*$)/,Vr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Et=/[\p{P}\p{S}]/u,la=/[\s\p{P}\p{S}]/u,ms=/[^\s\p{P}\p{S}]/u,Qr=E(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,la).getRegex(),fs=/(?!~)[\p{P}\p{S}]/u,Br=/(?!~)[\s\p{P}\p{S}]/u,qr=/(?:[^\s\p{P}\p{S}]|~)/u,Hr=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Ls=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,_r=E(Ls,"u").replace(/punct/g,Et).getRegex(),Ur=E(Ls,"u").replace(/punct/g,fs).getRegex(),ys="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Yr=E(ys,"gu").replace(/notPunctSpace/g,ms).replace(/punctSpace/g,la).replace(/punct/g,Et).getRegex(),Wr=E(ys,"gu").replace(/notPunctSpace/g,qr).replace(/punctSpace/g,Br).replace(/punct/g,fs).getRegex(),Jr=E("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ms).replace(/punctSpace/g,la).replace(/punct/g,Et).getRegex(),Gr=E(/\\(punct)/,"gu").replace(/punct/g,Et).getRegex(),Zr=E(/^<(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(),Kr=E(oa).replace("(?:-->|$)","-->").getRegex(),Xr=E("^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",Kr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),It=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ei=E(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",It).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ws=E(/^!?\[(label)\]\[(ref)\]/).replace("label",It).replace("ref",na).getRegex(),Ms=E(/^!?\[(ref)\](?:\[\])?/).replace("ref",na).getRegex(),ti=E("reflink|nolink(?!\\()","g").replace("reflink",ws).replace("nolink",Ms).getRegex(),ha={_backpedal:it,anyPunctuation:Gr,autolink:Zr,blockSkip:Hr,br:ps,code:$r,del:it,emStrongLDelim:_r,emStrongRDelimAst:Yr,emStrongRDelimUnd:Jr,escape:zr,link:ei,nolink:Ms,punctuation:Qr,reflink:ws,reflinkSearch:ti,tag:Xr,text:Vr,url:it},ai={...ha,link:E(/^!?\[(label)\]\((.*?)\)/).replace("label",It).getRegex(),reflink:E(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",It).getRegex()},ua={...ha,emStrongRDelimAst:Wr,emStrongLDelim:Ur,url:E(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},si={...ua,br:E(ps).replace("{2,}","*").getRegex(),text:E(ua.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},jt={normal:ca,gfm:Pr,pedantic:Fr},ot={normal:ha,gfm:ua,breaks:si,pedantic:ai},ri={"&":"&","<":"<",">":">",'"':""","'":"'"},bs=r=>ri[r];function ge(r,e){if(e){if(ae.escapeTest.test(r))return r.replace(ae.escapeReplace,bs)}else if(ae.escapeTestNoEncode.test(r))return r.replace(ae.escapeReplaceNoEncode,bs);return r}function Cs(r){try{r=encodeURI(r).replace(ae.percentDecode,"%")}catch{return null}return r}function xs(r,e){const t=r.replace(ae.findPipe,(i,n,c)=>{let l=!1,h=n;for(;--h>=0&&c[h]==="\\";)l=!l;return l?"|":" |"}),s=t.split(ae.splitPipe);let a=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;a<s.length;a++)s[a]=s[a].trim().replace(ae.slashPipe,"|");return s}function ct(r,e,t){const s=r.length;if(s===0)return"";let a=0;for(;a<s&&r.charAt(s-a-1)===e;)a++;return r.slice(0,s-a)}function ii(r,e){if(r.indexOf(e[1])===-1)return-1;let t=0;for(let s=0;s<r.length;s++)if(r[s]==="\\")s++;else if(r[s]===e[0])t++;else if(r[s]===e[1]&&(t--,t<0))return s;return t>0?-2:-1}function Ss(r,e,t,s,a){const i=e.href,n=e.title||null,c=r[1].replace(a.other.outputLinkReplace,"$1");s.state.inLink=!0;const l={type:r[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:n,text:c,tokens:s.inlineTokens(c)};return s.state.inLink=!1,l}function ni(r,e,t){const s=r.match(t.other.indentCodeCompensation);if(s===null)return e;const a=s[1];return e.split(`
|
|
3
|
+
`).map(i=>{const n=i.match(t.other.beginningSpace);if(n===null)return i;const[c]=n;return c.length>=a.length?i.slice(a.length):i}).join(`
|
|
4
|
+
`)}var Dt=class{options;rules;lexer;constructor(r){this.options=r||Oe}space(r){const e=this.rules.block.newline.exec(r);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(r){const e=this.rules.block.code.exec(r);if(e){const t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:ct(t,`
|
|
5
|
+
`)}}}fences(r){const e=this.rules.block.fences.exec(r);if(e){const t=e[0],s=ni(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:s}}}heading(r){const e=this.rules.block.heading.exec(r);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){const s=ct(t,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(t=s.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(r){const e=this.rules.block.hr.exec(r);if(e)return{type:"hr",raw:ct(e[0],`
|
|
6
|
+
`)}}blockquote(r){const e=this.rules.block.blockquote.exec(r);if(e){let t=ct(e[0],`
|
|
7
7
|
`).split(`
|
|
8
|
-
`),s="",a="";const
|
|
8
|
+
`),s="",a="";const i=[];for(;t.length>0;){let n=!1;const c=[];let l;for(l=0;l<t.length;l++)if(this.rules.other.blockquoteStart.test(t[l]))c.push(t[l]),n=!0;else if(!n)c.push(t[l]);else break;t=t.slice(l);const h=c.join(`
|
|
9
9
|
`),p=h.replace(this.rules.other.blockquoteSetextReplace,`
|
|
10
10
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
11
11
|
${h}`:h,a=a?`${a}
|
|
12
|
-
${p}`:p;const
|
|
12
|
+
${p}`:p;const L=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,i,!0),this.lexer.state.top=L,t.length===0)break;const y=i.at(-1);if(y?.type==="code")break;if(y?.type==="blockquote"){const N=y,v=N.raw+`
|
|
13
13
|
`+t.join(`
|
|
14
|
-
`),
|
|
14
|
+
`),C=this.blockquote(v);i[i.length-1]=C,s=s.substring(0,s.length-N.raw.length)+C.raw,a=a.substring(0,a.length-N.text.length)+C.text;break}else if(y?.type==="list"){const N=y,v=N.raw+`
|
|
15
15
|
`+t.join(`
|
|
16
|
-
`),
|
|
17
|
-
`);continue}}return{type:"blockquote",raw:s,tokens:
|
|
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 s=this.inlineQueue[t];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){for(this.options.pedantic&&(e=e.replace(
|
|
16
|
+
`),C=this.list(v);i[i.length-1]=C,s=s.substring(0,s.length-y.raw.length)+C.raw,a=a.substring(0,a.length-N.raw.length)+C.raw,t=v.substring(i.at(-1).raw.length).split(`
|
|
17
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:i,text:a}}}list(r){let e=this.rules.block.list.exec(r);if(e){let t=e[1].trim();const s=t.length>1,a={type:"list",raw:"",ordered:s,start:s?+t.slice(0,-1):"",loose:!1,items:[]};t=s?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=s?t:"[*+-]");const i=this.rules.other.listItemRegex(t);let n=!1;for(;r;){let l=!1,h="",p="";if(!(e=i.exec(r))||this.rules.block.hr.test(r))break;h=e[0],r=r.substring(h.length);let L=e[2].split(`
|
|
18
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,j=>" ".repeat(3*j.length)),y=r.split(`
|
|
19
|
+
`,1)[0],N=!L.trim(),v=0;if(this.options.pedantic?(v=2,p=L.trimStart()):N?v=e[1].length+1:(v=e[2].search(this.rules.other.nonSpaceChar),v=v>4?1:v,p=L.slice(v),v+=e[1].length),N&&this.rules.other.blankLine.test(y)&&(h+=y+`
|
|
20
|
+
`,r=r.substring(y.length+1),l=!0),!l){const j=this.rules.other.nextBulletRegex(v),q=this.rules.other.hrRegex(v),ie=this.rules.other.fencesBeginRegex(v),F=this.rules.other.headingBeginRegex(v),m=this.rules.other.htmlBeginRegex(v);for(;r;){const g=r.split(`
|
|
21
|
+
`,1)[0];let M;if(y=g,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),M=y):M=y.replace(this.rules.other.tabCharGlobal," "),ie.test(y)||F.test(y)||m.test(y)||j.test(y)||q.test(y))break;if(M.search(this.rules.other.nonSpaceChar)>=v||!y.trim())p+=`
|
|
22
|
+
`+M.slice(v);else{if(N||L.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ie.test(L)||F.test(L)||q.test(L))break;p+=`
|
|
23
|
+
`+y}!N&&!y.trim()&&(N=!0),h+=g+`
|
|
24
|
+
`,r=r.substring(g.length+1),L=M.slice(v)}}a.loose||(n?a.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(n=!0));let C=null,P;this.options.gfm&&(C=this.rules.other.listIsTask.exec(p),C&&(P=C[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:h,task:!!C,checked:P,loose:!1,text:p,tokens:[]}),a.raw+=h}const c=a.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;a.raw=a.raw.trimEnd();for(let l=0;l<a.items.length;l++)if(this.lexer.state.top=!1,a.items[l].tokens=this.lexer.blockTokens(a.items[l].text,[]),!a.loose){const h=a.items[l].tokens.filter(L=>L.type==="space"),p=h.length>0&&h.some(L=>this.rules.other.anyLine.test(L.raw));a.loose=p}if(a.loose)for(let l=0;l<a.items.length;l++)a.items[l].loose=!0;return a}}html(r){const e=this.rules.block.html.exec(r);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(r){const e=this.rules.block.def.exec(r);if(e){const t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=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:s,title:a}}}table(r){const e=this.rules.block.table.exec(r);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const t=xs(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
25
|
+
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===s.length){for(const n of s)this.rules.other.tableAlignRight.test(n)?i.align.push("right"):this.rules.other.tableAlignCenter.test(n)?i.align.push("center"):this.rules.other.tableAlignLeft.test(n)?i.align.push("left"):i.align.push(null);for(let n=0;n<t.length;n++)i.header.push({text:t[n],tokens:this.lexer.inline(t[n]),header:!0,align:i.align[n]});for(const n of a)i.rows.push(xs(n,i.header.length).map((c,l)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:i.align[l]})));return i}}lheading(r){const e=this.rules.block.lheading.exec(r);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(r){const e=this.rules.block.paragraph.exec(r);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(r){const e=this.rules.block.text.exec(r);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(r){const e=this.rules.inline.escape.exec(r);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(r){const e=this.rules.inline.tag.exec(r);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(r){const e=this.rules.inline.link.exec(r);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 i=ct(t.slice(0,-1),"\\");if((t.length-i.length)%2===0)return}else{const i=ii(e[2],"()");if(i===-2)return;if(i>-1){const n=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,n).trim(),e[3]=""}}let s=e[2],a="";if(this.options.pedantic){const i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],a=i[3])}else a=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?s=s.slice(1):s=s.slice(1,-1)),Ss(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(r,e){let t;if((t=this.rules.inline.reflink.exec(r))||(t=this.rules.inline.nolink.exec(r))){const s=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),a=e[s.toLowerCase()];if(!a){const i=t[0].charAt(0);return{type:"text",raw:i,text:i}}return Ss(t,a,t[0],this.lexer,this.rules)}}emStrong(r,e,t=""){let s=this.rules.inline.emStrongLDelim.exec(r);if(!(!s||s[3]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!t||this.rules.inline.punctuation.exec(t))){const a=[...s[0]].length-1;let i,n,c=a,l=0;const h=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*r.length+a);(s=h.exec(e))!=null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(n=[...i].length,s[3]||s[4]){c+=n;continue}else if((s[5]||s[6])&&a%3&&!((a+n)%3)){l+=n;continue}if(c-=n,c>0)continue;n=Math.min(n,n+c+l);const p=[...s[0]][0].length,L=r.slice(0,a+s.index+p+n);if(Math.min(a,n)%2){const N=L.slice(1,-1);return{type:"em",raw:L,text:N,tokens:this.lexer.inlineTokens(N)}}const y=L.slice(2,-2);return{type:"strong",raw:L,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(r){const e=this.rules.inline.code.exec(r);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," ");const s=this.rules.other.nonSpaceChar.test(t),a=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return s&&a&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(r){const e=this.rules.inline.br.exec(r);if(e)return{type:"br",raw:e[0]}}del(r){const e=this.rules.inline.del.exec(r);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(r){const e=this.rules.inline.autolink.exec(r);if(e){let t,s;return e[2]==="@"?(t=e[1],s="mailto:"+t):(t=e[1],s=t),{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}url(r){let e;if(e=this.rules.inline.url.exec(r)){let t,s;if(e[2]==="@")t=e[0],s="mailto:"+t;else{let a;do a=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(a!==e[0]);t=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(r){const e=this.rules.inline.text.exec(r);if(e){const t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},ye=class Na{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Oe,this.options.tokenizer=this.options.tokenizer||new Dt,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:ae,block:jt.normal,inline:ot.normal};this.options.pedantic?(t.block=jt.pedantic,t.inline=ot.pedantic):this.options.gfm&&(t.block=jt.gfm,this.options.breaks?t.inline=ot.breaks:t.inline=ot.gfm),this.tokenizer.rules=t}static get rules(){return{block:jt,inline:ot}}static lex(e,t){return new Na(t).lex(e)}static lexInline(e,t){return new Na(t).inlineTokens(e)}lex(e){e=e.replace(ae.carriageReturn,`
|
|
27
|
+
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const s=this.inlineQueue[t];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){for(this.options.pedantic&&(e=e.replace(ae.tabCharGlobal," ").replace(ae.spaceLine,""));e;){let a;if(this.options.extensions?.block?.some(n=>(a=n.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);const n=t.at(-1);a.raw.length===1&&n!==void 0?n.raw+=`
|
|
28
28
|
`:t.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);const n=t.at(-1);n?.type==="paragraph"||n?.type==="text"?(n.raw+=`
|
|
29
29
|
`+a.raw,n.text+=`
|
|
30
30
|
`+a.text,this.inlineQueue.at(-1).src=n.text):t.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);const n=t.at(-1);n?.type==="paragraph"||n?.type==="text"?(n.raw+=`
|
|
31
31
|
`+a.raw,n.text+=`
|
|
32
|
-
`+a.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title});continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),t.push(a);continue}let
|
|
32
|
+
`+a.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title});continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),t.push(a);continue}let i=e;if(this.options.extensions?.startBlock){let n=1/0;const c=e.slice(1);let l;this.options.extensions.startBlock.forEach(h=>{l=h.call({lexer:this},c),typeof l=="number"&&l>=0&&(n=Math.min(n,l))}),n<1/0&&n>=0&&(i=e.substring(0,n+1))}if(this.state.top&&(a=this.tokenizer.paragraph(i))){const n=t.at(-1);s&&n?.type==="paragraph"?(n.raw+=`
|
|
33
33
|
`+a.raw,n.text+=`
|
|
34
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(a),s=
|
|
34
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(a),s=i.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);const n=t.at(-1);n?.type==="text"?(n.raw+=`
|
|
35
35
|
`+a.raw,n.text+=`
|
|
36
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(a);continue}if(e){const n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}else throw new Error(n)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let s=e,a=null;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)c.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,a.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(a=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let
|
|
37
|
-
`;return s?'<pre><code class="language-'+
|
|
38
|
-
`:"<pre><code>"+(t?a:
|
|
39
|
-
`}blockquote({tokens:
|
|
40
|
-
${this.parser.parse(
|
|
41
|
-
`}html({text:
|
|
42
|
-
`}hr(
|
|
43
|
-
`}list(
|
|
36
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(a);continue}if(e){const n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}else throw new Error(n)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let s=e,a=null;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)c.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,a.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(a=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,n="";for(;e;){i||(n=""),i=!1;let c;if(this.options.extensions?.inline?.some(h=>(c=h.call({lexer:this},e,t))?(e=e.substring(c.raw.length),t.push(c),!0):!1))continue;if(c=this.tokenizer.escape(e)){e=e.substring(c.raw.length),t.push(c);continue}if(c=this.tokenizer.tag(e)){e=e.substring(c.raw.length),t.push(c);continue}if(c=this.tokenizer.link(e)){e=e.substring(c.raw.length),t.push(c);continue}if(c=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(c.raw.length);const h=t.at(-1);c.type==="text"&&h?.type==="text"?(h.raw+=c.raw,h.text+=c.text):t.push(c);continue}if(c=this.tokenizer.emStrong(e,s,n)){e=e.substring(c.raw.length),t.push(c);continue}if(c=this.tokenizer.codespan(e)){e=e.substring(c.raw.length),t.push(c);continue}if(c=this.tokenizer.br(e)){e=e.substring(c.raw.length),t.push(c);continue}if(c=this.tokenizer.del(e)){e=e.substring(c.raw.length),t.push(c);continue}if(c=this.tokenizer.autolink(e)){e=e.substring(c.raw.length),t.push(c);continue}if(!this.state.inLink&&(c=this.tokenizer.url(e))){e=e.substring(c.raw.length),t.push(c);continue}let l=e;if(this.options.extensions?.startInline){let h=1/0;const p=e.slice(1);let L;this.options.extensions.startInline.forEach(y=>{L=y.call({lexer:this},p),typeof L=="number"&&L>=0&&(h=Math.min(h,L))}),h<1/0&&h>=0&&(l=e.substring(0,h+1))}if(c=this.tokenizer.inlineText(l)){e=e.substring(c.raw.length),c.raw.slice(-1)!=="_"&&(n=c.raw.slice(-1)),i=!0;const h=t.at(-1);h?.type==="text"?(h.raw+=c.raw,h.text+=c.text):t.push(c);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}},Rt=class{options;parser;constructor(r){this.options=r||Oe}space(r){return""}code({text:r,lang:e,escaped:t}){const s=(e||"").match(ae.notSpaceStart)?.[0],a=r.replace(ae.endingNewline,"")+`
|
|
37
|
+
`;return s?'<pre><code class="language-'+ge(s)+'">'+(t?a:ge(a,!0))+`</code></pre>
|
|
38
|
+
`:"<pre><code>"+(t?a:ge(a,!0))+`</code></pre>
|
|
39
|
+
`}blockquote({tokens:r}){return`<blockquote>
|
|
40
|
+
${this.parser.parse(r)}</blockquote>
|
|
41
|
+
`}html({text:r}){return r}heading({tokens:r,depth:e}){return`<h${e}>${this.parser.parseInline(r)}</h${e}>
|
|
42
|
+
`}hr(r){return`<hr>
|
|
43
|
+
`}list(r){const e=r.ordered,t=r.start;let s="";for(let n=0;n<r.items.length;n++){const c=r.items[n];s+=this.listitem(c)}const a=e?"ol":"ul",i=e&&t!==1?' start="'+t+'"':"";return"<"+a+i+`>
|
|
44
44
|
`+s+"</"+a+`>
|
|
45
|
-
`}listitem(
|
|
46
|
-
`}checkbox({checked:
|
|
47
|
-
`}table(
|
|
45
|
+
`}listitem(r){let e="";if(r.task){const t=this.checkbox({checked:!!r.checked});r.loose?r.tokens[0]?.type==="paragraph"?(r.tokens[0].text=t+" "+r.tokens[0].text,r.tokens[0].tokens&&r.tokens[0].tokens.length>0&&r.tokens[0].tokens[0].type==="text"&&(r.tokens[0].tokens[0].text=t+" "+ge(r.tokens[0].tokens[0].text),r.tokens[0].tokens[0].escaped=!0)):r.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:!0}):e+=t+" "}return e+=this.parser.parse(r.tokens,!!r.loose),`<li>${e}</li>
|
|
46
|
+
`}checkbox({checked:r}){return"<input "+(r?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:r}){return`<p>${this.parser.parseInline(r)}</p>
|
|
47
|
+
`}table(r){let e="",t="";for(let a=0;a<r.header.length;a++)t+=this.tablecell(r.header[a]);e+=this.tablerow({text:t});let s="";for(let a=0;a<r.rows.length;a++){const i=r.rows[a];t="";for(let n=0;n<i.length;n++)t+=this.tablecell(i[n]);s+=this.tablerow({text:t})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
48
48
|
<thead>
|
|
49
49
|
`+e+`</thead>
|
|
50
50
|
`+s+`</table>
|
|
51
|
-
`}tablerow({text:
|
|
52
|
-
${
|
|
53
|
-
`}tablecell(
|
|
54
|
-
`}strong({tokens:
|
|
55
|
-
`+this.renderer.text(c);t?s+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l,escaped:!0}]}):s+=l;continue}default:{const c='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}parseInline(e,t=this.renderer){let s="";for(let a=0;a<e.length;a++){const
|
|
56
|
-
Please report this to https://github.com/markedjs/marked.`,
|
|
57
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qi(i,e){return $i(i)||Vi(i,e)||Hi(i,e)||Bi()}function Hi(i,e){if(i){if(typeof i=="string")return Ls(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)?Ls(i,e):void 0}}const ys=Object.entries,ws=Object.setPrototypeOf,_i=Object.isFrozen,qi=Object.getPrototypeOf,Ui=Object.getOwnPropertyDescriptor;let te=Object.freeze,ne=Object.seal,Ve=Object.create,Ms=typeof Reflect<"u"&&Reflect,ha=Ms.apply,ua=Ms.construct;te||(te=function(i){return i}),ne||(ne=function(i){return i}),ha||(ha=function(i,e){for(var t=arguments.length,s=new Array(t>2?t-2:0),a=2;a<t;a++)s[a-2]=arguments[a];return i.apply(e,s)}),ua||(ua=function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;s<e;s++)t[s-1]=arguments[s];return new i(...t)});const Be=U(Array.prototype.forEach),Wi=U(Array.prototype.lastIndexOf),Cs=U(Array.prototype.pop),Qe=U(Array.prototype.push),Yi=U(Array.prototype.splice),ae=Array.isArray,ot=U(String.prototype.toLowerCase),da=U(String.prototype.toString),bs=U(String.prototype.match),He=U(String.prototype.replace),xs=U(String.prototype.indexOf),Ji=U(String.prototype.trim),Gi=U(Number.prototype.toString),Zi=U(Boolean.prototype.toString),ks=typeof BigInt>"u"?null:U(BigInt.prototype.toString),Ss=typeof Symbol>"u"?null:U(Symbol.prototype.toString),$=U(Object.prototype.hasOwnProperty),ct=U(Object.prototype.toString),K=U(RegExp.prototype.test),lt=Ki(TypeError);function U(i){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 ha(i,e,s)}}function Ki(i){return function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return ua(i,t)}}function b(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ot;if(ws&&ws(i,null),!ae(e))return i;let s=e.length;for(;s--;){let a=e[s];if(typeof a=="string"){const r=t(a);r!==a&&(_i(e)||(e[s]=r),a=r)}i[a]=!0}return i}function Xi(i){for(let e=0;e<i.length;e++)$(i,e)||(i[e]=null);return i}function X(i){const e=Ve(null);for(const s of ys(i)){var t=Qi(s,2);const a=t[0],r=t[1];$(i,a)&&(ae(r)?e[a]=Xi(r):r&&typeof r=="object"&&r.constructor===Object?e[a]=X(r):e[a]=r)}return e}function er(i){switch(typeof i){case"string":return i;case"number":return Gi(i);case"boolean":return Zi(i);case"bigint":return ks?ks(i):"0";case"symbol":return Ss?Ss(i):"Symbol()";case"undefined":return ct(i);case"function":case"object":{if(i===null)return ct(i);const e=i,t=me(e,"toString");if(typeof t=="function"){const s=t(e);return typeof s=="string"?s:ct(s)}return ct(i)}default:return ct(i)}}function me(i,e){for(;i!==null;){const s=Ui(i,e);if(s){if(s.get)return U(s.get);if(typeof s.value=="function")return U(s.value)}i=qi(i)}function t(){return null}return t}function tr(i){try{return K(i,""),!0}catch{return!1}}const Ts=te(["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"]),ga=te(["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"]),pa=te(["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"]),ar=te(["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"]),ma=te(["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"]),sr=te(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),vs=te(["#text"]),As=te(["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"]),fa=te(["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"]),Es=te(["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"]),Nt=te(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ir=ne(/{{[\w\W]*|^[\w\W]*}}/g),rr=ne(/<%[\w\W]*|^[\w\W]*%>/g),nr=ne(/\${[\w\W]*/g),or=ne(/^data-[\-\w.\u00B7-\uFFFF]+$/),cr=ne(/^aria-[\-\w]+$/),Is=ne(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),lr=ne(/^(?:\w+script|data):/i),hr=ne(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ur=ne(/^html$/i),dr=ne(/^[a-z][.\w]*(-[.\w]+)+$/i),fe={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},gr=function(){return typeof window>"u"?null:window},pr=function(i,e){if(typeof i!="object"||typeof i.createPolicy!="function")return null;let t=null;const s="data-tt-policy-suffix";e&&e.hasAttribute(s)&&(t=e.getAttribute(s));const a="dompurify"+(t?"#"+t:"");try{return i.createPolicy(a,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Ds=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function js(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gr();const e=o=>js(o);if(e.version="3.4.7",e.removed=[],!i||!i.document||i.document.nodeType!==fe.document||!i.Element)return e.isSupported=!1,e;let t=i.document;const s=t,a=s.currentScript;i.DocumentFragment;const r=i.HTMLTemplateElement,n=i.Node,c=i.Element,l=i.NodeFilter;i.NamedNodeMap===void 0&&(i.NamedNodeMap||i.MozNamedAttrMap),i.HTMLFormElement;const p=i.DOMParser,f=i.trustedTypes,L=c.prototype,j=me(L,"cloneNode"),A=me(L,"remove"),x=me(L,"nextSibling"),z=me(L,"childNodes"),D=me(L,"parentNode"),P=me(L,"shadowRoot"),re=me(L,"attributes"),V=n&&n.prototype?me(n.prototype,"nodeType"):null,m=n&&n.prototype?me(n.prototype,"nodeName"):null;if(typeof r=="function"){const o=t.createElement("template");o.content&&o.content.ownerDocument&&(t=o.content.ownerDocument)}let d,w="";const T=t,B=T.implementation,ce=T.createNodeIterator,Ft=T.createDocumentFragment,$t=T.getElementsByTagName,Vt=s.importNode;let N=Ds();e.isSupported=typeof ys=="function"&&typeof D=="function"&&B&&B.createHTMLDocument!==void 0;const Te=ir,Lt=rr,yt=nr,qs=or,Us=cr,Ws=lr,Ra=hr,Ys=dr;let Na=Is,Q=null;const Bt=b({},[...Ts,...ga,...pa,...ma,...vs]);let q=null;const Qt=b({},[...As,...fa,...Es,...Nt]);let H=Object.seal(Ve(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}})),Ke=null,wt=null;const xe=Object.seal(Ve(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Oa=!0,Ht=!0,Pa=!1,za=!0,ke=!1,Xe=!0,ve=!1,_t=!1,qt=!1,Ne=!1,Mt=!1,Ct=!1,Fa=!0,$a=!1;const Va="user-content-";let Ut=!0,et=!1,Oe={},ue=null;const Wt=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 Ba=null;const Qa=b({},["audio","video","img","source","image","track"]);let Yt=null;const Ha=b({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),bt="http://www.w3.org/1998/Math/MathML",xt="http://www.w3.org/2000/svg",de="http://www.w3.org/1999/xhtml";let Pe=de,Jt=!1,Gt=null;const Js=b({},[bt,xt,de],da);let Zt=b({},["mi","mo","mn","ms","mtext"]),Kt=b({},["annotation-xml"]);const Gs=b({},["title","style","font","a","script"]);let tt=null;const Zs=["application/xhtml+xml","text/html"],Ks="text/html";let _=null,ze=null;const Xs=t.createElement("form"),_a=function(o){return o instanceof RegExp||o instanceof Function},Xt=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ze&&ze===o)return;(!o||typeof o!="object")&&(o={}),o=X(o),tt=Zs.indexOf(o.PARSER_MEDIA_TYPE)===-1?Ks:o.PARSER_MEDIA_TYPE,_=tt==="application/xhtml+xml"?da:ot,Q=$(o,"ALLOWED_TAGS")&&ae(o.ALLOWED_TAGS)?b({},o.ALLOWED_TAGS,_):Bt,q=$(o,"ALLOWED_ATTR")&&ae(o.ALLOWED_ATTR)?b({},o.ALLOWED_ATTR,_):Qt,Gt=$(o,"ALLOWED_NAMESPACES")&&ae(o.ALLOWED_NAMESPACES)?b({},o.ALLOWED_NAMESPACES,da):Js,Yt=$(o,"ADD_URI_SAFE_ATTR")&&ae(o.ADD_URI_SAFE_ATTR)?b(X(Ha),o.ADD_URI_SAFE_ATTR,_):Ha,Ba=$(o,"ADD_DATA_URI_TAGS")&&ae(o.ADD_DATA_URI_TAGS)?b(X(Qa),o.ADD_DATA_URI_TAGS,_):Qa,ue=$(o,"FORBID_CONTENTS")&&ae(o.FORBID_CONTENTS)?b({},o.FORBID_CONTENTS,_):Wt,Ke=$(o,"FORBID_TAGS")&&ae(o.FORBID_TAGS)?b({},o.FORBID_TAGS,_):X({}),wt=$(o,"FORBID_ATTR")&&ae(o.FORBID_ATTR)?b({},o.FORBID_ATTR,_):X({}),Oe=$(o,"USE_PROFILES")?o.USE_PROFILES&&typeof o.USE_PROFILES=="object"?X(o.USE_PROFILES):o.USE_PROFILES:!1,Oa=o.ALLOW_ARIA_ATTR!==!1,Ht=o.ALLOW_DATA_ATTR!==!1,Pa=o.ALLOW_UNKNOWN_PROTOCOLS||!1,za=o.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ke=o.SAFE_FOR_TEMPLATES||!1,Xe=o.SAFE_FOR_XML!==!1,ve=o.WHOLE_DOCUMENT||!1,Ne=o.RETURN_DOM||!1,Mt=o.RETURN_DOM_FRAGMENT||!1,Ct=o.RETURN_TRUSTED_TYPE||!1,qt=o.FORCE_BODY||!1,Fa=o.SANITIZE_DOM!==!1,$a=o.SANITIZE_NAMED_PROPS||!1,Ut=o.KEEP_CONTENT!==!1,et=o.IN_PLACE||!1,Na=tr(o.ALLOWED_URI_REGEXP)?o.ALLOWED_URI_REGEXP:Is,Pe=typeof o.NAMESPACE=="string"?o.NAMESPACE:de,Zt=$(o,"MATHML_TEXT_INTEGRATION_POINTS")&&o.MATHML_TEXT_INTEGRATION_POINTS&&typeof o.MATHML_TEXT_INTEGRATION_POINTS=="object"?X(o.MATHML_TEXT_INTEGRATION_POINTS):b({},["mi","mo","mn","ms","mtext"]),Kt=$(o,"HTML_INTEGRATION_POINTS")&&o.HTML_INTEGRATION_POINTS&&typeof o.HTML_INTEGRATION_POINTS=="object"?X(o.HTML_INTEGRATION_POINTS):b({},["annotation-xml"]);const u=$(o,"CUSTOM_ELEMENT_HANDLING")&&o.CUSTOM_ELEMENT_HANDLING&&typeof o.CUSTOM_ELEMENT_HANDLING=="object"?X(o.CUSTOM_ELEMENT_HANDLING):Ve(null);if(H=Ve(null),$(u,"tagNameCheck")&&_a(u.tagNameCheck)&&(H.tagNameCheck=u.tagNameCheck),$(u,"attributeNameCheck")&&_a(u.attributeNameCheck)&&(H.attributeNameCheck=u.attributeNameCheck),$(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(H.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),ke&&(Ht=!1),Mt&&(Ne=!0),Oe&&(Q=b({},vs),q=Ve(null),Oe.html===!0&&(b(Q,Ts),b(q,As)),Oe.svg===!0&&(b(Q,ga),b(q,fa),b(q,Nt)),Oe.svgFilters===!0&&(b(Q,pa),b(q,fa),b(q,Nt)),Oe.mathMl===!0&&(b(Q,ma),b(q,Es),b(q,Nt))),xe.tagCheck=null,xe.attributeCheck=null,$(o,"ADD_TAGS")&&(typeof o.ADD_TAGS=="function"?xe.tagCheck=o.ADD_TAGS:ae(o.ADD_TAGS)&&(Q===Bt&&(Q=X(Q)),b(Q,o.ADD_TAGS,_))),$(o,"ADD_ATTR")&&(typeof o.ADD_ATTR=="function"?xe.attributeCheck=o.ADD_ATTR:ae(o.ADD_ATTR)&&(q===Qt&&(q=X(q)),b(q,o.ADD_ATTR,_))),$(o,"ADD_URI_SAFE_ATTR")&&ae(o.ADD_URI_SAFE_ATTR)&&b(Yt,o.ADD_URI_SAFE_ATTR,_),$(o,"FORBID_CONTENTS")&&ae(o.FORBID_CONTENTS)&&(ue===Wt&&(ue=X(ue)),b(ue,o.FORBID_CONTENTS,_)),$(o,"ADD_FORBID_CONTENTS")&&ae(o.ADD_FORBID_CONTENTS)&&(ue===Wt&&(ue=X(ue)),b(ue,o.ADD_FORBID_CONTENTS,_)),Ut&&(Q["#text"]=!0),ve&&b(Q,["html","head","body"]),Q.table&&(b(Q,["tbody"]),delete Ke.tbody),o.TRUSTED_TYPES_POLICY){if(typeof o.TRUSTED_TYPES_POLICY.createHTML!="function")throw lt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof o.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw lt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');d=o.TRUSTED_TYPES_POLICY,w=d.createHTML("")}else d===void 0&&(d=pr(f,a)),d!==null&&typeof w=="string"&&(w=d.createHTML(""));(N.uponSanitizeElement.length>0||N.uponSanitizeAttribute.length>0)&&Q===Bt&&(Q=X(Q)),N.uponSanitizeAttribute.length>0&&q===Qt&&(q=X(q)),te&&te(o),ze=o},qa=b({},[...ga,...pa,...ar]),Ua=b({},[...ma,...sr]),ei=function(o){let u=D(o);(!u||!u.tagName)&&(u={namespaceURI:Pe,tagName:"template"});const g=ot(o.tagName),C=ot(u.tagName);return Gt[o.namespaceURI]?o.namespaceURI===xt?u.namespaceURI===de?g==="svg":u.namespaceURI===bt?g==="svg"&&(C==="annotation-xml"||Zt[C]):!!qa[g]:o.namespaceURI===bt?u.namespaceURI===de?g==="math":u.namespaceURI===xt?g==="math"&&Kt[C]:!!Ua[g]:o.namespaceURI===de?u.namespaceURI===xt&&!Kt[C]||u.namespaceURI===bt&&!Zt[C]?!1:!Ua[g]&&(Gs[g]||!qa[g]):!!(tt==="application/xhtml+xml"&&Gt[o.namespaceURI]):!1},Ae=function(o){Qe(e.removed,{element:o});try{D(o).removeChild(o)}catch{A(o)}},Ee=function(o,u){try{Qe(e.removed,{attribute:u.getAttributeNode(o),from:u})}catch{Qe(e.removed,{attribute:null,from:u})}if(u.removeAttribute(o),o==="is")if(Ne||Mt)try{Ae(u)}catch{}else try{u.setAttribute(o,"")}catch{}},Wa=function(o){let u=null,g=null;if(qt)o="<remove></remove>"+o;else{const R=bs(o,/^[\r\n\t ]+/);g=R&&R[0]}tt==="application/xhtml+xml"&&Pe===de&&(o='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+o+"</body></html>");const C=d?d.createHTML(o):o;if(Pe===de)try{u=new p().parseFromString(C,tt)}catch{}if(!u||!u.documentElement){u=B.createDocument(Pe,"template",null);try{u.documentElement.innerHTML=Jt?w:C}catch{}}const v=u.body||u.documentElement;return o&&g&&v.insertBefore(t.createTextNode(g),v.childNodes[0]||null),Pe===de?$t.call(u,ve?"html":"body")[0]:ve?u.documentElement:v},Ya=function(o){return ce.call(o.ownerDocument||o,o,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Ja=function(o){o.normalize();const u=ce.call(o.ownerDocument||o,o,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let g=u.nextNode();for(;g;){let C=g.data;Be([Te,Lt,yt],v=>{C=He(C,v," ")}),g.data=C,g=u.nextNode()}},kt=function(o){const u=m?m(o):null;return typeof u!="string"||_(u)!=="form"?!1:typeof o.nodeName!="string"||typeof o.textContent!="string"||typeof o.removeChild!="function"||o.attributes!==re(o)||typeof o.removeAttribute!="function"||typeof o.setAttribute!="function"||typeof o.namespaceURI!="string"||typeof o.insertBefore!="function"||typeof o.hasChildNodes!="function"||o.nodeType!==V(o)||o.childNodes!==z(o)},at=function(o){if(!V||typeof o!="object"||o===null)return!1;try{return V(o)===fe.documentFragment}catch{return!1}},St=function(o){if(!V||typeof o!="object"||o===null)return!1;try{return typeof V(o)=="number"}catch{return!1}};function ye(o,u,g){Be(o,C=>{C.call(e,u,g,ze)})}const Ga=function(o){let u=null;if(ye(N.beforeSanitizeElements,o,null),kt(o))return Ae(o),!0;const g=_(o.nodeName);if(ye(N.uponSanitizeElement,o,{tagName:g,allowedTags:Q}),Xe&&o.hasChildNodes()&&!St(o.firstElementChild)&&K(/<[/\w!]/g,o.innerHTML)&&K(/<[/\w!]/g,o.textContent)||Xe&&o.namespaceURI===de&&g==="style"&&St(o.firstElementChild)||o.nodeType===fe.progressingInstruction||Xe&&o.nodeType===fe.comment&&K(/<[/\w]/g,o.data))return Ae(o),!0;if(Ke[g]||!(xe.tagCheck instanceof Function&&xe.tagCheck(g))&&!Q[g]){if(!Ke[g]&&Ka(g)&&(H.tagNameCheck instanceof RegExp&&K(H.tagNameCheck,g)||H.tagNameCheck instanceof Function&&H.tagNameCheck(g)))return!1;if(Ut&&!ue[g]){const C=D(o),v=z(o);if(v&&C){const R=v.length;for(let we=R-1;we>=0;--we){const ge=j(v[we],!0);C.insertBefore(ge,x(o))}}}return Ae(o),!0}return(V?V(o):o.nodeType)===fe.element&&!ei(o)||(g==="noscript"||g==="noembed"||g==="noframes")&&K(/<\/no(script|embed|frames)/i,o.innerHTML)?(Ae(o),!0):(ke&&o.nodeType===fe.text&&(u=o.textContent,Be([Te,Lt,yt],C=>{u=He(u,C," ")}),o.textContent!==u&&(Qe(e.removed,{element:o.cloneNode()}),o.textContent=u)),ye(N.afterSanitizeElements,o,null),!1)},Za=function(o,u,g){if(wt[u]||Fa&&(u==="id"||u==="name")&&(g in t||g in Xs))return!1;const C=q[u]||xe.attributeCheck instanceof Function&&xe.attributeCheck(u,o);if(!(Ht&&!wt[u]&&K(qs,u))&&!(Oa&&K(Us,u))){if(!C||wt[u]){if(!(Ka(o)&&(H.tagNameCheck instanceof RegExp&&K(H.tagNameCheck,o)||H.tagNameCheck instanceof Function&&H.tagNameCheck(o))&&(H.attributeNameCheck instanceof RegExp&&K(H.attributeNameCheck,u)||H.attributeNameCheck instanceof Function&&H.attributeNameCheck(u,o))||u==="is"&&H.allowCustomizedBuiltInElements&&(H.tagNameCheck instanceof RegExp&&K(H.tagNameCheck,g)||H.tagNameCheck instanceof Function&&H.tagNameCheck(g))))return!1}else if(!Yt[u]&&!K(Na,He(g,Ra,""))&&!((u==="src"||u==="xlink:href"||u==="href")&&o!=="script"&&xs(g,"data:")===0&&Ba[o])&&!(Pa&&!K(Ws,He(g,Ra,"")))&&g)return!1}return!0},ti=b({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ka=function(o){return!ti[ot(o)]&&K(Ys,o)},Xa=function(o){ye(N.beforeSanitizeAttributes,o,null);const u=o.attributes;if(!u||kt(o))return;const g={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:q,forceKeepAttr:void 0};let C=u.length;for(;C--;){const v=u[C],R=v.name,we=v.namespaceURI,ge=v.value,le=_(R),$e=ge;let J=R==="value"?$e:Ji($e);if(g.attrName=le,g.attrValue=J,g.keepAttr=!0,g.forceKeepAttr=void 0,ye(N.uponSanitizeAttribute,o,g),J=g.attrValue,$a&&(le==="id"||le==="name")&&xs(J,Va)!==0&&(Ee(R,o),J=Va+J),Xe&&K(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,J)){Ee(R,o);continue}if(le==="attributename"&&bs(J,"href")){Ee(R,o);continue}if(g.forceKeepAttr)continue;if(!g.keepAttr){Ee(R,o);continue}if(!za&&K(/\/>/i,J)){Ee(R,o);continue}ke&&Be([Te,Lt,yt],ai=>{J=He(J,ai," ")});const es=_(o.nodeName);if(!Za(es,le,J)){Ee(R,o);continue}if(d&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!we)switch(f.getAttributeType(es,le)){case"TrustedHTML":{J=d.createHTML(J);break}case"TrustedScriptURL":{J=d.createScriptURL(J);break}}if(J!==$e)try{we?o.setAttributeNS(we,R,J):o.setAttribute(R,J),kt(o)?Ae(o):Cs(e.removed)}catch{Ee(R,o)}}ye(N.afterSanitizeAttributes,o,null)},Tt=function(o){let u=null;const g=Ya(o);for(ye(N.beforeSanitizeShadowDOM,o,null);u=g.nextNode();)if(ye(N.uponSanitizeShadowNode,u,null),Ga(u),Xa(u),at(u.content)&&Tt(u.content),(V?V(u):u.nodeType)===fe.element){const C=P?P(u):u.shadowRoot;at(C)&&(Fe(C),Tt(C))}ye(N.afterSanitizeShadowDOM,o,null)},Fe=function(o){const u=V?V(o):o.nodeType;if(u===fe.element){const v=P?P(o):o.shadowRoot;at(v)&&(Fe(v),Tt(v))}const g=z?z(o):o.childNodes;if(!g)return;const C=[];Be(g,v=>{Qe(C,v)});for(const v of C)Fe(v);if(u===fe.element){const v=m?m(o):null;if(typeof v=="string"&&_(v)==="template"){const R=o.content;at(R)&&Fe(R)}}};return e.sanitize=function(o){let u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},g=null,C=null,v=null,R=null;if(Jt=!o,Jt&&(o="<!-->"),typeof o!="string"&&!St(o)&&(o=er(o),typeof o!="string"))throw lt("dirty is not a string, aborting");if(!e.isSupported)return o;if(_t||Xt(u),e.removed=[],typeof o=="string"&&(et=!1),et){const le=m?m(o):o.nodeName;if(typeof le=="string"){const $e=_(le);if(!Q[$e]||Ke[$e])throw lt("root node is forbidden and cannot be sanitized in-place")}if(kt(o))throw lt("root node is clobbered and cannot be sanitized in-place");Fe(o)}else if(St(o))g=Wa("<!---->"),C=g.ownerDocument.importNode(o,!0),C.nodeType===fe.element&&C.nodeName==="BODY"||C.nodeName==="HTML"?g=C:g.appendChild(C),Fe(C);else{if(!Ne&&!ke&&!ve&&o.indexOf("<")===-1)return d&&Ct?d.createHTML(o):o;if(g=Wa(o),!g)return Ne?null:Ct?w:""}g&&qt&&Ae(g.firstChild);const we=Ya(et?o:g);for(;v=we.nextNode();)Ga(v),Xa(v),at(v.content)&&Tt(v.content);if(et)return ke&&Ja(o),o;if(Ne){if(ke&&Ja(g),Mt)for(R=Ft.call(g.ownerDocument);g.firstChild;)R.appendChild(g.firstChild);else R=g;return(q.shadowroot||q.shadowrootmode)&&(R=Vt.call(s,R,!0)),R}let ge=ve?g.outerHTML:g.innerHTML;return ve&&Q["!doctype"]&&g.ownerDocument&&g.ownerDocument.doctype&&g.ownerDocument.doctype.name&&K(ur,g.ownerDocument.doctype.name)&&(ge="<!DOCTYPE "+g.ownerDocument.doctype.name+`>
|
|
58
|
-
`+ge),ke&&Be([Te,Lt,yt],le=>{ge=He(ge,le," ")}),d&&Ct?d.createHTML(ge):ge},e.setConfig=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Xt(o),_t=!0},e.clearConfig=function(){ze=null,_t=!1},e.isValidAttribute=function(o,u,g){ze||Xt({});const C=_(o),v=_(u);return Za(C,v,g)},e.addHook=function(o,u){typeof u=="function"&&Qe(N[o],u)},e.removeHook=function(o,u){if(u!==void 0){const g=Wi(N[o],u);return g===-1?void 0:Yi(N[o],g,1)[0]}return Cs(N[o])},e.removeHooks=function(o){N[o]=[]},e.removeAllHooks=function(){N=Ds()},e}var Rs=js();class mr{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 Rs.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,a)=>{const r=s.value==="any"?0:parseFloat(s.value),n=a.value==="any"?0:parseFloat(a.value);return r-n})}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 Rs.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(t=>{const s=t.name,a=t.value,r=e.find(n=>n.name===s);if(r){const n=r.values.find(c=>c.type==="range"?!1:c.type==="checkbox"?'"'+c.value+'"'===a:!1);if(n)return n}return null}).filter(t=>t!==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 r of s){const n=e[r],c=t[r],l=this.isObject(n)&&this.isObject(c);if(l&&!this.deepEqual(n,c)||!l&&n!==c)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=r=>{s++,e(r),s>=2&&this.unsubscribe(t)};this.subscribe(a,t)}subscribeUntil(e,t,s=6e3,a=!0){const r=Math.random().toString(36).substring(2,15),n=c=>{c===t&&(e(c),this.unsubscribe(r))};return this.value===t?(e(this.value),null):(this.subscribe(n,r),setTimeout(()=>{a&&this.observers[r]&&e(this.value),this.unsubscribe(r)},s),r)}subscribeUntilHasValue(e,t=6e3,s=!0){const a=Math.random().toString(36).substring(2,15),r=n=>{n!=null&&(e(n),this.unsubscribe(a))};return this.value!==null&&this.value!==void 0?(e(this.value),null):(this.subscribe(r,a),t>0&&setTimeout(()=>{s&&this.observers[a]&&e(this.value),this.unsubscribe(a)},t),r)}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 La{static getOrSetCookie(e,t){let s=this.getCookie(e);return s==null&&(s=t??this.makeid(25),this.setCookie(e,s,{secure:!0,"max-age":3600})),s}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=s.length;for(let r=0;r<e;r++)t+=s.charAt(Math.floor(Math.random()*a));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,s){const a={path:"/",...s};s.expires instanceof Date&&(a.expires=s.expires.toUTCString());let r=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const n in a){r+="; "+n;const c=a[n];c!==!0&&(r+="="+c)}typeof document<"u"&&(document.cookie=r)}}class G{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 fr{$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 mr(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,La.deleteCookie(this.sessionId),La.deleteCookie("ms_visitorid")):this.sessionIdValue=La.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 ht{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,r)=>{const n=a[e.responseHeader.params.uniqueId]??"",c={custom:null,uniqueId:n,position:s+1+r,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e,n):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e,n):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e,n):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,n):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,n,!0):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e,n):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e,n):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e,n):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e,n):null,distance:this.doesMapExist("distance",e)&&this.getValueByKey("distance",a,e,n)!=="Infinity"&&this.getValueByKey("distance",a,e,n)?Math.floor(this.getValueByKey("distance",a,e,n)):null,unit:e.metadata.locationSearch?.unit??"",unmappedFields:this.getUnmappedFields(a,e,n),allFields:this.getAllFields(a,e)};t.push(c)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const s of e.metadata.facets){let a={values:[]};if(a.name=s.name,a.label=s.label,s.name in e.facet_counts.facet_fields){const r=e.facet_counts.facet_fields[s.name];for(let n=0;n<r.length;n+=2){const c={};c.value=r[n],c.parentName=a.name,c.count=r[n+1],c.type="checkbox",a.values.push(c)}}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(r=>r.result_card==="date")?.name,s.options=[],e.metadata.sorts?.length){const r=e.metadata.sorts.map(n=>({value:n.label,key:n.name+" "+n.order}));s.options=[{key:"",value:"Relevance"},...r]}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 r=s[a],n={};n.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(n.cDocTitle=this.getDataForAnalytics(r.titleTracking)),n.position=r.position,t.push(n)}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(n=>n.result_card==="").map(n=>n.name),r=[];for(const n of a)if(Object.keys(e).includes(n)){const c=Array.isArray(e[n])?this.getHighlightedResults(n,e[n].join(", "),s,t):this.getHighlightedResults(n,e[n]+"",s,t);r.push({key:n,value:c,isImage:this.checkIfImage(e[n])})}return r}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const s=t.metadata.results.map(r=>r.name),a=[];for(const r of Object.keys(e))s.indexOf(r)!==-1&&a.push({key:r,value:e[r],isImage:this.checkIfImage(e[r])});return a}static doesMapExist(e,t){return t.metadata.results.find(s=>s.result_card===e)!==void 0}static getValueByKey(e,t,s,a,r=!1){const n=s.metadata.results.find(l=>l.result_card===e);if(n===void 0)return null;const c=t[n.name];return c===void 0?null:typeof c=="string"?r?c:this.getHighlightedResults(n.name,c,a,s):typeof c=="number"?c:Array.isArray(c)?r?c.join(", "):this.getHighlightedResults(n.name,c.join(", "),a,s):null}static getHighlightedResults(e,t,s,a){if(a.highlighting&&s in a.highlighting){let r=a.highlighting[s];if(r&&e in r){let n=r[e];const c=this.cleanValue(n);if(c!=="")return c}}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 Lr(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 r=e.location[a];r&&(t[this.routeName+`[location][${a}]`]=r)}if(e.facets)for(const a in e.facets){const r=e.facets[a].type+":"+encodeURIComponent(e.facets[a].name)+":"+encodeURIComponent(e.facets[a].value);t[this.routeName+`[facets][${a}]`]=r}if(e.model&&(t[this.routeName+"[model]"]=e.model),this.queryStringHelper.urlHasQueryParams(window?.location.href??"")){const a=this.queryStringHelper.urlToParams(window?.location.href??"");for(const r in a)r.startsWith(this.routeName)&&delete a[r];return{...a,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const s in e)s.startsWith(this.routeName)||(t[s]=e[s]);return t}extractArrayOfFacetsFromQueryParameters(e){const t=[];for(const s in e)if(s.startsWith(this.routeName+"[facets]")){const a=G.removeXSSRiskyTags(e[s].split(":")?.[0]),r=G.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[1])),n=G.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[2]));t.push({type:a,name:r,value:n})}return t}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),n=isNaN(r)?1:r;let c=parseInt(G.removeXSSRiskyTags(s[this.routeName+"[itemsPerPage]"]));return isNaN(c)&&(c=10),{query:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:n,itemsPerPage:t??c,order:G.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[],model:G.removeXSSRiskyTags(s[this.routeName+"[model]"])||"",location:{address:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][address]"]||"")),radius:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][radius]"]||"")),lat:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lat]"]||"")),lon:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lon]"]||""))}}}}class Lr{routeName="";constructor(e){this.routeName=e}stringify=(e,t)=>{const s=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(s).map(a=>{const r=s[a];return Array.isArray(r)?r.map(n=>`${a}=${n}`).join("&"):`${a}=${r}`}).join("&")};filterOutIgnoredKeys(e,t){const s=t||[],a={};return Object.keys(e).forEach(r=>{s.includes(r)||e[r]!==""&&(a[r]=e[r])}),a}urlToParams(e){const t={},s=e.split("?")[1];return s&&s.split("&").forEach(a=>{const[r,n]=a.split("=");t[r]=n}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const _e={question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class ya 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,yr=13,je=32;function wa(i){}function wr(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=wa,onError:t=wa,onRetry:s=wa,onComment:a,maxBufferSize:r}=i,n=[];let c=0,l=!0,h,p="",f=0,L,j=!1;function A(m){if(j)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l&&(l=!1,m.charCodeAt(0)===239&&m.charCodeAt(1)===187&&m.charCodeAt(2)===191&&(m=m.slice(3))),n.length===0){const T=z(m);T!==""&&(n.push(T),c=T.length),x();return}if(m.indexOf(`
|
|
59
|
-
`)===-1&&m.indexOf("\r")===-1){n.push(m),c+=m.length,
|
|
60
|
-
`,
|
|
61
|
-
`,
|
|
62
|
-
`,
|
|
63
|
-
${
|
|
64
|
-
`,
|
|
65
|
-
`,
|
|
66
|
-
${
|
|
67
|
-
${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.test(d)?s(parseInt(d,10)):t(new ya(`Invalid \`retry\` value: "${d}"`,{type:"invalid-retry",value:d,line:w}));break;default:t(new ya(`Unknown field "${m.length>20?`${m.slice(0,20)}\u2026`:m}"`,{type:"unknown-field",field:m,value:d,line:w}));break}}function re(){f>0&&e({id:h,event:L,data:p}),h=void 0,p="",f=0,L=void 0}function V(m={}){if(m.consume&&n.length>0){const d=n.join("");D(d,0,d.length)}l=!0,h=void 0,p="",f=0,L=void 0,n.length=0,c=0,j=!1}return{feed:A,reset:V}}function Ps(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 zs(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 Fs 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($s(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e($s(this),t)}}function Mr(i){const e=globalThis.DOMException;return typeof e=="function"?new e(i,"SyntaxError"):new SyntaxError(i)}function Ma(i){return i instanceof Error?"errors"in i&&Array.isArray(i.errors)?i.errors.map(Ma).join(", "):"cause"in i&&i.cause instanceof Error?`${i}: ${Ma(i.cause)}`:i.message:`${i}`}function $s(i){return{type:i.type,message:i.message,code:i.code,defaultPrevented:i.defaultPrevented,cancelable:i.cancelable,timeStamp:i.timeStamp}}var Vs=i=>{throw TypeError(i)},Ca=(i,e,t)=>e.has(i)||Vs("Cannot "+t),k=(i,e,t)=>(Ca(i,e,"read from private field"),t?t.call(i):e.get(i)),W=(i,e,t)=>e.has(i)?Vs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),O=(i,e,t,s)=>(Ca(i,e,"write to private field"),e.set(i,t),t),be=(i,e,t)=>(Ca(i,e,"access private method"),t),ie,Re,qe,Ot,Pt,ut,Ue,dt,Se,We,Ye,Je,gt,he,ba,xa,ka,Bs,Sa,Ta,pt,va,Aa;class zt extends EventTarget{constructor(e,t){var s,a;super(),W(this,he),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,W(this,ie),W(this,Re),W(this,qe),W(this,Ot),W(this,Pt),W(this,ut),W(this,Ue),W(this,dt,null),W(this,Se),W(this,We),W(this,Ye,null),W(this,Je,null),W(this,gt,null),W(this,xa,async r=>{var n;k(this,We).reset();const{body:c,redirected:l,status:h,headers:p}=r;if(h===204){be(this,he,pt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(l?O(this,qe,new URL(r.url)):O(this,qe,void 0),h!==200){be(this,he,pt).call(this,`Non-200 status code (${h})`,h);return}if(!(p.get("content-type")||"").startsWith("text/event-stream")){be(this,he,pt).call(this,'Invalid content type, expected "text/event-stream"',h);return}if(k(this,ie)===this.CLOSED)return;O(this,ie,this.OPEN);const f=new Event("open");if((n=k(this,gt))==null||n.call(this,f),this.dispatchEvent(f),typeof c!="object"||!c||!("getReader"in c)){be(this,he,pt).call(this,"Invalid response body, expected a web ReadableStream",h),this.close();return}const L=new TextDecoder,j=c.getReader();let A=!0;do{const{done:x,value:z}=await j.read();z&&k(this,We).feed(L.decode(z,{stream:!x})),x&&(A=!1,k(this,We).reset(),be(this,he,va).call(this))}while(A)}),W(this,ka,r=>{O(this,Se,void 0),!(r.name==="AbortError"||r.type==="aborted")&&be(this,he,va).call(this,Ma(r))}),W(this,Sa,r=>{typeof r.id=="string"&&O(this,dt,r.id);const n=new MessageEvent(r.event||"message",{data:r.data,origin:k(this,qe)?k(this,qe).origin:k(this,Re).origin,lastEventId:r.id||""});k(this,Je)&&(!r.event||r.event==="message")&&k(this,Je).call(this,n),this.dispatchEvent(n)}),W(this,Ta,r=>{O(this,ut,r)}),W(this,Aa,()=>{O(this,Ue,void 0),k(this,ie)===this.CONNECTING&&be(this,he,ba).call(this)});try{if(e instanceof URL)O(this,Re,e);else if(typeof e=="string")O(this,Re,new URL(e,Cr()));else throw new Error("Invalid URL")}catch{throw Mr("An invalid or illegal string was specified")}O(this,We,wr({onEvent:k(this,Sa),onRetry:k(this,Ta)})),O(this,ie,this.CONNECTING),O(this,ut,3e3),O(this,Pt,(s=t?.fetch)!=null?s:globalThis.fetch),O(this,Ot,(a=t?.withCredentials)!=null?a:!1),be(this,he,ba).call(this)}get readyState(){return k(this,ie)}get url(){return k(this,Re).href}get withCredentials(){return k(this,Ot)}get onerror(){return k(this,Ye)}set onerror(e){O(this,Ye,e)}get onmessage(){return k(this,Je)}set onmessage(e){O(this,Je,e)}get onopen(){return k(this,gt)}set onopen(e){O(this,gt,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,Ue)&&clearTimeout(k(this,Ue)),k(this,ie)!==this.CLOSED&&(k(this,Se)&&k(this,Se).abort(),O(this,ie,this.CLOSED),O(this,Se,void 0))}}ie=new WeakMap,Re=new WeakMap,qe=new WeakMap,Ot=new WeakMap,Pt=new WeakMap,ut=new WeakMap,Ue=new WeakMap,dt=new WeakMap,Se=new WeakMap,We=new WeakMap,Ye=new WeakMap,Je=new WeakMap,gt=new WeakMap,he=new WeakSet,ba=function(){O(this,ie,this.CONNECTING),O(this,Se,new AbortController),k(this,Pt)(k(this,Re),be(this,he,Bs).call(this)).then(k(this,xa)).catch(k(this,ka))},xa=new WeakMap,ka=new WeakMap,Bs=function(){var i;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...k(this,dt)?{"Last-Event-ID":k(this,dt)}:void 0},cache:"no-store",signal:(i=k(this,Se))==null?void 0:i.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Sa=new WeakMap,Ta=new WeakMap,pt=function(i,e){var t;k(this,ie)!==this.CLOSED&&O(this,ie,this.CLOSED);const s=new Fs("error",{code:e,message:i});(t=k(this,Ye))==null||t.call(this,s),this.dispatchEvent(s)},va=function(i,e){var t;if(k(this,ie)===this.CLOSED)return;O(this,ie,this.CONNECTING);const s=new Fs("error",{code:e,message:i});(t=k(this,Ye))==null||t.call(this,s),this.dispatchEvent(s),O(this,Ue,setTimeout(k(this,Aa),k(this,ut)))},Aa=new WeakMap,zt.CONNECTING=0,zt.OPEN=1,zt.CLOSED=2;function Cr(){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 t=e||"https://static.searchstax.com/studio-js/v4/js/studio-analytics.js";if(!document.querySelector(`script[src="${t}"]`)){var s=document.createElement("script");s.type="text/javascript",s.src=t;var a=document.getElementsByTagName("script")[0];a.parentNode&&a.parentNode.insertBefore(s,a)}}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 r=["trackClick",t];t.key?this.msq().push(r,(function(n,c){JSON.stringify(n)===JSON.stringify(t)&&c?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 r=["answerSourceClick",t];t.key?this.msq().push(r,(function(n,c){JSON.stringify(n)===JSON.stringify(t)&&c?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+"",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 br{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 r=a.name+':"'+a.value+'"';s=s.concat("fq="+decodeURIComponent(r).replace(" "," "))});else{const a={};e.forEach(function(n){const c=n.name+":"+n.value,l=decodeURIComponent(c).replace(" "," ").split(":");a[l[0]]?a[l[0]].push(l[1]):a[l[0]]=[l[1]]});let r="";for(const n in a)if(Object.prototype.hasOwnProperty.call(a,n)){const c=a[n],l=n;for(const h of c)r+=r===""?` ${l}:"${h}"`:` OR ${l}:"${h}"`}s=s.concat("fq="+r.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 r=new Headers;r.append("Accept","application/json"),r.append("Authorization",s),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:r,credentials:"same-origin"}).then(n=>n.json()).then(n=>{a(n)})}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=ht.extractFacets(e);t?this.dataLayer.setSearchFacetsCachedTabs(s):this.dataLayer.setSearchFacetsCached(s),this.resolveFn&&this.resolveFn()}search(e,t,s=!1,a=!1,r=!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 n=this.url+this.generateQueryParams(e,a),c={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete c.signal,fetch(n,c).then(l=>l.json()).then(l=>{this.dataLayer.setLoading(!1),t(l,r)}).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 r=e.itemsPerPage!==void 0?`&rows=${e.itemsPerPage}`:"",n=new Proxy(new URLSearchParams(window?.location.search??""),{get:(h,p)=>h.get(p)??""}),c=n.languageVariant?"&fq=_language:"+n.languageVariant:"",l=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+r+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!t}`+(l?`&model=${l}`:"")+"&language="+this.dataLayer.language+c}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.searchObject.page!==1)return;const s=this.dataLayer;s.setAnswerLoading(!1),s.setAnswerErrorMessage(""),s.setAnswerError(!1);const a=new zt(this.dataLayer.questionURL+this.generateQueryParams(this.dataLayer.searchObject),{fetch:(r,n)=>fetch(r,{...n,headers:{...n?.headers,Authorization:this._authToken}})});return a.onmessage=r=>{if(r.data===_e.question||r.data===_e.notQuestion){r.data===_e.question?(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setIsQuestion(!0)):(s.setAnswerLoading(!1),this.dataLayer.setIsQuestion(!1)),s.setAnswerData("");return}if(r.data===_e.close){Le.trackAnswerData({...s.parsedData.trackingData,answer:s.$answer.getValue(),isQuestion:this.dataLayer.isQuestion,hasShowMore:this.dataLayer.parsedData.shouldShowAnswerLoadMore}),s.setAnswerLoading(!1),a.close();return}if(r.data.indexOf("[!CAUTION]")!==-1){s.setAnswerError(!0),s.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),a.close();return}if(r.data.indexOf("[comment]: <> ({")!==-1)try{const n=r.data.split("[comment]: <> ({");if(n.length<2){t(r.data);return}const c=n[1].split("})");if(c.length<2){t(r.data);return}const l=c[0],h=JSON.parse("{"+l+"}");this.dataLayer.answerWidgetShowMoreLimit=h.displayShowMoreAfter,h.showMoreEnabled||(this.dataLayer.answerWidgetShowMoreLimit=1e17);const p=c.slice(1).join("})");t(p)}catch{t(r.data)}else t(r.data)},a.addEventListener("error",r=>{(r.code===401||r.code===500)&&(s.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),s.setAnswerError(!0))}),a.onerror=()=>{s.setAnswerLoading(!1),a.close()},a}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(r=>r.json()).then(r=>{t(r)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const s of e)t.push(encodeURIComponent(s.key)+"="+encodeURIComponent(s.value));return"&"+t.join("&")}}var xr=Object.prototype.toString,Ge=Array.isArray||function(i){return xr.call(i)==="[object Array]"};function Ea(i){return typeof i=="function"}function kr(i){return Ge(i)?"array":typeof i}function Ia(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Qs(i,e){return i!=null&&typeof i=="object"&&e in i}function Sr(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var Tr=RegExp.prototype.test;function vr(i,e){return Tr.call(i,e)}var Ar=/\S/;function Er(i){return!vr(Ar,i)}var Ir={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function Dr(i){return String(i).replace(/[&<>"'`=\/]/g,function(e){return Ir[e]})}var jr=/\s*/,Rr=/\s+/,Hs=/\s*=/,Nr=/\s*\}/,Or=/#|\^|\/|>|\{|&|=|!/;function Pr(i,e){if(!i)return[];var t=!1,s=[],a=[],r=[],n=!1,c=!1,l="",h=0;function p(){if(n&&!c)for(;r.length;)delete a[r.pop()];else r=[];n=!1,c=!1}var f,L,j;function A(T){if(typeof T=="string"&&(T=T.split(Rr,2)),!Ge(T)||T.length!==2)throw new Error("Invalid tags: "+T);f=new RegExp(Ia(T[0])+"\\s*"),L=new RegExp("\\s*"+Ia(T[1])),j=new RegExp("\\s*"+Ia("}"+T[1]))}A(e||S.tags);for(var x=new mt(i),z,D,P,re,V,m;!x.eos();){if(z=x.pos,P=x.scanUntil(f),P)for(var d=0,w=P.length;d<w;++d)re=P.charAt(d),Er(re)?(r.push(a.length),l+=re):(c=!0,t=!0,l+=" "),a.push(["text",re,z,z+1]),z+=1,re===`
|
|
68
|
-
`&&(p(),l="",h=0,t=!1);if(!
|
|
69
|
-
`),
|
|
70
|
-
`)},
|
|
51
|
+
`}tablerow({text:r}){return`<tr>
|
|
52
|
+
${r}</tr>
|
|
53
|
+
`}tablecell(r){const e=this.parser.parseInline(r.tokens),t=r.header?"th":"td";return(r.align?`<${t} align="${r.align}">`:`<${t}>`)+e+`</${t}>
|
|
54
|
+
`}strong({tokens:r}){return`<strong>${this.parser.parseInline(r)}</strong>`}em({tokens:r}){return`<em>${this.parser.parseInline(r)}</em>`}codespan({text:r}){return`<code>${ge(r,!0)}</code>`}br(r){return"<br>"}del({tokens:r}){return`<del>${this.parser.parseInline(r)}</del>`}link({href:r,title:e,tokens:t}){const s=this.parser.parseInline(t),a=Cs(r);if(a===null)return s;r=a;let i='<a href="'+r+'"';return e&&(i+=' title="'+ge(e)+'"'),i+=">"+s+"</a>",i}image({href:r,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));const a=Cs(r);if(a===null)return ge(t);r=a;let i=`<img src="${r}" alt="${t}"`;return e&&(i+=` title="${ge(e)}"`),i+=">",i}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:ge(r.text)}},da=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return""+r}image({text:r}){return""+r}br(){return""}},we=class Oa{options;renderer;textRenderer;constructor(e){this.options=e||Oe,this.options.renderer=this.options.renderer||new Rt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new da}static parse(e,t){return new Oa(t).parse(e)}static parseInline(e,t){return new Oa(t).parseInline(e)}parse(e,t=!0){let s="";for(let a=0;a<e.length;a++){const i=e[a];if(this.options.extensions?.renderers?.[i.type]){const c=i,l=this.options.extensions.renderers[c.type].call({parser:this},c);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(c.type)){s+=l||"";continue}}const n=i;switch(n.type){case"space":{s+=this.renderer.space(n);continue}case"hr":{s+=this.renderer.hr(n);continue}case"heading":{s+=this.renderer.heading(n);continue}case"code":{s+=this.renderer.code(n);continue}case"table":{s+=this.renderer.table(n);continue}case"blockquote":{s+=this.renderer.blockquote(n);continue}case"list":{s+=this.renderer.list(n);continue}case"html":{s+=this.renderer.html(n);continue}case"paragraph":{s+=this.renderer.paragraph(n);continue}case"text":{let c=n,l=this.renderer.text(c);for(;a+1<e.length&&e[a+1].type==="text";)c=e[++a],l+=`
|
|
55
|
+
`+this.renderer.text(c);t?s+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l,escaped:!0}]}):s+=l;continue}default:{const c='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}parseInline(e,t=this.renderer){let s="";for(let a=0;a<e.length;a++){const i=e[a];if(this.options.extensions?.renderers?.[i.type]){const c=this.options.extensions.renderers[i.type].call({parser:this},i);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){s+=c||"";continue}}const n=i;switch(n.type){case"escape":{s+=t.text(n);break}case"html":{s+=t.html(n);break}case"link":{s+=t.link(n);break}case"image":{s+=t.image(n);break}case"strong":{s+=t.strong(n);break}case"em":{s+=t.em(n);break}case"codespan":{s+=t.codespan(n);break}case"br":{s+=t.br(n);break}case"del":{s+=t.del(n);break}case"text":{s+=t.text(n);break}default:{const c='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},Nt=class{options;block;constructor(r){this.options=r||Oe}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}provideLexer(){return this.block?ye.lex:ye.lexInline}provideParser(){return this.block?we.parse:we.parseInline}},oi=class{defaults=sa();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=we;Renderer=Rt;TextRenderer=da;Lexer=ye;Tokenizer=Dt;Hooks=Nt;constructor(...r){this.use(...r)}walkTokens(r,e){let t=[];for(const s of r)switch(t=t.concat(e.call(this,s)),s.type){case"table":{const a=s;for(const i of a.header)t=t.concat(this.walkTokens(i.tokens,e));for(const i of a.rows)for(const n of i)t=t.concat(this.walkTokens(n.tokens,e));break}case"list":{const a=s;t=t.concat(this.walkTokens(a.items,e));break}default:{const a=s;this.defaults.extensions?.childTokens?.[a.type]?this.defaults.extensions.childTokens[a.type].forEach(i=>{const n=a[i].flat(1/0);t=t.concat(this.walkTokens(n,e))}):a.tokens&&(t=t.concat(this.walkTokens(a.tokens,e)))}}return t}use(...r){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(t=>{const s={...t};if(s.async=this.defaults.async||s.async||!1,t.extensions&&(t.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const i=e.renderers[a.name];i?e.renderers[a.name]=function(...n){let c=a.renderer.apply(this,n);return c===!1&&(c=i.apply(this,n)),c}:e.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const i=e[a.level];i?i.unshift(a.tokenizer):e[a.level]=[a.tokenizer],a.start&&(a.level==="block"?e.startBlock?e.startBlock.push(a.start):e.startBlock=[a.start]:a.level==="inline"&&(e.startInline?e.startInline.push(a.start):e.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(e.childTokens[a.name]=a.childTokens)}),s.extensions=e),t.renderer){const a=this.defaults.renderer||new Rt(this.defaults);for(const i in t.renderer){if(!(i in a))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const n=i,c=t.renderer[n],l=a[n];a[n]=(...h)=>{let p=c.apply(a,h);return p===!1&&(p=l.apply(a,h)),p||""}}s.renderer=a}if(t.tokenizer){const a=this.defaults.tokenizer||new Dt(this.defaults);for(const i in t.tokenizer){if(!(i in a))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const n=i,c=t.tokenizer[n],l=a[n];a[n]=(...h)=>{let p=c.apply(a,h);return p===!1&&(p=l.apply(a,h)),p}}s.tokenizer=a}if(t.hooks){const a=this.defaults.hooks||new Nt;for(const i in t.hooks){if(!(i in a))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const n=i,c=t.hooks[n],l=a[n];Nt.passThroughHooks.has(i)?a[n]=h=>{if(this.defaults.async)return Promise.resolve(c.call(a,h)).then(L=>l.call(a,L));const p=c.call(a,h);return l.call(a,p)}:a[n]=(...h)=>{let p=c.apply(a,h);return p===!1&&(p=l.apply(a,h)),p}}s.hooks=a}if(t.walkTokens){const a=this.defaults.walkTokens,i=t.walkTokens;s.walkTokens=function(n){let c=[];return c.push(i.call(this,n)),a&&(c=c.concat(a.call(this,n))),c}}this.defaults={...this.defaults,...s}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,e){return ye.lex(r,e??this.defaults)}parser(r,e){return we.parse(r,e??this.defaults)}parseMarkdown(r){return(e,t)=>{const s={...t},a={...this.defaults,...s},i=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&s.async===!1)return i(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 e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=r);const n=a.hooks?a.hooks.provideLexer():r?ye.lex:ye.lexInline,c=a.hooks?a.hooks.provideParser():r?we.parse:we.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(e):e).then(l=>n(l,a)).then(l=>a.hooks?a.hooks.processAllTokens(l):l).then(l=>a.walkTokens?Promise.all(this.walkTokens(l,a.walkTokens)).then(()=>l):l).then(l=>c(l,a)).then(l=>a.hooks?a.hooks.postprocess(l):l).catch(i);try{a.hooks&&(e=a.hooks.preprocess(e));let l=n(e,a);a.hooks&&(l=a.hooks.processAllTokens(l)),a.walkTokens&&this.walkTokens(l,a.walkTokens);let h=c(l,a);return a.hooks&&(h=a.hooks.postprocess(h)),h}catch(l){return i(l)}}}onError(r,e){return t=>{if(t.message+=`
|
|
56
|
+
Please report this to https://github.com/markedjs/marked.`,r){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}}},Pe=new oi;function I(r,e){return Pe.parse(r,e)}I.options=I.setOptions=function(r){return Pe.setOptions(r),I.defaults=Pe.defaults,ls(I.defaults),I},I.getDefaults=sa,I.defaults=Oe,I.use=function(...r){return Pe.use(...r),I.defaults=Pe.defaults,ls(I.defaults),I},I.walkTokens=function(r,e){return Pe.walkTokens(r,e)},I.parseInline=Pe.parseInline,I.Parser=we,I.parser=we.parse,I.Renderer=Rt,I.TextRenderer=da,I.Lexer=ye,I.lexer=ye.lex,I.Tokenizer=Dt,I.Hooks=Nt,I.parse=I,I.options,I.setOptions,I.use,I.walkTokens,I.parseInline,we.parse,ye.lex;function ks(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,s=Array(e);t<e;t++)s[t]=r[t];return s}function ci(r){if(Array.isArray(r))return r}function li(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var s,a,i,n,c=[],l=!0,h=!1;try{if(i=(t=t.call(r)).next,e!==0)for(;!(l=(s=i.call(t)).done)&&(c.push(s.value),c.length!==e);l=!0);}catch(p){h=!0,a=p}finally{try{if(!l&&t.return!=null&&(n=t.return(),Object(n)!==n))return}finally{if(h)throw a}}return c}}function hi(){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 ui(r,e){return ci(r)||li(r,e)||di(r,e)||hi()}function di(r,e){if(r){if(typeof r=="string")return ks(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ks(r,e):void 0}}const Ts=Object.entries,vs=Object.setPrototypeOf,gi=Object.isFrozen,pi=Object.getPrototypeOf,mi=Object.getOwnPropertyDescriptor;let K=Object.freeze,X=Object.seal,_e=Object.create,As=typeof Reflect<"u"&&Reflect,ga=As.apply,pa=As.construct;K||(K=function(r){return r}),X||(X=function(r){return r}),ga||(ga=function(r,e){for(var t=arguments.length,s=new Array(t>2?t-2:0),a=2;a<t;a++)s[a-2]=arguments[a];return r.apply(e,s)}),pa||(pa=function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;s<e;s++)t[s-1]=arguments[s];return new r(...t)});const lt=U(Array.prototype.forEach),fi=U(Array.prototype.lastIndexOf),Es=U(Array.prototype.pop),Ue=U(Array.prototype.push),Li=U(Array.prototype.splice),ve=Array.isArray,ht=U(String.prototype.toLowerCase),ma=U(String.prototype.toString),Is=U(String.prototype.match),ut=U(String.prototype.replace),js=U(String.prototype.indexOf),yi=U(String.prototype.trim),wi=U(Number.prototype.toString),Mi=U(Boolean.prototype.toString),Ds=typeof BigInt>"u"?null:U(BigInt.prototype.toString),Rs=typeof Symbol>"u"?null:U(Symbol.prototype.toString),J=U(Object.prototype.hasOwnProperty),dt=U(Object.prototype.toString),ee=U(RegExp.prototype.test),Fe=bi(TypeError);function U(r){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 ga(r,e,s)}}function bi(r){return function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return pa(r,t)}}function k(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ht;if(vs&&vs(r,null),!ve(e))return r;let s=e.length;for(;s--;){let a=e[s];if(typeof a=="string"){const i=t(a);i!==a&&(gi(e)||(e[s]=i),a=i)}r[a]=!0}return r}function Ci(r){for(let e=0;e<r.length;e++)J(r,e)||(r[e]=null);return r}function se(r){const e=_e(null);for(const s of Ts(r)){var t=ui(s,2);const a=t[0],i=t[1];J(r,a)&&(ve(i)?e[a]=Ci(i):i&&typeof i=="object"&&i.constructor===Object?e[a]=se(i):e[a]=i)}return e}function xi(r){switch(typeof r){case"string":return r;case"number":return wi(r);case"boolean":return Mi(r);case"bigint":return Ds?Ds(r):"0";case"symbol":return Rs?Rs(r):"Symbol()";case"undefined":return dt(r);case"function":case"object":{if(r===null)return dt(r);const e=r,t=pe(e,"toString");if(typeof t=="function"){const s=t(e);return typeof s=="string"?s:dt(s)}return dt(r)}default:return dt(r)}}function pe(r,e){for(;r!==null;){const s=mi(r,e);if(s){if(s.get)return U(s.get);if(typeof s.value=="function")return U(s.value)}r=pi(r)}function t(){return null}return t}function Si(r){try{return ee(r,""),!0}catch{return!1}}const Ns=K(["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"]),fa=K(["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"]),La=K(["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"]),ki=K(["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"]),ya=K(["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"]),Ti=K(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Os=K(["#text"]),Ps=K(["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"]),wa=K(["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"]),Fs=K(["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"]),Ot=K(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),vi=X(/{{[\w\W]*|^[\w\W]*}}/g),Ai=X(/<%[\w\W]*|^[\w\W]*%>/g),Ei=X(/\${[\w\W]*/g),Ii=X(/^data-[\-\w.\u00B7-\uFFFF]+$/),ji=X(/^aria-[\-\w]+$/),zs=X(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Di=X(/^(?:\w+script|data):/i),Ri=X(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ni=X(/^html$/i),Oi=X(/^[a-z][.\w]*(-[.\w]+)+$/i),$s=X(/<[/\w!]/g),Pi=X(/<[/\w]/g),Fi=X(/<\/no(script|embed|frames)/i),zi=X(/\/>/i),me={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},$i=function(){return typeof window>"u"?null:window},Vi=function(r,e){if(typeof r!="object"||typeof r.createPolicy!="function")return null;let t=null;const s="data-tt-policy-suffix";e&&e.hasAttribute(s)&&(t=e.getAttribute(s));const a="dompurify"+(t?"#"+t:"");try{return r.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Vs=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ae=function(r,e,t,s){return J(r,e)&&ve(r[e])?k(s.base?se(s.base):{},r[e],s.transform):t};function Qs(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:$i();const e=o=>Qs(o);if(e.version="3.4.11",e.removed=[],!r||!r.document||r.document.nodeType!==me.document||!r.Element)return e.isSupported=!1,e;let t=r.document;const s=t,a=s.currentScript;r.DocumentFragment;const i=r.HTMLTemplateElement,n=r.Node,c=r.Element,l=r.NodeFilter;r.NamedNodeMap===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;const p=r.DOMParser,L=r.trustedTypes,y=c.prototype,N=pe(y,"cloneNode"),v=pe(y,"remove"),C=pe(y,"nextSibling"),P=pe(y,"childNodes"),j=pe(y,"parentNode"),q=pe(y,"shadowRoot"),ie=pe(y,"attributes"),F=n&&n.prototype?pe(n.prototype,"nodeType"):null,m=n&&n.prototype?pe(n.prototype,"nodeName"):null;if(typeof i=="function"){const o=t.createElement("template");o.content&&o.content.ownerDocument&&(t=o.content.ownerDocument)}let g,M="",A,_=!1,ne=0;const Mt=function(){if(ne>0)throw Fe('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},be=function(o){Mt(),ne++;try{return g.createHTML(o)}finally{ne--}},$t=function(o){Mt(),ne++;try{return g.createScriptURL(o)}finally{ne--}},Ce=function(){return _||(A=Vi(L,a),_=!0),A},Ie=t,Vt=Ie.implementation,Pa=Ie.createNodeIterator,er=Ie.createDocumentFragment,tr=Ie.getElementsByTagName,ar=s.importNode;let H=Vs();e.isSupported=typeof Ts=="function"&&typeof j=="function"&&Vt&&Vt.createHTMLDocument!==void 0;const sr=vi,rr=Ai,ir=Ei,nr=Ii,or=ji,cr=Di,Fa=Ri,lr=Oi;let za=zs,z=null;const $a=k({},[...Ns,...fa,...La,...ya,...Os]);let $=null;const Va=k({},[...Ps,...wa,...Fs,...Ot]);let V=Object.seal(_e(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}})),tt=null,Qa=null;const xe=Object.seal(_e(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ba=!0,Qt=!0,qa=!1,Ha=!0,Se=!1,at=!0,je=!1,Bt=!1,qt=null,Ht=null,_t=!1,Ve=!1,bt=!1,Ct=!1,_a=!0,Ua=!1;const Ya="user-content-";let Ut=!0,Yt=!1,Qe={},ue=null;const Wt=k({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Wa=null;const Ja=k({},["audio","video","img","source","image","track"]);let Jt=null;const Ga=k({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),xt="http://www.w3.org/1998/Math/MathML",St="http://www.w3.org/2000/svg",de="http://www.w3.org/1999/xhtml";let Be=de,Gt=!1,Zt=null;const hr=k({},[xt,St,de],ma),Za=K(["mi","mo","mn","ms","mtext"]);let Kt=k({},Za);const Ka=K(["annotation-xml"]);let Xt=k({},Ka);const ur=k({},["title","style","font","a","script"]);let st=null;const dr=["application/xhtml+xml","text/html"],gr="text/html";let Q=null,qe=null;const pr=t.createElement("form"),Xa=function(o){return o instanceof RegExp||o instanceof Function},ea=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(qe&&qe===o)return;(!o||typeof o!="object")&&(o={}),o=se(o),st=dr.indexOf(o.PARSER_MEDIA_TYPE)===-1?gr:o.PARSER_MEDIA_TYPE,Q=st==="application/xhtml+xml"?ma:ht,z=Ae(o,"ALLOWED_TAGS",$a,{transform:Q}),$=Ae(o,"ALLOWED_ATTR",Va,{transform:Q}),Zt=Ae(o,"ALLOWED_NAMESPACES",hr,{transform:ma}),Jt=Ae(o,"ADD_URI_SAFE_ATTR",Ga,{transform:Q,base:Ga}),Wa=Ae(o,"ADD_DATA_URI_TAGS",Ja,{transform:Q,base:Ja}),ue=Ae(o,"FORBID_CONTENTS",Wt,{transform:Q}),tt=Ae(o,"FORBID_TAGS",se({}),{transform:Q}),Qa=Ae(o,"FORBID_ATTR",se({}),{transform:Q}),Qe=J(o,"USE_PROFILES")?o.USE_PROFILES&&typeof o.USE_PROFILES=="object"?se(o.USE_PROFILES):o.USE_PROFILES:!1,Ba=o.ALLOW_ARIA_ATTR!==!1,Qt=o.ALLOW_DATA_ATTR!==!1,qa=o.ALLOW_UNKNOWN_PROTOCOLS||!1,Ha=o.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Se=o.SAFE_FOR_TEMPLATES||!1,at=o.SAFE_FOR_XML!==!1,je=o.WHOLE_DOCUMENT||!1,Ve=o.RETURN_DOM||!1,bt=o.RETURN_DOM_FRAGMENT||!1,Ct=o.RETURN_TRUSTED_TYPE||!1,_t=o.FORCE_BODY||!1,_a=o.SANITIZE_DOM!==!1,Ua=o.SANITIZE_NAMED_PROPS||!1,Ut=o.KEEP_CONTENT!==!1,Yt=o.IN_PLACE||!1,za=Si(o.ALLOWED_URI_REGEXP)?o.ALLOWED_URI_REGEXP:zs,Be=typeof o.NAMESPACE=="string"?o.NAMESPACE:de,Kt=J(o,"MATHML_TEXT_INTEGRATION_POINTS")&&o.MATHML_TEXT_INTEGRATION_POINTS&&typeof o.MATHML_TEXT_INTEGRATION_POINTS=="object"?se(o.MATHML_TEXT_INTEGRATION_POINTS):k({},Za),Xt=J(o,"HTML_INTEGRATION_POINTS")&&o.HTML_INTEGRATION_POINTS&&typeof o.HTML_INTEGRATION_POINTS=="object"?se(o.HTML_INTEGRATION_POINTS):k({},Ka);const u=J(o,"CUSTOM_ELEMENT_HANDLING")&&o.CUSTOM_ELEMENT_HANDLING&&typeof o.CUSTOM_ELEMENT_HANDLING=="object"?se(o.CUSTOM_ELEMENT_HANDLING):_e(null);if(V=_e(null),J(u,"tagNameCheck")&&Xa(u.tagNameCheck)&&(V.tagNameCheck=u.tagNameCheck),J(u,"attributeNameCheck")&&Xa(u.attributeNameCheck)&&(V.attributeNameCheck=u.attributeNameCheck),J(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(V.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),X(V),Se&&(Qt=!1),bt&&(Ve=!0),Qe&&(z=k({},Os),$=_e(null),Qe.html===!0&&(k(z,Ns),k($,Ps)),Qe.svg===!0&&(k(z,fa),k($,wa),k($,Ot)),Qe.svgFilters===!0&&(k(z,La),k($,wa),k($,Ot)),Qe.mathMl===!0&&(k(z,ya),k($,Fs),k($,Ot))),xe.tagCheck=null,xe.attributeCheck=null,J(o,"ADD_TAGS")&&(typeof o.ADD_TAGS=="function"?xe.tagCheck=o.ADD_TAGS:ve(o.ADD_TAGS)&&(z===$a&&(z=se(z)),k(z,o.ADD_TAGS,Q))),J(o,"ADD_ATTR")&&(typeof o.ADD_ATTR=="function"?xe.attributeCheck=o.ADD_ATTR:ve(o.ADD_ATTR)&&($===Va&&($=se($)),k($,o.ADD_ATTR,Q))),J(o,"ADD_URI_SAFE_ATTR")&&ve(o.ADD_URI_SAFE_ATTR)&&k(Jt,o.ADD_URI_SAFE_ATTR,Q),J(o,"FORBID_CONTENTS")&&ve(o.FORBID_CONTENTS)&&(ue===Wt&&(ue=se(ue)),k(ue,o.FORBID_CONTENTS,Q)),J(o,"ADD_FORBID_CONTENTS")&&ve(o.ADD_FORBID_CONTENTS)&&(ue===Wt&&(ue=se(ue)),k(ue,o.ADD_FORBID_CONTENTS,Q)),Ut&&(z["#text"]=!0),je&&k(z,["html","head","body"]),z.table&&(k(z,["tbody"]),delete tt.tbody),o.TRUSTED_TYPES_POLICY){if(typeof o.TRUSTED_TYPES_POLICY.createHTML!="function")throw Fe('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof o.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Fe('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const d=g;g=o.TRUSTED_TYPES_POLICY;try{M=be("")}catch(f){throw g=d,f}}else o.TRUSTED_TYPES_POLICY===null?(g=void 0,M=""):(g===void 0&&(g=Ce()),g&&typeof M=="string"&&(M=be("")));K&&K(o),qe=o},es=k({},[...fa,...La,...ki]),ts=k({},[...ya,...Ti]),mr=function(o,u,d){return u.namespaceURI===de?o==="svg":u.namespaceURI===xt?o==="svg"&&(d==="annotation-xml"||Kt[d]):!!es[o]},fr=function(o,u,d){return u.namespaceURI===de?o==="math":u.namespaceURI===St?o==="math"&&Xt[d]:!!ts[o]},Lr=function(o,u,d){return u.namespaceURI===St&&!Xt[d]||u.namespaceURI===xt&&!Kt[d]?!1:!ts[o]&&(ur[o]||!es[o])},yr=function(o){let u=j(o);(!u||!u.tagName)&&(u={namespaceURI:Be,tagName:"template"});const d=ht(o.tagName),f=ht(u.tagName);return Zt[o.namespaceURI]?o.namespaceURI===St?mr(d,u,f):o.namespaceURI===xt?fr(d,u,f):o.namespaceURI===de?Lr(d,u,f):!!(st==="application/xhtml+xml"&&Zt[o.namespaceURI]):!1},De=function(o){Ue(e.removed,{element:o});try{j(o).removeChild(o)}catch{if(v(o),!j(o))throw Fe("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},as=function(o){const u=P(o);if(u){const f=[];lt(u,x=>{Ue(f,x)}),lt(f,x=>{try{v(x)}catch{}})}const d=ie(o);if(d)for(let f=d.length-1;f>=0;--f){const x=d[f],D=x&&x.name;if(typeof D=="string")try{o.removeAttribute(D)}catch{}}},Re=function(o,u){try{Ue(e.removed,{attribute:u.getAttributeNode(o),from:u})}catch{Ue(e.removed,{attribute:null,from:u})}if(u.removeAttribute(o),o==="is")if(Ve||bt)try{De(u)}catch{}else try{u.setAttribute(o,"")}catch{}},wr=function(o){const u=ie(o);if(u)for(let d=u.length-1;d>=0;--d){const f=u[d],x=f&&f.name;if(!(typeof x!="string"||$[Q(x)]))try{o.removeAttribute(x)}catch{}}},Mr=function(o){const u=[o];for(;u.length>0;){const d=u.pop();(F?F(d):d.nodeType)===me.element&&wr(d);const f=P(d);if(f)for(let x=f.length-1;x>=0;--x)u.push(f[x])}},ss=function(o){let u=null,d=null;if(_t)o="<remove></remove>"+o;else{const D=Is(o,/^[\r\n\t ]+/);d=D&&D[0]}st==="application/xhtml+xml"&&Be===de&&(o='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+o+"</body></html>");const f=g?be(o):o;if(Be===de)try{u=new p().parseFromString(f,st)}catch{}if(!u||!u.documentElement){u=Vt.createDocument(Be,"template",null);try{u.documentElement.innerHTML=Gt?M:f}catch{}}const x=u.body||u.documentElement;return o&&d&&x.insertBefore(t.createTextNode(d),x.childNodes[0]||null),Be===de?tr.call(u,je?"html":"body")[0]:je?u.documentElement:x},rs=function(o){return Pa.call(o.ownerDocument||o,o,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},kt=function(o){return o=ut(o,sr," "),o=ut(o,rr," "),o=ut(o,ir," "),o},ta=function(o){var u;o.normalize();const d=Pa.call(o.ownerDocument||o,o,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let f=d.nextNode();for(;f;)f.data=kt(f.data),f=d.nextNode();const x=(u=o.querySelectorAll)===null||u===void 0?void 0:u.call(o,"template");x&<(x,D=>{He(D.content)&&ta(D.content)})},Tt=function(o){const u=m?m(o):null;return typeof u!="string"||Q(u)!=="form"?!1:typeof o.nodeName!="string"||typeof o.textContent!="string"||typeof o.removeChild!="function"||o.attributes!==ie(o)||typeof o.removeAttribute!="function"||typeof o.setAttribute!="function"||typeof o.namespaceURI!="string"||typeof o.insertBefore!="function"||typeof o.hasChildNodes!="function"||o.nodeType!==F(o)||o.childNodes!==P(o)},He=function(o){if(!F||typeof o!="object"||o===null)return!1;try{return F(o)===me.documentFragment}catch{return!1}},rt=function(o){if(!F||typeof o!="object"||o===null)return!1;try{return typeof F(o)=="number"}catch{return!1}};function Le(o,u,d){o.length!==0&<(o,f=>{f.call(e,u,d,qe)})}const br=function(o,u){return!!(at&&o.hasChildNodes()&&!rt(o.firstElementChild)&&ee($s,o.textContent)&&ee($s,o.innerHTML)||at&&o.namespaceURI===de&&u==="style"&&rt(o.firstElementChild)||o.nodeType===me.processingInstruction||at&&o.nodeType===me.comment&&ee(Pi,o.data))},Cr=function(o,u){if(!tt[u]&&os(u)&&(V.tagNameCheck instanceof RegExp&&ee(V.tagNameCheck,u)||V.tagNameCheck instanceof Function&&V.tagNameCheck(u)))return!1;if(Ut&&!ue[u]){const d=j(o),f=P(o);if(f&&d){const x=f.length;for(let D=x-1;D>=0;--D){const R=Yt?f[D]:N(f[D],!0);d.insertBefore(R,C(o))}}}return De(o),!0},is=function(o){if(Le(H.beforeSanitizeElements,o,null),Tt(o))return De(o),!0;const u=Q(m?m(o):o.nodeName);if(Le(H.uponSanitizeElement,o,{tagName:u,allowedTags:z}),br(o,u))return De(o),!0;if(tt[u]||!(xe.tagCheck instanceof Function&&xe.tagCheck(u))&&!z[u])return Cr(o,u);if((F?F(o):o.nodeType)===me.element&&!yr(o)||(u==="noscript"||u==="noembed"||u==="noframes")&&ee(Fi,o.innerHTML))return De(o),!0;if(Se&&o.nodeType===me.text){const d=kt(o.textContent);o.textContent!==d&&(Ue(e.removed,{element:o.cloneNode()}),o.textContent=d)}return Le(H.afterSanitizeElements,o,null),!1},ns=function(o,u,d){if(Qa[u]||_a&&(u==="id"||u==="name")&&(d in t||d in pr))return!1;const f=$[u]||xe.attributeCheck instanceof Function&&xe.attributeCheck(u,o);if(!(Qt&&ee(nr,u))&&!(Ba&&ee(or,u))){if(f){if(!Jt[u]&&!ee(za,ut(d,Fa,""))&&!((u==="src"||u==="xlink:href"||u==="href")&&o!=="script"&&js(d,"data:")===0&&Wa[o])&&!(qa&&!ee(cr,ut(d,Fa,"")))&&d)return!1}else if(!(os(o)&&(V.tagNameCheck instanceof RegExp&&ee(V.tagNameCheck,o)||V.tagNameCheck instanceof Function&&V.tagNameCheck(o))&&(V.attributeNameCheck instanceof RegExp&&ee(V.attributeNameCheck,u)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(u,o))||u==="is"&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&ee(V.tagNameCheck,d)||V.tagNameCheck instanceof Function&&V.tagNameCheck(d))))return!1}return!0},xr=k({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),os=function(o){return!xr[ht(o)]&&ee(lr,o)},Sr=function(o,u,d,f){if(g&&typeof L=="object"&&typeof L.getAttributeType=="function"&&!d)switch(L.getAttributeType(o,u)){case"TrustedHTML":return be(f);case"TrustedScriptURL":return $t(f)}return f},kr=function(o,u,d,f){try{d?o.setAttributeNS(d,u,f):o.setAttribute(u,f),Tt(o)?De(o):Es(e.removed)}catch{Re(u,o)}},cs=function(o){Le(H.beforeSanitizeAttributes,o,null);const u=o.attributes;if(!u||Tt(o))return;const d={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$,forceKeepAttr:void 0};let f=u.length;const x=Q(o.nodeName);for(;f--;){const D=u[f],R=D.name,Ne=D.namespaceURI,ke=D.value,oe=Q(R),Te=ke;let te=R==="value"?Te:yi(Te);if(d.attrName=oe,d.attrValue=te,d.keepAttr=!0,d.forceKeepAttr=void 0,Le(H.uponSanitizeAttribute,o,d),te=d.attrValue,Ua&&(oe==="id"||oe==="name")&&js(te,Ya)!==0&&(Re(R,o),te=Ya+te),at&&ee(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,te)){Re(R,o);continue}if(oe==="attributename"&&Is(te,"href")){Re(R,o);continue}if(!d.forceKeepAttr){if(!d.keepAttr){Re(R,o);continue}if(!Ha&&ee(zi,te)){Re(R,o);continue}if(Se&&(te=kt(te)),!ns(x,oe,te)){Re(R,o);continue}te=Sr(x,oe,Ne,te),te!==Te&&kr(o,R,Ne,te)}}Le(H.afterSanitizeAttributes,o,null)},vt=function(o){let u=null;const d=rs(o);for(Le(H.beforeSanitizeShadowDOM,o,null);u=d.nextNode();)if(Le(H.uponSanitizeShadowNode,u,null),is(u),cs(u),He(u.content)&&vt(u.content),(F?F(u):u.nodeType)===me.element){const f=q(u);He(f)&&(aa(f),vt(f))}Le(H.afterSanitizeShadowDOM,o,null)},aa=function(o){const u=[{node:o,shadow:null}];for(;u.length>0;){const d=u.pop();if(d.shadow){vt(d.shadow);continue}const f=d.node,x=(F?F(f):f.nodeType)===me.element,D=P(f);if(D)for(let R=D.length-1;R>=0;--R)u.push({node:D[R],shadow:null});if(x){const R=m?m(f):null;if(typeof R=="string"&&Q(R)==="template"){const Ne=f.content;He(Ne)&&u.push({node:Ne,shadow:null})}}if(x){const R=q(f);He(R)&&u.push({node:null,shadow:R},{node:R,shadow:null})}}};return e.sanitize=function(o){let u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d=null,f=null,x=null,D=null;if(Gt=!o,Gt&&(o="<!-->"),typeof o!="string"&&!rt(o)&&(o=xi(o),typeof o!="string"))throw Fe("dirty is not a string, aborting");if(!e.isSupported)return o;Bt?(z=qt,$=Ht):ea(u),(H.uponSanitizeElement.length>0||H.uponSanitizeAttribute.length>0)&&(z=se(z)),H.uponSanitizeAttribute.length>0&&($=se($)),e.removed=[];const R=Yt&&typeof o!="string"&&rt(o);if(R){const oe=m?m(o):o.nodeName;if(typeof oe=="string"){const Te=Q(oe);if(!z[Te]||tt[Te])throw Fe("root node is forbidden and cannot be sanitized in-place")}if(Tt(o))throw Fe("root node is clobbered and cannot be sanitized in-place");try{aa(o)}catch(Te){throw as(o),Te}}else if(rt(o))d=ss("<!---->"),f=d.ownerDocument.importNode(o,!0),f.nodeType===me.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?d=f:d.appendChild(f),aa(f);else{if(!Ve&&!Se&&!je&&o.indexOf("<")===-1)return g&&Ct?be(o):o;if(d=ss(o),!d)return Ve?null:Ct?M:""}d&&_t&&De(d.firstChild);const Ne=rs(R?o:d);try{for(;x=Ne.nextNode();)is(x),cs(x),He(x.content)&&vt(x.content)}catch(oe){throw R&&as(o),oe}if(R)return lt(e.removed,oe=>{oe.element&&Mr(oe.element)}),Se&&ta(o),o;if(Ve){if(Se&&ta(d),bt)for(D=er.call(d.ownerDocument);d.firstChild;)D.appendChild(d.firstChild);else D=d;return($.shadowroot||$.shadowrootmode)&&(D=ar.call(s,D,!0)),D}let ke=je?d.outerHTML:d.innerHTML;return je&&z["!doctype"]&&d.ownerDocument&&d.ownerDocument.doctype&&d.ownerDocument.doctype.name&&ee(Ni,d.ownerDocument.doctype.name)&&(ke="<!DOCTYPE "+d.ownerDocument.doctype.name+`>
|
|
58
|
+
`+ke),Se&&(ke=kt(ke)),g&&Ct?be(ke):ke},e.setConfig=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ea(o),Bt=!0,qt=z,Ht=$},e.clearConfig=function(){qe=null,Bt=!1,qt=null,Ht=null,g=A,M=""},e.isValidAttribute=function(o,u,d){qe||ea({});const f=Q(o),x=Q(u);return ns(f,x,d)},e.addHook=function(o,u){typeof u=="function"&&J(H,o)&&Ue(H[o],u)},e.removeHook=function(o,u){if(J(H,o)){if(u!==void 0){const d=fi(H[o],u);return d===-1?void 0:Li(H[o],d,1)[0]}return Es(H[o])}},e.removeHooks=function(o){J(H,o)&&(H[o]=[])},e.removeAllHooks=function(){H=Vs()},e}var Bs=Qs();class Qi{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 Bs.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,a)=>{const i=s.value==="any"?0:parseFloat(s.value),n=a.value==="any"?0:parseFloat(a.value);return i-n})}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 Bs.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 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,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 le{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 n=e[i],c=t[i],l=this.isObject(n)&&this.isObject(c);if(l&&!this.deepEqual(n,c)||!l&&n!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class b{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),n=c=>{c===t&&(e(c),this.unsubscribe(i))};return this.value===t?(e(this.value),null):(this.subscribe(n,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=n=>{n!=null&&(e(n),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 Ma{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 n in a){i+="; "+n;const c=a[n];c!==!0&&(i+="="+c)}typeof document<"u"&&(document.cookie=i)}}class G{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 Bi{$searchTermChange=new b("");$searchLocationChange=new b("");$searchLocationCoordinatesDecoded=new b("");$searchLatChange=new b("");$searchLongChange=new b("");$searchRadiusChange=new b(void 0);$loadingChange=new b(!1);$locationError=new b(!1);$searchResults=new b(null);$searchResultsMetadata=new b(null);$searchAutosuggest=new b(null);$searchFacets=new b(null);$searchFacetsCachedand=new b(null);$searchFacetsCachedor=new b(null);$searchFacetsCachedtabs=new b(null);$searchstaxConfig=new b(null);$autosuggestResults=new b(null);$itemsPerPage=new b(void 0);$searchObject=new b({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 b(null);$searchInputConfig=new b(null);$searchLocationConfig=new b(null);$searchExternalPromotions=new b(null);$facetsTemplateData=new b(null);$selectedFacetsTemplateData=new b(null);$paginationData=new b(null);$answerData=new b(null);$searchFeedbackData=new b(null);$inputWidgetTemplateData=new b(null);$locationWidgetTemplateData=new b(null);$searchSortingData=new b(null);$searchRelatedSearchesData=new b(null);$searchExternalPromotionsData=new b(null);$cookiesDisabled=new b(null);$locationDecodingLoading=new b(!1);$answer=new b("");$language=new b("en");$model=new b("");$answerLoading=new b(!1);$locationEnabled=new b(null);$answerError=new b(!1);$answerErrorMessage=new b("");$isQuestion=new b(!1);$inputTemplateRendered=new b(!1);currentPageValue=1;isAnswerWidgetCreatedValue=!1;renderingEngineValue=B.mustache;parsedData=new Qi(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,Ma.deleteCookie(this.sessionId),Ma.deleteCookie("ms_visitorid")):this.sessionIdValue=Ma.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,(!le.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){le.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&&(!le.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,le.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){le.deepEqual(e,this.searchFacetsCachedand??[])||this.$searchFacetsCachedand.setValue(e)}setSearchFacetsCachedor(e){le.deepEqual(e,this.searchFacetsCachedor??[])||this.$searchFacetsCachedor.setValue(e)}setSearchFacetsCachedtabs(e){le.deepEqual(e,this.searchFacetsCachedtabs??[])||this.$searchFacetsCachedtabs.setValue(e)}setSearchRelatedSearches(e){le.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){le.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 searchFacetsCachedand(){return this.$searchFacetsCachedand.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCachedand.getValue())):null}get searchFacetsCachedtabs(){return this.$searchFacetsCachedtabs.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCachedtabs.getValue())):null}get searchFacetsCachedor(){return this.$searchFacetsCachedor.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCachedor.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 gt{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,i)=>{const n=a[e.responseHeader.params.uniqueId]??"",c={custom:null,uniqueId:n,position:s+1+i,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e,n):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e,n):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e,n):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,n):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,n,!0):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e,n):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e,n):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e,n):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e,n):null,distance:this.doesMapExist("distance",e)&&this.getValueByKey("distance",a,e,n)!=="Infinity"&&this.getValueByKey("distance",a,e,n)?Math.floor(this.getValueByKey("distance",a,e,n)):null,unit:e.metadata.locationSearch?.unit??"",unmappedFields:this.getUnmappedFields(a,e,n),allFields:this.getAllFields(a,e)};t.push(c)}),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 n=0;n<i.length;n+=2){const c={};c.value=i[n],c.parentName=a.name,c.count=i[n+1],c.type="checkbox",a.values.push(c)}}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(n=>({value:n.label,key:n.name+" "+n.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],n={};n.cDocId=this.getDataForAnalytics(i.uniqueId),i.title&&(n.cDocTitle=this.getDataForAnalytics(i.titleTracking)),n.position=i.position,t.push(n)}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(n=>n.result_card==="").map(n=>n.name),i=[];for(const n of a)if(Object.keys(e).includes(n)){const c=Array.isArray(e[n])?this.getHighlightedResults(n,e[n].join(", "),s,t):this.getHighlightedResults(n,e[n]+"",s,t);i.push({key:n,value:c,isImage:this.checkIfImage(e[n])})}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 n=s.metadata.results.find(l=>l.result_card===e);if(n===void 0)return null;const c=t[n.name];return c===void 0?null:typeof c=="string"?i?c:this.getHighlightedResults(n.name,c,a,s):typeof c=="number"?c:Array.isArray(c)?i?c.join(", "):this.getHighlightedResults(n.name,c.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 n=i[e];const c=this.cleanValue(n);if(c!=="")return c}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class qs{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 qi(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=G.removeXSSRiskyTags(e[s].split(":")?.[0]),i=G.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[1])),n=G.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[2]));t.push({type:a,name:i,value:n})}return t}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),i=parseInt(a),n=isNaN(i)?1:i;let c=parseInt(G.removeXSSRiskyTags(s[this.routeName+"[itemsPerPage]"]));return{query:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:n,itemsPerPage:t??c,order:G.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[],model:G.removeXSSRiskyTags(s[this.routeName+"[model]"])||"",location:{address:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][address]"]||"")),radius:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][radius]"]||"")),lat:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lat]"]||"")),lon:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lon]"]||""))}}}}class qi{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(n=>`${a}=${n}`).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,n]=a.split("=");t[i]=n}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const Ye={question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class ba 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 Hs=10,Hi=13,ze=32;function Ca(r){}function _i(r){if(typeof r=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=Ca,onError:t=Ca,onRetry:s=Ca,onComment:a,maxBufferSize:i}=r,n=[];let c=0,l=!0,h,p="",L=0,y,N=!1;function v(m){if(N)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l&&(l=!1,m.charCodeAt(0)===239&&m.charCodeAt(1)===187&&m.charCodeAt(2)===191&&(m=m.slice(3))),n.length===0){const A=P(m);A!==""&&(n.push(A),c=A.length),C();return}if(m.indexOf(`
|
|
59
|
+
`)===-1&&m.indexOf("\r")===-1){n.push(m),c+=m.length,C();return}n.push(m);const g=n.join("");n.length=0,c=0;const M=P(g);M!==""&&(n.push(M),c=M.length),C()}function C(){i!==void 0&&(c+p.length<=i||(N=!0,n.length=0,c=0,h=void 0,p="",L=0,y=void 0,t(new ba(`Buffered data exceeded max buffer size of ${i} characters`,{type:"max-buffer-size-exceeded"}))))}function P(m){let g=0;if(m.indexOf("\r")===-1){let M=m.indexOf(`
|
|
60
|
+
`,g);for(;M!==-1;){if(g===M){L>0&&e({id:h,event:y,data:p}),h=void 0,p="",L=0,y=void 0,g=M+1,M=m.indexOf(`
|
|
61
|
+
`,g);continue}const A=m.charCodeAt(g);if(_s(m,g,A)){const _=m.charCodeAt(g+5)===ze?g+6:g+5,ne=m.slice(_,M);if(L===0&&m.charCodeAt(M+1)===Hs){e({id:h,event:y,data:ne}),h=void 0,p="",y=void 0,g=M+2,M=m.indexOf(`
|
|
62
|
+
`,g);continue}p=L===0?ne:`${p}
|
|
63
|
+
${ne}`,L++}else Us(m,g,A)?y=m.slice(m.charCodeAt(g+6)===ze?g+7:g+6,M)||void 0:j(m,g,M);g=M+1,M=m.indexOf(`
|
|
64
|
+
`,g)}return m.slice(g)}for(;g<m.length;){const M=m.indexOf("\r",g),A=m.indexOf(`
|
|
65
|
+
`,g);let _=-1;if(M!==-1&&A!==-1?_=M<A?M:A:M!==-1?M===m.length-1?_=-1:_=M:A!==-1&&(_=A),_===-1)break;j(m,g,_),g=_+1,m.charCodeAt(g-1)===Hi&&m.charCodeAt(g)===Hs&&g++}return m.slice(g)}function j(m,g,M){if(g===M){ie();return}const A=m.charCodeAt(g);if(_s(m,g,A)){const Ce=m.charCodeAt(g+5)===ze?g+6:g+5,Ie=m.slice(Ce,M);p=L===0?Ie:`${p}
|
|
66
|
+
${Ie}`,L++;return}if(Us(m,g,A)){y=m.slice(m.charCodeAt(g+6)===ze?g+7:g+6,M)||void 0;return}if(A===105&&m.charCodeAt(g+1)===100&&m.charCodeAt(g+2)===58){const Ce=m.slice(m.charCodeAt(g+3)===ze?g+4:g+3,M);h=Ce.includes("\0")?void 0:Ce;return}if(A===58){if(a){const Ce=m.slice(g,M);a(Ce.slice(m.charCodeAt(g+1)===ze?2:1))}return}const _=m.slice(g,M),ne=_.indexOf(":");if(ne===-1){q(_,"",_);return}const Mt=_.slice(0,ne),be=_.charCodeAt(ne+1)===ze?2:1,$t=_.slice(ne+be);q(Mt,$t,_)}function q(m,g,M){switch(m){case"event":y=g||void 0;break;case"data":p=L===0?g:`${p}
|
|
67
|
+
${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.test(g)?s(parseInt(g,10)):t(new ba(`Invalid \`retry\` value: "${g}"`,{type:"invalid-retry",value:g,line:M}));break;default:t(new ba(`Unknown field "${m.length>20?`${m.slice(0,20)}\u2026`:m}"`,{type:"unknown-field",field:m,value:g,line:M}));break}}function ie(){L>0&&e({id:h,event:y,data:p}),h=void 0,p="",L=0,y=void 0}function F(m={}){if(m.consume&&n.length>0){const g=n.join("");j(g,0,g.length)}l=!0,h=void 0,p="",L=0,y=void 0,n.length=0,c=0,N=!1}return{feed:v,reset:F}}function _s(r,e,t){return t===100&&r.charCodeAt(e+1)===97&&r.charCodeAt(e+2)===116&&r.charCodeAt(e+3)===97&&r.charCodeAt(e+4)===58}function Us(r,e,t){return t===101&&r.charCodeAt(e+1)===118&&r.charCodeAt(e+2)===101&&r.charCodeAt(e+3)===110&&r.charCodeAt(e+4)===116&&r.charCodeAt(e+5)===58}class Ys 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(Ws(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(Ws(this),t)}}function Ui(r){const e=globalThis.DOMException;return typeof e=="function"?new e(r,"SyntaxError"):new SyntaxError(r)}function xa(r){return r instanceof Error?"errors"in r&&Array.isArray(r.errors)?r.errors.map(xa).join(", "):"cause"in r&&r.cause instanceof Error?`${r}: ${xa(r.cause)}`:r.message:`${r}`}function Ws(r){return{type:r.type,message:r.message,code:r.code,defaultPrevented:r.defaultPrevented,cancelable:r.cancelable,timeStamp:r.timeStamp}}var Js=r=>{throw TypeError(r)},Sa=(r,e,t)=>e.has(r)||Js("Cannot "+t),S=(r,e,t)=>(Sa(r,e,"read from private field"),t?t.call(r):e.get(r)),Y=(r,e,t)=>e.has(r)?Js("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),O=(r,e,t,s)=>(Sa(r,e,"write to private field"),e.set(r,t),t),Me=(r,e,t)=>(Sa(r,e,"access private method"),t),ce,$e,We,Pt,Ft,pt,Je,mt,Ee,Ge,Ze,Ke,ft,he,ka,Ta,va,Gs,Aa,Ea,Lt,Ia,ja;class zt extends EventTarget{constructor(e,t){var s,a;super(),Y(this,he),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Y(this,ce),Y(this,$e),Y(this,We),Y(this,Pt),Y(this,Ft),Y(this,pt),Y(this,Je),Y(this,mt,null),Y(this,Ee),Y(this,Ge),Y(this,Ze,null),Y(this,Ke,null),Y(this,ft,null),Y(this,Ta,async i=>{var n;S(this,Ge).reset();const{body:c,redirected:l,status:h,headers:p}=i;if(h===204){Me(this,he,Lt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(l?O(this,We,new URL(i.url)):O(this,We,void 0),h!==200){Me(this,he,Lt).call(this,`Non-200 status code (${h})`,h);return}if(!(p.get("content-type")||"").startsWith("text/event-stream")){Me(this,he,Lt).call(this,'Invalid content type, expected "text/event-stream"',h);return}if(S(this,ce)===this.CLOSED)return;O(this,ce,this.OPEN);const L=new Event("open");if((n=S(this,ft))==null||n.call(this,L),this.dispatchEvent(L),typeof c!="object"||!c||!("getReader"in c)){Me(this,he,Lt).call(this,"Invalid response body, expected a web ReadableStream",h),this.close();return}const y=new TextDecoder,N=c.getReader();let v=!0;do{const{done:C,value:P}=await N.read();P&&S(this,Ge).feed(y.decode(P,{stream:!C})),C&&(v=!1,S(this,Ge).reset(),Me(this,he,Ia).call(this))}while(v)}),Y(this,va,i=>{O(this,Ee,void 0),!(i.name==="AbortError"||i.type==="aborted")&&Me(this,he,Ia).call(this,xa(i))}),Y(this,Aa,i=>{typeof i.id=="string"&&O(this,mt,i.id);const n=new MessageEvent(i.event||"message",{data:i.data,origin:S(this,We)?S(this,We).origin:S(this,$e).origin,lastEventId:i.id||""});S(this,Ke)&&(!i.event||i.event==="message")&&S(this,Ke).call(this,n),this.dispatchEvent(n)}),Y(this,Ea,i=>{O(this,pt,i)}),Y(this,ja,()=>{O(this,Je,void 0),S(this,ce)===this.CONNECTING&&Me(this,he,ka).call(this)});try{if(e instanceof URL)O(this,$e,e);else if(typeof e=="string")O(this,$e,new URL(e,Yi()));else throw new Error("Invalid URL")}catch{throw Ui("An invalid or illegal string was specified")}O(this,Ge,_i({onEvent:S(this,Aa),onRetry:S(this,Ea)})),O(this,ce,this.CONNECTING),O(this,pt,3e3),O(this,Ft,(s=t?.fetch)!=null?s:globalThis.fetch),O(this,Pt,(a=t?.withCredentials)!=null?a:!1),Me(this,he,ka).call(this)}get readyState(){return S(this,ce)}get url(){return S(this,$e).href}get withCredentials(){return S(this,Pt)}get onerror(){return S(this,Ze)}set onerror(e){O(this,Ze,e)}get onmessage(){return S(this,Ke)}set onmessage(e){O(this,Ke,e)}get onopen(){return S(this,ft)}set onopen(e){O(this,ft,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(){S(this,Je)&&clearTimeout(S(this,Je)),S(this,ce)!==this.CLOSED&&(S(this,Ee)&&S(this,Ee).abort(),O(this,ce,this.CLOSED),O(this,Ee,void 0))}}ce=new WeakMap,$e=new WeakMap,We=new WeakMap,Pt=new WeakMap,Ft=new WeakMap,pt=new WeakMap,Je=new WeakMap,mt=new WeakMap,Ee=new WeakMap,Ge=new WeakMap,Ze=new WeakMap,Ke=new WeakMap,ft=new WeakMap,he=new WeakSet,ka=function(){O(this,ce,this.CONNECTING),O(this,Ee,new AbortController),S(this,Ft)(S(this,$e),Me(this,he,Gs).call(this)).then(S(this,Ta)).catch(S(this,va))},Ta=new WeakMap,va=new WeakMap,Gs=function(){var r;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...S(this,mt)?{"Last-Event-ID":S(this,mt)}:void 0},cache:"no-store",signal:(r=S(this,Ee))==null?void 0:r.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Aa=new WeakMap,Ea=new WeakMap,Lt=function(r,e){var t;S(this,ce)!==this.CLOSED&&O(this,ce,this.CLOSED);const s=new Ys("error",{code:e,message:r});(t=S(this,Ze))==null||t.call(this,s),this.dispatchEvent(s)},Ia=function(r,e){var t;if(S(this,ce)===this.CLOSED)return;O(this,ce,this.CONNECTING);const s=new Ys("error",{code:e,message:r});(t=S(this,Ze))==null||t.call(this,s),this.dispatchEvent(s),O(this,Je,setTimeout(S(this,ja),S(this,pt)))},ja=new WeakMap,zt.CONNECTING=0,zt.OPEN=1,zt.CLOSED=2;function Yi(){const r="document"in globalThis?globalThis.document:void 0;return r&&typeof r=="object"&&"baseURI"in r&&typeof r.baseURI=="string"?r.baseURI:void 0}class fe{static subscribedToClickEvent=!1;static attachAnalyticsScript(e){window._msq=window._msq||[];const t=e||"https://static.searchstax.com/studio-js/v4/js/studio-analytics.js";if(!document.querySelector(`script[src="${t}"]`)){var s=document.createElement("script");s.type="text/javascript",s.src=t;var a=document.getElementsByTagName("script")[0];a.parentNode&&a.parentNode.insertBefore(s,a)}}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(n,c){JSON.stringify(n)===JSON.stringify(t)&&c?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(n,c){JSON.stringify(n)===JSON.stringify(t)&&c?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+"",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 Wi{cachedQuery="";cachedQueryOR="";cachedQueryTabs="";cachedANDFacets="";cachedORFacets="";cachedTabsFacets="";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(n){const c=n.name+":"+n.value,l=decodeURIComponent(c).replace(" "," ").split(":");a[l[0]]?a[l[0]].push(l[1]):a[l[0]]=[l[1]]});let i="";for(const n in a)if(Object.prototype.hasOwnProperty.call(a,n)){const c=a[n],l=n;for(const h of c)i+=i===""?` ${l}:"${h}"`:` OR ${l}:"${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(n=>n.json()).then(n=>{a(n)})}cacheFacets(e,t){return new Promise(s=>{if(this.resolveFn=s,e==="or"||e==="showUnavailable"){const a=this.dataLayer.searchObject.facets.filter(i=>i.type==="tabs"||i.type==="and");if(this.cachedQueryOR===this.dataLayer.searchObject.query&&this.dataLayer.searchObject.facets?.length>0&&a.length===0){this.resolveFn();return}else this.cachedORFacets=JSON.stringify(this.dataLayer.searchObject.facets.filter(i=>i.type==="or")),this.cachedQueryOR=this.dataLayer.searchObject.query,this.cacheFacetsCallback(void 0,e)}else if(e==="tabs")if(this.cachedTabsFacets&&this.cachedQueryTabs===this.dataLayer.searchObject.query&&this.dataLayer.searchObject.facets?.length>0){this.resolveFn();return}else this.cachedTabsFacets=JSON.stringify(this.dataLayer.searchObject.facets.filter(a=>a.type==="tabs")),this.cachedQueryTabs=this.dataLayer.searchObject.query,this.cacheFacetsCallback(void 0,e);else e?this.resolveFn():(this.cachedANDFacets=JSON.stringify(this.dataLayer.searchObject.facets.filter(a=>a.type==="and")),this.cachedORFacets=JSON.stringify(this.dataLayer.searchObject.facets.filter(a=>a.type==="or"||a.type==="showUnavailable")),this.cachedTabsFacets=JSON.stringify(this.dataLayer.searchObject.facets.filter(a=>a.type==="tabs")),this.cachedQueryOR=this.dataLayer.searchObject.query,this.cachedQueryTabs=this.dataLayer.searchObject.query,t?.includes("tabs")&&this.search({query:this.cachedQueryTabs,itemsPerPage:void 0,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps,location:this.dataLayer.searchObject.location,model:this.dataLayer.model},this.cacheFacetsCallback.bind(this),!0,!1,"tabs"),(t?.includes("or")||t?.includes("showUnavailable"))&&this.search({query:this.cachedQueryTabs,itemsPerPage:void 0,page:1,order:"",facets:[...this.dataLayer.searchObject.facets.filter(a=>a.type==="and"||a.type==="tabs")],additionalProps:this.dataLayer.searchObject.additionalProps,location:this.dataLayer.searchObject.location,model:this.dataLayer.model},this.cacheFacetsCallback.bind(this),!0,!1,"or"),this.resolveFn())})}cacheFacetsCallback(e,t){let s=this.dataLayer.searchFacets??[];e&&(s=gt.extractFacets(e)),t==="or"?this.dataLayer.setSearchFacetsCachedor(s):t==="tabs"?this.dataLayer.setSearchFacetsCachedtabs(s):this.dataLayer.setSearchFacetsCached(s),this.resolveFn&&this.resolveFn()}search(e,t,s=!1,a=!1,i){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 n=this.url+this.generateQueryParams(e,a),c={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete c.signal,fetch(n,c).then(l=>l.json()).then(l=>{this.dataLayer.setLoading(!1),t(l,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}`:"",n=new Proxy(new URLSearchParams(window?.location.search??""),{get:(h,p)=>h.get(p)??""}),c=n.languageVariant?"&fq=_language:"+n.languageVariant:"",l=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}`+(l?`&model=${l}`:"")+"&language="+this.dataLayer.language+c}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.searchObject.page!==1)return;const s=this.dataLayer;s.setAnswerLoading(!1),s.setAnswerErrorMessage(""),s.setAnswerError(!1);const a=new zt(this.dataLayer.questionURL+this.generateQueryParams(this.dataLayer.searchObject),{fetch:(i,n)=>fetch(i,{...n,headers:{...n?.headers,Authorization:this._authToken}})});return a.onmessage=i=>{if(i.data===Ye.question||i.data===Ye.notQuestion){i.data===Ye.question?(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setIsQuestion(!0)):(s.setAnswerLoading(!1),this.dataLayer.setIsQuestion(!1)),s.setAnswerData("");return}if(i.data===Ye.close){fe.trackAnswerData({...s.parsedData.trackingData,answer:s.$answer.getValue(),isQuestion:this.dataLayer.isQuestion,hasShowMore:this.dataLayer.parsedData.shouldShowAnswerLoadMore}),s.setAnswerLoading(!1),a.close();return}if(i.data.indexOf("[!CAUTION]")!==-1){s.setAnswerError(!0),s.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),a.close();return}if(i.data.indexOf("[comment]: <> ({")!==-1)try{const n=i.data.split("[comment]: <> ({");if(n.length<2){t(i.data);return}const c=n[1].split("})");if(c.length<2){t(i.data);return}const l=c[0],h=JSON.parse("{"+l+"}");this.dataLayer.answerWidgetShowMoreLimit=h.displayShowMoreAfter,h.showMoreEnabled||(this.dataLayer.answerWidgetShowMoreLimit=1e17);const p=c.slice(1).join("})");t(p)}catch{t(i.data)}else t(i.data)},a.addEventListener("error",i=>{(i.code===401||i.code===500)&&(s.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),s.setAnswerError(!0))}),a.onerror=()=>{s.setAnswerLoading(!1),a.close()},a}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 Ji=Object.prototype.toString,Xe=Array.isArray||function(r){return Ji.call(r)==="[object Array]"};function Da(r){return typeof r=="function"}function Gi(r){return Xe(r)?"array":typeof r}function Ra(r){return r.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Zs(r,e){return r!=null&&typeof r=="object"&&e in r}function Zi(r,e){return r!=null&&typeof r!="object"&&r.hasOwnProperty&&r.hasOwnProperty(e)}var Ki=RegExp.prototype.test;function Xi(r,e){return Ki.call(r,e)}var en=/\S/;function tn(r){return!Xi(en,r)}var an={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function sn(r){return String(r).replace(/[&<>"'`=\/]/g,function(e){return an[e]})}var rn=/\s*/,nn=/\s+/,Ks=/\s*=/,on=/\s*\}/,cn=/#|\^|\/|>|\{|&|=|!/;function ln(r,e){if(!r)return[];var t=!1,s=[],a=[],i=[],n=!1,c=!1,l="",h=0;function p(){if(n&&!c)for(;i.length;)delete a[i.pop()];else i=[];n=!1,c=!1}var L,y,N;function v(A){if(typeof A=="string"&&(A=A.split(nn,2)),!Xe(A)||A.length!==2)throw new Error("Invalid tags: "+A);L=new RegExp(Ra(A[0])+"\\s*"),y=new RegExp("\\s*"+Ra(A[1])),N=new RegExp("\\s*"+Ra("}"+A[1]))}v(e||T.tags);for(var C=new yt(r),P,j,q,ie,F,m;!C.eos();){if(P=C.pos,q=C.scanUntil(L),q)for(var g=0,M=q.length;g<M;++g)ie=q.charAt(g),tn(ie)?(i.push(a.length),l+=ie):(c=!0,t=!0,l+=" "),a.push(["text",ie,P,P+1]),P+=1,ie===`
|
|
68
|
+
`&&(p(),l="",h=0,t=!1);if(!C.scan(L))break;if(n=!0,j=C.scan(cn)||"name",C.scan(rn),j==="="?(q=C.scanUntil(Ks),C.scan(Ks),C.scanUntil(y)):j==="{"?(q=C.scanUntil(N),C.scan(on),C.scanUntil(y),j="&"):q=C.scanUntil(y),!C.scan(y))throw new Error("Unclosed tag at "+C.pos);if(j==">"?F=[j,q,P,C.pos,l,h,t]:F=[j,q,P,C.pos],h++,a.push(F),j==="#"||j==="^")s.push(F);else if(j==="/"){if(m=s.pop(),!m)throw new Error('Unopened section "'+q+'" at '+P);if(m[1]!==q)throw new Error('Unclosed section "'+m[1]+'" at '+P)}else j==="name"||j==="{"||j==="&"?c=!0:j==="="&&v(q)}if(p(),m=s.pop(),m)throw new Error('Unclosed section "'+m[1]+'" at '+C.pos);return un(hn(a))}function hn(r){for(var e=[],t,s,a=0,i=r.length;a<i;++a)t=r[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 un(r){for(var e=[],t=e,s=[],a,i,n=0,c=r.length;n<c;++n)switch(a=r[n],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 yt(r){this.string=r,this.tail=r,this.pos=0}yt.prototype.eos=function(){return this.tail===""},yt.prototype.scan=function(r){var e=this.tail.match(r);if(!e||e.index!==0)return"";var t=e[0];return this.tail=this.tail.substring(t.length),this.pos+=t.length,t},yt.prototype.scanUntil=function(r){var e=this.tail.search(r),t;switch(e){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,e),this.tail=this.tail.substring(e)}return this.pos+=t.length,t};function et(r,e){this.view=r,this.cache={".":this.view},this.parent=e}et.prototype.push=function(r){return new et(r,this)},et.prototype.lookup=function(r){var e=this.cache,t;if(e.hasOwnProperty(r))t=e[r];else{for(var s=this,a,i,n,c=!1;s;){if(r.indexOf(".")>0)for(a=s.view,i=r.split("."),n=0;a!=null&&n<i.length;)n===i.length-1&&(c=Zs(a,i[n])||Zi(a,i[n])),a=a[i[n++]];else a=s.view[r],c=Zs(s.view,r);if(c){t=a;break}s=s.parent}e[r]=t}return Da(t)&&(t=t.call(this.view)),t};function re(){this.templateCache={_cache:{},set:function(r,e){this._cache[r]=e},get:function(r){return this._cache[r]},clear:function(){this._cache={}}}}re.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()},re.prototype.parse=function(r,e){var t=this.templateCache,s=r+":"+(e||T.tags).join(":"),a=typeof t<"u",i=a?t.get(s):void 0;return i==null&&(i=ln(r,e),a&&t.set(s,i)),i},re.prototype.render=function(r,e,t,s){var a=this.getConfigTags(s),i=this.parse(r,a),n=e instanceof et?e:new et(e,void 0);return this.renderTokens(i,n,t,r,s)},re.prototype.renderTokens=function(r,e,t,s,a){for(var i="",n,c,l,h=0,p=r.length;h<p;++h)l=void 0,n=r[h],c=n[0],c==="#"?l=this.renderSection(n,e,t,s,a):c==="^"?l=this.renderInverted(n,e,t,s,a):c===">"?l=this.renderPartial(n,e,t,a):c==="&"?l=this.unescapedValue(n,e):c==="name"?l=this.escapedValue(n,e,a):c==="text"&&(l=this.rawValue(n)),l!==void 0&&(i+=l);return i},re.prototype.renderSection=function(r,e,t,s,a){var i=this,n="",c=e.lookup(r[1]);function l(L){return i.render(L,e,t,a)}if(c){if(Xe(c))for(var h=0,p=c.length;h<p;++h)n+=this.renderTokens(r[4],e.push(c[h]),t,s,a);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")n+=this.renderTokens(r[4],e.push(c),t,s,a);else if(Da(c)){if(typeof s!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(e.view,s.slice(r[3],r[5]),l),c!=null&&(n+=c)}else n+=this.renderTokens(r[4],e,t,s,a);return n}},re.prototype.renderInverted=function(r,e,t,s,a){var i=e.lookup(r[1]);if(!i||Xe(i)&&i.length===0)return this.renderTokens(r[4],e,t,s,a)},re.prototype.indentPartial=function(r,e,t){for(var s=e.replace(/[^ \t]/g,""),a=r.split(`
|
|
69
|
+
`),i=0;i<a.length;i++)a[i].length&&(i>0||!t)&&(a[i]=s+a[i]);return a.join(`
|
|
70
|
+
`)},re.prototype.renderPartial=function(r,e,t,s){if(t){var a=this.getConfigTags(s),i=Da(t)?t(r[1]):t[r[1]];if(i!=null){var n=r[6],c=r[5],l=r[4],h=i;c==0&&l&&(h=this.indentPartial(i,l,n));var p=this.parse(h,a);return this.renderTokens(p,e,t,h,s)}}},re.prototype.unescapedValue=function(r,e){var t=e.lookup(r[1]);if(t!=null)return t},re.prototype.escapedValue=function(r,e,t){var s=this.getConfigEscape(t)||T.escape,a=e.lookup(r[1]);if(a!=null)return typeof a=="number"&&s===T.escape?String(a):s(a)},re.prototype.rawValue=function(r){return r[1]},re.prototype.getConfigTags=function(r){return Xe(r)?r:r&&typeof r=="object"?r.tags:void 0},re.prototype.getConfigEscape=function(r){if(r&&typeof r=="object"&&!Xe(r))return r.escape};var T={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(r){wt.templateCache=r},get templateCache(){return wt.templateCache}},wt=new re;T.clearCache=function(){return wt.clearCache()},T.parse=function(r,e){return wt.parse(r,e)},T.render=function(r,e,t,s){if(typeof r!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+Gi(r)+'" was given as the first argument for mustache#render(template, view, partials)');return wt.render(r,e,t,s)},T.escape=sn,T.Scanner=yt,T.Context=et,T.Writer=re;const dn={main:{template:`
|
|
71
71
|
{{#shouldShowAnswer}}
|
|
72
72
|
<div class="searchstax-answer-wrap">
|
|
73
73
|
<div class="searchstax-answer-icon"></div>
|
|
@@ -104,7 +104,7 @@ ${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
|
|
|
104
104
|
</div>
|
|
105
105
|
</div>
|
|
106
106
|
{{/shouldShowAnswer}}
|
|
107
|
-
`}},
|
|
107
|
+
`}},gn={mainTemplate:{template:`
|
|
108
108
|
{{#hasExternalPromotions}}
|
|
109
109
|
<div class="searchstax-external-promotions-container" id="searchstax-external-promotions-container" data-test-id="searchstax-external-promotions-container">
|
|
110
110
|
External promotions go here
|
|
@@ -130,7 +130,7 @@ ${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
|
|
|
130
130
|
</p>
|
|
131
131
|
{{/url}}
|
|
132
132
|
</div>
|
|
133
|
-
`}},
|
|
133
|
+
`}},pn={mainTemplateDesktop:{template:`
|
|
134
134
|
{{#hasResultsOrExternalPromotions}}
|
|
135
135
|
<div class="searchstax-facets-container-desktop"></div>
|
|
136
136
|
{{/hasResultsOrExternalPromotions}}
|
|
@@ -188,7 +188,7 @@ ${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
|
|
|
188
188
|
<div class="searchstax-facets-pill-label">{{value}} ({{count}})</div>
|
|
189
189
|
<div class="searchstax-facets-pill-icon-close"></div>
|
|
190
190
|
</div>
|
|
191
|
-
`,containerClass:"searchstax-facets-pill-facets"}},
|
|
191
|
+
`,containerClass:"searchstax-facets-pill-facets"}},mn={mainTemplate:{template:`
|
|
192
192
|
{{#results.length}}
|
|
193
193
|
<div class="searchstax-pagination-container" data-test-id="searchstax-pagination-container">
|
|
194
194
|
<div class="searchstax-pagination-content">
|
|
@@ -206,7 +206,7 @@ ${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
|
|
|
206
206
|
<a class="searchstax-pagination-load-more" data-test-id="searchstax-pagination-load-more" tabindex="0">Show More</a>
|
|
207
207
|
{{/isLastPage}}
|
|
208
208
|
{{/results.length}}
|
|
209
|
-
`,loadMoreButtonClass:"searchstax-pagination-load-more"}},
|
|
209
|
+
`,loadMoreButtonClass:"searchstax-pagination-load-more"}},fn={main:{template:`
|
|
210
210
|
{{#hasRelatedSearches}}
|
|
211
211
|
<div class="searchstax-related-searches-container" data-test-id="searchstax-related-searches-container" id="searchstax-related-searches-container">
|
|
212
212
|
Related searches: <span id="searchstax-related-searches"></span>
|
|
@@ -221,7 +221,7 @@ ${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
|
|
|
221
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">
|
|
222
222
|
{{ related_search }}{{^last}}<span>,</span>{{/last}}
|
|
223
223
|
</span>
|
|
224
|
-
`,relatedSearchContainerClass:"searchstax-related-search-item"}},
|
|
224
|
+
`,relatedSearchContainerClass:"searchstax-related-search-item"}},Ln={main:{template:`
|
|
225
225
|
{{#searchExecuted}}
|
|
226
226
|
<a href="#searchstax-search-results" data-test-id="searchstax-skip" class="searchstax-skip">Skip to results section</a>
|
|
227
227
|
<h4 class="searchstax-feedback-container" data-test-id="searchstax-feedback-container">
|
|
@@ -235,7 +235,7 @@ ${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
|
|
|
235
235
|
{{/hasResults}}
|
|
236
236
|
</h4>
|
|
237
237
|
{{/searchExecuted}}
|
|
238
|
-
`,originalQueryClass:"searchstax-feedback-original-query"}},
|
|
238
|
+
`,originalQueryClass:"searchstax-feedback-original-query"}},yn={mainTemplate:{template:`
|
|
239
239
|
<div class="searchstax-search-input-container searchstax-search-input-container-new {{#locationEnabled}}searchstax-alternative-render{{/locationEnabled}}">
|
|
240
240
|
<div class="searchstax-search-input-wrapper">
|
|
241
241
|
<input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." aria-label="Search" />
|
|
@@ -247,7 +247,7 @@ ${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
|
|
|
247
247
|
</div>
|
|
248
248
|
`,searchInputId:"searchstax-search-input"},autosuggestItemTemplate:{template:`
|
|
249
249
|
<div class="searchstax-autosuggest-item-term-container">{{{term}}}</div>
|
|
250
|
-
`}},
|
|
250
|
+
`}},wn={mainTemplate:{template:`
|
|
251
251
|
<div class="searchstax-location-input-container" data-test-id="searchstax-location-input-container">
|
|
252
252
|
<div class="searchstax-location-input-wrapper">
|
|
253
253
|
<span class="searchstax-location-input-label">NEAR</span>
|
|
@@ -265,7 +265,7 @@ ${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
|
|
|
265
265
|
{{/shouldShowLocationDistanceDropdown}}
|
|
266
266
|
</div>
|
|
267
267
|
</div>
|
|
268
|
-
`,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"}},Mn={mainTemplate:{template:`
|
|
269
269
|
<section aria-label="search results container" tabindex="0">
|
|
270
270
|
<div class="searchstax-search-results-container" id="searchstax-search-results-container" data-test-id="searchstax-search-results-container">
|
|
271
271
|
<div class="searchstax-search-results" id="searchstax-search-results"></div>
|
|
@@ -337,7 +337,7 @@ ${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
|
|
|
337
337
|
</ul>
|
|
338
338
|
</div>
|
|
339
339
|
{{/searchExecuted}}
|
|
340
|
-
`}},
|
|
340
|
+
`}},bn={main:{template:`
|
|
341
341
|
{{#searchExecuted}}
|
|
342
342
|
{{#hasResultsOrExternalPromotions}}
|
|
343
343
|
{{#sortOptions.length}}
|
|
@@ -437,4 +437,4 @@ ${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
|
|
|
437
437
|
|
|
438
438
|
</div>
|
|
439
439
|
</div>
|
|
440
|
-
`,thumbsUpButtonClass:"searchstax-lightweight-widget-thumbs-up",thumbsDownButtonClass:"searchstax-lightweight-widget-thumbs-down"}};class y{static answer=$r;static externalPromotions=Vr;static facets=Br;static pagination=Qr;static relatedSearches=Hr;static searchFeedback=_r;static searchInput=qr;static location=Ur;static searchResults=Wr;static sorting=Yr;static feedback=Z}class Jr{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||y.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||y.externalPromotions.externalPromotion?.template;if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-external-promotion"),a.addEventListener("click",r=>{this.trackClick(e,r)}),a.innerHTML=S.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||y.externalPromotions.mainTemplate?.template;if(this.dataLayer.renderingEngine===F.mustache){this.searchExternalPromotionsMainContainer.innerHTML=S.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 Y{static addAccessibilityNotificationContainerToBody(){if(!document.getElementById("searchAccessibilityContainer")){const e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("id","searchAccessibilityContainer"),document.body.appendChild(e)}}static setAccessibilityText(e,t,s){this.addAccessibilityNotificationContainerToBody();const a=s??"searchAccessibility",r=document.getElementById(a);r&&r.remove();const n=document.createElement("span");n.setAttribute("id",a),n.innerHTML=e;const c=document.getElementById("searchAccessibilityContainer");c&&setTimeout(()=>{c.appendChild(n)},t??100)}}class Gr{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(r=>{a[r.name]||(a[r.name]=s)}),e.map(r=>({...r,values:r.values.slice(0,a[r.name]),showingAllFacets:r.values.length<=a[r.name],hasMoreFacets:r.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 r=this.dataLayer.searchFacets?.find(n=>n.name===a.name);return r?{...a,values:a.values.map(n=>{const c=r.values.find(l=>n.type==="range"?!1:n.type==="checkbox"?l.value===n.value:!1);return{...n,disabled:!c,isMobile:e}})}:{...a,values:a.values.map(n=>({...n,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 r=this.config?.templates?.facetItemContainerTemplate?.template||y.facets.facetItemContainerTemplate?.template;a.innerHTML=S.render(r,e),t.appendChild(a);const n=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerClass||y.facets.facetItemContainerTemplate?.facetListTitleContainerClass));n?.addEventListener("click",()=>{a.classList.toggle("active");const l=a.classList.contains("active"),h=n.querySelector(".searchstax-facet-title");h&&h.setAttribute("aria-expanded",String(l))}),n?.querySelector("."+this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerInner)?.addEventListener("keydown",l=>{if(l.code==="Enter"||l.code==="Space"){l.preventDefault(),a.classList.toggle("active");const h=a.classList.contains("active"),p=n.querySelector(".searchstax-facet-title");p&&p.setAttribute("aria-expanded",String(h))}});const c=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListContainerClass||y.facets.facetItemContainerTemplate?.facetListContainerClass));c&&(e.values.forEach(l=>{this.createFacetListItem(l,c,e.name)}),e.hasMoreFacets&&this.createHasMoreComponent(e,c,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 r=this.isChecked(e),n=this.config?.templates?.facetItemTemplate?.template||y.facets.facetItemTemplate?.template;a.innerHTML=S.render(n,{...e,isChecked:r});let c=y.facets.facetItemTemplate?.checkTriggerClasses;c=this.config?.templates?.facetItemTemplate?.checkTriggerClasses||c,c.forEach(h=>{a.querySelector("."+h)?.addEventListener("click",p=>{this.onFacetSelect(p,e,a)})});const l=a.querySelector("."+(this.config?.templates?.facetItemTemplate?.inputCheckboxClass||y.facets.facetItemTemplate?.inputCheckboxClass));l?.addEventListener("click",h=>{this.onFacetSelect(h,e,a,!0)}),l&&l?.setAttribute("data-test-value",`${encodeURIComponent(s)}:"${encodeURIComponent(e.value)}"`),t.appendChild(a)}}onFacetSelect=(e,t,s,a,r)=>{if(e.stopPropagation(),!t.disabled){const n=s.querySelector("input");let c=a?n.checked:!n.checked;r!==void 0&&(c=!r),n.checked=c;const l=this.dataLayer.searchObject;let h=[...l.facets];const p=this.extractFacetValue(t);c?h.find(f=>oe.deepEqual(f,p)?f:!1)||(this.config.facetingType==="tabs"&&(h=h.filter(f=>f.name!==p.name)),h.push(p)):h=h.filter(f=>!oe.deepEqual(f,p)),setTimeout(()=>{this.dataLayer.setSearchObject({...l,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 r=this.config?.templates?.showMoreButtonContainerTemplate?.template||y.facets.showMoreButtonContainerTemplate?.template;a.innerHTML=S.render(r,{...e,focusId:`moreLess${e?.values?.[0]?.value}`});const n=a.querySelector("."+(this.config?.templates?.showMoreButtonContainerTemplate?.showMoreButtonClass||y.facets.showMoreButtonContainerTemplate?.showMoreButtonClass));n&&(this.attachOnclickToShowMore(e,n,s),t&&t.appendChild(n))}}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,r=s?this.facetLimits:this.facetLimitsMobile;r[t.name]===void 0?r[t.name]=a*2:r[t.name]<=t.values.length?(Y.setAccessibilityText(`More Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),r[t.name]=r[t.name]+a):(Y.setAccessibilityText(`Less Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),r[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||y.facets.mainTemplateDesktop?.template;if(this.dataLayer.renderingEngine===F.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=S.render(s,{...e});const r=this.searchFacetsMainContainer?.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.facetsContainerClass||y.facets.mainTemplateDesktop.facetsContainerClass));if(r){r.innerHTML="";for(const n of e.facets)this.createFacetItem(n,r);if(this.searchFacetsMainContainer){const n=this.searchFacetsMainContainer.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.selectedFacetsContainerClass||y.facets.mainTemplateDesktop.selectedFacetsContainerClass));n&&(this.createSelectedFacetsComponents(n),this.createClearFacetsComponents(n))}if(this.focusedElement){if(this.focusedElement.classList.contains("searchstax-facet-show-more-button")||this.focusedElement.classList.contains("searchstax-facet-show-less-button")){const l=this.focusedElement.getAttribute("data-focus"),h=this.searchFacetsMainContainer.querySelector(`[data-focus="${l}"]`);h instanceof HTMLElement&&h.focus(),this.focusedElement=null;return}const n=this.focusedElement.getAttribute("data-test-value"),c=this.searchFacetsMainContainer.querySelector(`[data-test-value="${n}"]`);c instanceof HTMLInputElement&&c.focus(),this.focusedElement=null}}}setTimeout(()=>{document.querySelectorAll(".searchstax-facet-title").forEach(a=>{a.setAttribute("aria-expanded",String(!0)),a.setAttribute("tabindex","0"),a.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),r=decodeURIComponent(s.value);if(this.dataLayer.searchFacets){const n=(this.needCache?this.dataLayer.searchFacetsCached:this.dataLayer.searchFacets)?.find(c=>c.name===a);if(n){const c=n.values.find(l=>l.type==="range"?!1:l.type==="checkbox"?`"${l.value}"`==`"${r}"`:!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||y.facets.clearFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=S.render(s,{shouldShow:t.facets.length>0});const r=a.querySelector("."+(this.config?.templates?.clearFacetsTemplate?.containerClass||y.facets.clearFacetsTemplate?.containerClass));r&&(r.addEventListener("click",()=>{this.removeSelectedFacets()}),r.addEventListener("keyup",n=>{(n.code==="Space"||n.code==="Enter")&&this.removeSelectedFacets()}),e.appendChild(r))}}createSelectedFacetsComponent(e,t){if(typeof document<"u"){const s=this.config?.templates?.selectedFacetsTemplate?.template||y.facets.selectedFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=S.render(s,t);const r=a.querySelector("."+(this.config?.templates?.selectedFacetsTemplate?.containerClass||y.facets.selectedFacetsTemplate?.containerClass));r&&(r.addEventListener("click",()=>{this.unselectFacet(t)}),r.addEventListener("keyup",n=>{(n.code==="Space"||n.code==="Enter")&&this.unselectFacet(t)}),e.appendChild(r))}}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||y.facets.filterByTemplate?.template,s=document?.createElement("div");s.innerHTML=S.render(t,{});const a=s.querySelector("."+(this.config?.templates?.filterByTemplate?.containerClass||y.facets.filterByTemplate?.containerClass));a&&(e.prepend(a),a.addEventListener("click",this.openOverlay.bind(this)),a.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.openOverlay()}))}}openOverlay(){Y.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(){Y.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||y.facets.mainTemplateMobile?.template;if(this.dataLayer.renderingEngine===F.mustache){if(t.innerHTML=S.render(s,{...e,overlayOpened:this.overlayOpened}),this.searchFacetsMainContainer?.appendChild(t),this.config?.templates?.mainTemplateMobile)for(const c of this.config?.templates?.mainTemplateMobile?.closeOverlayTriggerClasses||[]){const l=t.querySelector("."+c);l&&(l.addEventListener("click",this.closeOverlay.bind(this)),l.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}else for(const c of y.facets.mainTemplateMobile.closeOverlayTriggerClasses){const l=t.querySelector("."+c);l&&(l.addEventListener("click",this.closeOverlay.bind(this)),l.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}const a=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.filterByContainerClass||y.facets.mainTemplateMobile.filterByContainerClass));a&&this.createFilterByComponent(a);const r=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.selectedFacetsContainerClass||y.facets.mainTemplateMobile.selectedFacetsContainerClass));r&&(this.createSelectedFacetsComponents(r),this.createClearFacetsComponents(r));const n=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.facetsContainerClass||y.facets.mainTemplateMobile.facetsContainerClass));if(n){n.innerHTML="";for(const c of e.facets)this.createFacetItem(c,n,!0)}}}}}class Zr{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??y.pagination.mainTemplate.previousButtonClass,this.nextButtonClass=this.config?.templates?.mainTemplate?.nextButtonClass??y.pagination.mainTemplate.nextButtonClass,this.loadMoreButtonClass=this.config?.templates?.infiniteScrollTemplate?.loadMoreButtonClass??y.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 r=a.querySelector('[tabindex="0"]');r instanceof HTMLElement&&r.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||y.pagination.mainTemplate?.template;this.dataLayer.isInfiniteScroll&&(t=this.config?.templates?.infiniteScrollTemplate?.template||y.pagination.infiniteScrollTemplate?.template),this.dataLayer.renderingEngine===F.mustache&&(this.searchPaginationMainContainer.innerHTML=S.render(t,e),setTimeout(()=>{this.overridePaginationEvents()},0))}}class Kr{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||y.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||y.relatedSearches.relatedSearch.template;if(this.dataLayer.renderingEngine===F.mustache){s.innerHTML=S.render(a,e);const r=s.querySelector("."+(this.config.templates?.relatedSearch?.relatedSearchContainerClass||y.relatedSearches.relatedSearch.relatedSearchContainerClass));r&&(t.appendChild(r),r.addEventListener("click",()=>{this.executeSearch(e)}),r.addEventListener("keyup",n=>{(n.code==="Space"||n.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||y.relatedSearches.main.template;if(this.dataLayer.renderingEngine===F.mustache&&this.searchRelatedSearchesMainContainer){this.searchRelatedSearchesMainContainer.innerHTML="",this.searchRelatedSearchesMainContainer.innerHTML=S.render(t,e);const s=this.searchRelatedSearchesMainContainer?.querySelector(`.${this.relatedSearchesContainerClass}`);if(s)for(const a of e.relatedSearches)this.addRelatedSearchComponent(a,s)}}}class Xr{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||y.searchFeedback.main?.originalQueryClass));e&&e.addEventListener("click",this.onOriginalQueryClick.bind(this))}renderMainTemplate(e){const t=this.config?.templates?.main?.template||y.searchFeedback.main.template;this.dataLayer.renderingEngine===F.mustache&&(this.searchFeedbackMainContainer.innerHTML=S.render(t,e),setTimeout(()=>{this.attachClick()},0))}}class en{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||y.searchInput.mainTemplate.template,s={...this.dataLayer.parsedData.data,locationEnabled:!!this.dataLayer.locationEnabled,hasInputValue:!1};if(this.dataLayer.setInputWidgetTemplateData(s),this.dataLayer.renderingEngine===F.mustache){const n=S.render(t,s);e.innerHTML=n,this.dataLayer.setInputTemplateRendered(!0)}const a=this.config.templates?.mainTemplate?.searchInputId||y.searchInput.mainTemplate.searchInputId,r=document?.querySelector(`#${a}`);if(r)this.searchInput=r,r.addEventListener("keyup",this.inputKeyupEvent.bind(this)),r.addEventListener("blur",this.hideAutosuggest.bind(this)),r.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 s=this.dataLayer.inputWidgetTemplateData;s&&this.dataLayer.setInputWidgetTemplateData({...s,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)),Y.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,Y.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 s=e[t];t===this.selectedAutosuggestItem?(s.classList.add("active"),Y.setAccessibilityText(`Selected suggestion: ${s.innerText}`)):s.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)),Y.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 s=this.config.templates?.autosuggestItemTemplate?.template||y.searchInput.autosuggestItemTemplate?.template;return t.innerHTML=S.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 r=s[a];r.numFound?Y.setAccessibilityText("Suggestions are available. Use up and down arrows to navigate while focusing input. Use Escape key to escape out of the suggestions",2e3):Y.setAccessibilityText("",0),this.autosuggestResults=r,this.dataLayer.setAutosuggestResults(r),r.numFound>0?r.suggestions.forEach(n=>{this.autosuggestContainer&&typeof document<"u"&&this.autosuggestContainer.appendChild(this.createAutosuggestItem(n))}):this.autosuggestContainer&&this.autosuggestContainer.classList.add("hidden")}}}}class tn{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(()=>{Y.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||y.searchResults.noSearchResultTemplate?.template,t=this.dataLayer.searchResultsMetadata?.spellingSuggestion??"";if(this.dataLayer.renderingEngine===F.mustache&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=S.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===F.mustache&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)Y.setAccessibilityText("Search has no results"),this.renderNoResultsTemplate();else{Y.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||y.searchResults.searchResultTemplate?.template,s=e.map(a=>S.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||y.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||y.searchResults.mainTemplate?.template;this.dataLayer.renderingEngine===F.mustache&&(this.searchResultsMainContainer.innerHTML=S.render(e,{}),setTimeout(()=>{const t=this.config?.templates?.mainTemplate?.searchResultsContainerId?this.config?.templates?.mainTemplate?.searchResultsContainerId:y.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 an{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||y.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||y.sorting.main.template;if(this.dataLayer.renderingEngine===F.mustache){this.searchSortingMainContainer.innerHTML=S.render(t,e),this.markOptionSelected();const s=document?.getElementById(this.selectId);s&&s.addEventListener("change",a=>{this.setOrderQuery(a.target.value)})}}}class sn{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 s=Z?.mainTemplate?.template;if(this.mainTemplateOverride&&(s=this.mainTemplateOverride),this.isLightweight&&(s=Z.lightweightTemplate?.template,this.lightweightTemplateOverride&&(s=this.lightweightTemplateOverride)),this.mainContainer.innerHTML=S.render(s,e),this.focusedElement&&this.mainContainer){const a=this.focusedElement.type==="radio"?this.focusedElement.getAttribute("id"):this.focusedElement.getAttribute("class"),r=this.focusedElement.type==="radio"?"id":"class",n=this.mainContainer.querySelector(`[${r}="${a}"]`);(n instanceof HTMLInputElement||n instanceof HTMLButtonElement||n instanceof HTMLTextAreaElement||n instanceof HTMLAnchorElement)&&n.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],r=s[s.length-1];e.key==="Tab"&&(e.shiftKey?(document.activeElement===a||!t.contains(document.activeElement))&&(e.preventDefault(),r?.focus()):(document.activeElement===r||!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=Z.mainTemplate?.modalContainerClass;return this.mainContainer?.querySelector(`.${e}`)||null}attachLightweightEvents(){const e=Z.lightweightTemplate?.thumbsUpButtonClass,t=Z.lightweightTemplate?.thumbsDownButtonClass,s=this.mainContainer?.querySelector("."+e),a=this.mainContainer?.querySelector("."+t);s&&s.addEventListener("click",()=>{const r=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[this.templateData.ratings.length-1].isSelected&&this.ratedQuestion===r||(this.templateData.thumbsUpActive=!0,this.templateData.thumbsDownActive=!1,this.templateData.ratings.forEach(n=>{n.isSelected=n.index===this.thumbsUpValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=r,this.submit())}),a&&a.addEventListener("click",()=>{const r=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[0].isSelected&&this.ratedQuestion===r||(this.templateData.thumbsUpActive=!1,this.templateData.thumbsDownActive=!0,this.templateData.ratings.forEach(n=>{n.isSelected=n.index===this.thumbsDownValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=r,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,Y.setAccessibilityText("Please enter a valid email address.")),this.templateData.ratings.some(t=>t.isSelected)?this.templateData.errors.rating=!1:(this.templateData.errors.rating=!0,Y.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(),Y.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,Y.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(s=>{s.addEventListener("click",a=>{const r=a.target.value;this.templateData.ratings.forEach(n=>{n.isSelected=n.index+""===r}),this.templateData.errors.rating=!1,this.renderMainTemplate(this.generateTemplateData())})})}attachOpenModalEvent(){const e=Z.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=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),Y.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),Y.setAccessibilityText("Feedback form closed",1e3)}showCheckmarkAnimation(){const e=Z.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&(t.disabled=!0);const s=Z.mainTemplate?.checkmarkClass,a=this.mainContainer?.querySelector("."+s);a&&a.classList.remove("hidden");const r=Z.mainTemplate?.submitButtonTextClass,n=this.mainContainer?.querySelector("."+r);n&&n.classList.add("visibility"),setTimeout(()=>{a&&a.classList.add("hidden"),n&&n.classList.remove("visibility"),t&&(t.disabled=!1)},2e3)}destroy(){this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null)}}class rn{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 sn({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 t=e.target.getAttribute("href");Le.trackAnswerLinkClick({href:t,answer:this.dataLayer.parsedData.getAnswerData,...this.dataLayer.parsedData.trackingData}).then(()=>{window.open(t,"_blank")}).catch(()=>{window.open(t,"_blank")})}attachLinkTracking(){document.querySelectorAll(".searchstax-answer-link").forEach(e=>{e.getAttribute("listener")!=="true"&&(e.setAttribute("listener","true"),e.addEventListener("click",this.trackLinkClick.bind(this)))})}renderMainTemplate(e){const t=this.config?.templates?.main?.template||y.answer.main.template;this.dataLayer.renderingEngine===F.mustache?(!this.renderedWithShowMore||!e.answerLoading||this.clicked)&&(e.showMoreButtonVisible&&(this.renderedWithShowMore=!0),this.answerContainer.innerHTML=S.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 _s{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||y.location.mainTemplate.template,s={...this.dataLayer.parsedData.data};if(this.dataLayer.setLocationWidgetTemplateData(s),this.dataLayer.renderingEngine===F.mustache){const a=S.render(t,s);e.innerHTML=a;const r=this.config.templates?.mainTemplate?.locationInputId||y.location.mainTemplate.locationInputId,n=document?.querySelector(`#${r}`);if(n)this.locationInput=n,n.addEventListener("blur",this.blurEvent.bind(this)),n.addEventListener("focus",this.focusEvent.bind(this));else throw new Error("Input not found");const c=this.config.templates?.mainTemplate?.radiusInputId||y.location.mainTemplate.radiusInputId,l=document?.querySelector(`#${c}`);l instanceof HTMLSelectElement&&(this.radiusInput=l,l.addEventListener("change",this.radiusSelectChangeEvent.bind(this)));const h=this.config.templates?.mainTemplate?.currentLocationActionButtonId||y.location.mainTemplate.currentLocationActionButtonId,p=document?.querySelector(`#${h}`);p&&p.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(),s=e.coords.longitude.toString(),a=Math.floor(parseFloat(t)*100)/100,r=Math.floor(parseFloat(s)*100)/100;this.dataLayer.setSearchLat(a+""),this.dataLayer.setSearchLong(r+"");const n=this.locationDecodeCoordinatesToAddress;n?n(a+"",r+"").then(c=>{this.setCurrentLocationFields(c.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(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===F.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 t=e.target.value;this.triggerGeocoder(t)}}class nn{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 fr("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 br({...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 t=(e.response?.docs??[]).map((a,r)=>({...a,position:r+1})),s=[];for(const a of t)s.push({relatedSearch:a.related_search,position:a.position});this.dataLayer.setSearchRelatedSearches(t),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=ht.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=ht.combineResultsWithMetadata(e),s=ht.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!==_e.question&&e!==_e.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 en({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 _s({containerId:e,config:t,dataLayer:this.dataLayer}),t?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(t?.locationValuesOverride?.locationFilterDefaultValue)):this.dataLayer.$searchResultsMetadata.subscribeUntilHasValue(()=>{this.searchLocationWidget=new _s({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 rn({containerId:e,config:t,dataLayer:this.dataLayer})}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new tn({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 Zr({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper})}addSearchFeedbackWidget(e,t){this.searchFeedbackConfig=t,this.searchFeedbackWidget=new Xr({containerId:e,config:t,dataLayer:this.dataLayer,searchTrigger:this.executeSearch.bind(this)})}addSearchSortingWidget(e,t){this.searchSortingConfig=t,this.searchSortingWidget=new an({containerId:e,config:t,dataLayer:this.dataLayer})}addRelatedSearchesWidget(e,t){this.relatedSearchesConfig=t,this.relatedSearchesWidget=new Kr({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 Jr({containerId:e,config:t,dataLayer:this.dataLayer})}addFacetsWidget(e,t){this.searchFacetsConfig=t,this.searchFacetsWidget=new Gr({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper},this.cacheFacets.bind(this))}executeSearch(e,t){const s={...this.dataLayer.searchObject};s.query=G.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(r=>a?{key:r,value:a[r]}:{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&&Le.trackRelatedSearchClick({...this.dataLayer.parsedData.trackingData,relatedSearch:e,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}executeLinkClick(e){let t=ht.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())}}export{nn as Searchstax};
|
|
440
|
+
`,thumbsUpButtonClass:"searchstax-lightweight-widget-thumbs-up",thumbsDownButtonClass:"searchstax-lightweight-widget-thumbs-down"}};class w{static answer=dn;static externalPromotions=gn;static facets=pn;static pagination=mn;static relatedSearches=fn;static searchFeedback=Ln;static searchInput=yn;static location=wn;static searchResults=Mn;static sorting=bn;static feedback=Z}class Cn{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 s=this.config?.templates?.externalPromotion?.template||w.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=T.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||w.externalPromotions.mainTemplate?.template;if(this.dataLayer.renderingEngine===B.mustache){this.searchExternalPromotionsMainContainer.innerHTML=T.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 W{static addAccessibilityNotificationContainerToBody(){if(!document.getElementById("searchAccessibilityContainer")){const e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("id","searchAccessibilityContainer"),document.body.appendChild(e)}}static setAccessibilityText(e,t,s){this.addAccessibilityNotificationContainerToBody();const a=s??"searchAccessibility",i=document.getElementById(a);i&&i.remove();const n=document.createElement("span");n.setAttribute("id",a),n.innerHTML=e;const c=document.getElementById("searchAccessibilityContainer");c&&setTimeout(()=>{c.appendChild(n)},t??100)}}class xn{dataLayer;config;containerId;routerHelper;cachedPhrase="";cachedANDFacets="";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)),t(this.config.facetingType),this.initializeSubscriptions()}get needDisabling(){return this.config.facetingType==="showUnavailable"}initializeSubscriptions(){this.dataLayer.$searchFacetsCachedand.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.$searchFacetsCachedor.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$searchResults.subscribe(e=>{e&&(this.cacheFacets(this.config.facetingType),this.renderMainTemplate(this.generateTemplateData()))})}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.componentFacets&&(t=this.componentFacets,this.needDisabling&&(t=t.map(a=>{const i=this.dataLayer.searchFacets?.find(n=>n.name===a.name);return i?{...a,values:a.values.map(n=>{const c=i.values.find(l=>n.type==="range"?!1:n.type==="checkbox"?l.value===n.value:!1);return{...n,disabled:!c,isMobile:e}})}:{...a,values:a.values.map(n=>({...n,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||w.facets.facetItemContainerTemplate?.template;a.innerHTML=T.render(i,e),t.appendChild(a);const n=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerClass||w.facets.facetItemContainerTemplate?.facetListTitleContainerClass));n?.addEventListener("click",()=>{a.classList.toggle("active");const l=a.classList.contains("active"),h=n.querySelector(".searchstax-facet-title");h&&h.setAttribute("aria-expanded",String(l))}),n?.querySelector("."+this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerInner)?.addEventListener("keydown",l=>{if(l.code==="Enter"||l.code==="Space"){l.preventDefault(),a.classList.toggle("active");const h=a.classList.contains("active"),p=n.querySelector(".searchstax-facet-title");p&&p.setAttribute("aria-expanded",String(h))}});const c=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListContainerClass||w.facets.facetItemContainerTemplate?.facetListContainerClass));c&&(e.values.forEach(l=>{this.createFacetListItem(l,c,e.name)}),e.hasMoreFacets&&this.createHasMoreComponent(e,c,s))}}isChecked(e){return!!this.dataLayer.searchObject.facets?.find(t=>le.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),n=this.config?.templates?.facetItemTemplate?.template||w.facets.facetItemTemplate?.template;a.innerHTML=T.render(n,{...e,isChecked:i});let c=w.facets.facetItemTemplate?.checkTriggerClasses;c=this.config?.templates?.facetItemTemplate?.checkTriggerClasses||c,c.forEach(h=>{a.querySelector("."+h)?.addEventListener("click",p=>{this.onFacetSelect(p,e,a)})});const l=a.querySelector("."+(this.config?.templates?.facetItemTemplate?.inputCheckboxClass||w.facets.facetItemTemplate?.inputCheckboxClass));l?.addEventListener("click",h=>{this.onFacetSelect(h,e,a,!0)}),l&&l?.setAttribute("data-test-value",`${encodeURIComponent(s)}:"${encodeURIComponent(e.value)}"`),t.appendChild(a)}}onFacetSelect=(e,t,s,a,i)=>{if(e.stopPropagation(),!t.disabled){const n=s.querySelector("input");let c=a?n.checked:!n.checked;i!==void 0&&(c=!i),n.checked=c;const l=this.dataLayer.searchObject;let h=[...l.facets];const p=this.extractFacetValue(t);c?h.find(L=>le.deepEqual(L,p)?L:!1)||(this.config.facetingType==="tabs"&&(h=h.filter(L=>L.name!==p.name)),h.push(p)):h=h.filter(L=>!le.deepEqual(L,p)),setTimeout(()=>{this.dataLayer.setSearchObject({...l,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||w.facets.showMoreButtonContainerTemplate?.template;a.innerHTML=T.render(i,{...e,focusId:`moreLess${e?.values?.[0]?.value}`});const n=a.querySelector("."+(this.config?.templates?.showMoreButtonContainerTemplate?.showMoreButtonClass||w.facets.showMoreButtonContainerTemplate?.showMoreButtonClass));n&&(this.attachOnclickToShowMore(e,n,s),t&&t.appendChild(n))}}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?(W.setAccessibilityText(`More Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),i[t.name]=i[t.name]+a):(W.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&&(!le.deepEqual(this.cachedData??{},e)||t)){this.cachedData=e;const s=this.config?.templates?.mainTemplateDesktop?.template||w.facets.mainTemplateDesktop?.template;if(this.dataLayer.renderingEngine===B.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=T.render(s,{...e});const i=this.searchFacetsMainContainer?.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.facetsContainerClass||w.facets.mainTemplateDesktop.facetsContainerClass));if(i){i.innerHTML="";for(const n of e.facets)this.createFacetItem(n,i);if(this.searchFacetsMainContainer){const n=this.searchFacetsMainContainer.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.selectedFacetsContainerClass||w.facets.mainTemplateDesktop.selectedFacetsContainerClass));n&&(this.createSelectedFacetsComponents(n),this.createClearFacetsComponents(n))}if(this.focusedElement){if(this.focusedElement.classList.contains("searchstax-facet-show-more-button")||this.focusedElement.classList.contains("searchstax-facet-show-less-button")){const l=this.focusedElement.getAttribute("data-focus"),h=this.searchFacetsMainContainer.querySelector(`[data-focus="${l}"]`);h instanceof HTMLElement&&h.focus(),this.focusedElement=null;return}const n=this.focusedElement.getAttribute("data-test-value"),c=this.searchFacetsMainContainer.querySelector(`[data-test-value="${n}"]`);c instanceof HTMLInputElement&&c.focus(),this.focusedElement=null}}}setTimeout(()=>{document.querySelectorAll(".searchstax-facet-title").forEach(a=>{a.setAttribute("aria-expanded",String(!0)),a.setAttribute("tabindex","0"),a.setAttribute("role","button")})},100),this.renderMobileTemplate(this.generateTemplateData(!0))}else this.generateSelectedFacetsData()}get componentFacets(){const e=this.config.facetingType;return e==="and"?this.dataLayer.searchFacetsCachedand:e==="or"?this.dataLayer.searchFacetsCachedor:e==="tabs"?this.dataLayer.searchFacetsCachedtabs:e==="showUnavailable"?this.dataLayer.searchFacetsCachedand:null}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 n=this.componentFacets?.find(c=>c.name===a);if(n){const c=n.values.find(l=>l.type==="range"?!1:l.type==="checkbox"?`"${l.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||w.facets.clearFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=T.render(s,{shouldShow:t.facets.length>0});const i=a.querySelector("."+(this.config?.templates?.clearFacetsTemplate?.containerClass||w.facets.clearFacetsTemplate?.containerClass));i&&(i.addEventListener("click",()=>{this.removeSelectedFacets()}),i.addEventListener("keyup",n=>{(n.code==="Space"||n.code==="Enter")&&this.removeSelectedFacets()}),e.appendChild(i))}}createSelectedFacetsComponent(e,t){if(typeof document<"u"){const s=this.config?.templates?.selectedFacetsTemplate?.template||w.facets.selectedFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=T.render(s,t);const i=a.querySelector("."+(this.config?.templates?.selectedFacetsTemplate?.containerClass||w.facets.selectedFacetsTemplate?.containerClass));i&&(i.addEventListener("click",()=>{this.unselectFacet(t)}),i.addEventListener("keyup",n=>{(n.code==="Space"||n.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||w.facets.filterByTemplate?.template,s=document?.createElement("div");s.innerHTML=T.render(t,{});const a=s.querySelector("."+(this.config?.templates?.filterByTemplate?.containerClass||w.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(){W.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(){W.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||w.facets.mainTemplateMobile?.template;if(this.dataLayer.renderingEngine===B.mustache){if(t.innerHTML=T.render(s,{...e,overlayOpened:this.overlayOpened}),this.searchFacetsMainContainer?.appendChild(t),this.config?.templates?.mainTemplateMobile)for(const c of this.config?.templates?.mainTemplateMobile?.closeOverlayTriggerClasses||[]){const l=t.querySelector("."+c);l&&(l.addEventListener("click",this.closeOverlay.bind(this)),l.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}else for(const c of w.facets.mainTemplateMobile.closeOverlayTriggerClasses){const l=t.querySelector("."+c);l&&(l.addEventListener("click",this.closeOverlay.bind(this)),l.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}const a=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.filterByContainerClass||w.facets.mainTemplateMobile.filterByContainerClass));a&&this.createFilterByComponent(a);const i=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.selectedFacetsContainerClass||w.facets.mainTemplateMobile.selectedFacetsContainerClass));i&&(this.createSelectedFacetsComponents(i),this.createClearFacetsComponents(i));const n=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.facetsContainerClass||w.facets.mainTemplateMobile.facetsContainerClass));if(n){n.innerHTML="";for(const c of e.facets)this.createFacetItem(c,n,!0)}}}}}class Sn{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 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||w.pagination.mainTemplate?.template;this.dataLayer.isInfiniteScroll&&(t=this.config?.templates?.infiniteScrollTemplate?.template||w.pagination.infiniteScrollTemplate?.template),this.dataLayer.renderingEngine===B.mustache&&(this.searchPaginationMainContainer.innerHTML=T.render(t,e),setTimeout(()=>{this.overridePaginationEvents()},0))}}class kn{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 s=document?.createElement("div"),a=this.config?.templates?.relatedSearch?.template||w.relatedSearches.relatedSearch.template;if(this.dataLayer.renderingEngine===B.mustache){s.innerHTML=T.render(a,e);const i=s.querySelector("."+(this.config.templates?.relatedSearch?.relatedSearchContainerClass||w.relatedSearches.relatedSearch.relatedSearchContainerClass));i&&(t.appendChild(i),i.addEventListener("click",()=>{this.executeSearch(e)}),i.addEventListener("keyup",n=>{(n.code==="Space"||n.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===B.mustache&&this.searchRelatedSearchesMainContainer){this.searchRelatedSearchesMainContainer.innerHTML="",this.searchRelatedSearchesMainContainer.innerHTML=T.render(t,e);const s=this.searchRelatedSearchesMainContainer?.querySelector(`.${this.relatedSearchesContainerClass}`);if(s)for(const a of e.relatedSearches)this.addRelatedSearchComponent(a,s)}}}class Tn{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===B.mustache&&(this.searchFeedbackMainContainer.innerHTML=T.render(t,e),setTimeout(()=>{this.attachClick()},0))}}class vn{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,s={...this.dataLayer.parsedData.data,locationEnabled:!!this.dataLayer.locationEnabled,hasInputValue:!1};if(this.dataLayer.setInputWidgetTemplateData(s),this.dataLayer.renderingEngine===B.mustache){const n=T.render(t,s);e.innerHTML=n,this.dataLayer.setInputTemplateRendered(!0)}const a=this.config.templates?.mainTemplate?.searchInputId||w.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===B.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 s=this.dataLayer.inputWidgetTemplateData;s&&this.dataLayer.setInputWidgetTemplateData({...s,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)),W.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,W.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 s=e[t];t===this.selectedAutosuggestItem?(s.classList.add("active"),W.setAccessibilityText(`Selected suggestion: ${s.innerText}`)):s.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)),W.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 s=this.config.templates?.autosuggestItemTemplate?.template||w.searchInput.autosuggestItemTemplate?.template;return t.innerHTML=T.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?W.setAccessibilityText("Suggestions are available. Use up and down arrows to navigate while focusing input. Use Escape key to escape out of the suggestions",2e3):W.setAccessibilityText("",0),this.autosuggestResults=i,this.dataLayer.setAutosuggestResults(i),i.numFound>0?i.suggestions.forEach(n=>{this.autosuggestContainer&&typeof document<"u"&&this.autosuggestContainer.appendChild(this.createAutosuggestItem(n))}):this.autosuggestContainer&&this.autosuggestContainer.classList.add("hidden")}}}}class An{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(()=>{W.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===B.mustache&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=T.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===B.mustache&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)W.setAccessibilityText("Search has no results"),this.renderNoResultsTemplate();else{W.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,s=e.map(a=>T.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||w.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||w.searchResults.mainTemplate?.template;this.dataLayer.renderingEngine===B.mustache&&(this.searchResultsMainContainer.innerHTML=T.render(e,{}),setTimeout(()=>{const t=this.config?.templates?.mainTemplate?.searchResultsContainerId?this.config?.templates?.mainTemplate?.searchResultsContainerId:w.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 En{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===B.mustache){this.searchSortingMainContainer.innerHTML=T.render(t,e),this.markOptionSelected();const s=document?.getElementById(this.selectId);s&&s.addEventListener("change",a=>{this.setOrderQuery(a.target.value)})}}}class In{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(){fe.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=Z?.mainTemplate?.template;if(this.mainTemplateOverride&&(s=this.mainTemplateOverride),this.isLightweight&&(s=Z.lightweightTemplate?.template,this.lightweightTemplateOverride&&(s=this.lightweightTemplateOverride)),this.mainContainer.innerHTML=T.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",n=this.mainContainer.querySelector(`[${i}="${a}"]`);(n instanceof HTMLInputElement||n instanceof HTMLButtonElement||n instanceof HTMLTextAreaElement||n instanceof HTMLAnchorElement)&&n.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=Z.mainTemplate?.modalContainerClass;return this.mainContainer?.querySelector(`.${e}`)||null}attachLightweightEvents(){const e=Z.lightweightTemplate?.thumbsUpButtonClass,t=Z.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(n=>{n.isSelected=n.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(n=>{n.isSelected=n.index===this.thumbsDownValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=i,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,W.setAccessibilityText("Please enter a valid email address.")),this.templateData.ratings.some(t=>t.isSelected)?this.templateData.errors.rating=!1:(this.templateData.errors.rating=!0,W.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&&(fe.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(),W.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,W.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(s=>{s.addEventListener("click",a=>{const i=a.target.value;this.templateData.ratings.forEach(n=>{n.isSelected=n.index+""===i}),this.templateData.errors.rating=!1,this.renderMainTemplate(this.generateTemplateData())})})}attachOpenModalEvent(){const e=Z.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=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),W.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),W.setAccessibilityText("Feedback form closed",1e3)}showCheckmarkAnimation(){const e=Z.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&(t.disabled=!0);const s=Z.mainTemplate?.checkmarkClass,a=this.mainContainer?.querySelector("."+s);a&&a.classList.remove("hidden");const i=Z.mainTemplate?.submitButtonTextClass,n=this.mainContainer?.querySelector("."+i);n&&n.classList.add("visibility"),setTimeout(()=>{a&&a.classList.add("hidden"),n&&n.classList.remove("visibility"),t&&(t.disabled=!1)},2e3)}destroy(){this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null)}}class jn{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 In({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,fe.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 t=e.target.getAttribute("href");fe.trackAnswerLinkClick({href:t,answer:this.dataLayer.parsedData.getAnswerData,...this.dataLayer.parsedData.trackingData}).then(()=>{window.open(t,"_blank")}).catch(()=>{window.open(t,"_blank")})}attachLinkTracking(){document.querySelectorAll(".searchstax-answer-link").forEach(e=>{e.getAttribute("listener")!=="true"&&(e.setAttribute("listener","true"),e.addEventListener("click",this.trackLinkClick.bind(this)))})}renderMainTemplate(e){const t=this.config?.templates?.main?.template||w.answer.main.template;this.dataLayer.renderingEngine===B.mustache?(!this.renderedWithShowMore||!e.answerLoading||this.clicked)&&(e.showMoreButtonVisible&&(this.renderedWithShowMore=!0),this.answerContainer.innerHTML=T.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 Xs{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,s={...this.dataLayer.parsedData.data};if(this.dataLayer.setLocationWidgetTemplateData(s),this.dataLayer.renderingEngine===B.mustache){const a=T.render(t,s);e.innerHTML=a;const i=this.config.templates?.mainTemplate?.locationInputId||w.location.mainTemplate.locationInputId,n=document?.querySelector(`#${i}`);if(n)this.locationInput=n,n.addEventListener("blur",this.blurEvent.bind(this)),n.addEventListener("focus",this.focusEvent.bind(this));else throw new Error("Input not found");const c=this.config.templates?.mainTemplate?.radiusInputId||w.location.mainTemplate.radiusInputId,l=document?.querySelector(`#${c}`);l instanceof HTMLSelectElement&&(this.radiusInput=l,l.addEventListener("change",this.radiusSelectChangeEvent.bind(this)));const h=this.config.templates?.mainTemplate?.currentLocationActionButtonId||w.location.mainTemplate.currentLocationActionButtonId,p=document?.querySelector(`#${h}`);p&&p.addEventListener("click",this.getCurrentLocation.bind(this))}}}setCurrentLocationFields(e){this.dataLayer.setLocationCoordinatesDecoded(e),this.dataLayer.setSearchLocation(this.dataLayer.searchLocationCoordinatesDecoded),this.dataLayer.renderingEngine===B.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 n=this.locationDecodeCoordinatesToAddress;n?n(a+"",i+"").then(c=>{this.setCurrentLocationFields(c.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(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===B.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 t=e.target.value;this.triggerGeocoder(t)}}class Dn{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=B.mustache;constructor(e=B.mustache){e&&(this.renderEngine=e)}setRenderingEngine(e=B.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&&fe.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){fe.attachAnalyticsScript(e)}initialize(e){if(this.dataLayer=new Bi("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 Wi({...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 qs(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 qs({})}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.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 t=(e.response?.docs??[]).map((a,i)=>({...a,position:i+1})),s=[];for(const a of t)s.push({relatedSearch:a.related_search,position:a.position});this.dataLayer.setSearchRelatedSearches(t),this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&s.length&&fe.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=gt.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){if(this.handleRouter(),!e)return;this.dataLayer.setItemsPerPage(parseInt(e.responseHeader.params.rows)),this.dataLayer.setModel(e.responseHeader.params.model);let t=gt.combineResultsWithMetadata(e),s=gt.extractFacets(e);if(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),this.firstRequest){const a=[];if(this.searchFacetsWidget.forEach(i=>{i.config.facetingType&&a.push(i.config.facetingType)}),!this.dataLayer.searchObject.facets.some(i=>i.type==="or")){const i=a.indexOf("or");i!==-1&&a.splice(i,1)}this.dataLayer.searchObject.facets.length>0&&this.searchHelper?.cacheFacets(void 0,a)}this.firstRequest=!1}parseAnswerResultsResponse(e){this.handleRouter(),e!==Ye.question&&e!==Ye.notQuestion&&(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setAnswerData(this.dataLayer.getAnswerData+e))}cacheFacets(e){this.searchHelper?.cacheFacets(e).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 vn({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 Xs({containerId:e,config:t,dataLayer:this.dataLayer}),t?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(t?.locationValuesOverride?.locationFilterDefaultValue)):this.dataLayer.$searchResultsMetadata.subscribeUntilHasValue(()=>{this.searchLocationWidget=new Xs({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 jn({containerId:e,config:t,dataLayer:this.dataLayer})}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new An({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 Sn({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper})}addSearchFeedbackWidget(e,t){this.searchFeedbackConfig=t,this.searchFeedbackWidget=new Tn({containerId:e,config:t,dataLayer:this.dataLayer,searchTrigger:this.executeSearch.bind(this)})}addSearchSortingWidget(e,t){this.searchSortingConfig=t,this.searchSortingWidget=new En({containerId:e,config:t,dataLayer:this.dataLayer})}addRelatedSearchesWidget(e,t){this.relatedSearchesConfig=t,this.relatedSearchesWidget=new kn({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 Cn({containerId:e,config:t,dataLayer:this.dataLayer})}addFacetsWidget(e,t){this.searchFacetsConfig=t,this.searchFacetsWidget.push(new xn({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper},this.cacheFacets.bind(this)))}executeSearch(e,t){const s={...this.dataLayer.searchObject};s.query=G.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&&fe.trackRelatedSearchClick({...this.dataLayer.parsedData.trackingData,relatedSearch:e,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}executeLinkClick(e){let t=gt.findResultByUniqueId(e,this.dataLayer.searchResults??[]);t&&(this.searchResultsConfig?.hooks?.afterLinkClick&&(t=this.searchResultsConfig.hooks.afterLinkClick(t)),t&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&fe.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())}}export{Dn as Searchstax};
|