@searchstax-inc/searchstudio-ux-js 4.2.2 → 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.
@@ -1,72 +1,73 @@
1
- var N=(i=>(i[i.mustache=0]="mustache",i[i.vue=1]="vue",i[i.react=2]="react",i[i.angular=3]="angular",i))(N||{});function Ut(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ae=Ut();function Ya(i){Ae=i}var Ge={exec:()=>null};function v(i,e=""){let t=typeof i=="string"?i:i.source;const s={replace:(a,r)=>{let n=typeof r=="string"?r:r.source;return n=n.replace(X.caret,"$1"),t=t.replace(a,n),s},getRegex:()=>new RegExp(t,e)};return s}var X={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:i=>new RegExp(`^( {0,3}${i})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}#`),htmlBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}<(?:[a-z].*>|!--)`,"i")},Zs=/^(?:[ \t]*(?:\n|$))+/,Xs=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ks=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ze=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ei=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Wt=/(?:[*+-]|\d{1,9}[.)])/,Ja=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ga=v(Ja).replace(/bull/g,Wt).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(),ti=v(Ja).replace(/bull/g,Wt).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(),Yt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ai=/^[^\n]+/,Jt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,si=v(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Jt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ii=v(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Wt).getRegex(),Mt="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",Gt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ri=v("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Gt).replace("tag",Mt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Za=v(Yt).replace("hr",Ze).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",Mt).getRegex(),ni=v(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Za).getRegex(),Zt={blockquote:ni,code:Xs,def:si,fences:Ks,heading:ei,hr:Ze,html:ri,lheading:Ga,list:ii,newline:Zs,paragraph:Za,table:Ge,text:ai},Xa=v("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ze).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",Mt).getRegex(),oi={...Zt,lheading:ti,table:Xa,paragraph:v(Yt).replace("hr",Ze).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Xa).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",Mt).getRegex()},ci={...Zt,html:v(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Gt).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:Ge,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:v(Yt).replace("hr",Ze).replace("heading",` *#{1,6} *[^
2
- ]`).replace("lheading",Ga).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},li=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,hi=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ka=/^( {2,}|\\)\n(?!\s*$)/,ui=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ct=/[\p{P}\p{S}]/u,Xt=/[\s\p{P}\p{S}]/u,es=/[^\s\p{P}\p{S}]/u,di=v(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Xt).getRegex(),ts=/(?!~)[\p{P}\p{S}]/u,gi=/(?!~)[\s\p{P}\p{S}]/u,pi=/(?:[^\s\p{P}\p{S}]|~)/u,mi=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,as=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,fi=v(as,"u").replace(/punct/g,Ct).getRegex(),Li=v(as,"u").replace(/punct/g,ts).getRegex(),ss="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",yi=v(ss,"gu").replace(/notPunctSpace/g,es).replace(/punctSpace/g,Xt).replace(/punct/g,Ct).getRegex(),wi=v(ss,"gu").replace(/notPunctSpace/g,pi).replace(/punctSpace/g,gi).replace(/punct/g,ts).getRegex(),Mi=v("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,es).replace(/punctSpace/g,Xt).replace(/punct/g,Ct).getRegex(),Ci=v(/\\(punct)/,"gu").replace(/punct/g,Ct).getRegex(),bi=v(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Si=v(Gt).replace("(?:-->|$)","-->").getRegex(),xi=v("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Si).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),bt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ki=v(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",bt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),is=v(/^!?\[(label)\]\[(ref)\]/).replace("label",bt).replace("ref",Jt).getRegex(),rs=v(/^!?\[(ref)\](?:\[\])?/).replace("ref",Jt).getRegex(),Ti=v("reflink|nolink(?!\\()","g").replace("reflink",is).replace("nolink",rs).getRegex(),Kt={_backpedal:Ge,anyPunctuation:Ci,autolink:bi,blockSkip:mi,br:Ka,code:hi,del:Ge,emStrongLDelim:fi,emStrongRDelimAst:yi,emStrongRDelimUnd:Mi,escape:li,link:ki,nolink:rs,punctuation:di,reflink:is,reflinkSearch:Ti,tag:xi,text:ui,url:Ge},Ai={...Kt,link:v(/^!?\[(label)\]\((.*?)\)/).replace("label",bt).getRegex(),reflink:v(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",bt).getRegex()},ea={...Kt,emStrongRDelimAst:wi,emStrongLDelim:Li,url:v(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},vi={...ea,br:v(Ka).replace("{2,}","*").getRegex(),text:v(ea.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},St={normal:Zt,gfm:oi,pedantic:ci},Xe={normal:Kt,gfm:ea,breaks:vi,pedantic:Ai},Ei={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ns=i=>Ei[i];function de(i,e){if(e){if(X.escapeTest.test(i))return i.replace(X.escapeReplace,ns)}else if(X.escapeTestNoEncode.test(i))return i.replace(X.escapeReplaceNoEncode,ns);return i}function os(i){try{i=encodeURI(i).replace(X.percentDecode,"%")}catch{return null}return i}function cs(i,e){const t=i.replace(X.findPipe,(r,n,o)=>{let l=!1,h=n;for(;--h>=0&&o[h]==="\\";)l=!l;return l?"|":" |"}),s=t.split(X.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(X.slashPipe,"|");return s}function Ke(i,e,t){const s=i.length;if(s===0)return"";let a=0;for(;a<s&&i.charAt(s-a-1)===e;)a++;return i.slice(0,s-a)}function Ii(i,e){if(i.indexOf(e[1])===-1)return-1;let t=0;for(let s=0;s<i.length;s++)if(i[s]==="\\")s++;else if(i[s]===e[0])t++;else if(i[s]===e[1]&&(t--,t<0))return s;return t>0?-2:-1}function ls(i,e,t,s,a){const r=e.href,n=e.title||null,o=i[1].replace(a.other.outputLinkReplace,"$1");s.state.inLink=!0;const l={type:i[0].charAt(0)==="!"?"image":"link",raw:t,href:r,title:n,text:o,tokens:s.inlineTokens(o)};return s.state.inLink=!1,l}function Di(i,e,t){const s=i.match(t.other.indentCodeCompensation);if(s===null)return e;const a=s[1];return e.split(`
3
- `).map(r=>{const n=r.match(t.other.beginningSpace);if(n===null)return r;const[o]=n;return o.length>=a.length?r.slice(a.length):r}).join(`
4
- `)}var xt=class{options;rules;lexer;constructor(i){this.options=i||Ae}space(i){const e=this.rules.block.newline.exec(i);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(i){const e=this.rules.block.code.exec(i);if(e){const t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Ke(t,`
5
- `)}}}fences(i){const e=this.rules.block.fences.exec(i);if(e){const t=e[0],s=Di(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(i){const e=this.rules.block.heading.exec(i);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){const s=Ke(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(i){const e=this.rules.block.hr.exec(i);if(e)return{type:"hr",raw:Ke(e[0],`
6
- `)}}blockquote(i){const e=this.rules.block.blockquote.exec(i);if(e){let t=Ke(e[0],`
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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},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 r=[];for(;t.length>0;){let n=!1;const o=[];let l;for(l=0;l<t.length;l++)if(this.rules.other.blockquoteStart.test(t[l]))o.push(t[l]),n=!0;else if(!n)o.push(t[l]);else break;t=t.slice(l);const h=o.join(`
9
- `),m=h.replace(this.rules.other.blockquoteSetextReplace,`
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
+ `),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
- ${m}`:m;const L=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(m,r,!0),this.lexer.state.top=L,t.length===0)break;const M=r.at(-1);if(M?.type==="code")break;if(M?.type==="blockquote"){const I=M,k=I.raw+`
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
- `),S=this.blockquote(k);r[r.length-1]=S,s=s.substring(0,s.length-I.raw.length)+S.raw,a=a.substring(0,a.length-I.text.length)+S.text;break}else if(M?.type==="list"){const I=M,k=I.raw+`
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
- `),S=this.list(k);r[r.length-1]=S,s=s.substring(0,s.length-M.raw.length)+S.raw,a=a.substring(0,a.length-I.raw.length)+S.raw,t=k.substring(r.at(-1).raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:s,tokens:r,text:a}}}list(i){let e=this.rules.block.list.exec(i);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 r=this.rules.other.listItemRegex(t);let n=!1;for(;i;){let l=!1,h="",m="";if(!(e=r.exec(i))||this.rules.block.hr.test(i))break;h=e[0],i=i.substring(h.length);let L=e[2].split(`
18
- `,1)[0].replace(this.rules.other.listReplaceTabs,g=>" ".repeat(3*g.length)),M=i.split(`
19
- `,1)[0],I=!L.trim(),k=0;if(this.options.pedantic?(k=2,m=L.trimStart()):I?k=e[1].length+1:(k=e[2].search(this.rules.other.nonSpaceChar),k=k>4?1:k,m=L.slice(k),k+=e[1].length),I&&this.rules.other.blankLine.test(M)&&(h+=M+`
20
- `,i=i.substring(M.length+1),l=!0),!l){const g=this.rules.other.nextBulletRegex(k),d=this.rules.other.hrRegex(k),y=this.rules.other.fencesBeginRegex(k),b=this.rules.other.headingBeginRegex(k),A=this.rules.other.htmlBeginRegex(k);for(;i;){const F=i.split(`
21
- `,1)[0];let oe;if(M=F,this.options.pedantic?(M=M.replace(this.rules.other.listReplaceNesting," "),oe=M):oe=M.replace(this.rules.other.tabCharGlobal," "),y.test(M)||b.test(M)||A.test(M)||g.test(M)||d.test(M))break;if(oe.search(this.rules.other.nonSpaceChar)>=k||!M.trim())m+=`
22
- `+oe.slice(k);else{if(I||L.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(L)||b.test(L)||d.test(L))break;m+=`
23
- `+M}!I&&!M.trim()&&(I=!0),h+=F+`
24
- `,i=i.substring(F.length+1),L=oe.slice(k)}}a.loose||(n?a.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(n=!0));let S=null,Q;this.options.gfm&&(S=this.rules.other.listIsTask.exec(m),S&&(Q=S[0]!=="[ ] ",m=m.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:h,task:!!S,checked:Q,loose:!1,text:m,tokens:[]}),a.raw+=h}const o=a.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.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"),m=h.length>0&&h.some(L=>this.rules.other.anyLine.test(L.raw));a.loose=m}if(a.loose)for(let l=0;l<a.items.length;l++)a.items[l].loose=!0;return a}}html(i){const e=this.rules.block.html.exec(i);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(i){const e=this.rules.block.def.exec(i);if(e){const t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),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(i){const e=this.rules.block.table.exec(i);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const t=cs(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
- `):[],r={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===s.length){for(const n of s)this.rules.other.tableAlignRight.test(n)?r.align.push("right"):this.rules.other.tableAlignCenter.test(n)?r.align.push("center"):this.rules.other.tableAlignLeft.test(n)?r.align.push("left"):r.align.push(null);for(let n=0;n<t.length;n++)r.header.push({text:t[n],tokens:this.lexer.inline(t[n]),header:!0,align:r.align[n]});for(const n of a)r.rows.push(cs(n,r.header.length).map((o,l)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:r.align[l]})));return r}}lheading(i){const e=this.rules.block.lheading.exec(i);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(i){const e=this.rules.block.paragraph.exec(i);if(e){const t=e[1].charAt(e[1].length-1)===`
26
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(i){const e=this.rules.block.text.exec(i);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(i){const e=this.rules.inline.escape.exec(i);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(i){const e=this.rules.inline.tag.exec(i);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(i){const e=this.rules.inline.link.exec(i);if(e){const t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;const r=Ke(t.slice(0,-1),"\\");if((t.length-r.length)%2===0)return}else{const r=Ii(e[2],"()");if(r===-2)return;if(r>-1){const n=(e[0].indexOf("!")===0?5:4)+e[1].length+r;e[2]=e[2].substring(0,r),e[0]=e[0].substring(0,n).trim(),e[3]=""}}let s=e[2],a="";if(this.options.pedantic){const r=this.rules.other.pedanticHrefTitle.exec(s);r&&(s=r[1],a=r[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)),ls(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(i,e){let t;if((t=this.rules.inline.reflink.exec(i))||(t=this.rules.inline.nolink.exec(i))){const s=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),a=e[s.toLowerCase()];if(!a){const r=t[0].charAt(0);return{type:"text",raw:r,text:r}}return ls(t,a,t[0],this.lexer,this.rules)}}emStrong(i,e,t=""){let s=this.rules.inline.emStrongLDelim.exec(i);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 r,n,o=a,l=0;const h=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*i.length+a);(s=h.exec(e))!=null;){if(r=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!r)continue;if(n=[...r].length,s[3]||s[4]){o+=n;continue}else if((s[5]||s[6])&&a%3&&!((a+n)%3)){l+=n;continue}if(o-=n,o>0)continue;n=Math.min(n,n+o+l);const m=[...s[0]][0].length,L=i.slice(0,a+s.index+m+n);if(Math.min(a,n)%2){const I=L.slice(1,-1);return{type:"em",raw:L,text:I,tokens:this.lexer.inlineTokens(I)}}const M=L.slice(2,-2);return{type:"strong",raw:L,text:M,tokens:this.lexer.inlineTokens(M)}}}}codespan(i){const e=this.rules.inline.code.exec(i);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(i){const e=this.rules.inline.br.exec(i);if(e)return{type:"br",raw:e[0]}}del(i){const e=this.rules.inline.del.exec(i);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(i){const e=this.rules.inline.autolink.exec(i);if(e){let t,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(i){let e;if(e=this.rules.inline.url.exec(i)){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(i){const e=this.rules.inline.text.exec(i);if(e){const t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},me=class ba{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ae,this.options.tokenizer=this.options.tokenizer||new xt,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:X,block:St.normal,inline:Xe.normal};this.options.pedantic?(t.block=St.pedantic,t.inline=Xe.pedantic):this.options.gfm&&(t.block=St.gfm,this.options.breaks?t.inline=Xe.breaks:t.inline=Xe.gfm),this.tokenizer.rules=t}static get rules(){return{block:St,inline:Xe}}static lex(e,t){return new ba(t).lex(e)}static lexInline(e,t){return new ba(t).inlineTokens(e)}lex(e){e=e.replace(X.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(X.tabCharGlobal," ").replace(X.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+=`
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 r=e;if(this.options.extensions?.startBlock){let n=1/0;const o=e.slice(1);let l;this.options.extensions.startBlock.forEach(h=>{l=h.call({lexer:this},o),typeof l=="number"&&l>=0&&(n=Math.min(n,l))}),n<1/0&&n>=0&&(r=e.substring(0,n+1))}if(this.state.top&&(a=this.tokenizer.paragraph(r))){const n=t.at(-1);s&&n?.type==="paragraph"?(n.raw+=`
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=r.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+=`
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 o=Object.keys(this.tokens.links);if(o.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)o.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 r=!1,n="";for(;e;){r||(n=""),r=!1;let o;if(this.options.extensions?.inline?.some(h=>(o=h.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);const h=t.at(-1);o.type==="text"&&h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,s,n)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let l=e;if(this.options.extensions?.startInline){let h=1/0;const m=e.slice(1);let L;this.options.extensions.startInline.forEach(M=>{L=M.call({lexer:this},m),typeof L=="number"&&L>=0&&(h=Math.min(h,L))}),h<1/0&&h>=0&&(l=e.substring(0,h+1))}if(o=this.tokenizer.inlineText(l)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(n=o.raw.slice(-1)),r=!0;const h=t.at(-1);h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(e){const h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return t}},kt=class{options;parser;constructor(i){this.options=i||Ae}space(i){return""}code({text:i,lang:e,escaped:t}){const s=(e||"").match(X.notSpaceStart)?.[0],a=i.replace(X.endingNewline,"")+`
37
- `;return s?'<pre><code class="language-'+de(s)+'">'+(t?a:de(a,!0))+`</code></pre>
38
- `:"<pre><code>"+(t?a:de(a,!0))+`</code></pre>
39
- `}blockquote({tokens:i}){return`<blockquote>
40
- ${this.parser.parse(i)}</blockquote>
41
- `}html({text:i}){return i}heading({tokens:i,depth:e}){return`<h${e}>${this.parser.parseInline(i)}</h${e}>
42
- `}hr(i){return`<hr>
43
- `}list(i){const e=i.ordered,t=i.start;let s="";for(let n=0;n<i.items.length;n++){const o=i.items[n];s+=this.listitem(o)}const a=e?"ol":"ul",r=e&&t!==1?' start="'+t+'"':"";return"<"+a+r+`>
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(i){let e="";if(i.task){const t=this.checkbox({checked:!!i.checked});i.loose?i.tokens[0]?.type==="paragraph"?(i.tokens[0].text=t+" "+i.tokens[0].text,i.tokens[0].tokens&&i.tokens[0].tokens.length>0&&i.tokens[0].tokens[0].type==="text"&&(i.tokens[0].tokens[0].text=t+" "+de(i.tokens[0].tokens[0].text),i.tokens[0].tokens[0].escaped=!0)):i.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:!0}):e+=t+" "}return e+=this.parser.parse(i.tokens,!!i.loose),`<li>${e}</li>
46
- `}checkbox({checked:i}){return"<input "+(i?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:i}){return`<p>${this.parser.parseInline(i)}</p>
47
- `}table(i){let e="",t="";for(let a=0;a<i.header.length;a++)t+=this.tablecell(i.header[a]);e+=this.tablerow({text:t});let s="";for(let a=0;a<i.rows.length;a++){const r=i.rows[a];t="";for(let n=0;n<r.length;n++)t+=this.tablecell(r[n]);s+=this.tablerow({text:t})}return s&&(s=`<tbody>${s}</tbody>`),`<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:i}){return`<tr>
52
- ${i}</tr>
53
- `}tablecell(i){const e=this.parser.parseInline(i.tokens),t=i.header?"th":"td";return(i.align?`<${t} align="${i.align}">`:`<${t}>`)+e+`</${t}>
54
- `}strong({tokens:i}){return`<strong>${this.parser.parseInline(i)}</strong>`}em({tokens:i}){return`<em>${this.parser.parseInline(i)}</em>`}codespan({text:i}){return`<code>${de(i,!0)}</code>`}br(i){return"<br>"}del({tokens:i}){return`<del>${this.parser.parseInline(i)}</del>`}link({href:i,title:e,tokens:t}){const s=this.parser.parseInline(t),a=os(i);if(a===null)return s;i=a;let r='<a href="'+i+'"';return e&&(r+=' title="'+de(e)+'"'),r+=">"+s+"</a>",r}image({href:i,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));const a=os(i);if(a===null)return de(t);i=a;let r=`<img src="${i}" alt="${t}"`;return e&&(r+=` title="${de(e)}"`),r+=">",r}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:de(i.text)}},ta=class{strong({text:i}){return i}em({text:i}){return i}codespan({text:i}){return i}del({text:i}){return i}html({text:i}){return i}text({text:i}){return i}link({text:i}){return""+i}image({text:i}){return""+i}br(){return""}},fe=class Sa{options;renderer;textRenderer;constructor(e){this.options=e||Ae,this.options.renderer=this.options.renderer||new kt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ta}static parse(e,t){return new Sa(t).parse(e)}static parseInline(e,t){return new Sa(t).parseInline(e)}parse(e,t=!0){let s="";for(let a=0;a<e.length;a++){const r=e[a];if(this.options.extensions?.renderers?.[r.type]){const o=r,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){s+=l||"";continue}}const n=r;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 o=n,l=this.renderer.text(o);for(;a+1<e.length&&e[a+1].type==="text";)o=e[++a],l+=`
55
- `+this.renderer.text(o);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 o='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return s}parseInline(e,t=this.renderer){let s="";for(let a=0;a<e.length;a++){const r=e[a];if(this.options.extensions?.renderers?.[r.type]){const o=this.options.extensions.renderers[r.type].call({parser:this},r);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){s+=o||"";continue}}const n=r;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 o='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return s}},Tt=class{options;block;constructor(i){this.options=i||Ae}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(i){return i}postprocess(i){return i}processAllTokens(i){return i}provideLexer(){return this.block?me.lex:me.lexInline}provideParser(){return this.block?fe.parse:fe.parseInline}},ji=class{defaults=Ut();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=fe;Renderer=kt;TextRenderer=ta;Lexer=me;Tokenizer=xt;Hooks=Tt;constructor(...i){this.use(...i)}walkTokens(i,e){let t=[];for(const s of i)switch(t=t.concat(e.call(this,s)),s.type){case"table":{const a=s;for(const r of a.header)t=t.concat(this.walkTokens(r.tokens,e));for(const r of a.rows)for(const n of r)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(r=>{const n=a[r].flat(1/0);t=t.concat(this.walkTokens(n,e))}):a.tokens&&(t=t.concat(this.walkTokens(a.tokens,e)))}}return t}use(...i){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return i.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 r=e.renderers[a.name];r?e.renderers[a.name]=function(...n){let o=a.renderer.apply(this,n);return o===!1&&(o=r.apply(this,n)),o}: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 r=e[a.level];r?r.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 kt(this.defaults);for(const r in t.renderer){if(!(r in a))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;const n=r,o=t.renderer[n],l=a[n];a[n]=(...h)=>{let m=o.apply(a,h);return m===!1&&(m=l.apply(a,h)),m||""}}s.renderer=a}if(t.tokenizer){const a=this.defaults.tokenizer||new xt(this.defaults);for(const r in t.tokenizer){if(!(r in a))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;const n=r,o=t.tokenizer[n],l=a[n];a[n]=(...h)=>{let m=o.apply(a,h);return m===!1&&(m=l.apply(a,h)),m}}s.tokenizer=a}if(t.hooks){const a=this.defaults.hooks||new Tt;for(const r in t.hooks){if(!(r in a))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;const n=r,o=t.hooks[n],l=a[n];Tt.passThroughHooks.has(r)?a[n]=h=>{if(this.defaults.async)return Promise.resolve(o.call(a,h)).then(L=>l.call(a,L));const m=o.call(a,h);return l.call(a,m)}:a[n]=(...h)=>{let m=o.apply(a,h);return m===!1&&(m=l.apply(a,h)),m}}s.hooks=a}if(t.walkTokens){const a=this.defaults.walkTokens,r=t.walkTokens;s.walkTokens=function(n){let o=[];return o.push(r.call(this,n)),a&&(o=o.concat(a.call(this,n))),o}}this.defaults={...this.defaults,...s}}),this}setOptions(i){return this.defaults={...this.defaults,...i},this}lexer(i,e){return me.lex(i,e??this.defaults)}parser(i,e){return fe.parse(i,e??this.defaults)}parseMarkdown(i){return(e,t)=>{const s={...t},a={...this.defaults,...s},r=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&s.async===!1)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return r(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=i);const n=a.hooks?a.hooks.provideLexer():i?me.lex:me.lexInline,o=a.hooks?a.hooks.provideParser():i?fe.parse:fe.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=>o(l,a)).then(l=>a.hooks?a.hooks.postprocess(l):l).catch(r);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=o(l,a);return a.hooks&&(h=a.hooks.postprocess(h)),h}catch(l){return r(l)}}}onError(i,e){return t=>{if(t.message+=`
56
- Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An error occurred:</p><pre>"+de(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},ve=new ji;function E(i,e){return ve.parse(i,e)}E.options=E.setOptions=function(i){return ve.setOptions(i),E.defaults=ve.defaults,Ya(E.defaults),E},E.getDefaults=Ut,E.defaults=Ae,E.use=function(...i){return ve.use(...i),E.defaults=ve.defaults,Ya(E.defaults),E},E.walkTokens=function(i,e){return ve.walkTokens(i,e)},E.parseInline=ve.parseInline,E.Parser=fe,E.parser=fe.parse,E.Renderer=kt,E.TextRenderer=ta,E.Lexer=me,E.lexer=me.lex,E.Tokenizer=xt,E.Hooks=Tt,E.parse=E,E.options,E.setOptions,E.use,E.walkTokens,E.parseInline,fe.parse,me.lex;const{entries:hs,setPrototypeOf:us,isFrozen:Ri,getPrototypeOf:Ni,getOwnPropertyDescriptor:Oi}=Object;let{freeze:K,seal:re,create:Oe}=Object,{apply:aa,construct:sa}=typeof Reflect<"u"&&Reflect;K||(K=function(i){return i}),re||(re=function(i){return i}),aa||(aa=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)}),sa||(sa=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 et=z(Array.prototype.forEach),Pi=z(Array.prototype.lastIndexOf),ds=z(Array.prototype.pop),tt=z(Array.prototype.push),Fi=z(Array.prototype.splice),ee=Array.isArray,at=z(String.prototype.toLowerCase),ia=z(String.prototype.toString),gs=z(String.prototype.match),Pe=z(String.prototype.replace),ps=z(String.prototype.indexOf),zi=z(String.prototype.trim),$i=z(Number.prototype.toString),_i=z(Boolean.prototype.toString),ms=typeof BigInt>"u"?null:z(BigInt.prototype.toString),fs=typeof Symbol>"u"?null:z(Symbol.prototype.toString),O=z(Object.prototype.hasOwnProperty),st=z(Object.prototype.toString),G=z(RegExp.prototype.test),At=Vi(TypeError);function z(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 aa(i,e,s)}}function Vi(i){return function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return sa(i,t)}}function C(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:at;if(us&&us(i,null),!ee(e))return i;let s=e.length;for(;s--;){let a=e[s];if(typeof a=="string"){const r=t(a);r!==a&&(Ri(e)||(e[s]=r),a=r)}i[a]=!0}return i}function Qi(i){for(let e=0;e<i.length;e++)O(i,e)||(i[e]=null);return i}function ae(i){const e=Oe(null);for(const[t,s]of hs(i))O(i,t)&&(ee(s)?e[t]=Qi(s):s&&typeof s=="object"&&s.constructor===Object?e[t]=ae(s):e[t]=s);return e}function Bi(i){switch(typeof i){case"string":return i;case"number":return $i(i);case"boolean":return _i(i);case"bigint":return ms?ms(i):"0";case"symbol":return fs?fs(i):"Symbol()";case"undefined":return st(i);case"function":case"object":{if(i===null)return st(i);const e=i,t=Fe(e,"toString");if(typeof t=="function"){const s=t(e);return typeof s=="string"?s:st(s)}return st(i)}default:return st(i)}}function Fe(i,e){for(;i!==null;){const s=Oi(i,e);if(s){if(s.get)return z(s.get);if(typeof s.value=="function")return z(s.value)}i=Ni(i)}function t(){return null}return t}function Hi(i){try{return G(i,""),!0}catch{return!1}}const Ls=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"]),ra=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"]),na=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"]),qi=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"]),oa=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"]),Ui=K(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ys=K(["#text"]),ws=K(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ca=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"]),Ms=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"]),vt=K(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Wi=re(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Yi=re(/<%[\w\W]*|[\w\W]*%>/gm),Ji=re(/\$\{[\w\W]*/gm),Gi=re(/^data-[\-\w.\u00B7-\uFFFF]+$/),Zi=re(/^aria-[\-\w]+$/),Cs=re(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Xi=re(/^(?:\w+script|data):/i),Ki=re(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),bs=re(/^html$/i),er=re(/^[a-z][.\w]*(-[.\w]+)+$/i);var Ss=Object.freeze({__proto__:null,ARIA_ATTR:Zi,ATTR_WHITESPACE:Ki,CUSTOM_ELEMENT:er,DATA_ATTR:Gi,DOCTYPE_NAME:bs,ERB_EXPR:Yi,IS_ALLOWED_URI:Cs,IS_SCRIPT_OR_DATA:Xi,MUSTACHE_EXPR:Wi,TMPLIT_EXPR:Ji});const it={element:1,text:3,progressingInstruction:7,comment:8,document:9},tr=function(){return typeof window>"u"?null:window},ar=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}},xs=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ks(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:tr();const e=c=>ks(c);if(e.version="3.4.2",e.removed=[],!i||!i.document||i.document.nodeType!==it.document||!i.Element)return e.isSupported=!1,e;let{document:t}=i;const s=t,a=s.currentScript,{DocumentFragment:r,HTMLTemplateElement:n,Node:o,Element:l,NodeFilter:h,NamedNodeMap:m=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:L,DOMParser:M,trustedTypes:I}=i,k=l.prototype,S=Fe(k,"cloneNode"),Q=Fe(k,"remove"),g=Fe(k,"nextSibling"),d=Fe(k,"childNodes"),y=Fe(k,"parentNode");if(typeof n=="function"){const c=t.createElement("template");c.content&&c.content.ownerDocument&&(t=c.content.ownerDocument)}let b,A="";const{implementation:F,createNodeIterator:oe,createDocumentFragment:ie,getElementsByTagName:jt}=t,{importNode:we}=s;let B=xs();e.isSupported=typeof hs=="function"&&typeof y=="function"&&F&&F.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:dt,ERB_EXPR:gt,TMPLIT_EXPR:pt,DATA_ATTR:$s,ARIA_ATTR:_s,IS_SCRIPT_OR_DATA:Vs,ATTR_WHITESPACE:xa,CUSTOM_ELEMENT:Qs}=Ss;let{IS_ALLOWED_URI:ka}=Ss,H=null;const Ta=C({},[...Ls,...ra,...na,...oa,...ys]);let Y=null;const Aa=C({},[...ws,...ca,...Ms,...vt]);let P=Object.seal(Oe(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}})),Ue=null,mt=null;const Me=Object.seal(Oe(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let va=!0,Rt=!0,Ea=!1,Ia=!0,Se=!1,We=!0,xe=!1,Nt=!1,Ot=!1,De=!1,ft=!1,Lt=!1,Da=!0,ja=!1;const Ra="user-content-";let Pt=!0,Ye=!1,je={},le=null;const Ft=C({},["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 Na=null;const Oa=C({},["audio","video","img","source","image","track"]);let zt=null;const Pa=C({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),yt="http://www.w3.org/1998/Math/MathML",wt="http://www.w3.org/2000/svg",he="http://www.w3.org/1999/xhtml";let Re=he,$t=!1,_t=null;const Bs=C({},[yt,wt,he],ia);let Vt=C({},["mi","mo","mn","ms","mtext"]),Qt=C({},["annotation-xml"]);const Hs=C({},["title","style","font","a","script"]);let Je=null;const qs=["application/xhtml+xml","text/html"],Us="text/html";let $=null,Ne=null;const Ws=t.createElement("form"),Fa=function(c){return c instanceof RegExp||c instanceof Function},Bt=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ne&&Ne===c)return;(!c||typeof c!="object")&&(c={}),c=ae(c),Je=qs.indexOf(c.PARSER_MEDIA_TYPE)===-1?Us:c.PARSER_MEDIA_TYPE,$=Je==="application/xhtml+xml"?ia:at,H=O(c,"ALLOWED_TAGS")&&ee(c.ALLOWED_TAGS)?C({},c.ALLOWED_TAGS,$):Ta,Y=O(c,"ALLOWED_ATTR")&&ee(c.ALLOWED_ATTR)?C({},c.ALLOWED_ATTR,$):Aa,_t=O(c,"ALLOWED_NAMESPACES")&&ee(c.ALLOWED_NAMESPACES)?C({},c.ALLOWED_NAMESPACES,ia):Bs,zt=O(c,"ADD_URI_SAFE_ATTR")&&ee(c.ADD_URI_SAFE_ATTR)?C(ae(Pa),c.ADD_URI_SAFE_ATTR,$):Pa,Na=O(c,"ADD_DATA_URI_TAGS")&&ee(c.ADD_DATA_URI_TAGS)?C(ae(Oa),c.ADD_DATA_URI_TAGS,$):Oa,le=O(c,"FORBID_CONTENTS")&&ee(c.FORBID_CONTENTS)?C({},c.FORBID_CONTENTS,$):Ft,Ue=O(c,"FORBID_TAGS")&&ee(c.FORBID_TAGS)?C({},c.FORBID_TAGS,$):ae({}),mt=O(c,"FORBID_ATTR")&&ee(c.FORBID_ATTR)?C({},c.FORBID_ATTR,$):ae({}),je=O(c,"USE_PROFILES")?c.USE_PROFILES&&typeof c.USE_PROFILES=="object"?ae(c.USE_PROFILES):c.USE_PROFILES:!1,va=c.ALLOW_ARIA_ATTR!==!1,Rt=c.ALLOW_DATA_ATTR!==!1,Ea=c.ALLOW_UNKNOWN_PROTOCOLS||!1,Ia=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Se=c.SAFE_FOR_TEMPLATES||!1,We=c.SAFE_FOR_XML!==!1,xe=c.WHOLE_DOCUMENT||!1,De=c.RETURN_DOM||!1,ft=c.RETURN_DOM_FRAGMENT||!1,Lt=c.RETURN_TRUSTED_TYPE||!1,Ot=c.FORCE_BODY||!1,Da=c.SANITIZE_DOM!==!1,ja=c.SANITIZE_NAMED_PROPS||!1,Pt=c.KEEP_CONTENT!==!1,Ye=c.IN_PLACE||!1,ka=Hi(c.ALLOWED_URI_REGEXP)?c.ALLOWED_URI_REGEXP:Cs,Re=typeof c.NAMESPACE=="string"?c.NAMESPACE:he,Vt=O(c,"MATHML_TEXT_INTEGRATION_POINTS")&&c.MATHML_TEXT_INTEGRATION_POINTS&&typeof c.MATHML_TEXT_INTEGRATION_POINTS=="object"?ae(c.MATHML_TEXT_INTEGRATION_POINTS):C({},["mi","mo","mn","ms","mtext"]),Qt=O(c,"HTML_INTEGRATION_POINTS")&&c.HTML_INTEGRATION_POINTS&&typeof c.HTML_INTEGRATION_POINTS=="object"?ae(c.HTML_INTEGRATION_POINTS):C({},["annotation-xml"]);const u=O(c,"CUSTOM_ELEMENT_HANDLING")&&c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING=="object"?ae(c.CUSTOM_ELEMENT_HANDLING):Oe(null);if(P=Oe(null),O(u,"tagNameCheck")&&Fa(u.tagNameCheck)&&(P.tagNameCheck=u.tagNameCheck),O(u,"attributeNameCheck")&&Fa(u.attributeNameCheck)&&(P.attributeNameCheck=u.attributeNameCheck),O(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(P.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),Se&&(Rt=!1),ft&&(De=!0),je&&(H=C({},ys),Y=Oe(null),je.html===!0&&(C(H,Ls),C(Y,ws)),je.svg===!0&&(C(H,ra),C(Y,ca),C(Y,vt)),je.svgFilters===!0&&(C(H,na),C(Y,ca),C(Y,vt)),je.mathMl===!0&&(C(H,oa),C(Y,Ms),C(Y,vt))),Me.tagCheck=null,Me.attributeCheck=null,O(c,"ADD_TAGS")&&(typeof c.ADD_TAGS=="function"?Me.tagCheck=c.ADD_TAGS:ee(c.ADD_TAGS)&&(H===Ta&&(H=ae(H)),C(H,c.ADD_TAGS,$))),O(c,"ADD_ATTR")&&(typeof c.ADD_ATTR=="function"?Me.attributeCheck=c.ADD_ATTR:ee(c.ADD_ATTR)&&(Y===Aa&&(Y=ae(Y)),C(Y,c.ADD_ATTR,$))),O(c,"ADD_URI_SAFE_ATTR")&&ee(c.ADD_URI_SAFE_ATTR)&&C(zt,c.ADD_URI_SAFE_ATTR,$),O(c,"FORBID_CONTENTS")&&ee(c.FORBID_CONTENTS)&&(le===Ft&&(le=ae(le)),C(le,c.FORBID_CONTENTS,$)),O(c,"ADD_FORBID_CONTENTS")&&ee(c.ADD_FORBID_CONTENTS)&&(le===Ft&&(le=ae(le)),C(le,c.ADD_FORBID_CONTENTS,$)),Pt&&(H["#text"]=!0),xe&&C(H,["html","head","body"]),H.table&&(C(H,["tbody"]),delete Ue.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw At('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw At('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');b=c.TRUSTED_TYPES_POLICY,A=b.createHTML("")}else b===void 0&&(b=ar(I,a)),b!==null&&typeof A=="string"&&(A=b.createHTML(""));K&&K(c),Ne=c},za=C({},[...ra,...na,...qi]),$a=C({},[...oa,...Ui]),Ys=function(c){let u=y(c);(!u||!u.tagName)&&(u={namespaceURI:Re,tagName:"template"});const p=at(c.tagName),D=at(u.tagName);return _t[c.namespaceURI]?c.namespaceURI===wt?u.namespaceURI===he?p==="svg":u.namespaceURI===yt?p==="svg"&&(D==="annotation-xml"||Vt[D]):!!za[p]:c.namespaceURI===yt?u.namespaceURI===he?p==="math":u.namespaceURI===wt?p==="math"&&Qt[D]:!!$a[p]:c.namespaceURI===he?u.namespaceURI===wt&&!Qt[D]||u.namespaceURI===yt&&!Vt[D]?!1:!$a[p]&&(Hs[p]||!za[p]):!!(Je==="application/xhtml+xml"&&_t[c.namespaceURI]):!1},ke=function(c){tt(e.removed,{element:c});try{y(c).removeChild(c)}catch{Q(c)}},Te=function(c,u){try{tt(e.removed,{attribute:u.getAttributeNode(c),from:u})}catch{tt(e.removed,{attribute:null,from:u})}if(u.removeAttribute(c),c==="is")if(De||ft)try{ke(u)}catch{}else try{u.setAttribute(c,"")}catch{}},_a=function(c){let u=null,p=null;if(Ot)c="<remove></remove>"+c;else{const R=gs(c,/^[\r\n\t ]+/);p=R&&R[0]}Je==="application/xhtml+xml"&&Re===he&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const D=b?b.createHTML(c):c;if(Re===he)try{u=new M().parseFromString(D,Je)}catch{}if(!u||!u.documentElement){u=F.createDocument(Re,"template",null);try{u.documentElement.innerHTML=$t?A:D}catch{}}const J=u.body||u.documentElement;return c&&p&&J.insertBefore(t.createTextNode(p),J.childNodes[0]||null),Re===he?jt.call(u,xe?"html":"body")[0]:xe?u.documentElement:J},Va=function(c){return oe.call(c.ownerDocument||c,c,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},Ht=function(c){return c instanceof L&&(typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||!(c.attributes instanceof m)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function")},qt=function(c){return typeof o=="function"&&c instanceof o};function ge(c,u,p){et(c,D=>{D.call(e,u,p,Ne)})}const Qa=function(c){let u=null;if(ge(B.beforeSanitizeElements,c,null),Ht(c))return ke(c),!0;const p=$(c.nodeName);if(ge(B.uponSanitizeElement,c,{tagName:p,allowedTags:H}),We&&c.hasChildNodes()&&!qt(c.firstElementChild)&&G(/<[/\w!]/g,c.innerHTML)&&G(/<[/\w!]/g,c.textContent)||We&&c.namespaceURI===he&&p==="style"&&qt(c.firstElementChild)||c.nodeType===it.progressingInstruction||We&&c.nodeType===it.comment&&G(/<[/\w]/g,c.data))return ke(c),!0;if(Ue[p]||!(Me.tagCheck instanceof Function&&Me.tagCheck(p))&&!H[p]){if(!Ue[p]&&Ha(p)&&(P.tagNameCheck instanceof RegExp&&G(P.tagNameCheck,p)||P.tagNameCheck instanceof Function&&P.tagNameCheck(p)))return!1;if(Pt&&!le[p]){const D=y(c)||c.parentNode,J=d(c)||c.childNodes;if(J&&D){const R=J.length;for(let pe=R-1;pe>=0;--pe){const ue=S(J[pe],!0);D.insertBefore(ue,g(c))}}}return ke(c),!0}return c instanceof l&&!Ys(c)||(p==="noscript"||p==="noembed"||p==="noframes")&&G(/<\/no(script|embed|frames)/i,c.innerHTML)?(ke(c),!0):(Se&&c.nodeType===it.text&&(u=c.textContent,et([dt,gt,pt],D=>{u=Pe(u,D," ")}),c.textContent!==u&&(tt(e.removed,{element:c.cloneNode()}),c.textContent=u)),ge(B.afterSanitizeElements,c,null),!1)},Ba=function(c,u,p){if(mt[u]||Da&&(u==="id"||u==="name")&&(p in t||p in Ws))return!1;const D=Y[u]||Me.attributeCheck instanceof Function&&Me.attributeCheck(u,c);if(!(Rt&&!mt[u]&&G($s,u))&&!(va&&G(_s,u))){if(!D||mt[u]){if(!(Ha(c)&&(P.tagNameCheck instanceof RegExp&&G(P.tagNameCheck,c)||P.tagNameCheck instanceof Function&&P.tagNameCheck(c))&&(P.attributeNameCheck instanceof RegExp&&G(P.attributeNameCheck,u)||P.attributeNameCheck instanceof Function&&P.attributeNameCheck(u,c))||u==="is"&&P.allowCustomizedBuiltInElements&&(P.tagNameCheck instanceof RegExp&&G(P.tagNameCheck,p)||P.tagNameCheck instanceof Function&&P.tagNameCheck(p))))return!1}else if(!zt[u]&&!G(ka,Pe(p,xa,""))&&!((u==="src"||u==="xlink:href"||u==="href")&&c!=="script"&&ps(p,"data:")===0&&Na[c])&&!(Ea&&!G(Vs,Pe(p,xa,"")))&&p)return!1}return!0},Js=C({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ha=function(c){return!Js[at(c)]&&G(Qs,c)},qa=function(c){ge(B.beforeSanitizeAttributes,c,null);const{attributes:u}=c;if(!u||Ht(c))return;const p={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let D=u.length;for(;D--;){const J=u[D],{name:R,namespaceURI:pe,value:ue}=J,Z=$(R),Ce=ue;let q=R==="value"?Ce:zi(Ce);if(p.attrName=Z,p.attrValue=q,p.keepAttr=!0,p.forceKeepAttr=void 0,ge(B.uponSanitizeAttribute,c,p),q=p.attrValue,ja&&(Z==="id"||Z==="name")&&ps(q,Ra)!==0&&(Te(R,c),q=Ra+q),We&&G(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,q)){Te(R,c);continue}if(Z==="attributename"&&gs(q,"href")){Te(R,c);continue}if(p.forceKeepAttr)continue;if(!p.keepAttr){Te(R,c);continue}if(!Ia&&G(/\/>/i,q)){Te(R,c);continue}Se&&et([dt,gt,pt],Gs=>{q=Pe(q,Gs," ")});const Wa=$(c.nodeName);if(!Ba(Wa,Z,q)){Te(R,c);continue}if(b&&typeof I=="object"&&typeof I.getAttributeType=="function"&&!pe)switch(I.getAttributeType(Wa,Z)){case"TrustedHTML":{q=b.createHTML(q);break}case"TrustedScriptURL":{q=b.createScriptURL(q);break}}if(q!==Ce)try{pe?c.setAttributeNS(pe,R,q):c.setAttribute(R,q),Ht(c)?ke(c):ds(e.removed)}catch{Te(R,c)}}ge(B.afterSanitizeAttributes,c,null)},Ua=function(c){let u=null;const p=Va(c);for(ge(B.beforeSanitizeShadowDOM,c,null);u=p.nextNode();)ge(B.uponSanitizeShadowNode,u,null),Qa(u),qa(u),u.content instanceof r&&Ua(u.content);ge(B.afterSanitizeShadowDOM,c,null)};return e.sanitize=function(c){let u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},p=null,D=null,J=null,R=null;if($t=!c,$t&&(c="<!-->"),typeof c!="string"&&!qt(c)&&(c=Bi(c),typeof c!="string"))throw At("dirty is not a string, aborting");if(!e.isSupported)return c;if(Nt||Bt(u),e.removed=[],typeof c=="string"&&(Ye=!1),Ye){const Z=c.nodeName;if(typeof Z=="string"){const Ce=$(Z);if(!H[Ce]||Ue[Ce])throw At("root node is forbidden and cannot be sanitized in-place")}}else if(c instanceof o)p=_a("<!---->"),D=p.ownerDocument.importNode(c,!0),D.nodeType===it.element&&D.nodeName==="BODY"||D.nodeName==="HTML"?p=D:p.appendChild(D);else{if(!De&&!Se&&!xe&&c.indexOf("<")===-1)return b&&Lt?b.createHTML(c):c;if(p=_a(c),!p)return De?null:Lt?A:""}p&&Ot&&ke(p.firstChild);const pe=Va(Ye?c:p);for(;J=pe.nextNode();)Qa(J),qa(J),J.content instanceof r&&Ua(J.content);if(Ye)return c;if(De){if(Se){p.normalize();let Z=p.innerHTML;et([dt,gt,pt],Ce=>{Z=Pe(Z,Ce," ")}),p.innerHTML=Z}if(ft)for(R=ie.call(p.ownerDocument);p.firstChild;)R.appendChild(p.firstChild);else R=p;return(Y.shadowroot||Y.shadowrootmode)&&(R=we.call(s,R,!0)),R}let ue=xe?p.outerHTML:p.innerHTML;return xe&&H["!doctype"]&&p.ownerDocument&&p.ownerDocument.doctype&&p.ownerDocument.doctype.name&&G(bs,p.ownerDocument.doctype.name)&&(ue="<!DOCTYPE "+p.ownerDocument.doctype.name+`>
57
- `+ue),Se&&et([dt,gt,pt],Z=>{ue=Pe(ue,Z," ")}),b&&Lt?b.createHTML(ue):ue},e.setConfig=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bt(c),Nt=!0},e.clearConfig=function(){Ne=null,Nt=!1},e.isValidAttribute=function(c,u,p){Ne||Bt({});const D=$(c),J=$(u);return Ba(D,J,p)},e.addHook=function(c,u){typeof u=="function"&&tt(B[c],u)},e.removeHook=function(c,u){if(u!==void 0){const p=Pi(B[c],u);return p===-1?void 0:Fi(B[c],p,1)[0]}return ds(B[c])},e.removeHooks=function(c){B[c]=[]},e.removeAllHooks=function(){B=xs()},e}var Ts=ks();class sr{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 Ts.sanitize(E.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 Ts.sanitize(E.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(o=>o.type==="range"?!1:o.type==="checkbox"?'"'+o.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 ne{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],o=t[r],l=this.isObject(n)&&this.isObject(o);if(l&&!this.deepEqual(n,o)||!l&&n!==o)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class w{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=o=>{o===t&&(e(o),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 o=a[n];o!==!0&&(r+="="+o)}typeof document<"u"&&(document.cookie=r)}}class U{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 ir{$searchTermChange=new w("");$searchLocationChange=new w("");$searchLocationCoordinatesDecoded=new w("");$searchLatChange=new w("");$searchLongChange=new w("");$searchRadiusChange=new w(void 0);$loadingChange=new w(!1);$locationError=new w(!1);$searchResults=new w(null);$searchResultsMetadata=new w(null);$searchAutosuggest=new w(null);$searchFacets=new w(null);$searchFacetsCached=new w(null);$searchFacetsCachedTabs=new w(null);$searchstaxConfig=new w(null);$autosuggestResults=new w(null);$itemsPerPage=new w(void 0);$searchObject=new w({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 w(null);$searchInputConfig=new w(null);$searchLocationConfig=new w(null);$searchExternalPromotions=new w(null);$facetsTemplateData=new w(null);$selectedFacetsTemplateData=new w(null);$paginationData=new w(null);$answerData=new w(null);$searchFeedbackData=new w(null);$inputWidgetTemplateData=new w(null);$locationWidgetTemplateData=new w(null);$searchSortingData=new w(null);$searchRelatedSearchesData=new w(null);$searchExternalPromotionsData=new w(null);$cookiesDisabled=new w(null);$locationDecodingLoading=new w(!1);$answer=new w("");$language=new w("en");$model=new w("");$answerLoading=new w(!1);$locationEnabled=new w(null);$answerError=new w(!1);$answerErrorMessage=new w("");$isQuestion=new w(!1);$inputTemplateRendered=new w(!1);currentPageValue=1;isAnswerWidgetCreatedValue=!1;renderingEngineValue=N.mustache;parsedData=new sr(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(U.removeXSSRiskyTags(e))}setSearchLocation(e){this.$searchLocationChange.setValue(U.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,(!ne.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){ne.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&&(!ne.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,ne.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){ne.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchFacetsCachedTabs(e){ne.deepEqual(e,this.searchFacetsCachedTabs??[])||this.$searchFacetsCachedTabs.setValue(e)}setSearchRelatedSearches(e){ne.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){ne.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(U.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 rt{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,r)=>{const n=a[e.responseHeader.params.uniqueId]??"",o={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(o)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const s of e.metadata.facets){let a={values:[]};if(a.name=s.name,a.label=s.label,s.name in e.facet_counts.facet_fields){const r=e.facet_counts.facet_fields[s.name];for(let n=0;n<r.length;n+=2){const o={};o.value=r[n],o.parentName=a.name,o.count=r[n+1],o.type="checkbox",a.values.push(o)}}a.values.length>0&&t.push(a)}return t}static extractSearchResultsMetadata(e){let t="",s={selectedSortOption:"",options:[]},a={enabled:!1,field:"",unit:"",filter:{enabled:!1,values:[],label:"",defaultValue:""}};if(e.metadata.locationSearch&&(a={enabled:e.metadata.locationSearch.enabled,field:e.metadata.locationSearch.field,unit:e.metadata.locationSearch.unit,filter:{enabled:e.metadata.locationSearch.filter?.enabled??!1,values:e.metadata.locationSearch.filter?.values??[],label:e.metadata.locationSearch.filter?.label??"",defaultValue:e.metadata.locationSearch.filter?.defaultValue??""}}),e.metadata.results.find(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 o=Array.isArray(e[n])?this.getHighlightedResults(n,e[n].join(", "),s,t):this.getHighlightedResults(n,e[n]+"",s,t);r.push({key:n,value:o,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 o=t[n.name];return o===void 0?null:typeof o=="string"?r?o:this.getHighlightedResults(n.name,o,a,s):typeof o=="number"?o:Array.isArray(o)?r?o.join(", "):this.getHighlightedResults(n.name,o.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 o=this.cleanValue(n);if(o!=="")return o}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class As{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 rr(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=U.removeXSSRiskyTags(e[s].split(":")?.[0]),r=U.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[1])),n=U.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=U.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),n=isNaN(r)?1:r;let o=parseInt(U.removeXSSRiskyTags(s[this.routeName+"[itemsPerPage]"]));return isNaN(o)&&(o=10),{query:U.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:n,itemsPerPage:t??o,order:U.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[],model:U.removeXSSRiskyTags(s[this.routeName+"[model]"])||"",location:{address:U.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][address]"]||"")),radius:U.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][radius]"]||"")),lat:U.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lat]"]||"")),lon:U.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lon]"]||""))}}}}class rr{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 ze={question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class vs 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 Es=10,nr=13,Ee=32;function ha(i){}function or(i){if(typeof i=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=ha,onError:t=ha,onRetry:s=ha,onComment:a}=i,r=[];let n=!0,o,l="",h=0,m;function L(g){if(n&&(n=!1,g.charCodeAt(0)===239&&g.charCodeAt(1)===187&&g.charCodeAt(2)===191&&(g=g.slice(3))),r.length===0){const b=M(g);b!==""&&r.push(b);return}if(g.indexOf(`
58
- `)===-1&&g.indexOf("\r")===-1){r.push(g);return}r.push(g);const d=r.join("");r.length=0;const y=M(d);y!==""&&r.push(y)}function M(g){let d=0;if(g.indexOf("\r")===-1){let y=g.indexOf(`
59
- `,d);for(;y!==-1;){if(d===y){h>0&&e({id:o,event:m,data:l}),o=void 0,l="",h=0,m=void 0,d=y+1,y=g.indexOf(`
60
- `,d);continue}const b=g.charCodeAt(d);if(Is(g,d,b)){const A=g.charCodeAt(d+5)===Ee?d+6:d+5,F=g.slice(A,y);if(h===0&&g.charCodeAt(y+1)===Es){e({id:o,event:m,data:F}),o=void 0,l="",m=void 0,d=y+2,y=g.indexOf(`
61
- `,d);continue}l=h===0?F:`${l}
62
- ${F}`,h++}else Ds(g,d,b)?m=g.slice(g.charCodeAt(d+6)===Ee?d+7:d+6,y)||void 0:I(g,d,y);d=y+1,y=g.indexOf(`
63
- `,d)}return g.slice(d)}for(;d<g.length;){const y=g.indexOf("\r",d),b=g.indexOf(`
64
- `,d);let A=-1;if(y!==-1&&b!==-1?A=y<b?y:b:y!==-1?y===g.length-1?A=-1:A=y:b!==-1&&(A=b),A===-1)break;I(g,d,A),d=A+1,g.charCodeAt(d-1)===nr&&g.charCodeAt(d)===Es&&d++}return g.slice(d)}function I(g,d,y){if(d===y){S();return}const b=g.charCodeAt(d);if(Is(g,d,b)){const we=g.charCodeAt(d+5)===Ee?d+6:d+5,B=g.slice(we,y);l=h===0?B:`${l}
65
- ${B}`,h++;return}if(Ds(g,d,b)){m=g.slice(g.charCodeAt(d+6)===Ee?d+7:d+6,y)||void 0;return}if(b===105&&g.charCodeAt(d+1)===100&&g.charCodeAt(d+2)===58){const we=g.slice(g.charCodeAt(d+3)===Ee?d+4:d+3,y);o=we.includes("\0")?void 0:we;return}if(b===58){if(a){const we=g.slice(d,y);a(we.slice(g.charCodeAt(d+1)===Ee?2:1))}return}const A=g.slice(d,y),F=A.indexOf(":");if(F===-1){k(A,"",A);return}const oe=A.slice(0,F),ie=A.charCodeAt(F+1)===Ee?2:1,jt=A.slice(F+ie);k(oe,jt,A)}function k(g,d,y){switch(g){case"event":m=d||void 0;break;case"data":l=h===0?d:`${l}
66
- ${d}`,h++;break;case"id":o=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.test(d)?s(parseInt(d,10)):t(new vs(`Invalid \`retry\` value: "${d}"`,{type:"invalid-retry",value:d,line:y}));break;default:t(new vs(`Unknown field "${g.length>20?`${g.slice(0,20)}\u2026`:g}"`,{type:"unknown-field",field:g,value:d,line:y}));break}}function S(){h>0&&e({id:o,event:m,data:l}),o=void 0,l="",h=0,m=void 0}function Q(g={}){if(g.consume&&r.length>0){const d=r.join("");I(d,0,d.length)}n=!0,o=void 0,l="",h=0,m=void 0,r.length=0}return{feed:L,reset:Q}}function Is(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 Ds(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 js 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(Rs(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(Rs(this),t)}}function cr(i){const e=globalThis.DOMException;return typeof e=="function"?new e(i,"SyntaxError"):new SyntaxError(i)}function ua(i){return i instanceof Error?"errors"in i&&Array.isArray(i.errors)?i.errors.map(ua).join(", "):"cause"in i&&i.cause instanceof Error?`${i}: ${ua(i.cause)}`:i.message:`${i}`}function Rs(i){return{type:i.type,message:i.message,code:i.code,defaultPrevented:i.defaultPrevented,cancelable:i.cancelable,timeStamp:i.timeStamp}}var Ns=i=>{throw TypeError(i)},da=(i,e,t)=>e.has(i)||Ns("Cannot "+t),x=(i,e,t)=>(da(i,e,"read from private field"),t?t.call(i):e.get(i)),_=(i,e,t)=>e.has(i)?Ns("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),j=(i,e,t,s)=>(da(i,e,"write to private field"),e.set(i,t),t),Le=(i,e,t)=>(da(i,e,"access private method"),t),se,Ie,$e,Et,It,nt,_e,ot,be,Ve,Qe,Be,ct,ce,ga,pa,ma,Os,fa,La,lt,ya,wa;class Dt extends EventTarget{constructor(e,t){var s,a;super(),_(this,ce),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,_(this,se),_(this,Ie),_(this,$e),_(this,Et),_(this,It),_(this,nt),_(this,_e),_(this,ot,null),_(this,be),_(this,Ve),_(this,Qe,null),_(this,Be,null),_(this,ct,null),_(this,pa,async r=>{var n;x(this,Ve).reset();const{body:o,redirected:l,status:h,headers:m}=r;if(h===204){Le(this,ce,lt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(l?j(this,$e,new URL(r.url)):j(this,$e,void 0),h!==200){Le(this,ce,lt).call(this,`Non-200 status code (${h})`,h);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){Le(this,ce,lt).call(this,'Invalid content type, expected "text/event-stream"',h);return}if(x(this,se)===this.CLOSED)return;j(this,se,this.OPEN);const L=new Event("open");if((n=x(this,ct))==null||n.call(this,L),this.dispatchEvent(L),typeof o!="object"||!o||!("getReader"in o)){Le(this,ce,lt).call(this,"Invalid response body, expected a web ReadableStream",h),this.close();return}const M=new TextDecoder,I=o.getReader();let k=!0;do{const{done:S,value:Q}=await I.read();Q&&x(this,Ve).feed(M.decode(Q,{stream:!S})),S&&(k=!1,x(this,Ve).reset(),Le(this,ce,ya).call(this))}while(k)}),_(this,ma,r=>{j(this,be,void 0),!(r.name==="AbortError"||r.type==="aborted")&&Le(this,ce,ya).call(this,ua(r))}),_(this,fa,r=>{typeof r.id=="string"&&j(this,ot,r.id);const n=new MessageEvent(r.event||"message",{data:r.data,origin:x(this,$e)?x(this,$e).origin:x(this,Ie).origin,lastEventId:r.id||""});x(this,Be)&&(!r.event||r.event==="message")&&x(this,Be).call(this,n),this.dispatchEvent(n)}),_(this,La,r=>{j(this,nt,r)}),_(this,wa,()=>{j(this,_e,void 0),x(this,se)===this.CONNECTING&&Le(this,ce,ga).call(this)});try{if(e instanceof URL)j(this,Ie,e);else if(typeof e=="string")j(this,Ie,new URL(e,lr()));else throw new Error("Invalid URL")}catch{throw cr("An invalid or illegal string was specified")}j(this,Ve,or({onEvent:x(this,fa),onRetry:x(this,La)})),j(this,se,this.CONNECTING),j(this,nt,3e3),j(this,It,(s=t?.fetch)!=null?s:globalThis.fetch),j(this,Et,(a=t?.withCredentials)!=null?a:!1),Le(this,ce,ga).call(this)}get readyState(){return x(this,se)}get url(){return x(this,Ie).href}get withCredentials(){return x(this,Et)}get onerror(){return x(this,Qe)}set onerror(e){j(this,Qe,e)}get onmessage(){return x(this,Be)}set onmessage(e){j(this,Be,e)}get onopen(){return x(this,ct)}set onopen(e){j(this,ct,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(){x(this,_e)&&clearTimeout(x(this,_e)),x(this,se)!==this.CLOSED&&(x(this,be)&&x(this,be).abort(),j(this,se,this.CLOSED),j(this,be,void 0))}}se=new WeakMap,Ie=new WeakMap,$e=new WeakMap,Et=new WeakMap,It=new WeakMap,nt=new WeakMap,_e=new WeakMap,ot=new WeakMap,be=new WeakMap,Ve=new WeakMap,Qe=new WeakMap,Be=new WeakMap,ct=new WeakMap,ce=new WeakSet,ga=function(){j(this,se,this.CONNECTING),j(this,be,new AbortController),x(this,It)(x(this,Ie),Le(this,ce,Os).call(this)).then(x(this,pa)).catch(x(this,ma))},pa=new WeakMap,ma=new WeakMap,Os=function(){var i;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...x(this,ot)?{"Last-Event-ID":x(this,ot)}:void 0},cache:"no-store",signal:(i=x(this,be))==null?void 0:i.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},fa=new WeakMap,La=new WeakMap,lt=function(i,e){var t;x(this,se)!==this.CLOSED&&j(this,se,this.CLOSED);const s=new js("error",{code:e,message:i});(t=x(this,Qe))==null||t.call(this,s),this.dispatchEvent(s)},ya=function(i,e){var t;if(x(this,se)===this.CLOSED)return;j(this,se,this.CONNECTING);const s=new js("error",{code:e,message:i});(t=x(this,Qe))==null||t.call(this,s),this.dispatchEvent(s),j(this,_e,setTimeout(x(this,wa),x(this,nt)))},wa=new WeakMap,Dt.CONNECTING=0,Dt.OPEN=1,Dt.CLOSED=2;function lr(){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 ye{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,o){JSON.stringify(n)===JSON.stringify(t)&&o?s():a()}).bind(this)):a()})}static trackAnswerLinkClick(e){const t={key:e.trackApiKey,question:e.searchTerm,session:e.session,href:e.href,language:e.language,model:e.model,answer:e.answer};return new Promise((s,a)=>{const r=["answerSourceClick",t];t.key?this.msq().push(r,(function(n,o){JSON.stringify(n)===JSON.stringify(t)&&o?s():a()}).bind(this)):a()})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,model:e.model,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches,language:e.language,model:e.model};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,latency:e.latencyVal,language:e.language,model:e.model,impressions:e.impressions,pageNo:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}static trackAnswerData(e){const t={session:e.session,key:e.trackApiKey,question:e.searchTerm,answer:e.answer,language:e.language,model:e.model,is_question:e.isQuestion+""};setTimeout(()=>{t.key&&this.msq().push(["trackquestionanswer",t])},0)}static trackFeedback(e){setTimeout(()=>{this.msq().push(["trackSearchSatisfaction",{key:e.trackApiKey,email:e.email,score:e.rating,comments:e.feedback,language:e.language,model:e.model}])},0)}}class hr{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 o=n.name+":"+n.value,l=decodeURIComponent(o).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 o=a[n],l=n;for(const h of o)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=rt.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),o={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete o.signal,fetch(n,o).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,m)=>h.get(m)??""}),o=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+o}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.searchObject.page!==1)return;const s=new Dt(this.dataLayer.questionURL+this.generateQueryParams(this.dataLayer.searchObject),{fetch:(r,n)=>fetch(r,{...n,headers:{...n?.headers,Authorization:this._authToken}})}),a=this.dataLayer;return s.onmessage=r=>{if(r.data===ze.question||r.data===ze.notQuestion){r.data===ze.question?(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setIsQuestion(!0)):(a.setAnswerLoading(!1),this.dataLayer.setIsQuestion(!1)),a.setAnswerData("");return}if(r.data===ze.close){ye.trackAnswerData({...a.parsedData.trackingData,answer:a.$answer.getValue(),isQuestion:this.dataLayer.isQuestion}),a.setAnswerLoading(!1),s.close();return}if(r.data.indexOf("[!CAUTION]")!==-1){a.setAnswerError(!0),a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),s.close();return}if(r.data.indexOf("[comment]: <> ({")!==-1)try{const n=r.data.split("[comment]: <> ({");if(n.length<2){t(r.data);return}const o=n[1].split("})");if(o.length<2){t(r.data);return}const l=o[0],h=JSON.parse("{"+l+"}");this.dataLayer.answerWidgetShowMoreLimit=h.displayShowMoreAfter,h.showMoreEnabled||(this.dataLayer.answerWidgetShowMoreLimit=1e17);const m=o.slice(1).join("})");t(m)}catch{t(r.data)}else t(r.data)},s.addEventListener("error",r=>{(r.code===401||r.code===500)&&(a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),a.setAnswerError(!0))}),s.onerror=()=>{a.setAnswerLoading(!1),s.close()},s}suggest(e,t,s){if(this.controllerSuggest&&this.controllerSuggest.abort(),this.suggester.trim()==="")return;this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const a=this.suggester+"?q="+e.trim()+this.toQueryString(s)+"&language="+this.dataLayer.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(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 ur=Object.prototype.toString,He=Array.isArray||function(i){return ur.call(i)==="[object Array]"};function Ma(i){return typeof i=="function"}function dr(i){return He(i)?"array":typeof i}function Ca(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Ps(i,e){return i!=null&&typeof i=="object"&&e in i}function gr(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var pr=RegExp.prototype.test;function mr(i,e){return pr.call(i,e)}var fr=/\S/;function Lr(i){return!mr(fr,i)}var yr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function wr(i){return String(i).replace(/[&<>"'`=\/]/g,function(e){return yr[e]})}var Mr=/\s*/,Cr=/\s+/,Fs=/\s*=/,br=/\s*\}/,Sr=/#|\^|\/|>|\{|&|=|!/;function xr(i,e){if(!i)return[];var t=!1,s=[],a=[],r=[],n=!1,o=!1,l="",h=0;function m(){if(n&&!o)for(;r.length;)delete a[r.pop()];else r=[];n=!1,o=!1}var L,M,I;function k(ie){if(typeof ie=="string"&&(ie=ie.split(Cr,2)),!He(ie)||ie.length!==2)throw new Error("Invalid tags: "+ie);L=new RegExp(Ca(ie[0])+"\\s*"),M=new RegExp("\\s*"+Ca(ie[1])),I=new RegExp("\\s*"+Ca("}"+ie[1]))}k(e||T.tags);for(var S=new ht(i),Q,g,d,y,b,A;!S.eos();){if(Q=S.pos,d=S.scanUntil(L),d)for(var F=0,oe=d.length;F<oe;++F)y=d.charAt(F),Lr(y)?(r.push(a.length),l+=y):(o=!0,t=!0,l+=" "),a.push(["text",y,Q,Q+1]),Q+=1,y===`
67
- `&&(m(),l="",h=0,t=!1);if(!S.scan(L))break;if(n=!0,g=S.scan(Sr)||"name",S.scan(Mr),g==="="?(d=S.scanUntil(Fs),S.scan(Fs),S.scanUntil(M)):g==="{"?(d=S.scanUntil(I),S.scan(br),S.scanUntil(M),g="&"):d=S.scanUntil(M),!S.scan(M))throw new Error("Unclosed tag at "+S.pos);if(g==">"?b=[g,d,Q,S.pos,l,h,t]:b=[g,d,Q,S.pos],h++,a.push(b),g==="#"||g==="^")s.push(b);else if(g==="/"){if(A=s.pop(),!A)throw new Error('Unopened section "'+d+'" at '+Q);if(A[1]!==d)throw new Error('Unclosed section "'+A[1]+'" at '+Q)}else g==="name"||g==="{"||g==="&"?o=!0:g==="="&&k(d)}if(m(),A=s.pop(),A)throw new Error('Unclosed section "'+A[1]+'" at '+S.pos);return Tr(kr(a))}function kr(i){for(var e=[],t,s,a=0,r=i.length;a<r;++a)t=i[a],t&&(t[0]==="text"&&s&&s[0]==="text"?(s[1]+=t[1],s[3]=t[3]):(e.push(t),s=t));return e}function Tr(i){for(var e=[],t=e,s=[],a,r,n=0,o=i.length;n<o;++n)switch(a=i[n],a[0]){case"#":case"^":t.push(a),s.push(a),t=a[4]=[];break;case"/":r=s.pop(),r[5]=a[2],t=s.length>0?s[s.length-1][4]:e;break;default:t.push(a)}return e}function ht(i){this.string=i,this.tail=i,this.pos=0}ht.prototype.eos=function(){return this.tail===""},ht.prototype.scan=function(i){var e=this.tail.match(i);if(!e||e.index!==0)return"";var t=e[0];return this.tail=this.tail.substring(t.length),this.pos+=t.length,t},ht.prototype.scanUntil=function(i){var e=this.tail.search(i),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 qe(i,e){this.view=i,this.cache={".":this.view},this.parent=e}qe.prototype.push=function(i){return new qe(i,this)},qe.prototype.lookup=function(i){var e=this.cache,t;if(e.hasOwnProperty(i))t=e[i];else{for(var s=this,a,r,n,o=!1;s;){if(i.indexOf(".")>0)for(a=s.view,r=i.split("."),n=0;a!=null&&n<r.length;)n===r.length-1&&(o=Ps(a,r[n])||gr(a,r[n])),a=a[r[n++]];else a=s.view[i],o=Ps(s.view,i);if(o){t=a;break}s=s.parent}e[i]=t}return Ma(t)&&(t=t.call(this.view)),t};function te(){this.templateCache={_cache:{},set:function(i,e){this._cache[i]=e},get:function(i){return this._cache[i]},clear:function(){this._cache={}}}}te.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()},te.prototype.parse=function(i,e){var t=this.templateCache,s=i+":"+(e||T.tags).join(":"),a=typeof t<"u",r=a?t.get(s):void 0;return r==null&&(r=xr(i,e),a&&t.set(s,r)),r},te.prototype.render=function(i,e,t,s){var a=this.getConfigTags(s),r=this.parse(i,a),n=e instanceof qe?e:new qe(e,void 0);return this.renderTokens(r,n,t,i,s)},te.prototype.renderTokens=function(i,e,t,s,a){for(var r="",n,o,l,h=0,m=i.length;h<m;++h)l=void 0,n=i[h],o=n[0],o==="#"?l=this.renderSection(n,e,t,s,a):o==="^"?l=this.renderInverted(n,e,t,s,a):o===">"?l=this.renderPartial(n,e,t,a):o==="&"?l=this.unescapedValue(n,e):o==="name"?l=this.escapedValue(n,e,a):o==="text"&&(l=this.rawValue(n)),l!==void 0&&(r+=l);return r},te.prototype.renderSection=function(i,e,t,s,a){var r=this,n="",o=e.lookup(i[1]);function l(L){return r.render(L,e,t,a)}if(o){if(He(o))for(var h=0,m=o.length;h<m;++h)n+=this.renderTokens(i[4],e.push(o[h]),t,s,a);else if(typeof o=="object"||typeof o=="string"||typeof o=="number")n+=this.renderTokens(i[4],e.push(o),t,s,a);else if(Ma(o)){if(typeof s!="string")throw new Error("Cannot use higher-order sections without the original template");o=o.call(e.view,s.slice(i[3],i[5]),l),o!=null&&(n+=o)}else n+=this.renderTokens(i[4],e,t,s,a);return n}},te.prototype.renderInverted=function(i,e,t,s,a){var r=e.lookup(i[1]);if(!r||He(r)&&r.length===0)return this.renderTokens(i[4],e,t,s,a)},te.prototype.indentPartial=function(i,e,t){for(var s=e.replace(/[^ \t]/g,""),a=i.split(`
68
- `),r=0;r<a.length;r++)a[r].length&&(r>0||!t)&&(a[r]=s+a[r]);return a.join(`
69
- `)},te.prototype.renderPartial=function(i,e,t,s){if(t){var a=this.getConfigTags(s),r=Ma(t)?t(i[1]):t[i[1]];if(r!=null){var n=i[6],o=i[5],l=i[4],h=r;o==0&&l&&(h=this.indentPartial(r,l,n));var m=this.parse(h,a);return this.renderTokens(m,e,t,h,s)}}},te.prototype.unescapedValue=function(i,e){var t=e.lookup(i[1]);if(t!=null)return t},te.prototype.escapedValue=function(i,e,t){var s=this.getConfigEscape(t)||T.escape,a=e.lookup(i[1]);if(a!=null)return typeof a=="number"&&s===T.escape?String(a):s(a)},te.prototype.rawValue=function(i){return i[1]},te.prototype.getConfigTags=function(i){return He(i)?i:i&&typeof i=="object"?i.tags:void 0},te.prototype.getConfigEscape=function(i){if(i&&typeof i=="object"&&!He(i))return i.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(i){ut.templateCache=i},get templateCache(){return ut.templateCache}},ut=new te;T.clearCache=function(){return ut.clearCache()},T.parse=function(i,e){return ut.parse(i,e)},T.render=function(i,e,t,s){if(typeof i!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+dr(i)+'" was given as the first argument for mustache#render(template, view, partials)');return ut.render(i,e,t,s)},T.escape=wr,T.Scanner=ht,T.Context=qe,T.Writer=te;const Ar={main:{template:`
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&&lt(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&&lt(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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};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:`
70
71
  {{#shouldShowAnswer}}
71
72
  <div class="searchstax-answer-wrap">
72
73
  <div class="searchstax-answer-icon"></div>
@@ -103,7 +104,7 @@ ${d}`,h++;break;case"id":o=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
103
104
  </div>
104
105
  </div>
105
106
  {{/shouldShowAnswer}}
106
- `}},vr={mainTemplate:{template:`
107
+ `}},gn={mainTemplate:{template:`
107
108
  {{#hasExternalPromotions}}
108
109
  <div class="searchstax-external-promotions-container" id="searchstax-external-promotions-container" data-test-id="searchstax-external-promotions-container">
109
110
  External promotions go here
@@ -129,7 +130,7 @@ ${d}`,h++;break;case"id":o=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
129
130
  </p>
130
131
  {{/url}}
131
132
  </div>
132
- `}},Er={mainTemplateDesktop:{template:`
133
+ `}},pn={mainTemplateDesktop:{template:`
133
134
  {{#hasResultsOrExternalPromotions}}
134
135
  <div class="searchstax-facets-container-desktop"></div>
135
136
  {{/hasResultsOrExternalPromotions}}
@@ -187,7 +188,7 @@ ${d}`,h++;break;case"id":o=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
187
188
  <div class="searchstax-facets-pill-label">{{value}} ({{count}})</div>
188
189
  <div class="searchstax-facets-pill-icon-close"></div>
189
190
  </div>
190
- `,containerClass:"searchstax-facets-pill-facets"}},Ir={mainTemplate:{template:`
191
+ `,containerClass:"searchstax-facets-pill-facets"}},mn={mainTemplate:{template:`
191
192
  {{#results.length}}
192
193
  <div class="searchstax-pagination-container" data-test-id="searchstax-pagination-container">
193
194
  <div class="searchstax-pagination-content">
@@ -205,7 +206,7 @@ ${d}`,h++;break;case"id":o=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
205
206
  <a class="searchstax-pagination-load-more" data-test-id="searchstax-pagination-load-more" tabindex="0">Show More</a>
206
207
  {{/isLastPage}}
207
208
  {{/results.length}}
208
- `,loadMoreButtonClass:"searchstax-pagination-load-more"}},Dr={main:{template:`
209
+ `,loadMoreButtonClass:"searchstax-pagination-load-more"}},fn={main:{template:`
209
210
  {{#hasRelatedSearches}}
210
211
  <div class="searchstax-related-searches-container" data-test-id="searchstax-related-searches-container" id="searchstax-related-searches-container">
211
212
  Related searches: <span id="searchstax-related-searches"></span>
@@ -220,7 +221,7 @@ ${d}`,h++;break;case"id":o=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
220
221
  <span role="link" class="searchstax-related-search searchstax-related-search-item" data-test-id="searchstax-related-search-item" aria-label="Related search: {{related_search}}" tabindex="0">
221
222
  {{ related_search }}{{^last}}<span>,</span>{{/last}}
222
223
  </span>
223
- `,relatedSearchContainerClass:"searchstax-related-search-item"}},jr={main:{template:`
224
+ `,relatedSearchContainerClass:"searchstax-related-search-item"}},Ln={main:{template:`
224
225
  {{#searchExecuted}}
225
226
  <a href="#searchstax-search-results" data-test-id="searchstax-skip" class="searchstax-skip">Skip to results section</a>
226
227
  <h4 class="searchstax-feedback-container" data-test-id="searchstax-feedback-container">
@@ -234,17 +235,19 @@ ${d}`,h++;break;case"id":o=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
234
235
  {{/hasResults}}
235
236
  </h4>
236
237
  {{/searchExecuted}}
237
- `,originalQueryClass:"searchstax-feedback-original-query"}},Rr={mainTemplate:{template:`
238
+ `,originalQueryClass:"searchstax-feedback-original-query"}},yn={mainTemplate:{template:`
238
239
  <div class="searchstax-search-input-container searchstax-search-input-container-new {{#locationEnabled}}searchstax-alternative-render{{/locationEnabled}}">
239
240
  <div class="searchstax-search-input-wrapper">
240
241
  <input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." aria-label="Search" />
242
+ <button id="searchstax-clear-input-action-button" class="searchstax-cross-icon hidden" aria-label="clear input" role="button"></button>
243
+ <span id="searchstax-separator-icon" class="searchstax-separator hidden"></span>
241
244
  </div>
242
245
  <div id="searchstax-location-container" class="searchstax-location-container"></div>
243
246
  <button class="searchstax-spinner-icon" id="searchstax-search-input-action-button" aria-label="search" role="button"></button>
244
247
  </div>
245
248
  `,searchInputId:"searchstax-search-input"},autosuggestItemTemplate:{template:`
246
249
  <div class="searchstax-autosuggest-item-term-container">{{{term}}}</div>
247
- `}},Nr={mainTemplate:{template:`
250
+ `}},wn={mainTemplate:{template:`
248
251
  <div class="searchstax-location-input-container" data-test-id="searchstax-location-input-container">
249
252
  <div class="searchstax-location-input-wrapper">
250
253
  <span class="searchstax-location-input-label">NEAR</span>
@@ -262,7 +265,7 @@ ${d}`,h++;break;case"id":o=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
262
265
  {{/shouldShowLocationDistanceDropdown}}
263
266
  </div>
264
267
  </div>
265
- `,locationInputId:"searchstax-location-input",radiusInputId:"searchstax-location-radius-select",currentLocationActionButtonId:"searchstax-location-get-current-location"}},Or={mainTemplate:{template:`
268
+ `,locationInputId:"searchstax-location-input",radiusInputId:"searchstax-location-radius-select",currentLocationActionButtonId:"searchstax-location-get-current-location"}},Mn={mainTemplate:{template:`
266
269
  <section aria-label="search results container" tabindex="0">
267
270
  <div class="searchstax-search-results-container" id="searchstax-search-results-container" data-test-id="searchstax-search-results-container">
268
271
  <div class="searchstax-search-results" id="searchstax-search-results"></div>
@@ -334,7 +337,7 @@ ${d}`,h++;break;case"id":o=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
334
337
  </ul>
335
338
  </div>
336
339
  {{/searchExecuted}}
337
- `}},Pr={main:{template:`
340
+ `}},bn={main:{template:`
338
341
  {{#searchExecuted}}
339
342
  {{#hasResultsOrExternalPromotions}}
340
343
  {{#sortOptions.length}}
@@ -351,7 +354,7 @@ ${d}`,h++;break;case"id":o=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
351
354
  {{/sortOptions.length}}
352
355
  {{/hasResultsOrExternalPromotions}}
353
356
  {{/searchExecuted}}
354
- `,selectId:"searchstax-search-order-select"}},W={mainTemplate:{template:`
357
+ `,selectId:"searchstax-search-order-select"}},Z={mainTemplate:{template:`
355
358
  <div class="sf-widget-container">
356
359
  <div id="sf-widget" class="sf-main">
357
360
  <a role="button" href="#" id="searchstax-open-feedback" class="sf-open-feedback" tabindex="0" aria-label="Open Search Feedback">[ - ] Search Feedback</a>
@@ -434,4 +437,4 @@ ${d}`,h++;break;case"id":o=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.t
434
437
 
435
438
  </div>
436
439
  </div>
437
- `,thumbsUpButtonClass:"searchstax-lightweight-widget-thumbs-up",thumbsDownButtonClass:"searchstax-lightweight-widget-thumbs-down"}};class f{static answer=Ar;static externalPromotions=vr;static facets=Er;static pagination=Ir;static relatedSearches=Dr;static searchFeedback=jr;static searchInput=Rr;static location=Nr;static searchResults=Or;static sorting=Pr;static feedback=W}class Fr{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||f.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||f.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=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||f.externalPromotions.mainTemplate?.template;if(this.dataLayer.renderingEngine===N.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 V{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 o=document.getElementById("searchAccessibilityContainer");o&&setTimeout(()=>{o.appendChild(n)},t??100)}}class zr{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 o=r.values.find(l=>n.type==="range"?!1:n.type==="checkbox"?l.value===n.value:!1);return{...n,disabled:!o,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||f.facets.facetItemContainerTemplate?.template;a.innerHTML=T.render(r,e),t.appendChild(a);const n=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerClass||f.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"),m=n.querySelector(".searchstax-facet-title");m&&m.setAttribute("aria-expanded",String(h))}});const o=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListContainerClass||f.facets.facetItemContainerTemplate?.facetListContainerClass));o&&(e.values.forEach(l=>{this.createFacetListItem(l,o,e.name)}),e.hasMoreFacets&&this.createHasMoreComponent(e,o,s))}}isChecked(e){return!!this.dataLayer.searchObject.facets?.find(t=>ne.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||f.facets.facetItemTemplate?.template;a.innerHTML=T.render(n,{...e,isChecked:r});let o=f.facets.facetItemTemplate?.checkTriggerClasses;o=this.config?.templates?.facetItemTemplate?.checkTriggerClasses||o,o.forEach(h=>{a.querySelector("."+h)?.addEventListener("click",m=>{this.onFacetSelect(m,e,a)})});const l=a.querySelector("."+(this.config?.templates?.facetItemTemplate?.inputCheckboxClass||f.facets.facetItemTemplate?.inputCheckboxClass));l?.addEventListener("click",h=>{this.onFacetSelect(h,e,a,!0)}),l&&l?.setAttribute("data-test-value",`${encodeURIComponent(s)}:&quot;${encodeURIComponent(e.value)}&quot;`),t.appendChild(a)}}onFacetSelect=(e,t,s,a,r)=>{if(e.stopPropagation(),!t.disabled){const n=s.querySelector("input");let o=a?n.checked:!n.checked;r!==void 0&&(o=!r),n.checked=o;const l=this.dataLayer.searchObject;let h=[...l.facets];const m=this.extractFacetValue(t);o?h.find(L=>ne.deepEqual(L,m)?L:!1)||(this.config.facetingType==="tabs"&&(h=h.filter(L=>L.name!==m.name)),h.push(m)):h=h.filter(L=>!ne.deepEqual(L,m)),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||f.facets.showMoreButtonContainerTemplate?.template;a.innerHTML=T.render(r,{...e,focusId:`moreLess${e?.values?.[0]?.value}`});const n=a.querySelector("."+(this.config?.templates?.showMoreButtonContainerTemplate?.showMoreButtonClass||f.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?(V.setAccessibilityText(`More Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),r[t.name]=r[t.name]+a):(V.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&&(!ne.deepEqual(this.cachedData??{},e)||t)){this.cachedData=e;const s=this.config?.templates?.mainTemplateDesktop?.template||f.facets.mainTemplateDesktop?.template;if(this.dataLayer.renderingEngine===N.mustache&&this.searchFacetsMainContainer){const a=document.activeElement;a instanceof HTMLInputElement&&a.type==="checkbox"||a?.classList.contains("searchstax-facet-show-more-button")||a?.classList.contains("searchstax-facet-show-less-button")?this.focusedElement=a:this.focusedElement=null,this.searchFacetsMainContainer.innerHTML=T.render(s,{...e});const r=this.searchFacetsMainContainer?.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.facetsContainerClass||f.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||f.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"),o=this.searchFacetsMainContainer.querySelector(`[data-test-value="${n}"]`);o instanceof HTMLInputElement&&o.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(o=>o.name===a);if(n){const o=n.values.find(l=>l.type==="range"?!1:l.type==="checkbox"?`"${l.value}"`==`"${r}"`:!1);o&&e.push(o)}}}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||f.facets.clearFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=T.render(s,{shouldShow:t.facets.length>0});const r=a.querySelector("."+(this.config?.templates?.clearFacetsTemplate?.containerClass||f.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||f.facets.selectedFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=T.render(s,t);const r=a.querySelector("."+(this.config?.templates?.selectedFacetsTemplate?.containerClass||f.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||f.facets.filterByTemplate?.template,s=document?.createElement("div");s.innerHTML=T.render(t,{});const a=s.querySelector("."+(this.config?.templates?.filterByTemplate?.containerClass||f.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(){V.setAccessibilityText("Facet overlay opened. Tab to select facets."),this.overlayOpened=!0,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.add("searchstax-show"))}closeOverlay(){V.setAccessibilityText("Facet overlay closed"),this.overlayOpened=!1,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.remove("searchstax-show"))}renderMobileTemplate(e){if(e&&typeof document<"u"){const t=document?.createElement("div");t.classList.add("searchstax-facets-container-mobile");const s=this.config?.templates?.mainTemplateMobile?.template||f.facets.mainTemplateMobile?.template;if(this.dataLayer.renderingEngine===N.mustache){if(t.innerHTML=T.render(s,{...e,overlayOpened:this.overlayOpened}),this.searchFacetsMainContainer?.appendChild(t),this.config?.templates?.mainTemplateMobile)for(const o of this.config?.templates?.mainTemplateMobile?.closeOverlayTriggerClasses||[]){const l=t.querySelector("."+o);l&&(l.addEventListener("click",this.closeOverlay.bind(this)),l.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}else for(const o of f.facets.mainTemplateMobile.closeOverlayTriggerClasses){const l=t.querySelector("."+o);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||f.facets.mainTemplateMobile.filterByContainerClass));a&&this.createFilterByComponent(a);const r=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.selectedFacetsContainerClass||f.facets.mainTemplateMobile.selectedFacetsContainerClass));r&&(this.createSelectedFacetsComponents(r),this.createClearFacetsComponents(r));const n=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.facetsContainerClass||f.facets.mainTemplateMobile.facetsContainerClass));if(n){n.innerHTML="";for(const o of e.facets)this.createFacetItem(o,n,!0)}}}}}class $r{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??f.pagination.mainTemplate.previousButtonClass,this.nextButtonClass=this.config?.templates?.mainTemplate?.nextButtonClass??f.pagination.mainTemplate.nextButtonClass,this.loadMoreButtonClass=this.config?.templates?.infiniteScrollTemplate?.loadMoreButtonClass??f.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||f.pagination.mainTemplate?.template;this.dataLayer.isInfiniteScroll&&(t=this.config?.templates?.infiniteScrollTemplate?.template||f.pagination.infiniteScrollTemplate?.template),this.dataLayer.renderingEngine===N.mustache&&(this.searchPaginationMainContainer.innerHTML=T.render(t,e),setTimeout(()=>{this.overridePaginationEvents()},0))}}class _r{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||f.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||f.relatedSearches.relatedSearch.template;if(this.dataLayer.renderingEngine===N.mustache){s.innerHTML=T.render(a,e);const r=s.querySelector("."+(this.config.templates?.relatedSearch?.relatedSearchContainerClass||f.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||f.relatedSearches.main.template;if(this.dataLayer.renderingEngine===N.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 Vr{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||f.searchFeedback.main?.originalQueryClass));e&&e.addEventListener("click",this.onOriginalQueryClick.bind(this))}renderMainTemplate(e){const t=this.config?.templates?.main?.template||f.searchFeedback.main.template;this.dataLayer.renderingEngine===N.mustache&&(this.searchFeedbackMainContainer.innerHTML=T.render(t,e),setTimeout(()=>{this.attachClick()},0))}}class Qr{searchHelper;dataLayer;config;suggestAfterMinChars;containerId;currentInputValue="";autosuggestResults;searchInput;actionButton;autosuggestContainer;buttonState="search";selectedAutosuggestItem=-1;suggestTrigger;searchTrigger;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.searchTrigger=e.searchTrigger,this.suggestTrigger=e.suggestTrigger,this.containerId=e.containerId,this.suggestAfterMinChars=e.config.suggestAfterMinChars,this.suggestAfterMinChars===void 0&&this.getSuggestAfterValue(),this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())},200)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||f.searchInput.mainTemplate.template,s={...this.dataLayer.parsedData.data,locationEnabled:!!this.dataLayer.locationEnabled};if(this.dataLayer.setInputWidgetTemplateData(s),this.dataLayer.renderingEngine===N.mustache){const n=T.render(t,s);e.innerHTML=n,this.dataLayer.setInputTemplateRendered(!0)}const a=this.config.templates?.mainTemplate?.searchInputId||f.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===N.mustache&&typeof document<"u"&&(this.autosuggestContainer=document?.createElement("div"),this.autosuggestContainer.classList.add("searchstax-autosuggest-container"),this.autosuggestContainer.addEventListener("mouseleave",()=>{this.resetAutosuggestSelection(),this.markActiveAutosuggestItem()}),this.searchInput?.after(this.autosuggestContainer))}getSuggestAfterValue(){this.dataLayer.searchHelper&&this.dataLayer.searchHelper.suggest("*",e=>{this.suggestAfterMinChars=e.metadata.minPrefixChars},[])}actionButtonInit(){typeof document<"u"&&(this.actionButton=document?.getElementById("searchstax-search-input-action-button"),this.actionButton&&this.actionButton.addEventListener("click",()=>{this.executeSearch(this.searchInput?.value??"")}))}attachSubscriptions(){this.dataLayer.$searchTermChange.subscribe(()=>{this.handleSearchTermChange()}),this.dataLayer.$loadingChange.subscribe(()=>{this.handleLoadingChange()}),this.dataLayer.$searchAutosuggest.subscribe(e=>{e&&this.appendSuggestions(e)}),this.dataLayer.$searchObject.subscribe(e=>{e.query!=="undefined"&&e.query!==void 0&&e.query!=="*"&&this.searchInput&&(this.searchInput.value=this.cleanSuggestionTerm(e.query??""))})}handleLoadingChange(){this.dataLayer.loading?this.updateActionButtonState("loading"):this.handleSearchTermChange()}handleSearchTermChange(){this.updateActionButtonState("search")}updateActionButtonState(e){if(this.buttonState=e,this.actionButton)switch(this.actionButton.classList.remove("searchstax-spinner-icon"),this.actionButton.classList.remove("searchstax-search-icon"),e){case"loading":this.actionButton.classList.add("searchstax-spinner-icon");break;case"search":this.actionButton.classList.add("searchstax-search-icon"),this.actionButton.setAttribute("aria-label","search");break}}selectPreviousAutosuggestItem(e){this.selectedAutosuggestItem>0?this.selectedAutosuggestItem--:this.selectedAutosuggestItem===0?(this.selectedAutosuggestItem=-1,e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),V.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=this.autosuggestResults.suggestions.length-1,this.markActiveAutosuggestItem()}selectNextAutosuggestItem(){this.selectedAutosuggestItem<this.autosuggestResults.suggestions.length-1?this.selectedAutosuggestItem++:this.selectedAutosuggestItem===this.autosuggestResults.suggestions.length-1?(this.selectedAutosuggestItem=-1,V.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=0,this.markActiveAutosuggestItem()}resetAutosuggestSelection(){this.selectedAutosuggestItem=-1,this.markActiveAutosuggestItem()}markActiveAutosuggestItem(){if(typeof document<"u"){const e=document?.getElementsByClassName("searchstax-autosuggest-item");for(let t=0;t<e.length;t++){const s=e[t];t===this.selectedAutosuggestItem?(s.classList.add("active"),V.setAccessibilityText(`Selected suggestion: ${s.innerText}`)):s.classList.remove("active")}}}inputKeyupEvent(e){const t=e.key;this.currentInputValue=e.target.value,t==="Enter"?this.suggestionChosen():t==="Escape"?this.hideAutosuggest(e.target):t==="ArrowUp"?this.selectPreviousAutosuggestItem(e.target):t==="ArrowDown"?this.selectNextAutosuggestItem():this.autosuggestHandling(e),this.handleSearchTermChange()}autosuggestHandling(e){this.suggestAfterMinChars&&e.target&&e.target.value.length>=this.suggestAfterMinChars?this.executeSuggest(e.target.value):this.hideAutosuggest()}inputPasteEvent(e){setTimeout(()=>{this.autosuggestHandling(e),this.handleSearchTermChange()},0)}executeSuggest(e){this.suggestTrigger(e)}executeSearch(e){this.hideAutosuggest(),this.searchTrigger(e===""?"*":e)}suggestionChosen(){this.selectedAutosuggestItem>-1?this.autosuggestItemClicked(this.autosuggestResults.suggestions[this.selectedAutosuggestItem]):this.executeSearch(this.currentInputValue)}hideAutosuggest(e){setTimeout(()=>{this.dataLayer.setAutosuggestResults({numFound:0,suggestions:[]}),this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.add("hidden")),this.resetAutosuggestSelection(),e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),V.setAccessibilityText("No Suggestion selected")},200)}cleanSuggestionTerm(e){return U.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||f.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 r=s[a];r.numFound?V.setAccessibilityText("Suggestions are available. Use up and down arrows to navigate while focusing input. Use Escape key to escape out of the suggestions",2e3):V.setAccessibilityText("",0),this.autosuggestResults=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 Br{dataLayer;config;linkClickCallback;searchCallback;containerId;searchResultsMainContainer;searchResultsContainer;searchResultLinks=[];constructor(e){this.linkClickCallback=e.linkClickCallback,this.searchCallback=e.searchTrigger,this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId;const t=document?.getElementById(this.containerId);if(t)this.searchResultsMainContainer=t;else throw new Error(`Search Results Main Container with id ${this.containerId} not found`);this.dataLayer.setIsInfiniteScroll(e.config.renderMethod==="infiniteScroll"),this.initializeSubscriptions(),this.renderMainTemplate()}initializeSubscriptions(){this.dataLayer.$searchObject.subscribe(()=>{V.setAccessibilityText("Searching...")}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.searchResultsContainer&&this.renderResults(e)})}changeTemplate(){this.dataLayer.searchResults&&this.renderResults(this.dataLayer.searchResults)}renderNoResultsTemplate(){const e=this.config?.templates?.noSearchResultTemplate?.template||f.searchResults.noSearchResultTemplate?.template,t=this.dataLayer.searchResultsMetadata?.spellingSuggestion??"";if(this.dataLayer.renderingEngine===N.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===N.mustache&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)V.setAccessibilityText("Search has no results"),this.renderNoResultsTemplate();else{V.setAccessibilityText(`Showing ${this.dataLayer.parsedData.startResultIndex} through ${this.dataLayer.parsedData.endResultIndex} results from ${this.dataLayer.parsedData.totalResults}. Press tab to navigate through results`);const t=this.config?.templates?.searchResultTemplate?.template||f.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||f.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||f.searchResults.mainTemplate?.template;this.dataLayer.renderingEngine===N.mustache&&(this.searchResultsMainContainer.innerHTML=T.render(e,{}),setTimeout(()=>{const t=this.config?.templates?.mainTemplate?.searchResultsContainerId?this.config?.templates?.mainTemplate?.searchResultsContainerId:f.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 Hr{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||f.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||f.sorting.main.template;if(this.dataLayer.renderingEngine===N.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 qr{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(){ye.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=W?.mainTemplate?.template;if(this.mainTemplateOverride&&(s=this.mainTemplateOverride),this.isLightweight&&(s=W.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"),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=W.mainTemplate?.modalContainerClass;return this.mainContainer?.querySelector(`.${e}`)||null}attachLightweightEvents(){const e=W.lightweightTemplate?.thumbsUpButtonClass,t=W.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=W.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.checkIfValid()})}checkIfValid(){const e=this.mainContainer?.querySelector("#"+W.mainTemplate?.emailInputId);this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,V.setAccessibilityText("Please enter a valid email address.")),this.templateData.ratings.some(t=>t.isSelected)?this.templateData.errors.rating=!1:(this.templateData.errors.rating=!0,V.setAccessibilityText("Please Rate your experience.")),this.templateData.errors.rating||this.templateData.errors.email?this.renderMainTemplate(this.generateTemplateData()):this.submit()}submit(){this.templateData.submitted=!0;const e=this.templateData.ratings.find(t=>t.isSelected)?.index;e!==void 0&&(ye.trackFeedback({trackApiKey:this.analyticsKey,email:this.emailOverride&&this.isLightweight?this.emailOverride():this.templateData.emailInput,rating:e,feedback:this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea,model:this.model?this.model:void 0,language:this.language?this.language:void 0}),this.showCheckmarkAnimation(),V.setAccessibilityText("Feedback has been sent.",1e3),this.mainContainer?.querySelector("."+W.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("#"+W.mainTemplate?.emailInputId);e&&(e.addEventListener("input",()=>{this.templateData.emailInput=e.value}),e.addEventListener("blur",()=>{setTimeout(()=>{this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,V.setAccessibilityText("Please enter a valid email address.")),this.renderMainTemplate(this.generateTemplateData())},300)}))}attachTextAreaEvents(){const e=this.mainContainer?.querySelector("#"+W.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("."+W.mainTemplate?.charactersRemainingContainerclass);t&&(t.innerText=this.templateData.charactersLeft+"")})}attachRatingEvents(){const e=W.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=W.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=W.mainTemplate?.closeModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.closeFeedbackModal()})}openFeedbackModal(){this.lastFocusedElementBeforeModal=document.activeElement,this.templateData.feedbackOpen=!0,this.renderMainTemplate(this.generateTemplateData()),setTimeout(()=>{const e=this.getModalElement();if(e){const t=this.getFocusableElements(e);t.length>0&&t[0].focus()}this.attachFocusTrap()},0),V.setAccessibilityText("Feedback form opened",1e3)}closeFeedbackModal(){this.templateData.feedbackOpen=!1,this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null),this.renderMainTemplate(this.generateTemplateData()),this.lastFocusedElementBeforeModal&&(this.lastFocusedElementBeforeModal.focus(),this.lastFocusedElementBeforeModal=null),V.setAccessibilityText("Feedback form closed",1e3)}showCheckmarkAnimation(){const e=W.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&(t.disabled=!0);const s=W.mainTemplate?.checkmarkClass,a=this.mainContainer?.querySelector("."+s);a&&a.classList.remove("hidden");const r=W.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 Ur{dataLayer;config;containerId;answerContainer=null;showMoreVisible=!1;renderFeedbackWidget=!1;clicked=!1;renderedWithShowMore=!1;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.renderFeedbackWidget=this.config.feedbackwidget?.renderFeedbackWidget||!1,this.config.showMoreAfterWordCount&&(this.dataLayer.answerWidgetShowMoreLimit=this.config.showMoreAfterWordCount),typeof document<"u"&&(this.answerContainer=document?.getElementById(this.containerId)),this.config.testString?(this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())):this.initializeSubscriptions(),this.dataLayer.setIsAnswerWidgetCreated(!0)}initializeSubscriptions(){this.dataLayer.$answer.subscribe(()=>{this.clicked?this.showMoreVisible=!1:this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerLoading.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerError.subscribe(e=>{e&&setTimeout(()=>{this.renderMainTemplate(this.generateTemplateData())},100)}),this.dataLayer.$searchObject.subscribe(()=>{this.clicked=!1,this.renderedWithShowMore=!1,this.showMoreVisible=!1}),this.dataLayer.$paginationData.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answer.subscribe(e=>{e&&setTimeout(()=>{this.initializeWidget()},600)}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.$answer.getValue()&&setTimeout(()=>{this.initializeWidget()},600)})}searchstaxFeedbackTextAreaOverride(){return"Question: "+(this.dataLayer.searchObject.query==="undefined"?"":this.dataLayer.searchObject.query)+" Answer: "+this.dataLayer.parsedData.getAnswerData}initializeWidget(){this.renderFeedbackWidget&&document.getElementById("feedbackWidgetContainer")&&!this.dataLayer.answerLoading&&new qr({analyticsKey:this.dataLayer.parsedData.trackingData.trackApiKey,containerId:"feedbackWidgetContainer",lightweight:!0,model:this.dataLayer.parsedData.trackingData.model,language:this.dataLayer.parsedData.trackingData.language,emailOverride:this.config.feedbackwidget?.emailOverride,feedbackTextAreaOverride:this.config.feedbackwidget?.searchstaxFeedbackTextAreaOverride??this.searchstaxFeedbackTextAreaOverride.bind(this),thumbsUpValue:this.config.feedbackwidget?.thumbsUpValue??10,thumbsDownValue:this.config.feedbackwidget?.thumbsDownValue??0,lightweightTemplateOverride:this.config.feedbackwidget?.lightweightTemplateOverride})}showMore(e){e.preventDefault(),this.clicked=!0,this.showMoreVisible=!1,this.renderMainTemplate(this.generateTemplateData()),this.config.testString||setTimeout(()=>{this.initializeWidget()},600)}attachClickEventToShowMore(){const e=document.querySelector(".searchstax-answer-load-more-button");e&&e.addEventListener("click",this.showMore.bind(this))}trackLinkClick(e){e.preventDefault(),e.stopPropagation();const t=e.target.getAttribute("href");ye.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||f.answer.main.template;this.dataLayer.renderingEngine===N.mustache?(!this.renderedWithShowMore||!e.answerLoading||this.clicked)&&(e.showMoreButtonVisible&&(this.renderedWithShowMore=!0),this.answerContainer.innerHTML=T.render(t,e),setTimeout(()=>{this.attachClickEventToShowMore(),this.attachLinkTracking()},100)):setTimeout(()=>{this.attachLinkTracking()},500)}generateTemplateData(){this.config.testString&&this.dataLayer.setAnswerData(this.config.testString??"");const e={...this.dataLayer.parsedData.data,showMoreButtonVisible:this.showMoreVisible};return this.config.testString&&(e.searchExecuted=!0),this.dataLayer.setAnswerFullData(e),e}}class zs{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||f.location.mainTemplate.template,s={...this.dataLayer.parsedData.data};if(this.dataLayer.setLocationWidgetTemplateData(s),this.dataLayer.renderingEngine===N.mustache){const a=T.render(t,s);e.innerHTML=a;const r=this.config.templates?.mainTemplate?.locationInputId||f.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 o=this.config.templates?.mainTemplate?.radiusInputId||f.location.mainTemplate.radiusInputId,l=document?.querySelector(`#${o}`);l instanceof HTMLSelectElement&&(this.radiusInput=l,l.addEventListener("change",this.radiusSelectChangeEvent.bind(this)));const h=this.config.templates?.mainTemplate?.currentLocationActionButtonId||f.location.mainTemplate.currentLocationActionButtonId,m=document?.querySelector(`#${h}`);m&&m.addEventListener("click",this.getCurrentLocation.bind(this))}}}setCurrentLocationFields(e){this.dataLayer.setLocationCoordinatesDecoded(e),this.dataLayer.setSearchLocation(this.dataLayer.searchLocationCoordinatesDecoded),this.dataLayer.renderingEngine===N.mustache&&this.locationInput&&(this.locationInput.value=this.dataLayer.searchLocationCoordinatesDecoded)}getCurrentLocation(){navigator.geolocation?navigator.geolocation.getCurrentPosition(e=>{const t=e.coords.latitude.toString(),s=e.coords.longitude.toString(),a=Math.floor(parseFloat(t)*100)/100,r=Math.floor(parseFloat(s)*100)/100;this.dataLayer.setSearchLat(a+""),this.dataLayer.setSearchLong(r+"");const n=this.locationDecodeCoordinatesToAddress;n?n(a+"",r+"").then(o=>{this.setCurrentLocationFields(o.address||"Current Location")}).catch(()=>{this.setCurrentLocationFields("Current Location")}):this.setCurrentLocationFields("Current Location")},()=>{console.error("Unable to retrieve your location")}):console.error("Geolocation is not supported by this browser.")}setRadiusValue(e){this.dataLayer.setSearchRadius(e)}radiusSelectChangeEvent(e){this.currentSelectValue=e.target.value,this.setRadiusValue(this.currentSelectValue)}attachSubscriptions(){this.dataLayer.$searchObject.subscribe(e=>{this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(e.location.address??"")),this.radiusInput&&e.location.radius&&(this.radiusInput.value=e.location.radius||"")})}cleanSuggestionTerm(e){return U.removeXSSRiskyTags(e.replace(/(<([^>]+)>)/gi,"")).trim()}triggerGeocoder(e){const t=this.locationDecode;this.dataLayer.setLocationDecodingLoading(!0),e&&this.dataLayer.searchLocation!==e&&e!==this.dataLayer.searchLocationCoordinatesDecoded?t(e).then(s=>{this.dataLayer.setSearchLocation(s.address||""),this.dataLayer.setSearchLat(s.lat||""),this.dataLayer.setSearchLong(s.lon||""),this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(s.address||"")),this.dataLayer.renderingEngine===N.mustache&&s.error&&this.locationInput&&this.locationInput.classList.add("searchstax-input-location-error"),s.error?this.dataLayer.setLocationError(!0):this.dataLayer.setLocationError(!1),this.dataLayer.setLocationDecodingLoading(!1)}).catch(()=>{this.dataLayer.setLocationDecodingLoading(!1)}):e===""&&(this.dataLayer.setSearchLocation(void 0),this.dataLayer.setSearchLat(void 0),this.dataLayer.setSearchLong(void 0),this.dataLayer.setLocationDecodingLoading(!1))}focusEvent(e){e.target.classList.remove("searchstax-input-location-error"),this.dataLayer.setLocationError(!1)}blurEvent(e){const t=e.target.value;this.triggerGeocoder(t)}}class Wr{routerEnabled=!1;cachedQuery="";routerHelper;searchHelper;searchResultsConfig;searchPaginationConfig;searchFeedbackConfig;searchSortingConfig;searchFacetsConfig;relatedSearchesConfig;externalPromotionsConfig;searchInputWidget;searchLocationWidget;searchResultsWidget;searchFacetsWidget;searchPaginationWidget;searchFeedbackWidget;searchSortingWidget;relatedSearchesWidget;externalPromotionsWidget;answerWidget;locationObserver=null;dataLayer;firstRequest=!0;previousQuery="";eventSource=null;renderEngine=N.mustache;constructor(e=N.mustache){e&&(this.renderEngine=e)}setRenderingEngine(e=N.mustache){this.dataLayer.setRenderingEngine(e)}handleHooks(){this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&this.dataLayer.$searchResults.subscribe(e=>{this.dataLayer.searchstaxConfig.hooks.afterSearch(e,this.dataLayer.searchResultUnparsedData)}),setTimeout(()=>{this.dataLayer.$searchObject.subscribe(e=>{e.query!==this.previousQuery&&this.dataLayer.setAnswerData(""),e.query!==""&&e.query!==void 0&&e.query!=="undefined"?(this.search(e),e.query!==this.previousQuery&&this.startSSE(e.query)):this.dataLayer.searchLocationConfig?.locationSearchEnabled&&!this.dataLayer.searchLocationConfig?.locationValuesOverride?this.getMetadata(e):this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue),this.previousQuery=e.query})},10),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&ye.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){ye.attachAnalyticsScript(e)}initialize(e){if(this.dataLayer=new ir("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 hr({...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 As(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 As({})}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&&ye.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=rt.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=rt.combineResultsWithMetadata(e),s=rt.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!==ze.question&&e!==ze.notQuestion&&(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setAnswerData(this.dataLayer.getAnswerData+e))}cacheFacets(e){e?this.searchHelper?.cacheFacets(!0).then(()=>{}):this.searchHelper?.cacheFacets().then(()=>{})}parseSuggestSuggestResponse(e){let t=e;this.dataLayer.searchInputConfig?.hooks?.afterAutosuggest&&(t=this.dataLayer.searchInputConfig.hooks.afterAutosuggest(e)),this.dataLayer.setSearchAutosuggest(t)}suggest(e,t){this.searchHelper&&this.searchHelper.suggest(e,this.parseSuggestSuggestResponse.bind(this),t)}changeLanguage(e){this.searchHelper&&this.dataLayer.setLanguage(e)}addSearchInputWidget(e,t){this.dataLayer.searchInputConfig||this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.dataLayer.setSearchInputConfig(t),this.searchInputWidget=new Qr({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 zs({containerId:e,config:t,dataLayer:this.dataLayer}),t?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(t?.locationValuesOverride?.locationFilterDefaultValue)):this.dataLayer.$searchResultsMetadata.subscribeUntilHasValue(()=>{this.searchLocationWidget=new zs({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 Ur({containerId:e,config:t,dataLayer:this.dataLayer})}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new Br({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 $r({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper})}addSearchFeedbackWidget(e,t){this.searchFeedbackConfig=t,this.searchFeedbackWidget=new Vr({containerId:e,config:t,dataLayer:this.dataLayer,searchTrigger:this.executeSearch.bind(this)})}addSearchSortingWidget(e,t){this.searchSortingConfig=t,this.searchSortingWidget=new Hr({containerId:e,config:t,dataLayer:this.dataLayer})}addRelatedSearchesWidget(e,t){this.relatedSearchesConfig=t,this.relatedSearchesWidget=new _r({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 Fr({containerId:e,config:t,dataLayer:this.dataLayer})}addFacetsWidget(e,t){this.searchFacetsConfig=t,this.searchFacetsWidget=new zr({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper},this.cacheFacets.bind(this))}executeSearch(e,t){const s={...this.dataLayer.searchObject};s.query=U.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&&ye.trackRelatedSearchClick({...this.dataLayer.parsedData.trackingData,relatedSearch:e,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}executeLinkClick(e){let t=rt.findResultByUniqueId(e,this.dataLayer.searchResults??[]);t&&(this.searchResultsConfig?.hooks?.afterLinkClick&&(t=this.searchResultsConfig.hooks.afterLinkClick(t)),t&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&ye.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{Wr 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)}:&quot;${encodeURIComponent(e.value)}&quot;`),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};