@searchstax-inc/searchstudio-ux-js 4.2.2 → 4.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,48 +1,48 @@
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 F=(i=>(i[i.mustache=0]="mustache",i[i.vue=1]="vue",i[i.react=2]="react",i[i.angular=3]="angular",i))(F||{});function ea(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ie=ea();function ts(i){Ie=i}var st={exec:()=>null};function E(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(ee.caret,"$1"),t=t.replace(a,n),s},getRegex:()=>new RegExp(t,e)};return s}var ee={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")},si=/^(?:[ \t]*(?:\n|$))+/,ii=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ri=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,it=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ni=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ta=/(?:[*+-]|\d{1,9}[.)])/,as=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ss=E(as).replace(/bull/g,ta).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(),oi=E(as).replace(/bull/g,ta).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(),aa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ci=/^[^\n]+/,sa=/(?!\s*\])(?:\\.|[^\[\]\\])+/,li=E(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",sa).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),hi=E(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ta).getRegex(),vt="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",ia=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ui=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",ia).replace("tag",vt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),is=E(aa).replace("hr",it).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",vt).getRegex(),di=E(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",is).getRegex(),ra={blockquote:di,code:ii,def:li,fences:ri,heading:ni,hr:it,html:ui,lheading:ss,list:hi,newline:si,paragraph:is,table:st,text:ci},rs=E("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",it).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",vt).getRegex(),gi={...ra,lheading:oi,table:rs,paragraph:E(aa).replace("hr",it).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",rs).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",vt).getRegex()},pi={...ra,html:E(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ia).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:st,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:E(aa).replace("hr",it).replace("heading",` *#{1,6} *[^
2
+ ]`).replace("lheading",ss).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},mi=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,fi=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ns=/^( {2,}|\\)\n(?!\s*$)/,Li=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,At=/[\p{P}\p{S}]/u,na=/[\s\p{P}\p{S}]/u,os=/[^\s\p{P}\p{S}]/u,yi=E(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,na).getRegex(),cs=/(?!~)[\p{P}\p{S}]/u,wi=/(?!~)[\s\p{P}\p{S}]/u,Mi=/(?:[^\s\p{P}\p{S}]|~)/u,Ci=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,ls=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,bi=E(ls,"u").replace(/punct/g,At).getRegex(),xi=E(ls,"u").replace(/punct/g,cs).getRegex(),hs="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ki=E(hs,"gu").replace(/notPunctSpace/g,os).replace(/punctSpace/g,na).replace(/punct/g,At).getRegex(),Si=E(hs,"gu").replace(/notPunctSpace/g,Mi).replace(/punctSpace/g,wi).replace(/punct/g,cs).getRegex(),Ti=E("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,os).replace(/punctSpace/g,na).replace(/punct/g,At).getRegex(),vi=E(/\\(punct)/,"gu").replace(/punct/g,At).getRegex(),Ai=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(),Ei=E(ia).replace("(?:-->|$)","-->").getRegex(),Ii=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",Ei).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Et=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Di=E(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Et).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),us=E(/^!?\[(label)\]\[(ref)\]/).replace("label",Et).replace("ref",sa).getRegex(),ds=E(/^!?\[(ref)\](?:\[\])?/).replace("ref",sa).getRegex(),ji=E("reflink|nolink(?!\\()","g").replace("reflink",us).replace("nolink",ds).getRegex(),oa={_backpedal:st,anyPunctuation:vi,autolink:Ai,blockSkip:Ci,br:ns,code:fi,del:st,emStrongLDelim:bi,emStrongRDelimAst:ki,emStrongRDelimUnd:Ti,escape:mi,link:Di,nolink:ds,punctuation:yi,reflink:us,reflinkSearch:ji,tag:Ii,text:Li,url:st},Ri={...oa,link:E(/^!?\[(label)\]\((.*?)\)/).replace("label",Et).getRegex(),reflink:E(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Et).getRegex()},ca={...oa,emStrongRDelimAst:Si,emStrongLDelim:xi,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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Ni={...ca,br:E(ns).replace("{2,}","*").getRegex(),text:E(ca.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},It={normal:ra,gfm:gi,pedantic:pi},rt={normal:oa,gfm:ca,breaks:Ni,pedantic:Ri},Oi={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},gs=i=>Oi[i];function pe(i,e){if(e){if(ee.escapeTest.test(i))return i.replace(ee.escapeReplace,gs)}else if(ee.escapeTestNoEncode.test(i))return i.replace(ee.escapeReplaceNoEncode,gs);return i}function ps(i){try{i=encodeURI(i).replace(ee.percentDecode,"%")}catch{return null}return i}function ms(i,e){const t=i.replace(ee.findPipe,(r,n,c)=>{let l=!1,h=n;for(;--h>=0&&c[h]==="\\";)l=!l;return l?"|":" |"}),s=t.split(ee.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(ee.slashPipe,"|");return s}function nt(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 Pi(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 fs(i,e,t,s,a){const r=e.href,n=e.title||null,c=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:c,tokens:s.inlineTokens(c)};return s.state.inLink=!1,l}function zi(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[c]=n;return c.length>=a.length?r.slice(a.length):r}).join(`
4
+ `)}var Dt=class{options;rules;lexer;constructor(i){this.options=i||Ie}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:nt(t,`
5
+ `)}}}fences(i){const e=this.rules.block.fences.exec(i);if(e){const t=e[0],s=zi(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=nt(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:nt(e[0],`
6
+ `)}}blockquote(i){const e=this.rules.block.blockquote.exec(i);if(e){let t=nt(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 r=[];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 f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,r,!0),this.lexer.state.top=f,t.length===0)break;const L=r.at(-1);if(L?.type==="code")break;if(L?.type==="blockquote"){const j=L,A=j.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
+ `),x=this.blockquote(A);r[r.length-1]=x,s=s.substring(0,s.length-j.raw.length)+x.raw,a=a.substring(0,a.length-j.text.length)+x.text;break}else if(L?.type==="list"){const j=L,A=j.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
+ `),x=this.list(A);r[r.length-1]=x,s=s.substring(0,s.length-L.raw.length)+x.raw,a=a.substring(0,a.length-j.raw.length)+x.raw,t=A.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="",p="";if(!(e=r.exec(i))||this.rules.block.hr.test(i))break;h=e[0],i=i.substring(h.length);let f=e[2].split(`
18
+ `,1)[0].replace(this.rules.other.listReplaceTabs,D=>" ".repeat(3*D.length)),L=i.split(`
19
+ `,1)[0],j=!f.trim(),A=0;if(this.options.pedantic?(A=2,p=f.trimStart()):j?A=e[1].length+1:(A=e[2].search(this.rules.other.nonSpaceChar),A=A>4?1:A,p=f.slice(A),A+=e[1].length),j&&this.rules.other.blankLine.test(L)&&(h+=L+`
20
+ `,i=i.substring(L.length+1),l=!0),!l){const D=this.rules.other.nextBulletRegex(A),P=this.rules.other.hrRegex(A),re=this.rules.other.fencesBeginRegex(A),V=this.rules.other.headingBeginRegex(A),m=this.rules.other.htmlBeginRegex(A);for(;i;){const d=i.split(`
21
+ `,1)[0];let w;if(L=d,this.options.pedantic?(L=L.replace(this.rules.other.listReplaceNesting," "),w=L):w=L.replace(this.rules.other.tabCharGlobal," "),re.test(L)||V.test(L)||m.test(L)||D.test(L)||P.test(L))break;if(w.search(this.rules.other.nonSpaceChar)>=A||!L.trim())p+=`
22
+ `+w.slice(A);else{if(j||f.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||re.test(f)||V.test(f)||P.test(f))break;p+=`
23
+ `+L}!j&&!L.trim()&&(j=!0),h+=d+`
24
+ `,i=i.substring(d.length+1),f=w.slice(A)}}a.loose||(n?a.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(n=!0));let x=null,z;this.options.gfm&&(x=this.rules.other.listIsTask.exec(p),x&&(z=x[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:h,task:!!x,checked:z,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(f=>f.type==="space"),p=h.length>0&&h.some(f=>this.rules.other.anyLine.test(f.raw));a.loose=p}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=ms(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(ms(n,r.header.length).map((c,l)=>({text:c,tokens:this.lexer.inline(c),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=nt(t.slice(0,-1),"\\");if((t.length-r.length)%2===0)return}else{const r=Pi(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)),fs(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 fs(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,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*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]){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,f=i.slice(0,a+s.index+p+n);if(Math.min(a,n)%2){const j=f.slice(1,-1);return{type:"em",raw:f,text:j,tokens:this.lexer.inlineTokens(j)}}const L=f.slice(2,-2);return{type:"strong",raw:f,text:L,tokens:this.lexer.inlineTokens(L)}}}}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 Da{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ie,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:ee,block:It.normal,inline:rt.normal};this.options.pedantic?(t.block=It.pedantic,t.inline=rt.pedantic):this.options.gfm&&(t.block=It.gfm,this.options.breaks?t.inline=rt.breaks:t.inline=rt.gfm),this.tokenizer.rules=t}static get rules(){return{block:It,inline:rt}}static lex(e,t){return new Da(t).lex(e)}static lexInline(e,t){return new Da(t).inlineTokens(e)}lex(e){e=e.replace(ee.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(ee.tabCharGlobal," ").replace(ee.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 r=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&&(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+=`
33
33
  `+a.raw,n.text+=`
34
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+=`
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>
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 r=!1,n="";for(;e;){r||(n=""),r=!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 f;this.options.extensions.startInline.forEach(L=>{f=L.call({lexer:this},p),typeof f=="number"&&f>=0&&(h=Math.min(h,f))}),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)),r=!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}},jt=class{options;parser;constructor(i){this.options=i||Ie}space(i){return""}code({text:i,lang:e,escaped:t}){const s=(e||"").match(ee.notSpaceStart)?.[0],a=i.replace(ee.endingNewline,"")+`
37
+ `;return s?'<pre><code class="language-'+pe(s)+'">'+(t?a:pe(a,!0))+`</code></pre>
38
+ `:"<pre><code>"+(t?a:pe(a,!0))+`</code></pre>
39
39
  `}blockquote({tokens:i}){return`<blockquote>
40
40
  ${this.parser.parse(i)}</blockquote>
41
41
  `}html({text:i}){return i}heading({tokens:i,depth:e}){return`<h${e}>${this.parser.parseInline(i)}</h${e}>
42
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+`>
43
+ `}list(i){const e=i.ordered,t=i.start;let s="";for(let n=0;n<i.items.length;n++){const c=i.items[n];s+=this.listitem(c)}const a=e?"ol":"ul",r=e&&t!==1?' start="'+t+'"':"";return"<"+a+r+`>
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>
45
+ `}listitem(i){let e="";if(i.task){const t=this.checkbox({checked:!!i.checked});i.loose?i.tokens[0]?.type==="paragraph"?(i.tokens[0].text=t+" "+i.tokens[0].text,i.tokens[0].tokens&&i.tokens[0].tokens.length>0&&i.tokens[0].tokens[0].type==="text"&&(i.tokens[0].tokens[0].text=t+" "+pe(i.tokens[0].tokens[0].text),i.tokens[0].tokens[0].escaped=!0)):i.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:!0}):e+=t+" "}return e+=this.parser.parse(i.tokens,!!i.loose),`<li>${e}</li>
46
46
  `}checkbox({checked:i}){return"<input "+(i?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:i}){return`<p>${this.parser.parseInline(i)}</p>
47
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>
48
48
  <thead>
@@ -51,22 +51,23 @@ ${this.parser.parse(i)}</blockquote>
51
51
  `}tablerow({text:i}){return`<tr>
52
52
  ${i}</tr>
53
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(`
54
+ `}strong({tokens:i}){return`<strong>${this.parser.parseInline(i)}</strong>`}em({tokens:i}){return`<em>${this.parser.parseInline(i)}</em>`}codespan({text:i}){return`<code>${pe(i,!0)}</code>`}br(i){return"<br>"}del({tokens:i}){return`<del>${this.parser.parseInline(i)}</del>`}link({href:i,title:e,tokens:t}){const s=this.parser.parseInline(t),a=ps(i);if(a===null)return s;i=a;let r='<a href="'+i+'"';return e&&(r+=' title="'+pe(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=ps(i);if(a===null)return pe(t);i=a;let r=`<img src="${i}" alt="${t}"`;return e&&(r+=` title="${pe(e)}"`),r+=">",r}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:pe(i.text)}},la=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""}},Ce=class ja{options;renderer;textRenderer;constructor(e){this.options=e||Ie,this.options.renderer=this.options.renderer||new jt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new la}static parse(e,t){return new ja(t).parse(e)}static parseInline(e,t){return new ja(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 c=r,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=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 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 r=e[a];if(this.options.extensions?.renderers?.[r.type]){const c=this.options.extensions.renderers[r.type].call({parser:this},r);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){s+=c||"";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 c='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},Rt=class{options;block;constructor(i){this.options=i||Ie}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?Ce.parse:Ce.parseInline}},Fi=class{defaults=ea();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ce;Renderer=jt;TextRenderer=la;Lexer=Me;Tokenizer=Dt;Hooks=Rt;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 c=a.renderer.apply(this,n);return c===!1&&(c=r.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 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 jt(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,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 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,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 Rt;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,c=t.hooks[n],l=a[n];Rt.passThroughHooks.has(r)?a[n]=h=>{if(this.defaults.async)return Promise.resolve(c.call(a,h)).then(f=>l.call(a,f));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,r=t.walkTokens;s.walkTokens=function(n){let c=[];return c.push(r.call(this,n)),a&&(c=c.concat(a.call(this,n))),c}}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 Ce.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,c=a.hooks?a.hooks.provideParser():i?Ce.parse:Ce.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(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=c(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>"+pe(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},De=new Fi;function I(i,e){return De.parse(i,e)}I.options=I.setOptions=function(i){return De.setOptions(i),I.defaults=De.defaults,ts(I.defaults),I},I.getDefaults=ea,I.defaults=Ie,I.use=function(...i){return De.use(...i),I.defaults=De.defaults,ts(I.defaults),I},I.walkTokens=function(i,e){return De.walkTokens(i,e)},I.parseInline=De.parseInline,I.Parser=Ce,I.parser=Ce.parse,I.Renderer=jt,I.TextRenderer=la,I.Lexer=Me,I.lexer=Me.lex,I.Tokenizer=Dt,I.Hooks=Rt,I.parse=I,I.options,I.setOptions,I.use,I.walkTokens,I.parseInline,Ce.parse,Me.lex;function Ls(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,s=Array(e);t<e;t++)s[t]=i[t];return s}function $i(i){if(Array.isArray(i))return i}function Vi(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var s,a,r,n,c=[],l=!0,h=!1;try{if(r=(t=t.call(i)).next,e!==0)for(;!(l=(s=r.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 Bi(){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 Qi(i,e){return $i(i)||Vi(i,e)||Hi(i,e)||Bi()}function Hi(i,e){if(i){if(typeof i=="string")return Ls(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ls(i,e):void 0}}const ys=Object.entries,ws=Object.setPrototypeOf,_i=Object.isFrozen,qi=Object.getPrototypeOf,Ui=Object.getOwnPropertyDescriptor;let te=Object.freeze,ne=Object.seal,Ve=Object.create,Ms=typeof Reflect<"u"&&Reflect,ha=Ms.apply,ua=Ms.construct;te||(te=function(i){return i}),ne||(ne=function(i){return i}),ha||(ha=function(i,e){for(var t=arguments.length,s=new Array(t>2?t-2:0),a=2;a<t;a++)s[a-2]=arguments[a];return i.apply(e,s)}),ua||(ua=function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;s<e;s++)t[s-1]=arguments[s];return new i(...t)});const Be=U(Array.prototype.forEach),Wi=U(Array.prototype.lastIndexOf),Cs=U(Array.prototype.pop),Qe=U(Array.prototype.push),Yi=U(Array.prototype.splice),ae=Array.isArray,ot=U(String.prototype.toLowerCase),da=U(String.prototype.toString),bs=U(String.prototype.match),He=U(String.prototype.replace),xs=U(String.prototype.indexOf),Ji=U(String.prototype.trim),Gi=U(Number.prototype.toString),Zi=U(Boolean.prototype.toString),ks=typeof BigInt>"u"?null:U(BigInt.prototype.toString),Ss=typeof Symbol>"u"?null:U(Symbol.prototype.toString),$=U(Object.prototype.hasOwnProperty),ct=U(Object.prototype.toString),K=U(RegExp.prototype.test),lt=Ki(TypeError);function U(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,s=new Array(t>1?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];return ha(i,e,s)}}function Ki(i){return function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return ua(i,t)}}function b(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ot;if(ws&&ws(i,null),!ae(e))return i;let s=e.length;for(;s--;){let a=e[s];if(typeof a=="string"){const r=t(a);r!==a&&(_i(e)||(e[s]=r),a=r)}i[a]=!0}return i}function Xi(i){for(let e=0;e<i.length;e++)$(i,e)||(i[e]=null);return i}function X(i){const e=Ve(null);for(const s of ys(i)){var t=Qi(s,2);const a=t[0],r=t[1];$(i,a)&&(ae(r)?e[a]=Xi(r):r&&typeof r=="object"&&r.constructor===Object?e[a]=X(r):e[a]=r)}return e}function er(i){switch(typeof i){case"string":return i;case"number":return Gi(i);case"boolean":return Zi(i);case"bigint":return ks?ks(i):"0";case"symbol":return Ss?Ss(i):"Symbol()";case"undefined":return ct(i);case"function":case"object":{if(i===null)return ct(i);const e=i,t=me(e,"toString");if(typeof t=="function"){const s=t(e);return typeof s=="string"?s:ct(s)}return ct(i)}default:return ct(i)}}function me(i,e){for(;i!==null;){const s=Ui(i,e);if(s){if(s.get)return U(s.get);if(typeof s.value=="function")return U(s.value)}i=qi(i)}function t(){return null}return t}function tr(i){try{return K(i,""),!0}catch{return!1}}const Ts=te(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ga=te(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),pa=te(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ar=te(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ma=te(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),sr=te(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),vs=te(["#text"]),As=te(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),fa=te(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Es=te(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Nt=te(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ir=ne(/{{[\w\W]*|^[\w\W]*}}/g),rr=ne(/<%[\w\W]*|^[\w\W]*%>/g),nr=ne(/\${[\w\W]*/g),or=ne(/^data-[\-\w.\u00B7-\uFFFF]+$/),cr=ne(/^aria-[\-\w]+$/),Is=ne(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),lr=ne(/^(?:\w+script|data):/i),hr=ne(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ur=ne(/^html$/i),dr=ne(/^[a-z][.\w]*(-[.\w]+)+$/i),fe={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},gr=function(){return typeof window>"u"?null:window},pr=function(i,e){if(typeof i!="object"||typeof i.createPolicy!="function")return null;let t=null;const s="data-tt-policy-suffix";e&&e.hasAttribute(s)&&(t=e.getAttribute(s));const a="dompurify"+(t?"#"+t:"");try{return i.createPolicy(a,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Ds=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function js(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gr();const e=o=>js(o);if(e.version="3.4.7",e.removed=[],!i||!i.document||i.document.nodeType!==fe.document||!i.Element)return e.isSupported=!1,e;let t=i.document;const s=t,a=s.currentScript;i.DocumentFragment;const r=i.HTMLTemplateElement,n=i.Node,c=i.Element,l=i.NodeFilter;i.NamedNodeMap===void 0&&(i.NamedNodeMap||i.MozNamedAttrMap),i.HTMLFormElement;const p=i.DOMParser,f=i.trustedTypes,L=c.prototype,j=me(L,"cloneNode"),A=me(L,"remove"),x=me(L,"nextSibling"),z=me(L,"childNodes"),D=me(L,"parentNode"),P=me(L,"shadowRoot"),re=me(L,"attributes"),V=n&&n.prototype?me(n.prototype,"nodeType"):null,m=n&&n.prototype?me(n.prototype,"nodeName"):null;if(typeof r=="function"){const o=t.createElement("template");o.content&&o.content.ownerDocument&&(t=o.content.ownerDocument)}let d,w="";const T=t,B=T.implementation,ce=T.createNodeIterator,Ft=T.createDocumentFragment,$t=T.getElementsByTagName,Vt=s.importNode;let N=Ds();e.isSupported=typeof ys=="function"&&typeof D=="function"&&B&&B.createHTMLDocument!==void 0;const Te=ir,Lt=rr,yt=nr,qs=or,Us=cr,Ws=lr,Ra=hr,Ys=dr;let Na=Is,Q=null;const Bt=b({},[...Ts,...ga,...pa,...ma,...vs]);let q=null;const Qt=b({},[...As,...fa,...Es,...Nt]);let H=Object.seal(Ve(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ke=null,wt=null;const xe=Object.seal(Ve(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Oa=!0,Ht=!0,Pa=!1,za=!0,ke=!1,Xe=!0,ve=!1,_t=!1,qt=!1,Ne=!1,Mt=!1,Ct=!1,Fa=!0,$a=!1;const Va="user-content-";let Ut=!0,et=!1,Oe={},ue=null;const Wt=b({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ba=null;const Qa=b({},["audio","video","img","source","image","track"]);let Yt=null;const Ha=b({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),bt="http://www.w3.org/1998/Math/MathML",xt="http://www.w3.org/2000/svg",de="http://www.w3.org/1999/xhtml";let Pe=de,Jt=!1,Gt=null;const Js=b({},[bt,xt,de],da);let Zt=b({},["mi","mo","mn","ms","mtext"]),Kt=b({},["annotation-xml"]);const Gs=b({},["title","style","font","a","script"]);let tt=null;const Zs=["application/xhtml+xml","text/html"],Ks="text/html";let _=null,ze=null;const Xs=t.createElement("form"),_a=function(o){return o instanceof RegExp||o instanceof Function},Xt=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ze&&ze===o)return;(!o||typeof o!="object")&&(o={}),o=X(o),tt=Zs.indexOf(o.PARSER_MEDIA_TYPE)===-1?Ks:o.PARSER_MEDIA_TYPE,_=tt==="application/xhtml+xml"?da:ot,Q=$(o,"ALLOWED_TAGS")&&ae(o.ALLOWED_TAGS)?b({},o.ALLOWED_TAGS,_):Bt,q=$(o,"ALLOWED_ATTR")&&ae(o.ALLOWED_ATTR)?b({},o.ALLOWED_ATTR,_):Qt,Gt=$(o,"ALLOWED_NAMESPACES")&&ae(o.ALLOWED_NAMESPACES)?b({},o.ALLOWED_NAMESPACES,da):Js,Yt=$(o,"ADD_URI_SAFE_ATTR")&&ae(o.ADD_URI_SAFE_ATTR)?b(X(Ha),o.ADD_URI_SAFE_ATTR,_):Ha,Ba=$(o,"ADD_DATA_URI_TAGS")&&ae(o.ADD_DATA_URI_TAGS)?b(X(Qa),o.ADD_DATA_URI_TAGS,_):Qa,ue=$(o,"FORBID_CONTENTS")&&ae(o.FORBID_CONTENTS)?b({},o.FORBID_CONTENTS,_):Wt,Ke=$(o,"FORBID_TAGS")&&ae(o.FORBID_TAGS)?b({},o.FORBID_TAGS,_):X({}),wt=$(o,"FORBID_ATTR")&&ae(o.FORBID_ATTR)?b({},o.FORBID_ATTR,_):X({}),Oe=$(o,"USE_PROFILES")?o.USE_PROFILES&&typeof o.USE_PROFILES=="object"?X(o.USE_PROFILES):o.USE_PROFILES:!1,Oa=o.ALLOW_ARIA_ATTR!==!1,Ht=o.ALLOW_DATA_ATTR!==!1,Pa=o.ALLOW_UNKNOWN_PROTOCOLS||!1,za=o.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ke=o.SAFE_FOR_TEMPLATES||!1,Xe=o.SAFE_FOR_XML!==!1,ve=o.WHOLE_DOCUMENT||!1,Ne=o.RETURN_DOM||!1,Mt=o.RETURN_DOM_FRAGMENT||!1,Ct=o.RETURN_TRUSTED_TYPE||!1,qt=o.FORCE_BODY||!1,Fa=o.SANITIZE_DOM!==!1,$a=o.SANITIZE_NAMED_PROPS||!1,Ut=o.KEEP_CONTENT!==!1,et=o.IN_PLACE||!1,Na=tr(o.ALLOWED_URI_REGEXP)?o.ALLOWED_URI_REGEXP:Is,Pe=typeof o.NAMESPACE=="string"?o.NAMESPACE:de,Zt=$(o,"MATHML_TEXT_INTEGRATION_POINTS")&&o.MATHML_TEXT_INTEGRATION_POINTS&&typeof o.MATHML_TEXT_INTEGRATION_POINTS=="object"?X(o.MATHML_TEXT_INTEGRATION_POINTS):b({},["mi","mo","mn","ms","mtext"]),Kt=$(o,"HTML_INTEGRATION_POINTS")&&o.HTML_INTEGRATION_POINTS&&typeof o.HTML_INTEGRATION_POINTS=="object"?X(o.HTML_INTEGRATION_POINTS):b({},["annotation-xml"]);const u=$(o,"CUSTOM_ELEMENT_HANDLING")&&o.CUSTOM_ELEMENT_HANDLING&&typeof o.CUSTOM_ELEMENT_HANDLING=="object"?X(o.CUSTOM_ELEMENT_HANDLING):Ve(null);if(H=Ve(null),$(u,"tagNameCheck")&&_a(u.tagNameCheck)&&(H.tagNameCheck=u.tagNameCheck),$(u,"attributeNameCheck")&&_a(u.attributeNameCheck)&&(H.attributeNameCheck=u.attributeNameCheck),$(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(H.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),ke&&(Ht=!1),Mt&&(Ne=!0),Oe&&(Q=b({},vs),q=Ve(null),Oe.html===!0&&(b(Q,Ts),b(q,As)),Oe.svg===!0&&(b(Q,ga),b(q,fa),b(q,Nt)),Oe.svgFilters===!0&&(b(Q,pa),b(q,fa),b(q,Nt)),Oe.mathMl===!0&&(b(Q,ma),b(q,Es),b(q,Nt))),xe.tagCheck=null,xe.attributeCheck=null,$(o,"ADD_TAGS")&&(typeof o.ADD_TAGS=="function"?xe.tagCheck=o.ADD_TAGS:ae(o.ADD_TAGS)&&(Q===Bt&&(Q=X(Q)),b(Q,o.ADD_TAGS,_))),$(o,"ADD_ATTR")&&(typeof o.ADD_ATTR=="function"?xe.attributeCheck=o.ADD_ATTR:ae(o.ADD_ATTR)&&(q===Qt&&(q=X(q)),b(q,o.ADD_ATTR,_))),$(o,"ADD_URI_SAFE_ATTR")&&ae(o.ADD_URI_SAFE_ATTR)&&b(Yt,o.ADD_URI_SAFE_ATTR,_),$(o,"FORBID_CONTENTS")&&ae(o.FORBID_CONTENTS)&&(ue===Wt&&(ue=X(ue)),b(ue,o.FORBID_CONTENTS,_)),$(o,"ADD_FORBID_CONTENTS")&&ae(o.ADD_FORBID_CONTENTS)&&(ue===Wt&&(ue=X(ue)),b(ue,o.ADD_FORBID_CONTENTS,_)),Ut&&(Q["#text"]=!0),ve&&b(Q,["html","head","body"]),Q.table&&(b(Q,["tbody"]),delete Ke.tbody),o.TRUSTED_TYPES_POLICY){if(typeof o.TRUSTED_TYPES_POLICY.createHTML!="function")throw lt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof o.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw lt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');d=o.TRUSTED_TYPES_POLICY,w=d.createHTML("")}else d===void 0&&(d=pr(f,a)),d!==null&&typeof w=="string"&&(w=d.createHTML(""));(N.uponSanitizeElement.length>0||N.uponSanitizeAttribute.length>0)&&Q===Bt&&(Q=X(Q)),N.uponSanitizeAttribute.length>0&&q===Qt&&(q=X(q)),te&&te(o),ze=o},qa=b({},[...ga,...pa,...ar]),Ua=b({},[...ma,...sr]),ei=function(o){let u=D(o);(!u||!u.tagName)&&(u={namespaceURI:Pe,tagName:"template"});const g=ot(o.tagName),C=ot(u.tagName);return Gt[o.namespaceURI]?o.namespaceURI===xt?u.namespaceURI===de?g==="svg":u.namespaceURI===bt?g==="svg"&&(C==="annotation-xml"||Zt[C]):!!qa[g]:o.namespaceURI===bt?u.namespaceURI===de?g==="math":u.namespaceURI===xt?g==="math"&&Kt[C]:!!Ua[g]:o.namespaceURI===de?u.namespaceURI===xt&&!Kt[C]||u.namespaceURI===bt&&!Zt[C]?!1:!Ua[g]&&(Gs[g]||!qa[g]):!!(tt==="application/xhtml+xml"&&Gt[o.namespaceURI]):!1},Ae=function(o){Qe(e.removed,{element:o});try{D(o).removeChild(o)}catch{A(o)}},Ee=function(o,u){try{Qe(e.removed,{attribute:u.getAttributeNode(o),from:u})}catch{Qe(e.removed,{attribute:null,from:u})}if(u.removeAttribute(o),o==="is")if(Ne||Mt)try{Ae(u)}catch{}else try{u.setAttribute(o,"")}catch{}},Wa=function(o){let u=null,g=null;if(qt)o="<remove></remove>"+o;else{const R=bs(o,/^[\r\n\t ]+/);g=R&&R[0]}tt==="application/xhtml+xml"&&Pe===de&&(o='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+o+"</body></html>");const C=d?d.createHTML(o):o;if(Pe===de)try{u=new p().parseFromString(C,tt)}catch{}if(!u||!u.documentElement){u=B.createDocument(Pe,"template",null);try{u.documentElement.innerHTML=Jt?w:C}catch{}}const v=u.body||u.documentElement;return o&&g&&v.insertBefore(t.createTextNode(g),v.childNodes[0]||null),Pe===de?$t.call(u,ve?"html":"body")[0]:ve?u.documentElement:v},Ya=function(o){return ce.call(o.ownerDocument||o,o,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Ja=function(o){o.normalize();const u=ce.call(o.ownerDocument||o,o,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let g=u.nextNode();for(;g;){let C=g.data;Be([Te,Lt,yt],v=>{C=He(C,v," ")}),g.data=C,g=u.nextNode()}},kt=function(o){const u=m?m(o):null;return typeof u!="string"||_(u)!=="form"?!1:typeof o.nodeName!="string"||typeof o.textContent!="string"||typeof o.removeChild!="function"||o.attributes!==re(o)||typeof o.removeAttribute!="function"||typeof o.setAttribute!="function"||typeof o.namespaceURI!="string"||typeof o.insertBefore!="function"||typeof o.hasChildNodes!="function"||o.nodeType!==V(o)||o.childNodes!==z(o)},at=function(o){if(!V||typeof o!="object"||o===null)return!1;try{return V(o)===fe.documentFragment}catch{return!1}},St=function(o){if(!V||typeof o!="object"||o===null)return!1;try{return typeof V(o)=="number"}catch{return!1}};function ye(o,u,g){Be(o,C=>{C.call(e,u,g,ze)})}const Ga=function(o){let u=null;if(ye(N.beforeSanitizeElements,o,null),kt(o))return Ae(o),!0;const g=_(o.nodeName);if(ye(N.uponSanitizeElement,o,{tagName:g,allowedTags:Q}),Xe&&o.hasChildNodes()&&!St(o.firstElementChild)&&K(/<[/\w!]/g,o.innerHTML)&&K(/<[/\w!]/g,o.textContent)||Xe&&o.namespaceURI===de&&g==="style"&&St(o.firstElementChild)||o.nodeType===fe.progressingInstruction||Xe&&o.nodeType===fe.comment&&K(/<[/\w]/g,o.data))return Ae(o),!0;if(Ke[g]||!(xe.tagCheck instanceof Function&&xe.tagCheck(g))&&!Q[g]){if(!Ke[g]&&Ka(g)&&(H.tagNameCheck instanceof RegExp&&K(H.tagNameCheck,g)||H.tagNameCheck instanceof Function&&H.tagNameCheck(g)))return!1;if(Ut&&!ue[g]){const C=D(o),v=z(o);if(v&&C){const R=v.length;for(let we=R-1;we>=0;--we){const ge=j(v[we],!0);C.insertBefore(ge,x(o))}}}return Ae(o),!0}return(V?V(o):o.nodeType)===fe.element&&!ei(o)||(g==="noscript"||g==="noembed"||g==="noframes")&&K(/<\/no(script|embed|frames)/i,o.innerHTML)?(Ae(o),!0):(ke&&o.nodeType===fe.text&&(u=o.textContent,Be([Te,Lt,yt],C=>{u=He(u,C," ")}),o.textContent!==u&&(Qe(e.removed,{element:o.cloneNode()}),o.textContent=u)),ye(N.afterSanitizeElements,o,null),!1)},Za=function(o,u,g){if(wt[u]||Fa&&(u==="id"||u==="name")&&(g in t||g in Xs))return!1;const C=q[u]||xe.attributeCheck instanceof Function&&xe.attributeCheck(u,o);if(!(Ht&&!wt[u]&&K(qs,u))&&!(Oa&&K(Us,u))){if(!C||wt[u]){if(!(Ka(o)&&(H.tagNameCheck instanceof RegExp&&K(H.tagNameCheck,o)||H.tagNameCheck instanceof Function&&H.tagNameCheck(o))&&(H.attributeNameCheck instanceof RegExp&&K(H.attributeNameCheck,u)||H.attributeNameCheck instanceof Function&&H.attributeNameCheck(u,o))||u==="is"&&H.allowCustomizedBuiltInElements&&(H.tagNameCheck instanceof RegExp&&K(H.tagNameCheck,g)||H.tagNameCheck instanceof Function&&H.tagNameCheck(g))))return!1}else if(!Yt[u]&&!K(Na,He(g,Ra,""))&&!((u==="src"||u==="xlink:href"||u==="href")&&o!=="script"&&xs(g,"data:")===0&&Ba[o])&&!(Pa&&!K(Ws,He(g,Ra,"")))&&g)return!1}return!0},ti=b({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ka=function(o){return!ti[ot(o)]&&K(Ys,o)},Xa=function(o){ye(N.beforeSanitizeAttributes,o,null);const u=o.attributes;if(!u||kt(o))return;const g={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:q,forceKeepAttr:void 0};let C=u.length;for(;C--;){const v=u[C],R=v.name,we=v.namespaceURI,ge=v.value,le=_(R),$e=ge;let J=R==="value"?$e:Ji($e);if(g.attrName=le,g.attrValue=J,g.keepAttr=!0,g.forceKeepAttr=void 0,ye(N.uponSanitizeAttribute,o,g),J=g.attrValue,$a&&(le==="id"||le==="name")&&xs(J,Va)!==0&&(Ee(R,o),J=Va+J),Xe&&K(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,J)){Ee(R,o);continue}if(le==="attributename"&&bs(J,"href")){Ee(R,o);continue}if(g.forceKeepAttr)continue;if(!g.keepAttr){Ee(R,o);continue}if(!za&&K(/\/>/i,J)){Ee(R,o);continue}ke&&Be([Te,Lt,yt],ai=>{J=He(J,ai," ")});const es=_(o.nodeName);if(!Za(es,le,J)){Ee(R,o);continue}if(d&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!we)switch(f.getAttributeType(es,le)){case"TrustedHTML":{J=d.createHTML(J);break}case"TrustedScriptURL":{J=d.createScriptURL(J);break}}if(J!==$e)try{we?o.setAttributeNS(we,R,J):o.setAttribute(R,J),kt(o)?Ae(o):Cs(e.removed)}catch{Ee(R,o)}}ye(N.afterSanitizeAttributes,o,null)},Tt=function(o){let u=null;const g=Ya(o);for(ye(N.beforeSanitizeShadowDOM,o,null);u=g.nextNode();)if(ye(N.uponSanitizeShadowNode,u,null),Ga(u),Xa(u),at(u.content)&&Tt(u.content),(V?V(u):u.nodeType)===fe.element){const C=P?P(u):u.shadowRoot;at(C)&&(Fe(C),Tt(C))}ye(N.afterSanitizeShadowDOM,o,null)},Fe=function(o){const u=V?V(o):o.nodeType;if(u===fe.element){const v=P?P(o):o.shadowRoot;at(v)&&(Fe(v),Tt(v))}const g=z?z(o):o.childNodes;if(!g)return;const C=[];Be(g,v=>{Qe(C,v)});for(const v of C)Fe(v);if(u===fe.element){const v=m?m(o):null;if(typeof v=="string"&&_(v)==="template"){const R=o.content;at(R)&&Fe(R)}}};return e.sanitize=function(o){let u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},g=null,C=null,v=null,R=null;if(Jt=!o,Jt&&(o="<!-->"),typeof o!="string"&&!St(o)&&(o=er(o),typeof o!="string"))throw lt("dirty is not a string, aborting");if(!e.isSupported)return o;if(_t||Xt(u),e.removed=[],typeof o=="string"&&(et=!1),et){const le=m?m(o):o.nodeName;if(typeof le=="string"){const $e=_(le);if(!Q[$e]||Ke[$e])throw lt("root node is forbidden and cannot be sanitized in-place")}if(kt(o))throw lt("root node is clobbered and cannot be sanitized in-place");Fe(o)}else if(St(o))g=Wa("<!---->"),C=g.ownerDocument.importNode(o,!0),C.nodeType===fe.element&&C.nodeName==="BODY"||C.nodeName==="HTML"?g=C:g.appendChild(C),Fe(C);else{if(!Ne&&!ke&&!ve&&o.indexOf("<")===-1)return d&&Ct?d.createHTML(o):o;if(g=Wa(o),!g)return Ne?null:Ct?w:""}g&&qt&&Ae(g.firstChild);const we=Ya(et?o:g);for(;v=we.nextNode();)Ga(v),Xa(v),at(v.content)&&Tt(v.content);if(et)return ke&&Ja(o),o;if(Ne){if(ke&&Ja(g),Mt)for(R=Ft.call(g.ownerDocument);g.firstChild;)R.appendChild(g.firstChild);else R=g;return(q.shadowroot||q.shadowrootmode)&&(R=Vt.call(s,R,!0)),R}let ge=ve?g.outerHTML:g.innerHTML;return ve&&Q["!doctype"]&&g.ownerDocument&&g.ownerDocument.doctype&&g.ownerDocument.doctype.name&&K(ur,g.ownerDocument.doctype.name)&&(ge="<!DOCTYPE "+g.ownerDocument.doctype.name+`>
58
+ `+ge),ke&&Be([Te,Lt,yt],le=>{ge=He(ge,le," ")}),d&&Ct?d.createHTML(ge):ge},e.setConfig=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Xt(o),_t=!0},e.clearConfig=function(){ze=null,_t=!1},e.isValidAttribute=function(o,u,g){ze||Xt({});const C=_(o),v=_(u);return Za(C,v,g)},e.addHook=function(o,u){typeof u=="function"&&Qe(N[o],u)},e.removeHook=function(o,u){if(u!==void 0){const g=Wi(N[o],u);return g===-1?void 0:Yi(N[o],g,1)[0]}return Cs(N[o])},e.removeHooks=function(o){N[o]=[]},e.removeAllHooks=function(){N=Ds()},e}var Rs=js();class mr{dataLayer;constructor(e){this.dataLayer=e}get answerWidgetShowMoreLimit(){return this.dataLayer.answerWidgetShowMoreLimit??100}get currentPage(){return this.dataLayer.searchObject?.page}get totalPages(){return this.resultsPerPage===0?0:Math.ceil(this.totalResults/this.resultsPerPage)}get totalResults(){return this.dataLayer.searchResultsMetadata?.totalResultsValue||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){return this.dataLayer.searchResultsMetadata?.sorting.options||[]}get selectedSortOption(){return this.dataLayer.searchResultsMetadata?.sorting.selectedSortOption||""}get startResultIndex(){return(this.dataLayer.searchObject?.page-1)*this.resultsPerPage+1}get endResultIndex(){const e=(this.dataLayer.searchObject?.page-1)*this.resultsPerPage+(this.resultsPerPage??0);return e>this.totalResults?this.totalResults:e}get isFirstPage(){return this.dataLayer.searchObject?.page===1}get isLastPage(){return this.dataLayer.searchObject?.page>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){return this.dataLayer.searchResultsMetadata?.autoCorrectedQuery||""}get originalQuery(){return this.dataLayer.searchObject?.query||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswerLoadMore(){return this.dataLayer.getAnswerData.split(" ").length>this.answerWidgetShowMoreLimit}get answerTruncated(){return this.dataLayer.getAnswerData.split(" ").slice(0,this.answerWidgetShowMoreLimit).join(" ")+"..."}get fullAnswerFormatted(){return Rs.sanitize(I.parse(this.dataLayer.getAnswerData)).replace(/<a /g,'<a target="_blank" class="searchstax-answer-link" rel="noopener noreferrer" ')}get answerLoading(){return this.dataLayer.answerLoading}get shouldShowAnswerError(){return this.dataLayer.answerError}get locationError(){return this.dataLayer.locationError}get shouldShowAnswer(){return(this.dataLayer.getAnswerData!==""||this.dataLayer.parsedData.answerLoading||this.shouldShowAnswerError)&&this.dataLayer.searchObject.query!=="*"}get searchTerm(){return this.dataLayer.searchResultsMetadata?.autoCorrectedQuery||this.dataLayer.searchObject?.query||""}get locationSearchEnabled(){return this.dataLayer.locationEnabled??!1}get locationSearchDistanceEnabled(){return(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationDistanceEnabled?this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationDistanceEnabled:this.dataLayer.searchResultsMetadata?.location?.filter?.enabled)??!1}get locationSearchDistanceValues(){const e=this.dataLayer.searchLocationConfig?.locationValuesOverride?.filterValues??this.dataLayer.searchResultsMetadata?.location?.filter?.values,t=this.dataLayer.searchLocationConfig?.locationValuesOverride?.filterUnit??this.dataLayer.searchResultsMetadata?.location?.unit;return!e||e.length===0?[]:e.map(s=>({label:s==="any"?"Any Distance":s+" "+(t??""),value:s,isSelected:s===this.dataLayer.searchRadius})).sort((s,a)=>{const r=s.value==="any"?0:parseFloat(s.value),n=a.value==="any"?0:parseFloat(a.value);return r-n})}get shouldShowLocationDistanceDropdown(){return this.locationSearchDistanceEnabled&&this.locationSearchDistanceValues.length>1}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get answerErrorMessage(){return Rs.sanitize(I.parse(this.dataLayer.answerErrorMessage)).replace("<br>","")}get searchExecuted(){return this.dataLayer.searchObject?.query!==void 0&&this.dataLayer.searchObject?.query!=="undefined"&&this.dataLayer.searchObject?.query!==""}get selectedFacets(){const e=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return e?(this.dataLayer.searchObject?.facets??[]).map(t=>{const s=t.name,a=t.value,r=e.find(n=>n.name===s);if(r){const n=r.values.find(c=>c.type==="range"?!1:c.type==="checkbox"?'"'+c.value+'"'===a:!1);if(n)return n}return null}).filter(t=>t!==null):[]}get cachedANDFacets(){let e="";for(const t of this.dataLayer.searchObject.facets)(t.type==="and"||t.type==="tabs")&&(e+=JSON.stringify(t));return e}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalPages:this.totalPages,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,selectedFacets:this.selectedFacets,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,answerTruncated:this.answerTruncated,fullAnswerFormatted:this.fullAnswerFormatted,shouldShowAnswerLoadMore:this.shouldShowAnswerLoadMore,answerLoading:this.answerLoading,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption,shouldShowAnswerError:this.shouldShowAnswerError,answerErrorMessage:this.answerErrorMessage,locationSearchEnabled:this.locationSearchEnabled,locationSearchDistanceEnabled:this.locationSearchDistanceEnabled,locationSearchDistanceValues:this.locationSearchDistanceValues,shouldShowLocationDistanceDropdown:this.shouldShowLocationDistanceDropdown,locationError:this.locationError}}get trackingData(){return{searchTerm:this.searchTerm,trackApiKey:this.dataLayer.searchstaxConfig?.trackApiKey??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:this.dataLayer.searchResultsMetadata?.recordsPerPageValue??0,totalResults:this.dataLayer.searchResultsMetadata?.totalResultsValue??0,currentPage:this.dataLayer.currentPage,latencyVal:this.dataLayer.searchResultsMetadata?.latency??0,...this.dataLayer.model?{model:this.dataLayer.model}:{}}}}class oe{static deepEqual(e,t){const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(const r of s){const n=e[r],c=t[r],l=this.isObject(n)&&this.isObject(c);if(l&&!this.deepEqual(n,c)||!l&&n!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class M{value;observers={};constructor(e){this.value=e,this.observers={}}subscribe(e,t){const s=Math.random().toString(36).substring(2,15),a=t||s;return this.observers[a]=e,e(this.value),a}unsubscribe(e){this.observers[e]&&delete this.observers[e]}subscribeOnce(e){const t=Math.random().toString(36).substring(2,15),s=a=>{e(a),this.unsubscribe(t)};this.subscribe(s,t)}subscribeTwice(e){const t=Math.random().toString(36).substring(2,15);let s=0;const a=r=>{s++,e(r),s>=2&&this.unsubscribe(t)};this.subscribe(a,t)}subscribeUntil(e,t,s=6e3,a=!0){const r=Math.random().toString(36).substring(2,15),n=c=>{c===t&&(e(c),this.unsubscribe(r))};return this.value===t?(e(this.value),null):(this.subscribe(n,r),setTimeout(()=>{a&&this.observers[r]&&e(this.value),this.unsubscribe(r)},s),r)}subscribeUntilHasValue(e,t=6e3,s=!0){const a=Math.random().toString(36).substring(2,15),r=n=>{n!=null&&(e(n),this.unsubscribe(a))};return this.value!==null&&this.value!==void 0?(e(this.value),null):(this.subscribe(r,a),t>0&&setTimeout(()=>{s&&this.observers[a]&&e(this.value),this.unsubscribe(a)},t),r)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){for(const e in this.observers)if(Object.prototype.hasOwnProperty.call(this.observers,e)){const t=this.observers[e];typeof t=="function"&&t(this.value)}}}class La{static getOrSetCookie(e,t){let s=this.getCookie(e);return s==null&&(s=t??this.makeid(25),this.setCookie(e,s,{secure:!0,"max-age":3600})),s}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=s.length;for(let r=0;r<e;r++)t+=s.charAt(Math.floor(Math.random()*a));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,s){const a={path:"/",...s};s.expires instanceof Date&&(a.expires=s.expires.toUTCString());let r=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const n in a){r+="; "+n;const c=a[n];c!==!0&&(r+="="+c)}typeof document<"u"&&(document.cookie=r)}}class G{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",s=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(s,""):""}}class fr{$searchTermChange=new M("");$searchLocationChange=new M("");$searchLocationCoordinatesDecoded=new M("");$searchLatChange=new M("");$searchLongChange=new M("");$searchRadiusChange=new M(void 0);$loadingChange=new M(!1);$locationError=new M(!1);$searchResults=new M(null);$searchResultsMetadata=new M(null);$searchAutosuggest=new M(null);$searchFacets=new M(null);$searchFacetsCached=new M(null);$searchFacetsCachedTabs=new M(null);$searchstaxConfig=new M(null);$autosuggestResults=new M(null);$itemsPerPage=new M(void 0);$searchObject=new M({query:"",itemsPerPage:void 0,page:99999999,order:"",facets:[],additionalProps:[],location:{term:void 0,radius:void 0,lat:void 0,lon:void 0},model:""});$searchRelatedSearches=new M(null);$searchInputConfig=new M(null);$searchLocationConfig=new M(null);$searchExternalPromotions=new M(null);$facetsTemplateData=new M(null);$selectedFacetsTemplateData=new M(null);$paginationData=new M(null);$answerData=new M(null);$searchFeedbackData=new M(null);$inputWidgetTemplateData=new M(null);$locationWidgetTemplateData=new M(null);$searchSortingData=new M(null);$searchRelatedSearchesData=new M(null);$searchExternalPromotionsData=new M(null);$cookiesDisabled=new M(null);$locationDecodingLoading=new M(!1);$answer=new M("");$language=new M("en");$model=new M("");$answerLoading=new M(!1);$locationEnabled=new M(null);$answerError=new M(!1);$answerErrorMessage=new M("");$isQuestion=new M(!1);$inputTemplateRendered=new M(!1);currentPageValue=1;isAnswerWidgetCreatedValue=!1;renderingEngineValue=F.mustache;parsedData=new mr(this);sessionId;sessionIdValue=null;autoCorrect=!0;forceNotCorrect=!1;lastSearchValue="";turnAIAnswerGenerationOn=!1;questionURL="";isInfiniteScroll=!1;firstSearchHappened=!1;facetsWereSet=!1;answerWidgetShowMoreLimit=100;searchHelper;searchResultUnparsed;constructor(e,t){this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,La.deleteCookie(this.sessionId),La.deleteCookie("ms_visitorid")):this.sessionIdValue=La.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(G.removeXSSRiskyTags(e))}setSearchLocation(e){this.$searchLocationChange.setValue(G.removeXSSRiskyTags(e))}setSearchRadius(e){this.$searchRadiusChange.setValue(e)}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setIsAnswerWidgetCreated(e){this.isAnswerWidgetCreatedValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){this.firstSearchHappened=!0,(!oe.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){oe.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){let t=e;t={...t,itemsPerPage:this.itemsPerPage,model:this.model},this.searchstaxConfig?.hooks?.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!oe.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&(this.searchObject.itemsPerPage!==t.itemsPerPage&&t.itemsPerPage!==void 0&&this.setItemsPerPage(t.itemsPerPage),this.$searchObject.setValue(t))}setSearchFacets(e){this.facetsWereSet=!0,oe.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){oe.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchFacetsCachedTabs(e){oe.deepEqual(e,this.searchFacetsCachedTabs??[])||this.$searchFacetsCachedTabs.setValue(e)}setSearchRelatedSearches(e){oe.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){oe.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setModel(e){this.$model.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setSearchLocationConfig(e){this.$searchLocationConfig.setValue(e)}setAutosuggestResults(e){this.$autosuggestResults.setValue(e)}setFacetsTemplateData(e){this.$facetsTemplateData.setValue(e)}setSelectedFacetsTemplateData(e){this.$selectedFacetsTemplateData.setValue(e)}setPaginationData(e){this.$paginationData.setValue(e)}setAnswerFullData(e){this.$answerData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}setAnswerLoading(e){this.$answerLoading.setValue(e)}setAnswerError(e){this.$answerError.setValue(e)}setIsQuestion(e){this.$isQuestion.setValue(e)}setAnswerErrorMessage(e){this.$answerErrorMessage.setValue(e)}setLocationDecodingLoading(e){this.$locationDecodingLoading.setValue(e)}setSearchLat(e){this.$searchLatChange.setValue(e)}setSearchLong(e){this.$searchLongChange.setValue(e)}setInputTemplateRendered(e){this.$inputTemplateRendered.setValue(e)}setLocationError(e){this.$locationError.setValue(e)}setInputWidgetTemplateData(e){this.$inputWidgetTemplateData.setValue(e)}setLocationWidgetTemplateData(e){this.$locationWidgetTemplateData.setValue(e)}setLocationCoordinatesDecoded(e){this.$searchLocationCoordinatesDecoded.setValue(G.removeXSSRiskyTags(e))}setLocationEnabled(e){this.$locationEnabled.setValue(e)}setSearchResultUnparsedData(e){this.searchResultUnparsed=e}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCached(){return this.$searchFacetsCached.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCached.getValue())):null}get searchFacetsCachedTabs(){return this.$searchFacetsCachedTabs.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCachedTabs.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get searchLocation(){return this.$searchLocationChange.getValue()}get searchRadius(){return this.$searchRadiusChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get model(){return this.$model.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get searchLocationConfig(){return this.$searchLocationConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}get answerFullData(){return this.$answerData.getValue()}get answerLoading(){return this.$answerLoading.getValue()}get isQuestion(){return this.$isQuestion.getValue()}get answerError(){return this.$answerError.getValue()}get answerErrorMessage(){return this.$answerErrorMessage.getValue()}get locationDecodingLoading(){return this.$locationDecodingLoading.getValue()}get searchLat(){return this.$searchLatChange.getValue()}get searchLong(){return this.$searchLongChange.getValue()}get inputTemplateRendered(){return this.$inputTemplateRendered.getValue()}get locationError(){return this.$locationError.getValue()}get inputWidgetTemplateData(){return this.$inputWidgetTemplateData.getValue()}get locationWidgetTemplateData(){return this.$locationWidgetTemplateData.getValue()}get searchLocationCoordinatesDecoded(){return this.$searchLocationCoordinatesDecoded.getValue()}get locationEnabled(){return this.$locationEnabled.getValue()}get searchResultUnparsedData(){return this.searchResultUnparsed}}class ht{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,r)=>{const n=a[e.responseHeader.params.uniqueId]??"",c={custom:null,uniqueId:n,position:s+1+r,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e,n):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e,n):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e,n):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,n):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,n,!0):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e,n):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e,n):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e,n):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e,n):null,distance:this.doesMapExist("distance",e)&&this.getValueByKey("distance",a,e,n)!=="Infinity"&&this.getValueByKey("distance",a,e,n)?Math.floor(this.getValueByKey("distance",a,e,n)):null,unit:e.metadata.locationSearch?.unit??"",unmappedFields:this.getUnmappedFields(a,e,n),allFields:this.getAllFields(a,e)};t.push(c)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const s of e.metadata.facets){let a={values:[]};if(a.name=s.name,a.label=s.label,s.name in e.facet_counts.facet_fields){const r=e.facet_counts.facet_fields[s.name];for(let n=0;n<r.length;n+=2){const c={};c.value=r[n],c.parentName=a.name,c.count=r[n+1],c.type="checkbox",a.values.push(c)}}a.values.length>0&&t.push(a)}return t}static extractSearchResultsMetadata(e){let t="",s={selectedSortOption:"",options:[]},a={enabled:!1,field:"",unit:"",filter:{enabled:!1,values:[],label:"",defaultValue:""}};if(e.metadata.locationSearch&&(a={enabled:e.metadata.locationSearch.enabled,field:e.metadata.locationSearch.field,unit:e.metadata.locationSearch.unit,filter:{enabled:e.metadata.locationSearch.filter?.enabled??!1,values:e.metadata.locationSearch.filter?.values??[],label:e.metadata.locationSearch.filter?.label??"",defaultValue:e.metadata.locationSearch.filter?.defaultValue??""}}),e.metadata.results.find(r=>r.result_card==="date")?.name,s.options=[],e.metadata.sorts?.length){const r=e.metadata.sorts.map(n=>({value:n.label,key:n.name+" "+n.order}));s.options=[{key:"",value:"Relevance"},...r]}return t=e?.spellcheck?.suggestions?.[1]?.suggestion?.[0]??"",typeof t!="string"&&(t=t?.word??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:t,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:s,location:a,isLocationMapped:this.doesMapExist("distance",e)}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const r=s[a],n={};n.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(n.cDocTitle=this.getDataForAnalytics(r.titleTracking)),n.position=r.position,t.push(n)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(s=>s.uniqueId===e)??null}static getUnmappedFields(e,t,s){const a=t.metadata.results.filter(n=>n.result_card==="").map(n=>n.name),r=[];for(const n of a)if(Object.keys(e).includes(n)){const c=Array.isArray(e[n])?this.getHighlightedResults(n,e[n].join(", "),s,t):this.getHighlightedResults(n,e[n]+"",s,t);r.push({key:n,value:c,isImage:this.checkIfImage(e[n])})}return r}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const s=t.metadata.results.map(r=>r.name),a=[];for(const r of Object.keys(e))s.indexOf(r)!==-1&&a.push({key:r,value:e[r],isImage:this.checkIfImage(e[r])});return a}static doesMapExist(e,t){return t.metadata.results.find(s=>s.result_card===e)!==void 0}static getValueByKey(e,t,s,a,r=!1){const n=s.metadata.results.find(l=>l.result_card===e);if(n===void 0)return null;const c=t[n.name];return c===void 0?null:typeof c=="string"?r?c:this.getHighlightedResults(n.name,c,a,s):typeof c=="number"?c:Array.isArray(c)?r?c.join(", "):this.getHighlightedResults(n.name,c.join(", "),a,s):null}static getHighlightedResults(e,t,s,a){if(a.highlighting&&s in a.highlighting){let r=a.highlighting[s];if(r&&e in r){let n=r[e];const c=this.cleanValue(n);if(c!=="")return c}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class Ns{routeName="searchstax";ignoredKeys=[];queryStringHelper;titleParser;constructor(e){e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new Lr(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=typeof document<"u"?document?.title:"";this.titleParser&&(s=this.titleParser(e)),typeof document<"u"&&(document.title=s),window?.location.href!==t&&window?.history.replaceState(window.history.state,s,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window?.location.href??"")?window?.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):window?.location.href+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},s=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=s+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.itemsPerPage&&e.itemsPerPage!==10&&(t[this.routeName+"[itemsPerPage]"]=e.itemsPerPage+""),e.location)for(const a in e.location){const r=e.location[a];r&&(t[this.routeName+`[location][${a}]`]=r)}if(e.facets)for(const a in e.facets){const r=e.facets[a].type+":"+encodeURIComponent(e.facets[a].name)+":"+encodeURIComponent(e.facets[a].value);t[this.routeName+`[facets][${a}]`]=r}if(e.model&&(t[this.routeName+"[model]"]=e.model),this.queryStringHelper.urlHasQueryParams(window?.location.href??"")){const a=this.queryStringHelper.urlToParams(window?.location.href??"");for(const r in a)r.startsWith(this.routeName)&&delete a[r];return{...a,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const s in e)s.startsWith(this.routeName)||(t[s]=e[s]);return t}extractArrayOfFacetsFromQueryParameters(e){const t=[];for(const s in e)if(s.startsWith(this.routeName+"[facets]")){const a=G.removeXSSRiskyTags(e[s].split(":")?.[0]),r=G.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[1])),n=G.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[2]));t.push({type:a,name:r,value:n})}return t}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),n=isNaN(r)?1:r;let c=parseInt(G.removeXSSRiskyTags(s[this.routeName+"[itemsPerPage]"]));return isNaN(c)&&(c=10),{query:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:n,itemsPerPage:t??c,order:G.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[],model:G.removeXSSRiskyTags(s[this.routeName+"[model]"])||"",location:{address:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][address]"]||"")),radius:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][radius]"]||"")),lat:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lat]"]||"")),lon:G.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lon]"]||""))}}}}class Lr{routeName="";constructor(e){this.routeName=e}stringify=(e,t)=>{const s=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(s).map(a=>{const r=s[a];return Array.isArray(r)?r.map(n=>`${a}=${n}`).join("&"):`${a}=${r}`}).join("&")};filterOutIgnoredKeys(e,t){const s=t||[],a={};return Object.keys(e).forEach(r=>{s.includes(r)||e[r]!==""&&(a[r]=e[r])}),a}urlToParams(e){const t={},s=e.split("?")[1];return s&&s.split("&").forEach(a=>{const[r,n]=a.split("=");t[r]=n}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const _e={question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class ya extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const Os=10,yr=13,je=32;function wa(i){}function wr(i){if(typeof i=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=wa,onError:t=wa,onRetry:s=wa,onComment:a,maxBufferSize:r}=i,n=[];let c=0,l=!0,h,p="",f=0,L,j=!1;function A(m){if(j)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l&&(l=!1,m.charCodeAt(0)===239&&m.charCodeAt(1)===187&&m.charCodeAt(2)===191&&(m=m.slice(3))),n.length===0){const T=z(m);T!==""&&(n.push(T),c=T.length),x();return}if(m.indexOf(`
59
+ `)===-1&&m.indexOf("\r")===-1){n.push(m),c+=m.length,x();return}n.push(m);const d=n.join("");n.length=0,c=0;const w=z(d);w!==""&&(n.push(w),c=w.length),x()}function x(){r!==void 0&&(c+p.length<=r||(j=!0,n.length=0,c=0,h=void 0,p="",f=0,L=void 0,t(new ya(`Buffered data exceeded max buffer size of ${r} characters`,{type:"max-buffer-size-exceeded"}))))}function z(m){let d=0;if(m.indexOf("\r")===-1){let w=m.indexOf(`
60
+ `,d);for(;w!==-1;){if(d===w){f>0&&e({id:h,event:L,data:p}),h=void 0,p="",f=0,L=void 0,d=w+1,w=m.indexOf(`
61
+ `,d);continue}const T=m.charCodeAt(d);if(Ps(m,d,T)){const B=m.charCodeAt(d+5)===je?d+6:d+5,ce=m.slice(B,w);if(f===0&&m.charCodeAt(w+1)===Os){e({id:h,event:L,data:ce}),h=void 0,p="",L=void 0,d=w+2,w=m.indexOf(`
62
+ `,d);continue}p=f===0?ce:`${p}
63
+ ${ce}`,f++}else zs(m,d,T)?L=m.slice(m.charCodeAt(d+6)===je?d+7:d+6,w)||void 0:D(m,d,w);d=w+1,w=m.indexOf(`
64
+ `,d)}return m.slice(d)}for(;d<m.length;){const w=m.indexOf("\r",d),T=m.indexOf(`
65
+ `,d);let B=-1;if(w!==-1&&T!==-1?B=w<T?w:T:w!==-1?w===m.length-1?B=-1:B=w:T!==-1&&(B=T),B===-1)break;D(m,d,B),d=B+1,m.charCodeAt(d-1)===yr&&m.charCodeAt(d)===Os&&d++}return m.slice(d)}function D(m,d,w){if(d===w){re();return}const T=m.charCodeAt(d);if(Ps(m,d,T)){const N=m.charCodeAt(d+5)===je?d+6:d+5,Te=m.slice(N,w);p=f===0?Te:`${p}
66
+ ${Te}`,f++;return}if(zs(m,d,T)){L=m.slice(m.charCodeAt(d+6)===je?d+7:d+6,w)||void 0;return}if(T===105&&m.charCodeAt(d+1)===100&&m.charCodeAt(d+2)===58){const N=m.slice(m.charCodeAt(d+3)===je?d+4:d+3,w);h=N.includes("\0")?void 0:N;return}if(T===58){if(a){const N=m.slice(d,w);a(N.slice(m.charCodeAt(d+1)===je?2:1))}return}const B=m.slice(d,w),ce=B.indexOf(":");if(ce===-1){P(B,"",B);return}const Ft=B.slice(0,ce),$t=B.charCodeAt(ce+1)===je?2:1,Vt=B.slice(ce+$t);P(Ft,Vt,B)}function P(m,d,w){switch(m){case"event":L=d||void 0;break;case"data":p=f===0?d:`${p}
67
+ ${d}`,f++;break;case"id":h=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.test(d)?s(parseInt(d,10)):t(new ya(`Invalid \`retry\` value: "${d}"`,{type:"invalid-retry",value:d,line:w}));break;default:t(new ya(`Unknown field "${m.length>20?`${m.slice(0,20)}\u2026`:m}"`,{type:"unknown-field",field:m,value:d,line:w}));break}}function re(){f>0&&e({id:h,event:L,data:p}),h=void 0,p="",f=0,L=void 0}function V(m={}){if(m.consume&&n.length>0){const d=n.join("");D(d,0,d.length)}l=!0,h=void 0,p="",f=0,L=void 0,n.length=0,c=0,j=!1}return{feed:A,reset:V}}function Ps(i,e,t){return t===100&&i.charCodeAt(e+1)===97&&i.charCodeAt(e+2)===116&&i.charCodeAt(e+3)===97&&i.charCodeAt(e+4)===58}function zs(i,e,t){return t===101&&i.charCodeAt(e+1)===118&&i.charCodeAt(e+2)===101&&i.charCodeAt(e+3)===110&&i.charCodeAt(e+4)===116&&i.charCodeAt(e+5)===58}class Fs extends Event{constructor(e,t){var s,a;super(e),this.code=(s=t?.code)!=null?s:void 0,this.message=(a=t?.message)!=null?a:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,t,s){return s($s(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e($s(this),t)}}function Mr(i){const e=globalThis.DOMException;return typeof e=="function"?new e(i,"SyntaxError"):new SyntaxError(i)}function Ma(i){return i instanceof Error?"errors"in i&&Array.isArray(i.errors)?i.errors.map(Ma).join(", "):"cause"in i&&i.cause instanceof Error?`${i}: ${Ma(i.cause)}`:i.message:`${i}`}function $s(i){return{type:i.type,message:i.message,code:i.code,defaultPrevented:i.defaultPrevented,cancelable:i.cancelable,timeStamp:i.timeStamp}}var Vs=i=>{throw TypeError(i)},Ca=(i,e,t)=>e.has(i)||Vs("Cannot "+t),k=(i,e,t)=>(Ca(i,e,"read from private field"),t?t.call(i):e.get(i)),W=(i,e,t)=>e.has(i)?Vs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),O=(i,e,t,s)=>(Ca(i,e,"write to private field"),e.set(i,t),t),be=(i,e,t)=>(Ca(i,e,"access private method"),t),ie,Re,qe,Ot,Pt,ut,Ue,dt,Se,We,Ye,Je,gt,he,ba,xa,ka,Bs,Sa,Ta,pt,va,Aa;class zt extends EventTarget{constructor(e,t){var s,a;super(),W(this,he),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,W(this,ie),W(this,Re),W(this,qe),W(this,Ot),W(this,Pt),W(this,ut),W(this,Ue),W(this,dt,null),W(this,Se),W(this,We),W(this,Ye,null),W(this,Je,null),W(this,gt,null),W(this,xa,async r=>{var n;k(this,We).reset();const{body:c,redirected:l,status:h,headers:p}=r;if(h===204){be(this,he,pt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(l?O(this,qe,new URL(r.url)):O(this,qe,void 0),h!==200){be(this,he,pt).call(this,`Non-200 status code (${h})`,h);return}if(!(p.get("content-type")||"").startsWith("text/event-stream")){be(this,he,pt).call(this,'Invalid content type, expected "text/event-stream"',h);return}if(k(this,ie)===this.CLOSED)return;O(this,ie,this.OPEN);const f=new Event("open");if((n=k(this,gt))==null||n.call(this,f),this.dispatchEvent(f),typeof c!="object"||!c||!("getReader"in c)){be(this,he,pt).call(this,"Invalid response body, expected a web ReadableStream",h),this.close();return}const L=new TextDecoder,j=c.getReader();let A=!0;do{const{done:x,value:z}=await j.read();z&&k(this,We).feed(L.decode(z,{stream:!x})),x&&(A=!1,k(this,We).reset(),be(this,he,va).call(this))}while(A)}),W(this,ka,r=>{O(this,Se,void 0),!(r.name==="AbortError"||r.type==="aborted")&&be(this,he,va).call(this,Ma(r))}),W(this,Sa,r=>{typeof r.id=="string"&&O(this,dt,r.id);const n=new MessageEvent(r.event||"message",{data:r.data,origin:k(this,qe)?k(this,qe).origin:k(this,Re).origin,lastEventId:r.id||""});k(this,Je)&&(!r.event||r.event==="message")&&k(this,Je).call(this,n),this.dispatchEvent(n)}),W(this,Ta,r=>{O(this,ut,r)}),W(this,Aa,()=>{O(this,Ue,void 0),k(this,ie)===this.CONNECTING&&be(this,he,ba).call(this)});try{if(e instanceof URL)O(this,Re,e);else if(typeof e=="string")O(this,Re,new URL(e,Cr()));else throw new Error("Invalid URL")}catch{throw Mr("An invalid or illegal string was specified")}O(this,We,wr({onEvent:k(this,Sa),onRetry:k(this,Ta)})),O(this,ie,this.CONNECTING),O(this,ut,3e3),O(this,Pt,(s=t?.fetch)!=null?s:globalThis.fetch),O(this,Ot,(a=t?.withCredentials)!=null?a:!1),be(this,he,ba).call(this)}get readyState(){return k(this,ie)}get url(){return k(this,Re).href}get withCredentials(){return k(this,Ot)}get onerror(){return k(this,Ye)}set onerror(e){O(this,Ye,e)}get onmessage(){return k(this,Je)}set onmessage(e){O(this,Je,e)}get onopen(){return k(this,gt)}set onopen(e){O(this,gt,e)}addEventListener(e,t,s){const a=t;super.addEventListener(e,a,s)}removeEventListener(e,t,s){const a=t;super.removeEventListener(e,a,s)}close(){k(this,Ue)&&clearTimeout(k(this,Ue)),k(this,ie)!==this.CLOSED&&(k(this,Se)&&k(this,Se).abort(),O(this,ie,this.CLOSED),O(this,Se,void 0))}}ie=new WeakMap,Re=new WeakMap,qe=new WeakMap,Ot=new WeakMap,Pt=new WeakMap,ut=new WeakMap,Ue=new WeakMap,dt=new WeakMap,Se=new WeakMap,We=new WeakMap,Ye=new WeakMap,Je=new WeakMap,gt=new WeakMap,he=new WeakSet,ba=function(){O(this,ie,this.CONNECTING),O(this,Se,new AbortController),k(this,Pt)(k(this,Re),be(this,he,Bs).call(this)).then(k(this,xa)).catch(k(this,ka))},xa=new WeakMap,ka=new WeakMap,Bs=function(){var i;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...k(this,dt)?{"Last-Event-ID":k(this,dt)}:void 0},cache:"no-store",signal:(i=k(this,Se))==null?void 0:i.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Sa=new WeakMap,Ta=new WeakMap,pt=function(i,e){var t;k(this,ie)!==this.CLOSED&&O(this,ie,this.CLOSED);const s=new Fs("error",{code:e,message:i});(t=k(this,Ye))==null||t.call(this,s),this.dispatchEvent(s)},va=function(i,e){var t;if(k(this,ie)===this.CLOSED)return;O(this,ie,this.CONNECTING);const s=new Fs("error",{code:e,message:i});(t=k(this,Ye))==null||t.call(this,s),this.dispatchEvent(s),O(this,Ue,setTimeout(k(this,Aa),k(this,ut)))},Aa=new WeakMap,zt.CONNECTING=0,zt.OPEN=1,zt.CLOSED=2;function Cr(){const i="document"in globalThis?globalThis.document:void 0;return i&&typeof i=="object"&&"baseURI"in i&&typeof i.baseURI=="string"?i.baseURI:void 0}class Le{static subscribedToClickEvent=!1;static attachAnalyticsScript(e){window._msq=window._msq||[];const t=e||"https://static.searchstax.com/studio-js/v4/js/studio-analytics.js";if(!document.querySelector(`script[src="${t}"]`)){var s=document.createElement("script");s.type="text/javascript",s.src=t;var a=document.getElementsByTagName("script")[0];a.parentNode&&a.parentNode.insertBefore(s,a)}}static msq=()=>typeof window<"u"&&window?._msq?window?._msq:[];static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language,model:e.model};return new Promise((s,a)=>{const r=["trackClick",t];t.key?this.msq().push(r,(function(n,c){JSON.stringify(n)===JSON.stringify(t)&&c?s():a()}).bind(this)):a()})}static trackAnswerLinkClick(e){const t={key:e.trackApiKey,question:e.searchTerm,session:e.session,href:e.href,language:e.language,model:e.model,answer:e.answer};return new Promise((s,a)=>{const r=["answerSourceClick",t];t.key?this.msq().push(r,(function(n,c){JSON.stringify(n)===JSON.stringify(t)&&c?s():a()}).bind(this)):a()})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,model:e.model,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches,language:e.language,model:e.model};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,latency:e.latencyVal,language:e.language,model:e.model,impressions:e.impressions,pageNo:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}static trackAnswerData(e){const t={session:e.session,key:e.trackApiKey,question:e.searchTerm,answer:e.answer,language:e.language,model:e.model,is_question:e.isQuestion+"",has_show_more:e.hasShowMore};setTimeout(()=>{t.key&&this.msq().push(["trackquestionanswer",t])},0)}static trackShowMoreClick(e){const t={session:e.session,key:e.trackApiKey,language:e.language,model:e.model,question:e.searchTerm};setTimeout(()=>{t.key&&this.msq().push(["answershowmoreclick",t])},0)}static trackFeedback(e){setTimeout(()=>{this.msq().push(["trackSearchSatisfaction",{key:e.trackApiKey,email:e.email,score:e.rating,comments:e.feedback,language:e.language,model:e.model}])},0)}}class br{cachedQuery="";cachedANDFacets="";url="";relatedSearches="";suggester="";authHeader;authHeaderRelated;trackApiKey="";session="";searchAuthType;searchAuth="";controllerSearch;signalSearch;controllerSuggest;signalSuggest;_authToken="";resolveFn;dataLayer;constructor(e,t){this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json"),this._authToken=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`,this.authHeader.append("Authorization",this._authToken),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let s=[];if(!t)e.forEach(function(a){const r=a.name+':"'+a.value+'"';s=s.concat("fq="+decodeURIComponent(r).replace(" "," "))});else{const a={};e.forEach(function(n){const c=n.name+":"+n.value,l=decodeURIComponent(c).replace(" "," ").split(":");a[l[0]]?a[l[0]].push(l[1]):a[l[0]]=[l[1]]});let r="";for(const n in a)if(Object.prototype.hasOwnProperty.call(a,n)){const c=a[n],l=n;for(const h of c)r+=r===""?` ${l}:"${h}"`:` OR ${l}:"${h}"`}s=s.concat("fq="+r.trim())}return s=s.map(a=>a.replace(/&/g,"%26").replace(/\+/g,"%2B")),s.length?"&"+s.join("&"):""}generateLocationQuery(e){let t="";if(e.lat&&e.lon){const s=Math.floor(parseFloat(e.lat)*100)/100,a=Math.floor(parseFloat(e.lon)*100)/100;t+=`&pt=${s},${a}`}return e.radius&&t!==""&&e.radius!=="any"&&(t+=`&distanceFilter=${e.radius}`),t}getRelatedSearches(e,t,s,a){const r=new Headers;r.append("Accept","application/json"),r.append("Authorization",s),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:r,credentials:"same-origin"}).then(n=>n.json()).then(n=>{a(n)})}cacheFacets(e){return new Promise(t=>{if(this.resolveFn=t,this.dataLayer.searchObject.query!==this.cachedQuery||this.cachedANDFacets+e!==this.dataLayer.parsedData.cachedANDFacets+e){this.cachedANDFacets=this.dataLayer.parsedData.cachedANDFacets+e,this.cachedQuery=this.dataLayer.searchObject.query;const s=[this.dataLayer.searchObject.facets.filter(a=>e?!1:a.type==="and"||a.type==="tabs")].flat();this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:s,additionalProps:this.dataLayer.searchObject.additionalProps,location:this.dataLayer.searchObject.location,model:this.dataLayer.model},this.cacheFacetsCallback.bind(this),!0,!1,e)}else this.resolveFn()})}cacheFacetsCallback(e,t){let s=ht.extractFacets(e);t?this.dataLayer.setSearchFacetsCachedTabs(s):this.dataLayer.setSearchFacetsCached(s),this.resolveFn&&this.resolveFn()}search(e,t,s=!1,a=!1,r=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const n=this.url+this.generateQueryParams(e,a),c={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete c.signal,fetch(n,c).then(l=>l.json()).then(l=>{this.dataLayer.setLoading(!1),t(l,r)}).catch(()=>{this.dataLayer.setLoading(!1)})}}generateQueryParams(e,t){let s=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),a=e.order?`&sort=${e.order}`:"";const r=e.itemsPerPage!==void 0?`&rows=${e.itemsPerPage}`:"",n=new Proxy(new URLSearchParams(window?.location.search??""),{get:(h,p)=>h.get(p)??""}),c=n.languageVariant?"&fq=_language:"+n.languageVariant:"",l=e.model??this.dataLayer.model;return"?q="+encodeURIComponent(e.query.trim())+"&start="+s+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(h=>h.type==="or"||h.type==="showUnavailable"),!0)+this.generateLocationQuery(e.location)+this.generateFacetQuery(e.facets.filter(h=>h.type==="and"||h.type==="tabs"),!1)+a+r+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!t}`+(l?`&model=${l}`:"")+"&language="+this.dataLayer.language+c}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.searchObject.page!==1)return;const s=this.dataLayer;s.setAnswerLoading(!1),s.setAnswerErrorMessage(""),s.setAnswerError(!1);const a=new zt(this.dataLayer.questionURL+this.generateQueryParams(this.dataLayer.searchObject),{fetch:(r,n)=>fetch(r,{...n,headers:{...n?.headers,Authorization:this._authToken}})});return a.onmessage=r=>{if(r.data===_e.question||r.data===_e.notQuestion){r.data===_e.question?(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setIsQuestion(!0)):(s.setAnswerLoading(!1),this.dataLayer.setIsQuestion(!1)),s.setAnswerData("");return}if(r.data===_e.close){Le.trackAnswerData({...s.parsedData.trackingData,answer:s.$answer.getValue(),isQuestion:this.dataLayer.isQuestion,hasShowMore:this.dataLayer.parsedData.shouldShowAnswerLoadMore}),s.setAnswerLoading(!1),a.close();return}if(r.data.indexOf("[!CAUTION]")!==-1){s.setAnswerError(!0),s.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),a.close();return}if(r.data.indexOf("[comment]: <> ({")!==-1)try{const n=r.data.split("[comment]: <> ({");if(n.length<2){t(r.data);return}const c=n[1].split("})");if(c.length<2){t(r.data);return}const l=c[0],h=JSON.parse("{"+l+"}");this.dataLayer.answerWidgetShowMoreLimit=h.displayShowMoreAfter,h.showMoreEnabled||(this.dataLayer.answerWidgetShowMoreLimit=1e17);const p=c.slice(1).join("})");t(p)}catch{t(r.data)}else t(r.data)},a.addEventListener("error",r=>{(r.code===401||r.code===500)&&(s.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),s.setAnswerError(!0))}),a.onerror=()=>{s.setAnswerLoading(!1),a.close()},a}suggest(e,t,s){if(this.controllerSuggest&&this.controllerSuggest.abort(),this.suggester.trim()==="")return;this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const a=this.suggester+"?q="+e.trim()+this.toQueryString(s)+"&language="+this.dataLayer.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(r=>r.json()).then(r=>{t(r)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const s of e)t.push(encodeURIComponent(s.key)+"="+encodeURIComponent(s.value));return"&"+t.join("&")}}var xr=Object.prototype.toString,Ge=Array.isArray||function(i){return xr.call(i)==="[object Array]"};function Ea(i){return typeof i=="function"}function kr(i){return Ge(i)?"array":typeof i}function Ia(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Qs(i,e){return i!=null&&typeof i=="object"&&e in i}function Sr(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var Tr=RegExp.prototype.test;function vr(i,e){return Tr.call(i,e)}var Ar=/\S/;function Er(i){return!vr(Ar,i)}var Ir={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function Dr(i){return String(i).replace(/[&<>"'`=\/]/g,function(e){return Ir[e]})}var jr=/\s*/,Rr=/\s+/,Hs=/\s*=/,Nr=/\s*\}/,Or=/#|\^|\/|>|\{|&|=|!/;function Pr(i,e){if(!i)return[];var t=!1,s=[],a=[],r=[],n=!1,c=!1,l="",h=0;function p(){if(n&&!c)for(;r.length;)delete a[r.pop()];else r=[];n=!1,c=!1}var f,L,j;function A(T){if(typeof T=="string"&&(T=T.split(Rr,2)),!Ge(T)||T.length!==2)throw new Error("Invalid tags: "+T);f=new RegExp(Ia(T[0])+"\\s*"),L=new RegExp("\\s*"+Ia(T[1])),j=new RegExp("\\s*"+Ia("}"+T[1]))}A(e||S.tags);for(var x=new mt(i),z,D,P,re,V,m;!x.eos();){if(z=x.pos,P=x.scanUntil(f),P)for(var d=0,w=P.length;d<w;++d)re=P.charAt(d),Er(re)?(r.push(a.length),l+=re):(c=!0,t=!0,l+=" "),a.push(["text",re,z,z+1]),z+=1,re===`
68
+ `&&(p(),l="",h=0,t=!1);if(!x.scan(f))break;if(n=!0,D=x.scan(Or)||"name",x.scan(jr),D==="="?(P=x.scanUntil(Hs),x.scan(Hs),x.scanUntil(L)):D==="{"?(P=x.scanUntil(j),x.scan(Nr),x.scanUntil(L),D="&"):P=x.scanUntil(L),!x.scan(L))throw new Error("Unclosed tag at "+x.pos);if(D==">"?V=[D,P,z,x.pos,l,h,t]:V=[D,P,z,x.pos],h++,a.push(V),D==="#"||D==="^")s.push(V);else if(D==="/"){if(m=s.pop(),!m)throw new Error('Unopened section "'+P+'" at '+z);if(m[1]!==P)throw new Error('Unclosed section "'+m[1]+'" at '+z)}else D==="name"||D==="{"||D==="&"?c=!0:D==="="&&A(P)}if(p(),m=s.pop(),m)throw new Error('Unclosed section "'+m[1]+'" at '+x.pos);return Fr(zr(a))}function zr(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 Fr(i){for(var e=[],t=e,s=[],a,r,n=0,c=i.length;n<c;++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 mt(i){this.string=i,this.tail=i,this.pos=0}mt.prototype.eos=function(){return this.tail===""},mt.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},mt.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 Ze(i,e){this.view=i,this.cache={".":this.view},this.parent=e}Ze.prototype.push=function(i){return new Ze(i,this)},Ze.prototype.lookup=function(i){var e=this.cache,t;if(e.hasOwnProperty(i))t=e[i];else{for(var s=this,a,r,n,c=!1;s;){if(i.indexOf(".")>0)for(a=s.view,r=i.split("."),n=0;a!=null&&n<r.length;)n===r.length-1&&(c=Qs(a,r[n])||Sr(a,r[n])),a=a[r[n++]];else a=s.view[i],c=Qs(s.view,i);if(c){t=a;break}s=s.parent}e[i]=t}return Ea(t)&&(t=t.call(this.view)),t};function se(){this.templateCache={_cache:{},set:function(i,e){this._cache[i]=e},get:function(i){return this._cache[i]},clear:function(){this._cache={}}}}se.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()},se.prototype.parse=function(i,e){var t=this.templateCache,s=i+":"+(e||S.tags).join(":"),a=typeof t<"u",r=a?t.get(s):void 0;return r==null&&(r=Pr(i,e),a&&t.set(s,r)),r},se.prototype.render=function(i,e,t,s){var a=this.getConfigTags(s),r=this.parse(i,a),n=e instanceof Ze?e:new Ze(e,void 0);return this.renderTokens(r,n,t,i,s)},se.prototype.renderTokens=function(i,e,t,s,a){for(var r="",n,c,l,h=0,p=i.length;h<p;++h)l=void 0,n=i[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&&(r+=l);return r},se.prototype.renderSection=function(i,e,t,s,a){var r=this,n="",c=e.lookup(i[1]);function l(f){return r.render(f,e,t,a)}if(c){if(Ge(c))for(var h=0,p=c.length;h<p;++h)n+=this.renderTokens(i[4],e.push(c[h]),t,s,a);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")n+=this.renderTokens(i[4],e.push(c),t,s,a);else if(Ea(c)){if(typeof s!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(e.view,s.slice(i[3],i[5]),l),c!=null&&(n+=c)}else n+=this.renderTokens(i[4],e,t,s,a);return n}},se.prototype.renderInverted=function(i,e,t,s,a){var r=e.lookup(i[1]);if(!r||Ge(r)&&r.length===0)return this.renderTokens(i[4],e,t,s,a)},se.prototype.indentPartial=function(i,e,t){for(var s=e.replace(/[^ \t]/g,""),a=i.split(`
68
69
  `),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:`
70
+ `)},se.prototype.renderPartial=function(i,e,t,s){if(t){var a=this.getConfigTags(s),r=Ea(t)?t(i[1]):t[i[1]];if(r!=null){var n=i[6],c=i[5],l=i[4],h=r;c==0&&l&&(h=this.indentPartial(r,l,n));var p=this.parse(h,a);return this.renderTokens(p,e,t,h,s)}}},se.prototype.unescapedValue=function(i,e){var t=e.lookup(i[1]);if(t!=null)return t},se.prototype.escapedValue=function(i,e,t){var s=this.getConfigEscape(t)||S.escape,a=e.lookup(i[1]);if(a!=null)return typeof a=="number"&&s===S.escape?String(a):s(a)},se.prototype.rawValue=function(i){return i[1]},se.prototype.getConfigTags=function(i){return Ge(i)?i:i&&typeof i=="object"?i.tags:void 0},se.prototype.getConfigEscape=function(i){if(i&&typeof i=="object"&&!Ge(i))return i.escape};var S={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){ft.templateCache=i},get templateCache(){return ft.templateCache}},ft=new se;S.clearCache=function(){return ft.clearCache()},S.parse=function(i,e){return ft.parse(i,e)},S.render=function(i,e,t,s){if(typeof i!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+kr(i)+'" was given as the first argument for mustache#render(template, view, partials)');return ft.render(i,e,t,s)},S.escape=Dr,S.Scanner=mt,S.Context=Ze,S.Writer=se;const $r={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
+ `}},Vr={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
+ `}},Br={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"}},Qr={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"}},Hr={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"}},_r={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"}},qr={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
+ `}},Ur={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"}},Wr={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
+ `}},Yr={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 y{static answer=$r;static externalPromotions=Vr;static facets=Br;static pagination=Qr;static relatedSearches=Hr;static searchFeedback=_r;static searchInput=qr;static location=Ur;static searchResults=Wr;static sorting=Yr;static feedback=Z}class Jr{dataLayer;config;containerId;externalPromotionsContainerId;searchExternalPromotionsMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.externalPromotionsContainerId=this.config.templates?.mainTemplate?.externalPromotionsContainerId||y.externalPromotions.mainTemplate.externalPromotionsContainerId,typeof document<"u"&&(this.searchExternalPromotionsMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}initializeSubscriptions(){this.dataLayer.$searchExternalPromotions.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data,externalPromotions:this.dataLayer.parsedData.externalPromotions};return this.dataLayer.setExternalPromotionsData(e),e}addExternalSearch(e){const t=typeof document<"u"?document?.getElementById(this.externalPromotionsContainerId):null;if(t){const s=this.config?.templates?.externalPromotion?.template||y.externalPromotions.externalPromotion?.template;if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-external-promotion"),a.addEventListener("click",r=>{this.trackClick(e,r)}),a.innerHTML=S.render(s,e),t.appendChild(a)}}}trackClick(e,t){t.stopPropagation(),t.preventDefault(),window?.open(e.url,"_blank")}renderMainTemplate(e){const t=this.config?.templates?.mainTemplate?.template||y.externalPromotions.mainTemplate?.template;if(this.dataLayer.renderingEngine===F.mustache){this.searchExternalPromotionsMainContainer.innerHTML=S.render(t,e);const s=typeof document<"u"?document?.getElementById(this.externalPromotionsContainerId):null;s&&(s.innerHTML="");for(const a of e.externalPromotions)this.addExternalSearch(a)}}}class Y{static addAccessibilityNotificationContainerToBody(){if(!document.getElementById("searchAccessibilityContainer")){const e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("id","searchAccessibilityContainer"),document.body.appendChild(e)}}static setAccessibilityText(e,t,s){this.addAccessibilityNotificationContainerToBody();const a=s??"searchAccessibility",r=document.getElementById(a);r&&r.remove();const n=document.createElement("span");n.setAttribute("id",a),n.innerHTML=e;const c=document.getElementById("searchAccessibilityContainer");c&&setTimeout(()=>{c.appendChild(n)},t??100)}}class Gr{dataLayer;config;containerId;routerHelper;cachedPhrase="";cachedANDFacets="";isCached=!1;overlayOpened=!1;facetPaginationStep;facetPaginationStepMobile;searchFacetsMainContainer=null;searchFacetsMobileContainer=null;searchFacetsDesktopContainer=null;facetLimits={};facetLimitsMobile={};deactivatedFacets={};focusedElement=null;cachedData=null;cacheFacets;constructor(e,t){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.routerHelper=e.routerHelper,this.cacheFacets=t,this.facetPaginationStep=this.config.itemsPerPageDesktop,this.facetPaginationStepMobile=this.config.itemsPerPageMobile,typeof document<"u"&&(this.searchFacetsMainContainer=document?.getElementById(this.containerId)),this.needCache&&t(this.config.facetingType==="tabs"),this.initializeSubscriptions()}get needCache(){return this.config.facetingType==="showUnavailable"||this.config.facetingType==="or"||this.config.facetingType==="tabs"}get needDisabling(){return this.config.facetingType==="showUnavailable"}initializeSubscriptions(){this.needCache&&(this.dataLayer.$searchFacetsCached.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$searchFacetsCachedTabs.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())})),this.dataLayer.$searchResults.subscribe(e=>{e&&(this.needCache&&!this.isCached&&(this.dataLayer.searchFacets&&!this.dataLayer.searchFacetsCached&&this.dataLayer.setSearchFacetsCached(this.dataLayer.searchFacets),this.cacheFacets(this.config.facetingType==="tabs")),this.renderMainTemplate(this.generateTemplateData()))}),this.dataLayer.$searchObject.subscribe(e=>{this.cachedPhrase!==e.query||this.cachedANDFacets!==this.dataLayer.parsedData.cachedANDFacets?(this.cachedANDFacets=this.dataLayer.parsedData.cachedANDFacets,this.cachedPhrase=e.query,this.isCached=!1):this.isCached=!0})}extractFacetValue(e){return{type:this.config.facetingType,name:e.parentName,value:e.value}}applyFacetLimits(e,t){const s=t?this.facetPaginationStepMobile:this.facetPaginationStep,a=t?this.facetLimits:this.facetLimitsMobile;return e.forEach(r=>{a[r.name]||(a[r.name]=s)}),e.map(r=>({...r,values:r.values.slice(0,a[r.name]),showingAllFacets:r.values.length<=a[r.name],hasMoreFacets:r.values.length>s}))}generateTemplateData(e){if(this.generateSelectedFacetsData(),this.dataLayer.searchFacets){let t=this.dataLayer.searchFacets;this.config.hooks?.beforeFacetsRender&&(t=this.config.hooks.beforeFacetsRender(t)),this.needCache&&this.dataLayer.searchFacetsCached&&(t=this.dataLayer.searchFacetsCached,this.config.facetingType==="tabs"&&this.dataLayer.searchFacetsCachedTabs&&(t=this.dataLayer.searchFacetsCachedTabs),this.needDisabling&&(t=t.map(a=>{const r=this.dataLayer.searchFacets?.find(n=>n.name===a.name);return r?{...a,values:a.values.map(n=>{const c=r.values.find(l=>n.type==="range"?!1:n.type==="checkbox"?l.value===n.value:!1);return{...n,disabled:!c,isMobile:e}})}:{...a,values:a.values.map(n=>({...n,disabled:!0})),isMobile:e}}))),this.config.specificFacets&&(t=t.filter(a=>this.config.specificFacets?.includes(a.name)));const s={facets:this.applyFacetLimits(t,e),...this.dataLayer.parsedData.data,isMobile:e};return this.dataLayer.setFacetsTemplateData(s),s}else{const t={facets:[],...this.dataLayer.parsedData.data,isMobile:e};return this.dataLayer.setFacetsTemplateData(t),t}}createFacetItem(e,t,s){if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-facet-container"),this.deactivatedFacets[e.name]||a.classList.add("active");const r=this.config?.templates?.facetItemContainerTemplate?.template||y.facets.facetItemContainerTemplate?.template;a.innerHTML=S.render(r,e),t.appendChild(a);const n=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerClass||y.facets.facetItemContainerTemplate?.facetListTitleContainerClass));n?.addEventListener("click",()=>{a.classList.toggle("active");const l=a.classList.contains("active"),h=n.querySelector(".searchstax-facet-title");h&&h.setAttribute("aria-expanded",String(l))}),n?.querySelector("."+this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerInner)?.addEventListener("keydown",l=>{if(l.code==="Enter"||l.code==="Space"){l.preventDefault(),a.classList.toggle("active");const h=a.classList.contains("active"),p=n.querySelector(".searchstax-facet-title");p&&p.setAttribute("aria-expanded",String(h))}});const c=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListContainerClass||y.facets.facetItemContainerTemplate?.facetListContainerClass));c&&(e.values.forEach(l=>{this.createFacetListItem(l,c,e.name)}),e.hasMoreFacets&&this.createHasMoreComponent(e,c,s))}}isChecked(e){return!!this.dataLayer.searchObject.facets?.find(t=>oe.deepEqual(t,this.extractFacetValue(e)))}createFacetListItem(e,t,s){if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-facet-value-container"),e.disabled&&a.classList.add("searchstax-facet-value-disabled");const r=this.isChecked(e),n=this.config?.templates?.facetItemTemplate?.template||y.facets.facetItemTemplate?.template;a.innerHTML=S.render(n,{...e,isChecked:r});let c=y.facets.facetItemTemplate?.checkTriggerClasses;c=this.config?.templates?.facetItemTemplate?.checkTriggerClasses||c,c.forEach(h=>{a.querySelector("."+h)?.addEventListener("click",p=>{this.onFacetSelect(p,e,a)})});const l=a.querySelector("."+(this.config?.templates?.facetItemTemplate?.inputCheckboxClass||y.facets.facetItemTemplate?.inputCheckboxClass));l?.addEventListener("click",h=>{this.onFacetSelect(h,e,a,!0)}),l&&l?.setAttribute("data-test-value",`${encodeURIComponent(s)}:&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 c=a?n.checked:!n.checked;r!==void 0&&(c=!r),n.checked=c;const l=this.dataLayer.searchObject;let h=[...l.facets];const p=this.extractFacetValue(t);c?h.find(f=>oe.deepEqual(f,p)?f:!1)||(this.config.facetingType==="tabs"&&(h=h.filter(f=>f.name!==p.name)),h.push(p)):h=h.filter(f=>!oe.deepEqual(f,p)),setTimeout(()=>{this.dataLayer.setSearchObject({...l,facets:h,page:1}),this.config.facetingType==="tabs"&&this.renderMainTemplate(this.generateTemplateData(),!0)},0)}};createHasMoreComponent(e,t,s){if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-facet-show-more-container");const r=this.config?.templates?.showMoreButtonContainerTemplate?.template||y.facets.showMoreButtonContainerTemplate?.template;a.innerHTML=S.render(r,{...e,focusId:`moreLess${e?.values?.[0]?.value}`});const n=a.querySelector("."+(this.config?.templates?.showMoreButtonContainerTemplate?.showMoreButtonClass||y.facets.showMoreButtonContainerTemplate?.showMoreButtonClass));n&&(this.attachOnclickToShowMore(e,n,s),t&&t.appendChild(n))}}attachOnclickToShowMore(e,t,s){t.addEventListener("click",a=>{this.onShowMoreLessClick(a,e,s)}),t.addEventListener("keydown",a=>{a.code==="Space"&&a.preventDefault()}),t.addEventListener("keyup",a=>{(a.code==="Space"||a.code==="Enter")&&(a.preventDefault(),this.onShowMoreLessClick(a,e,s))})}onShowMoreLessClick(e,t,s){e.preventDefault();const a=s?this.facetPaginationStepMobile:this.facetPaginationStep,r=s?this.facetLimits:this.facetLimitsMobile;r[t.name]===void 0?r[t.name]=a*2:r[t.name]<=t.values.length?(Y.setAccessibilityText(`More Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),r[t.name]=r[t.name]+a):(Y.setAccessibilityText(`Less Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),r[t.name]=a),this.generateTemplateData(s),this.renderMainTemplate(this.generateTemplateData())}renderMainTemplate(e,t){if(e&&(!oe.deepEqual(this.cachedData??{},e)||t)){this.cachedData=e;const s=this.config?.templates?.mainTemplateDesktop?.template||y.facets.mainTemplateDesktop?.template;if(this.dataLayer.renderingEngine===F.mustache&&this.searchFacetsMainContainer){const a=document.activeElement;a instanceof HTMLInputElement&&a.type==="checkbox"||a?.classList.contains("searchstax-facet-show-more-button")||a?.classList.contains("searchstax-facet-show-less-button")?this.focusedElement=a:this.focusedElement=null,this.searchFacetsMainContainer.innerHTML=S.render(s,{...e});const r=this.searchFacetsMainContainer?.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.facetsContainerClass||y.facets.mainTemplateDesktop.facetsContainerClass));if(r){r.innerHTML="";for(const n of e.facets)this.createFacetItem(n,r);if(this.searchFacetsMainContainer){const n=this.searchFacetsMainContainer.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.selectedFacetsContainerClass||y.facets.mainTemplateDesktop.selectedFacetsContainerClass));n&&(this.createSelectedFacetsComponents(n),this.createClearFacetsComponents(n))}if(this.focusedElement){if(this.focusedElement.classList.contains("searchstax-facet-show-more-button")||this.focusedElement.classList.contains("searchstax-facet-show-less-button")){const l=this.focusedElement.getAttribute("data-focus"),h=this.searchFacetsMainContainer.querySelector(`[data-focus="${l}"]`);h instanceof HTMLElement&&h.focus(),this.focusedElement=null;return}const n=this.focusedElement.getAttribute("data-test-value"),c=this.searchFacetsMainContainer.querySelector(`[data-test-value="${n}"]`);c instanceof HTMLInputElement&&c.focus(),this.focusedElement=null}}}setTimeout(()=>{document.querySelectorAll(".searchstax-facet-title").forEach(a=>{a.setAttribute("aria-expanded",String(!0)),a.setAttribute("tabindex","0"),a.setAttribute("role","button")})},100),this.renderMobileTemplate(this.generateTemplateData(!0))}else this.generateSelectedFacetsData()}generateSelectedFacetsData(){const e=[],t=this.dataLayer.searchObject.facets;for(const s of t){const a=decodeURIComponent(s.name),r=decodeURIComponent(s.value);if(this.dataLayer.searchFacets){const n=(this.needCache?this.dataLayer.searchFacetsCached:this.dataLayer.searchFacets)?.find(c=>c.name===a);if(n){const c=n.values.find(l=>l.type==="range"?!1:l.type==="checkbox"?`"${l.value}"`==`"${r}"`:!1);c&&e.push(c)}}}this.dataLayer.setSelectedFacetsTemplateData(e)}createSelectedFacetsComponents(e){this.generateSelectedFacetsData(),this.dataLayer.selectedFacetsTemplateData?.forEach(t=>{this.createSelectedFacetsComponent(e,t)})}createClearFacetsComponents(e){if(typeof document<"u"){const t=this.dataLayer.searchObject,s=this.config?.templates?.clearFacetsTemplate?.template||y.facets.clearFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=S.render(s,{shouldShow:t.facets.length>0});const r=a.querySelector("."+(this.config?.templates?.clearFacetsTemplate?.containerClass||y.facets.clearFacetsTemplate?.containerClass));r&&(r.addEventListener("click",()=>{this.removeSelectedFacets()}),r.addEventListener("keyup",n=>{(n.code==="Space"||n.code==="Enter")&&this.removeSelectedFacets()}),e.appendChild(r))}}createSelectedFacetsComponent(e,t){if(typeof document<"u"){const s=this.config?.templates?.selectedFacetsTemplate?.template||y.facets.selectedFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=S.render(s,t);const r=a.querySelector("."+(this.config?.templates?.selectedFacetsTemplate?.containerClass||y.facets.selectedFacetsTemplate?.containerClass));r&&(r.addEventListener("click",()=>{this.unselectFacet(t)}),r.addEventListener("keyup",n=>{(n.code==="Space"||n.code==="Enter")&&this.unselectFacet(t)}),e.appendChild(r))}}unselectFacet(e){const t=this.dataLayer.searchObject;let s=[...t.facets];e.type==="checkbox"&&(s=s.filter(a=>JSON.stringify(a)!==JSON.stringify(this.extractFacetValue(e)))),setTimeout(()=>{this.dataLayer.setSearchObject({...t,facets:s}),this.generateSelectedFacetsData()},0)}removeSelectedFacets(){const e=this.dataLayer.searchObject;this.dataLayer.setSearchObject({...e,facets:[]})}createFilterByComponent(e){if(typeof document<"u"){const t=this.config?.templates?.filterByTemplate?.template||y.facets.filterByTemplate?.template,s=document?.createElement("div");s.innerHTML=S.render(t,{});const a=s.querySelector("."+(this.config?.templates?.filterByTemplate?.containerClass||y.facets.filterByTemplate?.containerClass));a&&(e.prepend(a),a.addEventListener("click",this.openOverlay.bind(this)),a.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.openOverlay()}))}}openOverlay(){Y.setAccessibilityText("Facet overlay opened. Tab to select facets."),this.overlayOpened=!0,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.add("searchstax-show"))}closeOverlay(){Y.setAccessibilityText("Facet overlay closed"),this.overlayOpened=!1,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.remove("searchstax-show"))}renderMobileTemplate(e){if(e&&typeof document<"u"){const t=document?.createElement("div");t.classList.add("searchstax-facets-container-mobile");const s=this.config?.templates?.mainTemplateMobile?.template||y.facets.mainTemplateMobile?.template;if(this.dataLayer.renderingEngine===F.mustache){if(t.innerHTML=S.render(s,{...e,overlayOpened:this.overlayOpened}),this.searchFacetsMainContainer?.appendChild(t),this.config?.templates?.mainTemplateMobile)for(const c of this.config?.templates?.mainTemplateMobile?.closeOverlayTriggerClasses||[]){const l=t.querySelector("."+c);l&&(l.addEventListener("click",this.closeOverlay.bind(this)),l.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}else for(const c of y.facets.mainTemplateMobile.closeOverlayTriggerClasses){const l=t.querySelector("."+c);l&&(l.addEventListener("click",this.closeOverlay.bind(this)),l.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}const a=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.filterByContainerClass||y.facets.mainTemplateMobile.filterByContainerClass));a&&this.createFilterByComponent(a);const r=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.selectedFacetsContainerClass||y.facets.mainTemplateMobile.selectedFacetsContainerClass));r&&(this.createSelectedFacetsComponents(r),this.createClearFacetsComponents(r));const n=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.facetsContainerClass||y.facets.mainTemplateMobile.facetsContainerClass));if(n){n.innerHTML="";for(const c of e.facets)this.createFacetItem(c,n,!0)}}}}}class Zr{dataLayer;config;containerId;previousButtonClass;nextButtonClass;loadMoreButtonClass;routerHelper;searchPaginationMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.routerHelper=e.routerHelper,this.previousButtonClass=this.config?.templates?.mainTemplate?.previousButtonClass??y.pagination.mainTemplate.previousButtonClass,this.nextButtonClass=this.config?.templates?.mainTemplate?.nextButtonClass??y.pagination.mainTemplate.nextButtonClass,this.loadMoreButtonClass=this.config?.templates?.infiniteScrollTemplate?.loadMoreButtonClass??y.pagination.infiniteScrollTemplate.loadMoreButtonClass,typeof document<"u"&&(this.searchPaginationMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}get isFirstPage(){return this.dataLayer.searchObject?.page===1}get isLastPage(){return this.dataLayer.parsedData.data.isLastPage}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data,previousPageLink:this.routerHelper?.searchObjectToUrl({...this.dataLayer.searchObject,page:this.dataLayer.searchObject?.page-1}),nextPageLink:this.routerHelper?.searchObjectToUrl({...this.dataLayer.searchObject,page:this.dataLayer.searchObject?.page+1})};return this.dataLayer.setPaginationData(e),e}goToPage(e,t){const s=this.dataLayer.searchObject;s&&(s.page=e,this.dataLayer.setSearchObject(s));const a=document.querySelector(".searchstax-page-layout-result-container");if(a instanceof HTMLElement){const r=a.querySelector('[tabindex="0"]');r instanceof HTMLElement&&r.focus()}else document.body.tabIndex=-1,document.body.focus();t||(a instanceof HTMLElement?a.scrollIntoView({block:"start",behavior:"auto"}):window?.scrollTo(0,0))}nextPage(e){e?.preventDefault(),e?.stopPropagation(),this.isLastPage||this.goToPage(this.dataLayer.searchObject?.page+1,this.dataLayer.isInfiniteScroll)}previousPage(e){e?.preventDefault(),e?.stopPropagation(),this.isFirstPage||this.goToPage(this.dataLayer.searchObject?.page-1)}overridePaginationEvents(){if(this.searchPaginationMainContainer){const e=this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass),t=this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass),s=this.searchPaginationMainContainer.querySelector("."+this.loadMoreButtonClass);e&&(e.addEventListener("click",this.previousPage.bind(this)),e.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.previousPage(a)})),t&&(t.addEventListener("click",this.nextPage.bind(this)),t.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.nextPage(a)})),s&&(s.addEventListener("click",this.nextPage.bind(this)),s.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.nextPage(a)}))}}renderMainTemplate(e){this.searchPaginationMainContainer&&(this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass)?.removeEventListener("click",this.previousPage),this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass)?.removeEventListener("click",this.nextPage));let t=this.config?.templates?.mainTemplate?.template||y.pagination.mainTemplate?.template;this.dataLayer.isInfiniteScroll&&(t=this.config?.templates?.infiniteScrollTemplate?.template||y.pagination.infiniteScrollTemplate?.template),this.dataLayer.renderingEngine===F.mustache&&(this.searchPaginationMainContainer.innerHTML=S.render(t,e),setTimeout(()=>{this.overridePaginationEvents()},0))}}class Kr{dataLayer;config;containerId;relatedSearchesContainerClass;searchRelatedSearchesMainContainer=null;track;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.relatedSearchesContainerClass=this.config.templates?.main?.relatedSearchesContainerClass||y.relatedSearches.main.relatedSearchesContainerClass,typeof document<"u"&&(this.searchRelatedSearchesMainContainer=document?.getElementById(this.containerId)),this.track=e.trackRelatedSearchClick,this.initializeSubscriptions()}initializeSubscriptions(){this.dataLayer.$searchRelatedSearches.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setRelatedSearchesData(e),e}addRelatedSearchComponent(e,t){if(typeof document<"u"){const s=document?.createElement("div"),a=this.config?.templates?.relatedSearch?.template||y.relatedSearches.relatedSearch.template;if(this.dataLayer.renderingEngine===F.mustache){s.innerHTML=S.render(a,e);const r=s.querySelector("."+(this.config.templates?.relatedSearch?.relatedSearchContainerClass||y.relatedSearches.relatedSearch.relatedSearchContainerClass));r&&(t.appendChild(r),r.addEventListener("click",()=>{this.executeSearch(e)}),r.addEventListener("keyup",n=>{(n.code==="Space"||n.code==="Enter")&&this.executeSearch(e)}))}}}executeSearch(e){const t=this.dataLayer.searchObject;t.query=e.related_search,this.dataLayer.setSearchObject(t),this.track(e)}renderMainTemplate(e){const t=this.config?.templates?.main?.template||y.relatedSearches.main.template;if(this.dataLayer.renderingEngine===F.mustache&&this.searchRelatedSearchesMainContainer){this.searchRelatedSearchesMainContainer.innerHTML="",this.searchRelatedSearchesMainContainer.innerHTML=S.render(t,e);const s=this.searchRelatedSearchesMainContainer?.querySelector(`.${this.relatedSearchesContainerClass}`);if(s)for(const a of e.relatedSearches)this.addRelatedSearchComponent(a,s)}}}class Xr{dataLayer;config;containerId;searchFeedbackMainContainer=null;searchTrigger;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.searchTrigger=e.searchTrigger,typeof document<"u"&&(this.searchFeedbackMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions()}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setSearchFeedbackData(e),e}onOriginalQueryClick(e){e.stopPropagation(),e.preventDefault();const t=e.target?.innerHTML;this.searchTrigger(t,!0)}attachClick(){const e=this.searchFeedbackMainContainer?.querySelector("."+(this.config?.templates?.main?.originalQueryClass||y.searchFeedback.main?.originalQueryClass));e&&e.addEventListener("click",this.onOriginalQueryClick.bind(this))}renderMainTemplate(e){const t=this.config?.templates?.main?.template||y.searchFeedback.main.template;this.dataLayer.renderingEngine===F.mustache&&(this.searchFeedbackMainContainer.innerHTML=S.render(t,e),setTimeout(()=>{this.attachClick()},0))}}class en{searchHelper;dataLayer;config;suggestAfterMinChars;containerId;currentInputValue="";autosuggestResults;suppressNextEnter=!1;searchInput;actionButton;autosuggestContainer;clearButton;separatorIcon;buttonState="search";selectedAutosuggestItem=-1;suggestTrigger;searchTrigger;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.searchTrigger=e.searchTrigger,this.suggestTrigger=e.suggestTrigger,this.containerId=e.containerId,this.suggestAfterMinChars=e.config.suggestAfterMinChars,this.suggestAfterMinChars===void 0&&this.getSuggestAfterValue(),this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())},200)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||y.searchInput.mainTemplate.template,s={...this.dataLayer.parsedData.data,locationEnabled:!!this.dataLayer.locationEnabled,hasInputValue:!1};if(this.dataLayer.setInputWidgetTemplateData(s),this.dataLayer.renderingEngine===F.mustache){const n=S.render(t,s);e.innerHTML=n,this.dataLayer.setInputTemplateRendered(!0)}const a=this.config.templates?.mainTemplate?.searchInputId||y.searchInput.mainTemplate.searchInputId,r=document?.querySelector(`#${a}`);if(r)this.searchInput=r,r.addEventListener("keyup",this.inputKeyupEvent.bind(this)),r.addEventListener("blur",this.hideAutosuggest.bind(this)),r.addEventListener("paste",this.inputPasteEvent.bind(this));else throw new Error("Input not found")}}createAutosuggestContainer(){this.dataLayer.renderingEngine===F.mustache&&typeof document<"u"&&(this.autosuggestContainer=document?.createElement("div"),this.autosuggestContainer.classList.add("searchstax-autosuggest-container"),this.autosuggestContainer.addEventListener("mouseleave",()=>{this.resetAutosuggestSelection(),this.markActiveAutosuggestItem()}),this.searchInput?.after(this.autosuggestContainer))}getSuggestAfterValue(){this.dataLayer.searchHelper&&this.dataLayer.searchHelper.suggest("*",e=>{this.suggestAfterMinChars=e.metadata.minPrefixChars},[])}actionButtonInit(){typeof document<"u"&&(this.actionButton=document?.getElementById("searchstax-search-input-action-button"),this.actionButton&&this.actionButton.addEventListener("click",()=>{this.executeSearch(this.searchInput?.value??"")}),this.clearButton=document?.getElementById("searchstax-clear-input-action-button"),this.separatorIcon=document?.getElementById("searchstax-separator-icon"),this.clearButton&&this.clearButton.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.clearInput()}))}updateClearButtonVisibility(e){const t=e.length>0;t?(this.clearButton?.classList.remove("hidden"),this.separatorIcon?.classList.remove("hidden")):(this.clearButton?.classList.add("hidden"),this.separatorIcon?.classList.add("hidden"));const s=this.dataLayer.inputWidgetTemplateData;s&&this.dataLayer.setInputWidgetTemplateData({...s,hasInputValue:t})}attachSubscriptions(){this.dataLayer.$searchTermChange.subscribe(()=>{this.handleSearchTermChange()}),this.dataLayer.$loadingChange.subscribe(()=>{this.handleLoadingChange()}),this.dataLayer.$searchAutosuggest.subscribe(e=>{e&&this.appendSuggestions(e)}),this.dataLayer.$searchObject.subscribe(e=>{e.query!=="undefined"&&e.query!==void 0&&e.query!=="*"&&this.searchInput&&(this.searchInput.value=this.cleanSuggestionTerm(e.query??""),this.updateClearButtonVisibility(this.searchInput.value))})}handleLoadingChange(){this.dataLayer.loading?this.updateActionButtonState("loading"):this.handleSearchTermChange()}handleSearchTermChange(){this.updateActionButtonState("search")}updateActionButtonState(e){if(this.buttonState=e,this.actionButton)switch(this.actionButton.classList.remove("searchstax-spinner-icon"),this.actionButton.classList.remove("searchstax-search-icon"),e){case"loading":this.actionButton.classList.add("searchstax-spinner-icon");break;case"search":this.actionButton.classList.add("searchstax-search-icon"),this.actionButton.setAttribute("aria-label","search");break}}selectPreviousAutosuggestItem(e){this.selectedAutosuggestItem>0?this.selectedAutosuggestItem--:this.selectedAutosuggestItem===0?(this.selectedAutosuggestItem=-1,e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),Y.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=this.autosuggestResults.suggestions.length-1,this.markActiveAutosuggestItem()}selectNextAutosuggestItem(){this.selectedAutosuggestItem<this.autosuggestResults.suggestions.length-1?this.selectedAutosuggestItem++:this.selectedAutosuggestItem===this.autosuggestResults.suggestions.length-1?(this.selectedAutosuggestItem=-1,Y.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=0,this.markActiveAutosuggestItem()}resetAutosuggestSelection(){this.selectedAutosuggestItem=-1,this.markActiveAutosuggestItem()}clearInput(){this.suppressNextEnter=!0,this.searchInput&&(this.searchInput.value="",this.currentInputValue=""),this.updateClearButtonVisibility(""),this.hideAutosuggest(),this.searchInput?.focus()}markActiveAutosuggestItem(){if(typeof document<"u"){const e=document?.getElementsByClassName("searchstax-autosuggest-item");for(let t=0;t<e.length;t++){const s=e[t];t===this.selectedAutosuggestItem?(s.classList.add("active"),Y.setAccessibilityText(`Selected suggestion: ${s.innerText}`)):s.classList.remove("active")}}}inputKeyupEvent(e){const t=e.key;if(this.currentInputValue=e.target.value,t==="Enter"){if(this.suppressNextEnter){this.suppressNextEnter=!1;return}this.suggestionChosen()}else this.suppressNextEnter=!1,t==="Escape"?this.hideAutosuggest(e.target):t==="ArrowUp"?this.selectPreviousAutosuggestItem(e.target):t==="ArrowDown"?this.selectNextAutosuggestItem():this.autosuggestHandling(e);this.handleSearchTermChange(),this.updateClearButtonVisibility(this.currentInputValue)}autosuggestHandling(e){this.suggestAfterMinChars&&e.target&&e.target.value.length>=this.suggestAfterMinChars?this.executeSuggest(e.target.value):this.hideAutosuggest()}inputPasteEvent(e){setTimeout(()=>{this.autosuggestHandling(e),this.handleSearchTermChange(),this.updateClearButtonVisibility(e.target.value)},0)}executeSuggest(e){this.suggestTrigger(e)}executeSearch(e){this.hideAutosuggest(),this.searchTrigger(e===""?"*":e)}suggestionChosen(){this.selectedAutosuggestItem>-1?this.autosuggestItemClicked(this.autosuggestResults.suggestions[this.selectedAutosuggestItem]):this.executeSearch(this.currentInputValue)}hideAutosuggest(e){setTimeout(()=>{this.dataLayer.setAutosuggestResults({numFound:0,suggestions:[]}),this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.add("hidden")),this.resetAutosuggestSelection(),e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),Y.setAccessibilityText("No Suggestion selected")},200)}cleanSuggestionTerm(e){return G.removeXSSRiskyTags(e.replace(/(<([^>]+)>)/gi,"")).trim()}autosuggestItemClicked(e){this.searchInput.value=this.cleanSuggestionTerm(e.term??""),this.executeSearch(this.cleanSuggestionTerm(e.term))}createAutosuggestItem(e){const t=document?.createElement("div");t.classList.add("searchstax-autosuggest-item"),t.addEventListener("click",()=>{this.autosuggestItemClicked(e)}),t.addEventListener("mouseenter",()=>{this.onSuggestionEnter(e)});const s=this.config.templates?.autosuggestItemTemplate?.template||y.searchInput.autosuggestItemTemplate?.template;return t.innerHTML=S.render(s,e),t}onSuggestionEnter(e){this.selectedAutosuggestItem=this.autosuggestResults?.suggestions.indexOf(e)||0,this.markActiveAutosuggestItem()}appendSuggestions(e){this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.remove("hidden"));for(const t in e.suggest)if(Object.prototype.hasOwnProperty.call(e.suggest,t)){const s=e.suggest[t];for(const a in s)if(Object.prototype.hasOwnProperty.call(s,a)){const r=s[a];r.numFound?Y.setAccessibilityText("Suggestions are available. Use up and down arrows to navigate while focusing input. Use Escape key to escape out of the suggestions",2e3):Y.setAccessibilityText("",0),this.autosuggestResults=r,this.dataLayer.setAutosuggestResults(r),r.numFound>0?r.suggestions.forEach(n=>{this.autosuggestContainer&&typeof document<"u"&&this.autosuggestContainer.appendChild(this.createAutosuggestItem(n))}):this.autosuggestContainer&&this.autosuggestContainer.classList.add("hidden")}}}}class tn{dataLayer;config;linkClickCallback;searchCallback;containerId;searchResultsMainContainer;searchResultsContainer;searchResultLinks=[];constructor(e){this.linkClickCallback=e.linkClickCallback,this.searchCallback=e.searchTrigger,this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId;const t=document?.getElementById(this.containerId);if(t)this.searchResultsMainContainer=t;else throw new Error(`Search Results Main Container with id ${this.containerId} not found`);this.dataLayer.setIsInfiniteScroll(e.config.renderMethod==="infiniteScroll"),this.initializeSubscriptions(),this.renderMainTemplate()}initializeSubscriptions(){this.dataLayer.$searchObject.subscribe(()=>{Y.setAccessibilityText("Searching...")}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.searchResultsContainer&&this.renderResults(e)})}changeTemplate(){this.dataLayer.searchResults&&this.renderResults(this.dataLayer.searchResults)}renderNoResultsTemplate(){const e=this.config?.templates?.noSearchResultTemplate?.template||y.searchResults.noSearchResultTemplate?.template,t=this.dataLayer.searchResultsMetadata?.spellingSuggestion??"";if(this.dataLayer.renderingEngine===F.mustache&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=S.render(e,{spellingSuggestion:t,...this.dataLayer.parsedData.data,searchCallback:this.searchCallback.bind(this)})),t&&this.searchResultsContainer){const s=this.searchResultsContainer.querySelector("a");s&&s.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.searchCallback(t)})}}renderResults(e){if(this.dataLayer.renderingEngine===F.mustache&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)Y.setAccessibilityText("Search has no results"),this.renderNoResultsTemplate();else{Y.setAccessibilityText(`Showing ${this.dataLayer.parsedData.startResultIndex} through ${this.dataLayer.parsedData.endResultIndex} results from ${this.dataLayer.parsedData.totalResults}. Press tab to navigate through results`);const t=this.config?.templates?.searchResultTemplate?.template||y.searchResults.searchResultTemplate?.template,s=e.map(a=>S.render(t,a));this.config?.renderMethod==="infiniteScroll"&&this.dataLayer.searchObject.page>1?this.searchResultsContainer.innerHTML+=s.join(""):this.searchResultsContainer.innerHTML=s.join(""),this.searchResultLinks=Array.from(this.searchResultsContainer.querySelectorAll(`[${this.uniqueIdAttribute}]`)),this.attachLinkClickEvents()}}removeLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.removeEventListener("click",()=>{}),e.removeEventListener("keydown",()=>{})})}get uniqueIdAttribute(){return this.config?.templates?.searchResultTemplate?.searchResultUniqueIdAttribute||y.searchResults.searchResultTemplate?.searchResultUniqueIdAttribute}attachLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const s=e.getAttribute(this.uniqueIdAttribute)??"";s&&this.linkClickCallback(s)}),e.addEventListener("keydown",t=>{if(t.code==="Space"||t.code==="Enter"){const s=e.getAttribute(this.uniqueIdAttribute)??"";s&&this.linkClickCallback(s)}})})}renderMainTemplate(){const e=this.config?.templates?.mainTemplate?.template||y.searchResults.mainTemplate?.template;this.dataLayer.renderingEngine===F.mustache&&(this.searchResultsMainContainer.innerHTML=S.render(e,{}),setTimeout(()=>{const t=this.config?.templates?.mainTemplate?.searchResultsContainerId?this.config?.templates?.mainTemplate?.searchResultsContainerId:y.searchResults.mainTemplate?.searchResultsContainerId,s=document?.getElementById(t);if(s)this.searchResultsContainer=s;else throw new Error(`Search Results Container with id ${t} not found`)},0))}}class an{dataLayer;config;containerId;selectId;searchSortingMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.selectId=this.config.templates?.main?.selectId||y.sorting.main.selectId,this.searchSortingMainContainer=document?.getElementById(this.containerId),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setSearchSortingData(e),e}setOrderQuery(e){const t=this.dataLayer.searchObject;t&&(t.order=e,this.dataLayer.setSearchObject(t))}markOptionSelected(){const e=document?.getElementById(this.selectId);if(e){const t=e.querySelector(`option[value="${decodeURIComponent(this.dataLayer.searchObject.order)}"]`);t&&(t.selected=!0)}}renderMainTemplate(e){const t=this.config?.templates?.main?.template||y.sorting.main.template;if(this.dataLayer.renderingEngine===F.mustache){this.searchSortingMainContainer.innerHTML=S.render(t,e),this.markOptionSelected();const s=document?.getElementById(this.selectId);s&&s.addEventListener("change",a=>{this.setOrderQuery(a.target.value)})}}}class sn{analyticsKey;containerId;mainContainer;isLightweight;emailOverride;feedbackTextAreaOverride;mainTemplateOverride;lightweightTemplateOverride;focusedElement=null;focusTrapListener=null;lastFocusedElementBeforeModal=null;templateData={feedbackOpen:!1,ratings:[{index:1,isSelected:!1},{index:2,isSelected:!1},{index:3,isSelected:!1},{index:4,isSelected:!1},{index:5,isSelected:!1},{index:6,isSelected:!1},{index:7,isSelected:!1},{index:8,isSelected:!1},{index:9,isSelected:!1},{index:10,isSelected:!1}],emailInput:"",feedbackTextArea:"",charactersLeft:2e3,maxLength:2e3,errors:{rating:!1,email:!1},submitted:!1,thumbsUpActive:!1,thumbsDownActive:!1};thumbsUpValue=10;thumbsDownValue=1;ratedQuestion="";language="";model="";analyticsSrc="";constructor(e){this.analyticsKey=e.analyticsKey,this.containerId=e.containerId??"sf-feedback",this.isLightweight=e.lightweight??!1,this.isLightweight&&this.templateData.ratings.unshift({index:0,isSelected:!1}),this.thumbsUpValue=e.thumbsUpValue??10,this.thumbsDownValue=e.thumbsDownValue??1,this.emailOverride=e.emailOverride,this.feedbackTextAreaOverride=e.feedbackTextAreaOverride,this.mainTemplateOverride=e.mainTemplateOverride,this.lightweightTemplateOverride=e.lightweightTemplateOverride,this.mainContainer=document.getElementById(this.containerId),this.language=e.language??"",this.model=e.model??"",this.analyticsSrc=e.analyticsSrc??"",this.init()}init(){Le.attachAnalyticsScript(this.analyticsSrc),this.renderMainTemplate(this.generateTemplateData())}generateTemplateData(){return this.templateData}renderMainTemplate(e){const t=document.activeElement;(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLAnchorElement)&&(t.type==="radio"||t.type==="button"||t.type==="textarea"||t instanceof HTMLAnchorElement)?this.focusedElement=t:this.focusedElement=null,this.mainContainer;let s=Z?.mainTemplate?.template;if(this.mainTemplateOverride&&(s=this.mainTemplateOverride),this.isLightweight&&(s=Z.lightweightTemplate?.template,this.lightweightTemplateOverride&&(s=this.lightweightTemplateOverride)),this.mainContainer.innerHTML=S.render(s,e),this.focusedElement&&this.mainContainer){const a=this.focusedElement.type==="radio"?this.focusedElement.getAttribute("id"):this.focusedElement.getAttribute("class"),r=this.focusedElement.type==="radio"?"id":"class",n=this.mainContainer.querySelector(`[${r}="${a}"]`);(n instanceof HTMLInputElement||n instanceof HTMLButtonElement||n instanceof HTMLTextAreaElement||n instanceof HTMLAnchorElement)&&n.focus(),this.focusedElement=null}this.attachEvents()}attachEvents(){this.isLightweight?this.attachLightweightEvents():(this.attachOpenModalEvent(),this.closeModalEvent(),this.attachRatingEvents(),this.attachTextAreaEvents(),this.attachEmailInputEvents(),this.attachSubmitButtonEvents())}attachFocusTrap(){this.focusTrapListener&&document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=e=>{if(!this.templateData.feedbackOpen)return;const t=this.getModalElement();if(!t)return;const s=this.getFocusableElements(t);if(s.length===0)return;const a=s[0],r=s[s.length-1];e.key==="Tab"&&(e.shiftKey?(document.activeElement===a||!t.contains(document.activeElement))&&(e.preventDefault(),r?.focus()):(document.activeElement===r||!t.contains(document.activeElement))&&(e.preventDefault(),a?.focus())),e.key==="Escape"&&(e.preventDefault(),this.closeFeedbackModal())},document.addEventListener("keydown",this.focusTrapListener)}getFocusableElements(e){const t=["button:not([disabled])","input:not([disabled])","textarea:not([disabled])","select:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(e.querySelectorAll(t))}getModalElement(){const e=Z.mainTemplate?.modalContainerClass;return this.mainContainer?.querySelector(`.${e}`)||null}attachLightweightEvents(){const e=Z.lightweightTemplate?.thumbsUpButtonClass,t=Z.lightweightTemplate?.thumbsDownButtonClass,s=this.mainContainer?.querySelector("."+e),a=this.mainContainer?.querySelector("."+t);s&&s.addEventListener("click",()=>{const r=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[this.templateData.ratings.length-1].isSelected&&this.ratedQuestion===r||(this.templateData.thumbsUpActive=!0,this.templateData.thumbsDownActive=!1,this.templateData.ratings.forEach(n=>{n.isSelected=n.index===this.thumbsUpValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=r,this.submit())}),a&&a.addEventListener("click",()=>{const r=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[0].isSelected&&this.ratedQuestion===r||(this.templateData.thumbsUpActive=!1,this.templateData.thumbsDownActive=!0,this.templateData.ratings.forEach(n=>{n.isSelected=n.index===this.thumbsDownValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=r,this.submit())})}attachSubmitButtonEvents(){const e=Z.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.checkIfValid()})}checkIfValid(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.emailInputId);this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,Y.setAccessibilityText("Please enter a valid email address.")),this.templateData.ratings.some(t=>t.isSelected)?this.templateData.errors.rating=!1:(this.templateData.errors.rating=!0,Y.setAccessibilityText("Please Rate your experience.")),this.templateData.errors.rating||this.templateData.errors.email?this.renderMainTemplate(this.generateTemplateData()):this.submit()}submit(){this.templateData.submitted=!0;const e=this.templateData.ratings.find(t=>t.isSelected)?.index;e!==void 0&&(Le.trackFeedback({trackApiKey:this.analyticsKey,email:this.emailOverride&&this.isLightweight?this.emailOverride():this.templateData.emailInput,rating:e,feedback:this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea,model:this.model?this.model:void 0,language:this.language?this.language:void 0}),this.showCheckmarkAnimation(),Y.setAccessibilityText("Feedback has been sent.",1e3),this.mainContainer?.querySelector("."+Z.mainTemplate?.checkmarkClass)?setTimeout(()=>{this.closeFeedbackModal(),this.renderMainTemplate(this.generateTemplateData())},2e3):(setTimeout(()=>{this.closeFeedbackModal()},500),this.renderMainTemplate(this.generateTemplateData())))}validateEmail(e){return e===""?!0:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}attachEmailInputEvents(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.emailInputId);e&&(e.addEventListener("input",()=>{this.templateData.emailInput=e.value}),e.addEventListener("blur",()=>{setTimeout(()=>{this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,Y.setAccessibilityText("Please enter a valid email address.")),this.renderMainTemplate(this.generateTemplateData())},300)}))}attachTextAreaEvents(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.feedbackTextAreaId);e&&e.addEventListener("input",()=>{this.templateData.feedbackTextArea=e.value,this.templateData.charactersLeft=this.templateData.maxLength-e.value.length;const t=this.mainContainer?.querySelector("."+Z.mainTemplate?.charactersRemainingContainerclass);t&&(t.innerText=this.templateData.charactersLeft+"")})}attachRatingEvents(){const e=Z.mainTemplate?.ratingInputclass,t=this.mainContainer?.querySelectorAll("."+e);t&&t.forEach(s=>{s.addEventListener("click",a=>{const r=a.target.value;this.templateData.ratings.forEach(n=>{n.isSelected=n.index+""===r}),this.templateData.errors.rating=!1,this.renderMainTemplate(this.generateTemplateData())})})}attachOpenModalEvent(){const e=Z.mainTemplate?.openModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",s=>{s.preventDefault(),this.toggleModal()})}toggleModal(){this.templateData.feedbackOpen?this.closeFeedbackModal():this.openFeedbackModal()}closeModalEvent(){const e=Z.mainTemplate?.closeModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.closeFeedbackModal()})}openFeedbackModal(){this.lastFocusedElementBeforeModal=document.activeElement,this.templateData.feedbackOpen=!0,this.renderMainTemplate(this.generateTemplateData()),setTimeout(()=>{const e=this.getModalElement();if(e){const t=this.getFocusableElements(e);t.length>0&&t[0].focus()}this.attachFocusTrap()},0),Y.setAccessibilityText("Feedback form opened",1e3)}closeFeedbackModal(){this.templateData.feedbackOpen=!1,this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null),this.renderMainTemplate(this.generateTemplateData()),this.lastFocusedElementBeforeModal&&(this.lastFocusedElementBeforeModal.focus(),this.lastFocusedElementBeforeModal=null),Y.setAccessibilityText("Feedback form closed",1e3)}showCheckmarkAnimation(){const e=Z.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&(t.disabled=!0);const s=Z.mainTemplate?.checkmarkClass,a=this.mainContainer?.querySelector("."+s);a&&a.classList.remove("hidden");const r=Z.mainTemplate?.submitButtonTextClass,n=this.mainContainer?.querySelector("."+r);n&&n.classList.add("visibility"),setTimeout(()=>{a&&a.classList.add("hidden"),n&&n.classList.remove("visibility"),t&&(t.disabled=!1)},2e3)}destroy(){this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null)}}class rn{dataLayer;config;containerId;answerContainer=null;showMoreVisible=!1;renderFeedbackWidget=!1;clicked=!1;renderedWithShowMore=!1;showMoreListenerAttached=!1;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.renderFeedbackWidget=this.config.feedbackwidget?.renderFeedbackWidget||!1,this.config.showMoreAfterWordCount&&(this.dataLayer.answerWidgetShowMoreLimit=this.config.showMoreAfterWordCount),typeof document<"u"&&(this.answerContainer=document?.getElementById(this.containerId),this.attachShowMoreClickListener()),this.config.testString?(this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())):this.initializeSubscriptions(),this.dataLayer.setIsAnswerWidgetCreated(!0)}initializeSubscriptions(){this.dataLayer.$answer.subscribe(()=>{this.clicked?this.showMoreVisible=!1:this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerLoading.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerError.subscribe(e=>{e&&setTimeout(()=>{this.renderMainTemplate(this.generateTemplateData())},100)}),this.dataLayer.$searchObject.subscribe(()=>{this.clicked=!1,this.renderedWithShowMore=!1,this.showMoreVisible=!1}),this.dataLayer.$paginationData.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answer.subscribe(e=>{e&&setTimeout(()=>{this.initializeWidget()},600)}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.$answer.getValue()&&setTimeout(()=>{this.initializeWidget()},600)})}searchstaxFeedbackTextAreaOverride(){return"Question: "+(this.dataLayer.searchObject.query==="undefined"?"":this.dataLayer.searchObject.query)+" Answer: "+this.dataLayer.parsedData.getAnswerData}initializeWidget(){this.renderFeedbackWidget&&document.getElementById("feedbackWidgetContainer")&&!this.dataLayer.answerLoading&&new sn({analyticsKey:this.dataLayer.parsedData.trackingData.trackApiKey,containerId:"feedbackWidgetContainer",lightweight:!0,model:this.dataLayer.parsedData.trackingData.model,language:this.dataLayer.parsedData.trackingData.language,emailOverride:this.config.feedbackwidget?.emailOverride,feedbackTextAreaOverride:this.config.feedbackwidget?.searchstaxFeedbackTextAreaOverride??this.searchstaxFeedbackTextAreaOverride.bind(this),thumbsUpValue:this.config.feedbackwidget?.thumbsUpValue??10,thumbsDownValue:this.config.feedbackwidget?.thumbsDownValue??0,lightweightTemplateOverride:this.config.feedbackwidget?.lightweightTemplateOverride})}showMore(e){e.preventDefault(),this.clicked=!0,this.showMoreVisible=!1,Le.trackShowMoreClick({...this.dataLayer.parsedData.trackingData}),this.renderMainTemplate(this.generateTemplateData()),this.config.testString||setTimeout(()=>{this.initializeWidget()},600)}attachShowMoreClickListener(){!this.answerContainer||this.showMoreListenerAttached||(this.showMoreListenerAttached=!0,this.answerContainer.addEventListener("click",e=>{e.target?.closest?.(".searchstax-answer-load-more-button")&&this.showMore(e)}))}trackLinkClick(e){e.preventDefault(),e.stopPropagation();const t=e.target.getAttribute("href");Le.trackAnswerLinkClick({href:t,answer:this.dataLayer.parsedData.getAnswerData,...this.dataLayer.parsedData.trackingData}).then(()=>{window.open(t,"_blank")}).catch(()=>{window.open(t,"_blank")})}attachLinkTracking(){document.querySelectorAll(".searchstax-answer-link").forEach(e=>{e.getAttribute("listener")!=="true"&&(e.setAttribute("listener","true"),e.addEventListener("click",this.trackLinkClick.bind(this)))})}renderMainTemplate(e){const t=this.config?.templates?.main?.template||y.answer.main.template;this.dataLayer.renderingEngine===F.mustache?(!this.renderedWithShowMore||!e.answerLoading||this.clicked)&&(e.showMoreButtonVisible&&(this.renderedWithShowMore=!0),this.answerContainer.innerHTML=S.render(t,e),setTimeout(()=>{this.attachLinkTracking()},100)):setTimeout(()=>{this.attachLinkTracking()},500)}generateTemplateData(){this.config.testString&&this.dataLayer.setAnswerData(this.config.testString??"");const e={...this.dataLayer.parsedData.data,showMoreButtonVisible:this.showMoreVisible};return this.config.testString&&(e.searchExecuted=!0),this.dataLayer.setAnswerFullData(e),e}}class _s{dataLayer;config;containerId;currentSelectValue="";locationInput;radiusInput;locationDecode;locationDecodeCoordinatesToAddress;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.locationDecode=e.config.hooks?.locationDecode,this.locationDecodeCoordinatesToAddress=e.config.hooks?.locationDecodeCoordinatesToAddress,this.dataLayer.locationEnabled&&this.dataLayer.$inputTemplateRendered.subscribeUntil(()=>{this.renderMainTemplate(),this.attachSubscriptions()},!0,500)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||y.location.mainTemplate.template,s={...this.dataLayer.parsedData.data};if(this.dataLayer.setLocationWidgetTemplateData(s),this.dataLayer.renderingEngine===F.mustache){const a=S.render(t,s);e.innerHTML=a;const r=this.config.templates?.mainTemplate?.locationInputId||y.location.mainTemplate.locationInputId,n=document?.querySelector(`#${r}`);if(n)this.locationInput=n,n.addEventListener("blur",this.blurEvent.bind(this)),n.addEventListener("focus",this.focusEvent.bind(this));else throw new Error("Input not found");const c=this.config.templates?.mainTemplate?.radiusInputId||y.location.mainTemplate.radiusInputId,l=document?.querySelector(`#${c}`);l instanceof HTMLSelectElement&&(this.radiusInput=l,l.addEventListener("change",this.radiusSelectChangeEvent.bind(this)));const h=this.config.templates?.mainTemplate?.currentLocationActionButtonId||y.location.mainTemplate.currentLocationActionButtonId,p=document?.querySelector(`#${h}`);p&&p.addEventListener("click",this.getCurrentLocation.bind(this))}}}setCurrentLocationFields(e){this.dataLayer.setLocationCoordinatesDecoded(e),this.dataLayer.setSearchLocation(this.dataLayer.searchLocationCoordinatesDecoded),this.dataLayer.renderingEngine===F.mustache&&this.locationInput&&(this.locationInput.value=this.dataLayer.searchLocationCoordinatesDecoded)}getCurrentLocation(){navigator.geolocation?navigator.geolocation.getCurrentPosition(e=>{const t=e.coords.latitude.toString(),s=e.coords.longitude.toString(),a=Math.floor(parseFloat(t)*100)/100,r=Math.floor(parseFloat(s)*100)/100;this.dataLayer.setSearchLat(a+""),this.dataLayer.setSearchLong(r+"");const n=this.locationDecodeCoordinatesToAddress;n?n(a+"",r+"").then(c=>{this.setCurrentLocationFields(c.address||"Current Location")}).catch(()=>{this.setCurrentLocationFields("Current Location")}):this.setCurrentLocationFields("Current Location")},()=>{console.error("Unable to retrieve your location")}):console.error("Geolocation is not supported by this browser.")}setRadiusValue(e){this.dataLayer.setSearchRadius(e)}radiusSelectChangeEvent(e){this.currentSelectValue=e.target.value,this.setRadiusValue(this.currentSelectValue)}attachSubscriptions(){this.dataLayer.$searchObject.subscribe(e=>{this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(e.location.address??"")),this.radiusInput&&e.location.radius&&(this.radiusInput.value=e.location.radius||"")})}cleanSuggestionTerm(e){return G.removeXSSRiskyTags(e.replace(/(<([^>]+)>)/gi,"")).trim()}triggerGeocoder(e){const t=this.locationDecode;this.dataLayer.setLocationDecodingLoading(!0),e&&this.dataLayer.searchLocation!==e&&e!==this.dataLayer.searchLocationCoordinatesDecoded?t(e).then(s=>{this.dataLayer.setSearchLocation(s.address||""),this.dataLayer.setSearchLat(s.lat||""),this.dataLayer.setSearchLong(s.lon||""),this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(s.address||"")),this.dataLayer.renderingEngine===F.mustache&&s.error&&this.locationInput&&this.locationInput.classList.add("searchstax-input-location-error"),s.error?this.dataLayer.setLocationError(!0):this.dataLayer.setLocationError(!1),this.dataLayer.setLocationDecodingLoading(!1)}).catch(()=>{this.dataLayer.setLocationDecodingLoading(!1)}):e===""&&(this.dataLayer.setSearchLocation(void 0),this.dataLayer.setSearchLat(void 0),this.dataLayer.setSearchLong(void 0),this.dataLayer.setLocationDecodingLoading(!1))}focusEvent(e){e.target.classList.remove("searchstax-input-location-error"),this.dataLayer.setLocationError(!1)}blurEvent(e){const t=e.target.value;this.triggerGeocoder(t)}}class nn{routerEnabled=!1;cachedQuery="";routerHelper;searchHelper;searchResultsConfig;searchPaginationConfig;searchFeedbackConfig;searchSortingConfig;searchFacetsConfig;relatedSearchesConfig;externalPromotionsConfig;searchInputWidget;searchLocationWidget;searchResultsWidget;searchFacetsWidget;searchPaginationWidget;searchFeedbackWidget;searchSortingWidget;relatedSearchesWidget;externalPromotionsWidget;answerWidget;locationObserver=null;dataLayer;firstRequest=!0;previousQuery="";eventSource=null;renderEngine=F.mustache;constructor(e=F.mustache){e&&(this.renderEngine=e)}setRenderingEngine(e=F.mustache){this.dataLayer.setRenderingEngine(e)}handleHooks(){this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&this.dataLayer.$searchResults.subscribe(e=>{this.dataLayer.searchstaxConfig.hooks.afterSearch(e,this.dataLayer.searchResultUnparsedData)}),setTimeout(()=>{this.dataLayer.$searchObject.subscribe(e=>{e.query!==this.previousQuery&&this.dataLayer.setAnswerData(""),e.query!==""&&e.query!==void 0&&e.query!=="undefined"?(this.search(e),e.query!==this.previousQuery&&this.startSSE(e.query)):this.dataLayer.searchLocationConfig?.locationSearchEnabled&&!this.dataLayer.searchLocationConfig?.locationValuesOverride?this.getMetadata(e):this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue),this.previousQuery=e.query})},10),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&Le.trackSearch({...this.dataLayer.parsedData.trackingData,impressions:this.dataLayer.searchResultsMetadata.impressions})})}startSSE(e){this.eventSource&&(this.eventSource?.close(),this.dataLayer.setAnswerData("")),this.dataLayer.turnAIAnswerGenerationOn===!0&&this.dataLayer.questionURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&(this.eventSource=this.searchHelper?.startSSE(e,this.parseAnswerResultsResponse.bind(this)))}attachAnalyticsScript(e){Le.attachAnalyticsScript(e)}initialize(e){if(this.dataLayer=new fr("searchstax_session_id",e.sessionId),this.renderEngine&&this.dataLayer.setRenderingEngine(this.renderEngine),this.handleHooks(),e.questionURL&&(this.dataLayer.questionURL=e.questionURL),e.analyticsBaseUrl&&typeof window<"u"&&(window.analyticsBaseUrl=e.analyticsBaseUrl,window._msq=e._msq||[],this.attachAnalyticsScript(e.analyticsSrc)),e.autoCorrect===!1&&(this.dataLayer.autoCorrect=!1),e.language&&this.dataLayer.setLanguage(e.language),e.model&&this.dataLayer.setModel(e.model),this.dataLayer.searchstaxConfig||(this.dataLayer.setSearchstaxConfig(e),this.searchHelper=new br({...e,sessionId:this.dataLayer.sessionId},this.dataLayer),this.dataLayer.searchHelper=this.searchHelper),e.router?.enabled===void 0||e.router?.enabled===!0){this.routerEnabled=!0,this.routerHelper=new Ns(e.router?e.router:{enabled:!0});const t=this.routerHelper.urlToSearchObject(window?.location.href??"");this.dataLayer.searchObject.itemsPerPage?t.itemsPerPage=this.dataLayer.searchObject.itemsPerPage:t.itemsPerPage&&this.dataLayer.setItemsPerPage(t.itemsPerPage),t.model&&this.dataLayer.setModel(t.model),t.location&&(t.location.address&&this.dataLayer.setSearchLocation(t.location.address),t.location.lat&&this.dataLayer.setSearchLat(t.location.lat),t.location.lon&&this.dataLayer.setSearchLong(t.location.lon),t.location.radius&&this.dataLayer.setSearchRadius(t.location.radius)),this.dataLayer.setSearchObject(t),addEventListener("popstate",()=>{this.routerHelper&&this.dataLayer.setSearchObject(this.routerHelper.urlToSearchObject(window?.location.href??"",this.dataLayer.searchObject.itemsPerPage))})}else this.routerHelper=new Ns({})}getMetadata(e){this.searchHelper&&(e.query==="undefined"||e.query===void 0)&&this.dataLayer.setSearchObject({...e,query:"*"})}search(e){if(this.searchHelper){const t=this.dataLayer.forceNotCorrect;this.searchHelper.url&&(this.searchHelper.search(e,this.parseSearchResultsResponse.bind(this),this.firstRequest,t),this.firstRequest=!1),this.getRelatedSearches()}}getRelatedSearches(){this.searchHelper&&this.relatedSearchesConfig&&this.relatedSearchesConfig?.relatedSearchesURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&this.searchHelper.getRelatedSearches(this.dataLayer.searchObject,this.relatedSearchesConfig.relatedSearchesURL,this.relatedSearchesConfig.relatedSearchesAPIKey,this.parseRelatedSearchesResponse.bind(this))}parseRelatedSearchesResponse(e){const t=(e.response?.docs??[]).map((a,r)=>({...a,position:r+1})),s=[];for(const a of t)s.push({relatedSearch:a.related_search,position:a.position});this.dataLayer.setSearchRelatedSearches(t),this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&s.length&&Le.trackRelatedSearches({...this.dataLayer.parsedData.trackingData,impressions:s,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}handleRouter(){if(this.routerEnabled){const e={...this.dataLayer.searchObject};this.dataLayer.isInfiniteScroll&&delete e.page,this.routerHelper.updateUrl(e)}}parseSearchResultsResponseMetadata(e){const t=ht.extractSearchResultsMetadata(e),s=this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue??t.location?.filter?.defaultValue;!this.dataLayer.searchRadius&&s&&this.dataLayer.setSearchRadius(s),this.dataLayer.setSearchResultsMetadata(t)}parseSearchResultsResponse(e){this.handleRouter(),this.dataLayer.setItemsPerPage(parseInt(e.responseHeader.params.rows)),this.dataLayer.setModel(e.responseHeader.params.model);let t=ht.combineResultsWithMetadata(e),s=ht.extractFacets(e);this.dataLayer.setSearchFacets(s),this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&(t=this.dataLayer.searchstaxConfig.hooks.afterSearch(t,e)),this.dataLayer.setSearchExternalPromotions(e.externalLinks??[]),this.parseSearchResultsResponseMetadata(e),this.dataLayer.setSearchResultUnparsedData(e),this.dataLayer.setSearchResults(t)}parseAnswerResultsResponse(e){this.handleRouter(),e!==_e.question&&e!==_e.notQuestion&&(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setAnswerData(this.dataLayer.getAnswerData+e))}cacheFacets(e){e?this.searchHelper?.cacheFacets(!0).then(()=>{}):this.searchHelper?.cacheFacets().then(()=>{})}parseSuggestSuggestResponse(e){let t=e;this.dataLayer.searchInputConfig?.hooks?.afterAutosuggest&&(t=this.dataLayer.searchInputConfig.hooks.afterAutosuggest(e)),this.dataLayer.setSearchAutosuggest(t)}suggest(e,t){this.searchHelper&&this.searchHelper.suggest(e,this.parseSuggestSuggestResponse.bind(this),t)}changeLanguage(e){this.searchHelper&&this.dataLayer.setLanguage(e)}addSearchInputWidget(e,t){this.dataLayer.searchInputConfig||this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.dataLayer.setSearchInputConfig(t),this.searchInputWidget=new en({containerId:e,config:t,searchTrigger:this.executeSearch.bind(this),suggestTrigger:this.executeSuggest.bind(this),dataLayer:this.dataLayer})},200)}addSearchLocationWidget(e,t){this.dataLayer.searchLocationConfig||(t.locationSearchEnabled?(this.dataLayer.setLocationEnabled(!0),this.dataLayer.setSearchLocationConfig(t),t.locationValuesOverride?(this.searchLocationWidget=new _s({containerId:e,config:t,dataLayer:this.dataLayer}),t?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(t?.locationValuesOverride?.locationFilterDefaultValue)):this.dataLayer.$searchResultsMetadata.subscribeUntilHasValue(()=>{this.searchLocationWidget=new _s({containerId:e,config:t,dataLayer:this.dataLayer})},0)):this.dataLayer.setLocationEnabled(!1))}addAnswerWidget(e,t){this.dataLayer.turnAIAnswerGenerationOn=!0,t.testString||this.startSSE(this.dataLayer.searchObject.query),this.dataLayer.setAnswerData(t.testString??""),this.answerWidget=new rn({containerId:e,config:t,dataLayer:this.dataLayer})}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new tn({containerId:e,linkClickCallback:this.executeLinkClick.bind(this),searchTrigger:this.executeSearch.bind(this),config:t,dataLayer:this.dataLayer}))}addPaginationWidget(e,t){this.searchPaginationConfig=t,this.searchPaginationWidget=new Zr({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper})}addSearchFeedbackWidget(e,t){this.searchFeedbackConfig=t,this.searchFeedbackWidget=new Xr({containerId:e,config:t,dataLayer:this.dataLayer,searchTrigger:this.executeSearch.bind(this)})}addSearchSortingWidget(e,t){this.searchSortingConfig=t,this.searchSortingWidget=new an({containerId:e,config:t,dataLayer:this.dataLayer})}addRelatedSearchesWidget(e,t){this.relatedSearchesConfig=t,this.relatedSearchesWidget=new Kr({containerId:e,config:t,dataLayer:this.dataLayer,trackRelatedSearchClick:this.trackRelatedSearchClick.bind(this)}),setTimeout(()=>{this.getRelatedSearches()},0)}addExternalPromotionsWidget(e,t){this.externalPromotionsConfig=t,this.externalPromotionsWidget=new Jr({containerId:e,config:t,dataLayer:this.dataLayer})}addFacetsWidget(e,t){this.searchFacetsConfig=t,this.searchFacetsWidget=new Gr({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper},this.cacheFacets.bind(this))}executeSearch(e,t){const s={...this.dataLayer.searchObject};s.query=G.removeXSSRiskyTags(e),s.page=1,s.facets=[],s.location={...s.location},this.locationObserver&&this.dataLayer.$locationDecodingLoading.unsubscribe(this.locationObserver),this.locationObserver=this.dataLayer.$locationDecodingLoading.subscribeUntil(()=>{s.location.address=this.dataLayer.searchLocation,s.location.radius=this.dataLayer.searchRadius,s.location.lat=this.dataLayer.searchLat,s.location.lon=this.dataLayer.searchLong,this.dataLayer.forceNotCorrect=!!t;let a=this.routerHelper?.searchObjectToParams(s);a&&(a=this.routerHelper?.extractParamsThatDoNotStartWithRouteName(a)),a&&(s.additionalProps=Object.keys(a).map(r=>a?{key:r,value:a[r]}:{key:"",value:""})),this.dataLayer.setSearchObject(s),this.dataLayer.lastSearchValue=s.query},!1)}executeSuggest(e){let t={term:e,queryParams:[]};this.dataLayer.searchInputConfig?.hooks?.beforeAutosuggest&&(t=this.dataLayer.searchInputConfig.hooks.beforeAutosuggest(t)),t&&t.term!==void 0&&t.queryParams!==void 0&&this.suggest(t.term,t.queryParams)}trackRelatedSearchClick(e){this.dataLayer.searchResultsMetadata&&this.dataLayer.searchRelatedSearches&&!this.dataLayer.cookiesDisabled&&Le.trackRelatedSearchClick({...this.dataLayer.parsedData.trackingData,relatedSearch:e,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}executeLinkClick(e){let t=ht.findResultByUniqueId(e,this.dataLayer.searchResults??[]);t&&(this.searchResultsConfig?.hooks?.afterLinkClick&&(t=this.searchResultsConfig.hooks.afterLinkClick(t)),t&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&Le.trackClick({result:t,...this.dataLayer.parsedData.trackingData}).then(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}).catch(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}))}setPage(e){this.searchPaginationWidget?.goToPage(e)}setCookiesDisabled(e){this.dataLayer.setCookiesDisabled(e)}changeResultTemplate(e){this.searchResultsConfig&&(this.searchResultsConfig.templates=this.searchResultsConfig?.templates?{...this.searchResultsConfig?.templates,...e}:e,this.searchResultsWidget?.changeTemplate())}}export{nn as Searchstax};