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

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,30 +1,30 @@
1
- var j=(i=>(i[i.mustache=0]="mustache",i[i.vue=1]="vue",i[i.react=2]="react",i[i.angular=3]="angular",i))(j||{});function Qt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ke=Qt();function _a(i){ke=i}var qe={exec:()=>null};function k(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(Y.caret,"$1"),t=t.replace(a,n),s},getRegex:()=>new RegExp(t,e)};return s}var Y={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")},Qs=/^(?:[ \t]*(?:\n|$))+/,Hs=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,_s=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ue=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Bs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ht=/(?:[*+-]|\d{1,9}[.)])/,Ba=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,qa=k(Ba).replace(/bull/g,Ht).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(),qs=k(Ba).replace(/bull/g,Ht).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),_t=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Us=/^[^\n]+/,Bt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ws=k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Bt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ys=k(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ht).getRegex(),yt="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",qt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Js=k("^ {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",qt).replace("tag",yt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ua=k(_t).replace("hr",Ue).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",yt).getRegex(),Gs=k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ua).getRegex(),Ut={blockquote:Gs,code:Hs,def:Ws,fences:_s,heading:Bs,hr:Ue,html:Js,lheading:qa,list:Ys,newline:Qs,paragraph:Ua,table:qe,text:Us},Wa=k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ue).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",yt).getRegex(),Zs={...Ut,lheading:qs,table:Wa,paragraph:k(_t).replace("hr",Ue).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Wa).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",yt).getRegex()},Ks={...Ut,html:k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",qt).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:qe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:k(_t).replace("hr",Ue).replace("heading",` *#{1,6} *[^
2
- ]`).replace("lheading",qa).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Xs=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ei=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ya=/^( {2,}|\\)\n(?!\s*$)/,ti=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,wt=/[\p{P}\p{S}]/u,Wt=/[\s\p{P}\p{S}]/u,Ja=/[^\s\p{P}\p{S}]/u,ai=k(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Wt).getRegex(),Ga=/(?!~)[\p{P}\p{S}]/u,si=/(?!~)[\s\p{P}\p{S}]/u,ii=/(?:[^\s\p{P}\p{S}]|~)/u,ri=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Za=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ni=k(Za,"u").replace(/punct/g,wt).getRegex(),oi=k(Za,"u").replace(/punct/g,Ga).getRegex(),Ka="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ci=k(Ka,"gu").replace(/notPunctSpace/g,Ja).replace(/punctSpace/g,Wt).replace(/punct/g,wt).getRegex(),li=k(Ka,"gu").replace(/notPunctSpace/g,ii).replace(/punctSpace/g,si).replace(/punct/g,Ga).getRegex(),hi=k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ja).replace(/punctSpace/g,Wt).replace(/punct/g,wt).getRegex(),ui=k(/\\(punct)/,"gu").replace(/punct/g,wt).getRegex(),di=k(/^<(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(),gi=k(qt).replace("(?:-->|$)","-->").getRegex(),pi=k("^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",gi).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Mt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,mi=k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Mt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Xa=k(/^!?\[(label)\]\[(ref)\]/).replace("label",Mt).replace("ref",Bt).getRegex(),es=k(/^!?\[(ref)\](?:\[\])?/).replace("ref",Bt).getRegex(),Li=k("reflink|nolink(?!\\()","g").replace("reflink",Xa).replace("nolink",es).getRegex(),Yt={_backpedal:qe,anyPunctuation:ui,autolink:di,blockSkip:ri,br:Ya,code:ei,del:qe,emStrongLDelim:ni,emStrongRDelimAst:ci,emStrongRDelimUnd:hi,escape:Xs,link:mi,nolink:es,punctuation:ai,reflink:Xa,reflinkSearch:Li,tag:pi,text:ti,url:qe},fi={...Yt,link:k(/^!?\[(label)\]\((.*?)\)/).replace("label",Mt).getRegex(),reflink:k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Mt).getRegex()},Jt={...Yt,emStrongRDelimAst:li,emStrongLDelim:oi,url:k(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},yi={...Jt,br:k(Ya).replace("{2,}","*").getRegex(),text:k(Jt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ct={normal:Ut,gfm:Zs,pedantic:Ks},We={normal:Yt,gfm:Jt,breaks:yi,pedantic:fi},wi={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ts=i=>wi[i];function le(i,e){if(e){if(Y.escapeTest.test(i))return i.replace(Y.escapeReplace,ts)}else if(Y.escapeTestNoEncode.test(i))return i.replace(Y.escapeReplaceNoEncode,ts);return i}function as(i){try{i=encodeURI(i).replace(Y.percentDecode,"%")}catch{return null}return i}function ss(i,e){const t=i.replace(Y.findPipe,(r,n,o)=>{let l=!1,h=n;for(;--h>=0&&o[h]==="\\";)l=!l;return l?"|":" |"}),s=t.split(Y.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(Y.slashPipe,"|");return s}function Ye(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 Mi(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 is(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 Ci(i,e,t){const s=i.match(t.other.indentCodeCompensation);if(s===null)return e;const a=s[1];return e.split(`
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
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 bt=class{options;rules;lexer;constructor(i){this.options=i||ke}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:Ye(t,`
5
- `)}}}fences(i){const e=this.rules.block.fences.exec(i);if(e){const t=e[0],s=Ci(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=Ye(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:Ye(e[0],`
6
- `)}}blockquote(i){const e=this.rules.block.blockquote.exec(i);if(e){let t=Ye(e[0],`
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],`
7
7
  `).split(`
8
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
- `),g=h.replace(this.rules.other.blockquoteSetextReplace,`
9
+ `),m=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
- ${g}`:g;const L=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(g,r,!0),this.lexer.state.top=L,t.length===0)break;const y=r.at(-1);if(y?.type==="code")break;if(y?.type==="blockquote"){const T=y,C=T.raw+`
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+`
13
13
  `+t.join(`
14
- `),p=this.blockquote(C);r[r.length-1]=p,s=s.substring(0,s.length-T.raw.length)+p.raw,a=a.substring(0,a.length-T.text.length)+p.text;break}else if(y?.type==="list"){const T=y,C=T.raw+`
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+`
15
15
  `+t.join(`
16
- `),p=this.list(C);r[r.length-1]=p,s=s.substring(0,s.length-y.raw.length)+p.raw,a=a.substring(0,a.length-T.raw.length)+p.raw,t=C.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="",g="";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,v=>" ".repeat(3*v.length)),y=i.split(`
19
- `,1)[0],T=!L.trim(),C=0;if(this.options.pedantic?(C=2,g=L.trimStart()):T?C=e[1].length+1:(C=e[2].search(this.rules.other.nonSpaceChar),C=C>4?1:C,g=L.slice(C),C+=e[1].length),T&&this.rules.other.blankLine.test(y)&&(h+=y+`
20
- `,i=i.substring(y.length+1),l=!0),!l){const v=this.rules.other.nextBulletRegex(C),R=this.rules.other.hrRegex(C),Q=this.rules.other.fencesBeginRegex(C),D=this.rules.other.headingBeginRegex(C),q=this.rules.other.htmlBeginRegex(C);for(;i;){const ae=i.split(`
21
- `,1)[0];let ue;if(y=ae,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),ue=y):ue=y.replace(this.rules.other.tabCharGlobal," "),Q.test(y)||D.test(y)||q.test(y)||v.test(y)||R.test(y))break;if(ue.search(this.rules.other.nonSpaceChar)>=C||!y.trim())g+=`
22
- `+ue.slice(C);else{if(T||L.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Q.test(L)||D.test(L)||R.test(L))break;g+=`
23
- `+y}!T&&!y.trim()&&(T=!0),h+=ae+`
24
- `,i=i.substring(ae.length+1),L=ue.slice(C)}}a.loose||(n?a.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(n=!0));let p=null,x;this.options.gfm&&(p=this.rules.other.listIsTask.exec(g),p&&(x=p[0]!=="[ ] ",g=g.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:h,task:!!p,checked:x,loose:!1,text:g,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"),g=h.length>0&&h.some(L=>this.rules.other.anyLine.test(L.raw));a.loose=g}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=ss(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(ss(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=Ye(t.slice(0,-1),"\\");if((t.length-r.length)%2===0)return}else{const r=Mi(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)),is(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 is(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 g=[...s[0]][0].length,L=i.slice(0,a+s.index+g+n);if(Math.min(a,n)%2){const T=L.slice(1,-1);return{type:"em",raw:L,text:T,tokens:this.lexer.inlineTokens(T)}}const y=L.slice(2,-2);return{type:"strong",raw:L,text:y,tokens:this.lexer.inlineTokens(y)}}}}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}}}},pe=class ya{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ke,this.options.tokenizer=this.options.tokenizer||new bt,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:Y,block:Ct.normal,inline:We.normal};this.options.pedantic?(t.block=Ct.pedantic,t.inline=We.pedantic):this.options.gfm&&(t.block=Ct.gfm,this.options.breaks?t.inline=We.breaks:t.inline=We.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ct,inline:We}}static lex(e,t){return new ya(t).lex(e)}static lexInline(e,t){return new ya(t).inlineTokens(e)}lex(e){e=e.replace(Y.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(Y.tabCharGlobal," ").replace(Y.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
+ `),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+=`
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+=`
@@ -33,16 +33,16 @@ ${g}`:g;const L=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
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 g=e.slice(1);let L;this.options.extensions.startInline.forEach(y=>{L=y.call({lexer:this},g),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}},xt=class{options;parser;constructor(i){this.options=i||ke}space(i){return""}code({text:i,lang:e,escaped:t}){const s=(e||"").match(Y.notSpaceStart)?.[0],a=i.replace(Y.endingNewline,"")+`
37
- `;return s?'<pre><code class="language-'+le(s)+'">'+(t?a:le(a,!0))+`</code></pre>
38
- `:"<pre><code>"+(t?a:le(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 o=Object.keys(this.tokens.links);if(o.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)o.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,a.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(a=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let r=!1,n="";for(;e;){r||(n=""),r=!1;let o;if(this.options.extensions?.inline?.some(h=>(o=h.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);const h=t.at(-1);o.type==="text"&&h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,s,n)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let l=e;if(this.options.extensions?.startInline){let h=1/0;const m=e.slice(1);let L;this.options.extensions.startInline.forEach(M=>{L=M.call({lexer:this},m),typeof L=="number"&&L>=0&&(h=Math.min(h,L))}),h<1/0&&h>=0&&(l=e.substring(0,h+1))}if(o=this.tokenizer.inlineText(l)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(n=o.raw.slice(-1)),r=!0;const h=t.at(-1);h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(e){const h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return t}},kt=class{options;parser;constructor(i){this.options=i||Ae}space(i){return""}code({text:i,lang:e,escaped:t}){const s=(e||"").match(X.notSpaceStart)?.[0],a=i.replace(X.endingNewline,"")+`
37
+ `;return s?'<pre><code class="language-'+de(s)+'">'+(t?a:de(a,!0))+`</code></pre>
38
+ `:"<pre><code>"+(t?a:de(a,!0))+`</code></pre>
39
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
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+`>
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+" "+le(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+" "+de(i.tokens[0].tokens[0].text),i.tokens[0].tokens[0].escaped=!0)):i.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:!0}):e+=t+" "}return e+=this.parser.parse(i.tokens,!!i.loose),`<li>${e}</li>
46
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,17 +51,22 @@ ${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>${le(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=as(i);if(a===null)return s;i=a;let r='<a href="'+i+'"';return e&&(r+=' title="'+le(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=as(i);if(a===null)return le(t);i=a;let r=`<img src="${i}" alt="${t}"`;return e&&(r+=` title="${le(e)}"`),r+=">",r}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:le(i.text)}},Gt=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""}},me=class wa{options;renderer;textRenderer;constructor(e){this.options=e||ke,this.options.renderer=this.options.renderer||new xt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Gt}static parse(e,t){return new wa(t).parse(e)}static parseInline(e,t){return new wa(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}},kt=class{options;block;constructor(i){this.options=i||ke}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(i){return i}postprocess(i){return i}processAllTokens(i){return i}provideLexer(){return this.block?pe.lex:pe.lexInline}provideParser(){return this.block?me.parse:me.parseInline}},bi=class{defaults=Qt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=me;Renderer=xt;TextRenderer=Gt;Lexer=pe;Tokenizer=bt;Hooks=kt;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 xt(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 g=o.apply(a,h);return g===!1&&(g=l.apply(a,h)),g||""}}s.renderer=a}if(t.tokenizer){const a=this.defaults.tokenizer||new bt(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 g=o.apply(a,h);return g===!1&&(g=l.apply(a,h)),g}}s.tokenizer=a}if(t.hooks){const a=this.defaults.hooks||new kt;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];kt.passThroughHooks.has(r)?a[n]=h=>{if(this.defaults.async)return Promise.resolve(o.call(a,h)).then(L=>l.call(a,L));const g=o.call(a,h);return l.call(a,g)}:a[n]=(...h)=>{let g=o.apply(a,h);return g===!1&&(g=l.apply(a,h)),g}}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 pe.lex(i,e??this.defaults)}parser(i,e){return me.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?pe.lex:pe.lexInline,o=a.hooks?a.hooks.provideParser():i?me.parse:me.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>"+le(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},Se=new bi;function S(i,e){return Se.parse(i,e)}S.options=S.setOptions=function(i){return Se.setOptions(i),S.defaults=Se.defaults,_a(S.defaults),S},S.getDefaults=Qt,S.defaults=ke,S.use=function(...i){return Se.use(...i),S.defaults=Se.defaults,_a(S.defaults),S},S.walkTokens=function(i,e){return Se.walkTokens(i,e)},S.parseInline=Se.parseInline,S.Parser=me,S.parser=me.parse,S.Renderer=xt,S.TextRenderer=Gt,S.Lexer=pe,S.lexer=pe.lex,S.Tokenizer=bt,S.Hooks=kt,S.parse=S,S.options,S.setOptions,S.use,S.walkTokens,S.parseInline,me.parse,pe.lex;const{entries:rs,setPrototypeOf:ns,isFrozen:xi,getPrototypeOf:ki,getOwnPropertyDescriptor:Si}=Object;let{freeze:J,seal:ee,create:Je}=Object,{apply:Zt,construct:Kt}=typeof Reflect<"u"&&Reflect;J||(J=function(i){return i}),ee||(ee=function(i){return i}),Zt||(Zt=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)}),Kt||(Kt=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 Ge=Z(Array.prototype.forEach),Ti=Z(Array.prototype.lastIndexOf),os=Z(Array.prototype.pop),Ze=Z(Array.prototype.push),vi=Z(Array.prototype.splice),St=Z(String.prototype.toLowerCase),Xt=Z(String.prototype.toString),ea=Z(String.prototype.match),Ie=Z(String.prototype.replace),Ai=Z(String.prototype.indexOf),Ei=Z(String.prototype.trim),re=Z(Object.prototype.hasOwnProperty),G=Z(RegExp.prototype.test),Ke=Di(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 Zt(i,e,s)}}function Di(i){return function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return Kt(i,t)}}function w(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:St;ns&&ns(i,null);let s=e.length;for(;s--;){let a=e[s];if(typeof a=="string"){const r=t(a);r!==a&&(xi(e)||(e[s]=r),a=r)}i[a]=!0}return i}function Ii(i){for(let e=0;e<i.length;e++)re(i,e)||(i[e]=null);return i}function he(i){const e=Je(null);for(const[t,s]of rs(i))re(i,t)&&(Array.isArray(s)?e[t]=Ii(s):s&&typeof s=="object"&&s.constructor===Object?e[t]=he(s):e[t]=s);return e}function Xe(i,e){for(;i!==null;){const s=Si(i,e);if(s){if(s.get)return Z(s.get);if(typeof s.value=="function")return Z(s.value)}i=ki(i)}function t(){return null}return t}const cs=J(["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"]),ta=J(["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"]),aa=J(["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"]),ji=J(["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"]),sa=J(["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"]),Ri=J(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ls=J(["#text"]),hs=J(["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","slot"]),ia=J(["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"]),us=J(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Tt=J(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ni=ee(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Oi=ee(/<%[\w\W]*|[\w\W]*%>/gm),Pi=ee(/\$\{[\w\W]*/gm),Fi=ee(/^data-[\-\w.\u00B7-\uFFFF]+$/),zi=ee(/^aria-[\-\w]+$/),ds=ee(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),$i=ee(/^(?:\w+script|data):/i),Vi=ee(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),gs=ee(/^html$/i),Qi=ee(/^[a-z][.\w]*(-[.\w]+)+$/i);var ps=Object.freeze({__proto__:null,ARIA_ATTR:zi,ATTR_WHITESPACE:Vi,CUSTOM_ELEMENT:Qi,DATA_ATTR:Fi,DOCTYPE_NAME:gs,ERB_EXPR:Oi,IS_ALLOWED_URI:ds,IS_SCRIPT_OR_DATA:$i,MUSTACHE_EXPR:Ni,TMPLIT_EXPR:Pi});const et={element:1,text:3,progressingInstruction:7,comment:8,document:9},Hi=function(){return typeof window>"u"?null:window},_i=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}},ms=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ls(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Hi();const e=c=>Ls(c);if(e.version="3.4.0",e.removed=[],!i||!i.document||i.document.nodeType!==et.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:g=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:L,DOMParser:y,trustedTypes:T}=i,C=l.prototype,p=Xe(C,"cloneNode"),x=Xe(C,"remove"),v=Xe(C,"nextSibling"),R=Xe(C,"childNodes"),Q=Xe(C,"parentNode");if(typeof n=="function"){const c=t.createElement("template");c.content&&c.content.ownerDocument&&(t=c.content.ownerDocument)}let D,q="";const{implementation:ae,createNodeIterator:ue,createDocumentFragment:se,getElementsByTagName:vs}=t,{importNode:As}=s;let U=ms();e.isSupported=typeof rs=="function"&&typeof Q=="function"&&ae&&ae.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ct,ERB_EXPR:lt,TMPLIT_EXPR:ht,DATA_ATTR:Es,ARIA_ATTR:Ds,IS_SCRIPT_OR_DATA:Is,ATTR_WHITESPACE:Ma,CUSTOM_ELEMENT:js}=ps;let{IS_ALLOWED_URI:Ca}=ps,z=null;const ba=w({},[...cs,...ta,...aa,...sa,...ls]);let H=null;const xa=w({},[...hs,...ia,...us,...Tt]);let N=Object.seal(Je(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}})),Ve=null,ut=null;const ye=Object.seal(Je(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ka=!0,Dt=!0,Sa=!1,Ta=!0,Me=!1,Qe=!0,Ce=!1,It=!1,jt=!1,ve=!1,dt=!1,gt=!1,va=!0,Aa=!1;const Rs="user-content-";let Rt=!0,He=!1,Ae={},oe=null;const Nt=w({},["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 Ea=null;const Da=w({},["audio","video","img","source","image","track"]);let Ot=null;const Ia=w({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),pt="http://www.w3.org/1998/Math/MathML",mt="http://www.w3.org/2000/svg",ce="http://www.w3.org/1999/xhtml";let Ee=ce,Pt=!1,Ft=null;const Ns=w({},[pt,mt,ce],Xt);let Lt=w({},["mi","mo","mn","ms","mtext"]),ft=w({},["annotation-xml"]);const Os=w({},["title","style","font","a","script"]);let _e=null;const Ps=["application/xhtml+xml","text/html"],Fs="text/html";let O=null,De=null;const zs=t.createElement("form"),ja=function(c){return c instanceof RegExp||c instanceof Function},zt=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(De&&De===c)){if((!c||typeof c!="object")&&(c={}),c=he(c),_e=Ps.indexOf(c.PARSER_MEDIA_TYPE)===-1?Fs:c.PARSER_MEDIA_TYPE,O=_e==="application/xhtml+xml"?Xt:St,z=re(c,"ALLOWED_TAGS")?w({},c.ALLOWED_TAGS,O):ba,H=re(c,"ALLOWED_ATTR")?w({},c.ALLOWED_ATTR,O):xa,Ft=re(c,"ALLOWED_NAMESPACES")?w({},c.ALLOWED_NAMESPACES,Xt):Ns,Ot=re(c,"ADD_URI_SAFE_ATTR")?w(he(Ia),c.ADD_URI_SAFE_ATTR,O):Ia,Ea=re(c,"ADD_DATA_URI_TAGS")?w(he(Da),c.ADD_DATA_URI_TAGS,O):Da,oe=re(c,"FORBID_CONTENTS")?w({},c.FORBID_CONTENTS,O):Nt,Ve=re(c,"FORBID_TAGS")?w({},c.FORBID_TAGS,O):he({}),ut=re(c,"FORBID_ATTR")?w({},c.FORBID_ATTR,O):he({}),Ae=re(c,"USE_PROFILES")?c.USE_PROFILES:!1,ka=c.ALLOW_ARIA_ATTR!==!1,Dt=c.ALLOW_DATA_ATTR!==!1,Sa=c.ALLOW_UNKNOWN_PROTOCOLS||!1,Ta=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Me=c.SAFE_FOR_TEMPLATES||!1,Qe=c.SAFE_FOR_XML!==!1,Ce=c.WHOLE_DOCUMENT||!1,ve=c.RETURN_DOM||!1,dt=c.RETURN_DOM_FRAGMENT||!1,gt=c.RETURN_TRUSTED_TYPE||!1,jt=c.FORCE_BODY||!1,va=c.SANITIZE_DOM!==!1,Aa=c.SANITIZE_NAMED_PROPS||!1,Rt=c.KEEP_CONTENT!==!1,He=c.IN_PLACE||!1,Ca=c.ALLOWED_URI_REGEXP||ds,Ee=c.NAMESPACE||ce,Lt=c.MATHML_TEXT_INTEGRATION_POINTS||Lt,ft=c.HTML_INTEGRATION_POINTS||ft,N=c.CUSTOM_ELEMENT_HANDLING||Je(null),c.CUSTOM_ELEMENT_HANDLING&&ja(c.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(N.tagNameCheck=c.CUSTOM_ELEMENT_HANDLING.tagNameCheck),c.CUSTOM_ELEMENT_HANDLING&&ja(c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(N.attributeNameCheck=c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(N.allowCustomizedBuiltInElements=c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Me&&(Dt=!1),dt&&(ve=!0),Ae&&(z=w({},ls),H=Je(null),Ae.html===!0&&(w(z,cs),w(H,hs)),Ae.svg===!0&&(w(z,ta),w(H,ia),w(H,Tt)),Ae.svgFilters===!0&&(w(z,aa),w(H,ia),w(H,Tt)),Ae.mathMl===!0&&(w(z,sa),w(H,us),w(H,Tt))),ye.tagCheck=null,ye.attributeCheck=null,c.ADD_TAGS&&(typeof c.ADD_TAGS=="function"?ye.tagCheck=c.ADD_TAGS:(z===ba&&(z=he(z)),w(z,c.ADD_TAGS,O))),c.ADD_ATTR&&(typeof c.ADD_ATTR=="function"?ye.attributeCheck=c.ADD_ATTR:(H===xa&&(H=he(H)),w(H,c.ADD_ATTR,O))),c.ADD_URI_SAFE_ATTR&&w(Ot,c.ADD_URI_SAFE_ATTR,O),c.FORBID_CONTENTS&&(oe===Nt&&(oe=he(oe)),w(oe,c.FORBID_CONTENTS,O)),c.ADD_FORBID_CONTENTS&&(oe===Nt&&(oe=he(oe)),w(oe,c.ADD_FORBID_CONTENTS,O)),Rt&&(z["#text"]=!0),Ce&&w(z,["html","head","body"]),z.table&&(w(z,["tbody"]),delete Ve.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');D=c.TRUSTED_TYPES_POLICY,q=D.createHTML("")}else D===void 0&&(D=_i(T,a)),D!==null&&typeof q=="string"&&(q=D.createHTML(""));J&&J(c),De=c}},Ra=w({},[...ta,...aa,...ji]),Na=w({},[...sa,...Ri]),$s=function(c){let d=Q(c);(!d||!d.tagName)&&(d={namespaceURI:Ee,tagName:"template"});const u=St(c.tagName),A=St(d.tagName);return Ft[c.namespaceURI]?c.namespaceURI===mt?d.namespaceURI===ce?u==="svg":d.namespaceURI===pt?u==="svg"&&(A==="annotation-xml"||Lt[A]):!!Ra[u]:c.namespaceURI===pt?d.namespaceURI===ce?u==="math":d.namespaceURI===mt?u==="math"&&ft[A]:!!Na[u]:c.namespaceURI===ce?d.namespaceURI===mt&&!ft[A]||d.namespaceURI===pt&&!Lt[A]?!1:!Na[u]&&(Os[u]||!Ra[u]):!!(_e==="application/xhtml+xml"&&Ft[c.namespaceURI]):!1},be=function(c){Ze(e.removed,{element:c});try{Q(c).removeChild(c)}catch{x(c)}},xe=function(c,d){try{Ze(e.removed,{attribute:d.getAttributeNode(c),from:d})}catch{Ze(e.removed,{attribute:null,from:d})}if(d.removeAttribute(c),c==="is")if(ve||dt)try{be(d)}catch{}else try{d.setAttribute(c,"")}catch{}},Oa=function(c){let d=null,u=null;if(jt)c="<remove></remove>"+c;else{const I=ea(c,/^[\r\n\t ]+/);u=I&&I[0]}_e==="application/xhtml+xml"&&Ee===ce&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const A=D?D.createHTML(c):c;if(Ee===ce)try{d=new y().parseFromString(A,_e)}catch{}if(!d||!d.documentElement){d=ae.createDocument(Ee,"template",null);try{d.documentElement.innerHTML=Pt?q:A}catch{}}const _=d.body||d.documentElement;return c&&u&&_.insertBefore(t.createTextNode(u),_.childNodes[0]||null),Ee===ce?vs.call(d,Ce?"html":"body")[0]:Ce?d.documentElement:_},Pa=function(c){return ue.call(c.ownerDocument||c,c,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},$t=function(c){return c instanceof L&&(typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||!(c.attributes instanceof g)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function")},Vt=function(c){return typeof o=="function"&&c instanceof o};function de(c,d,u){Ge(c,A=>{A.call(e,d,u,De)})}const Fa=function(c){let d=null;if(de(U.beforeSanitizeElements,c,null),$t(c))return be(c),!0;const u=O(c.nodeName);if(de(U.uponSanitizeElement,c,{tagName:u,allowedTags:z}),Qe&&c.hasChildNodes()&&!Vt(c.firstElementChild)&&G(/<[/\w!]/g,c.innerHTML)&&G(/<[/\w!]/g,c.textContent)||Qe&&c.namespaceURI===ce&&u==="style"&&Vt(c.firstElementChild)||c.nodeType===et.progressingInstruction||Qe&&c.nodeType===et.comment&&G(/<[/\w]/g,c.data))return be(c),!0;if(Ve[u]||!(ye.tagCheck instanceof Function&&ye.tagCheck(u))&&!z[u]){if(!Ve[u]&&$a(u)&&(N.tagNameCheck instanceof RegExp&&G(N.tagNameCheck,u)||N.tagNameCheck instanceof Function&&N.tagNameCheck(u)))return!1;if(Rt&&!oe[u]){const A=Q(c)||c.parentNode,_=R(c)||c.childNodes;if(_&&A){const I=_.length;for(let ge=I-1;ge>=0;--ge){const ie=p(_[ge],!0);ie.__removalCount=(c.__removalCount||0)+1,A.insertBefore(ie,v(c))}}}return be(c),!0}return c instanceof l&&!$s(c)||(u==="noscript"||u==="noembed"||u==="noframes")&&G(/<\/no(script|embed|frames)/i,c.innerHTML)?(be(c),!0):(Me&&c.nodeType===et.text&&(d=c.textContent,Ge([ct,lt,ht],A=>{d=Ie(d,A," ")}),c.textContent!==d&&(Ze(e.removed,{element:c.cloneNode()}),c.textContent=d)),de(U.afterSanitizeElements,c,null),!1)},za=function(c,d,u){if(ut[d]||va&&(d==="id"||d==="name")&&(u in t||u in zs))return!1;if(!(Dt&&!ut[d]&&G(Es,d))&&!(ka&&G(Ds,d))&&!(ye.attributeCheck instanceof Function&&ye.attributeCheck(d,c))){if(!H[d]||ut[d]){if(!($a(c)&&(N.tagNameCheck instanceof RegExp&&G(N.tagNameCheck,c)||N.tagNameCheck instanceof Function&&N.tagNameCheck(c))&&(N.attributeNameCheck instanceof RegExp&&G(N.attributeNameCheck,d)||N.attributeNameCheck instanceof Function&&N.attributeNameCheck(d,c))||d==="is"&&N.allowCustomizedBuiltInElements&&(N.tagNameCheck instanceof RegExp&&G(N.tagNameCheck,u)||N.tagNameCheck instanceof Function&&N.tagNameCheck(u))))return!1}else if(!Ot[d]&&!G(Ca,Ie(u,Ma,""))&&!((d==="src"||d==="xlink:href"||d==="href")&&c!=="script"&&Ai(u,"data:")===0&&Ea[c])&&!(Sa&&!G(Is,Ie(u,Ma,"")))&&u)return!1}return!0},$a=function(c){return c!=="annotation-xml"&&ea(c,js)},Va=function(c){de(U.beforeSanitizeAttributes,c,null);const{attributes:d}=c;if(!d||$t(c))return;const u={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:H,forceKeepAttr:void 0};let A=d.length;for(;A--;){const _=d[A],{name:I,namespaceURI:ge,value:ie}=_,W=O(I),Be=ie;let B=I==="value"?Be:Ei(Be);if(u.attrName=W,u.attrValue=B,u.keepAttr=!0,u.forceKeepAttr=void 0,de(U.uponSanitizeAttribute,c,u),B=u.attrValue,Aa&&(W==="id"||W==="name")&&(xe(I,c),B=Rs+B),Qe&&G(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,B)){xe(I,c);continue}if(W==="attributename"&&ea(B,"href")){xe(I,c);continue}if(u.forceKeepAttr)continue;if(!u.keepAttr){xe(I,c);continue}if(!Ta&&G(/\/>/i,B)){xe(I,c);continue}Me&&Ge([ct,lt,ht],Vs=>{B=Ie(B,Vs," ")});const Ha=O(c.nodeName);if(!za(Ha,W,B)){xe(I,c);continue}if(D&&typeof T=="object"&&typeof T.getAttributeType=="function"&&!ge)switch(T.getAttributeType(Ha,W)){case"TrustedHTML":{B=D.createHTML(B);break}case"TrustedScriptURL":{B=D.createScriptURL(B);break}}if(B!==Be)try{ge?c.setAttributeNS(ge,I,B):c.setAttribute(I,B),$t(c)?be(c):os(e.removed)}catch{xe(I,c)}}de(U.afterSanitizeAttributes,c,null)},Qa=function(c){let d=null;const u=Pa(c);for(de(U.beforeSanitizeShadowDOM,c,null);d=u.nextNode();)de(U.uponSanitizeShadowNode,d,null),Fa(d),Va(d),d.content instanceof r&&Qa(d.content);de(U.afterSanitizeShadowDOM,c,null)};return e.sanitize=function(c){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,A=null,_=null,I=null;if(Pt=!c,Pt&&(c="<!-->"),typeof c!="string"&&!Vt(c))if(typeof c.toString=="function"){if(c=c.toString(),typeof c!="string")throw Ke("dirty is not a string, aborting")}else throw Ke("toString is not a function");if(!e.isSupported)return c;if(It||zt(d),e.removed=[],typeof c=="string"&&(He=!1),He){if(c.nodeName){const W=O(c.nodeName);if(!z[W]||Ve[W])throw Ke("root node is forbidden and cannot be sanitized in-place")}}else if(c instanceof o)u=Oa("<!---->"),A=u.ownerDocument.importNode(c,!0),A.nodeType===et.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?u=A:u.appendChild(A);else{if(!ve&&!Me&&!Ce&&c.indexOf("<")===-1)return D&&gt?D.createHTML(c):c;if(u=Oa(c),!u)return ve?null:gt?q:""}u&&jt&&be(u.firstChild);const ge=Pa(He?c:u);for(;_=ge.nextNode();)Fa(_),Va(_),_.content instanceof r&&Qa(_.content);if(He)return c;if(ve){if(Me){u.normalize();let W=u.innerHTML;Ge([ct,lt,ht],Be=>{W=Ie(W,Be," ")}),u.innerHTML=W}if(dt)for(I=se.call(u.ownerDocument);u.firstChild;)I.appendChild(u.firstChild);else I=u;return(H.shadowroot||H.shadowrootmode)&&(I=As.call(s,I,!0)),I}let ie=Ce?u.outerHTML:u.innerHTML;return Ce&&z["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&G(gs,u.ownerDocument.doctype.name)&&(ie="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
57
- `+ie),Me&&Ge([ct,lt,ht],W=>{ie=Ie(ie,W," ")}),D&&gt?D.createHTML(ie):ie},e.setConfig=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};zt(c),It=!0},e.clearConfig=function(){De=null,It=!1},e.isValidAttribute=function(c,d,u){De||zt({});const A=O(c),_=O(d);return za(A,_,u)},e.addHook=function(c,d){typeof d=="function"&&Ze(U[c],d)},e.removeHook=function(c,d){if(d!==void 0){const u=Ti(U[c],d);return u===-1?void 0:vi(U[c],u,1)[0]}return os(U[c])},e.removeHooks=function(c){U[c]=[]},e.removeAllHooks=function(){U=ms()},e}var fs=Ls();class Bi{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 fs.sanitize(S.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 fs.sanitize(S.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 te{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 f{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 ra{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 ${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 qi{$searchTermChange=new f("");$searchLocationChange=new f("");$searchLocationCoordinatesDecoded=new f("");$searchLatChange=new f("");$searchLongChange=new f("");$searchRadiusChange=new f(void 0);$loadingChange=new f(!1);$locationError=new f(!1);$searchResults=new f(null);$searchResultsMetadata=new f(null);$searchAutosuggest=new f(null);$searchFacets=new f(null);$searchFacetsCached=new f(null);$searchFacetsCachedTabs=new f(null);$searchstaxConfig=new f(null);$autosuggestResults=new f(null);$itemsPerPage=new f(void 0);$searchObject=new f({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 f(null);$searchInputConfig=new f(null);$searchLocationConfig=new f(null);$searchExternalPromotions=new f(null);$facetsTemplateData=new f(null);$selectedFacetsTemplateData=new f(null);$paginationData=new f(null);$answerData=new f(null);$searchFeedbackData=new f(null);$inputWidgetTemplateData=new f(null);$locationWidgetTemplateData=new f(null);$searchSortingData=new f(null);$searchRelatedSearchesData=new f(null);$searchExternalPromotionsData=new f(null);$cookiesDisabled=new f(null);$locationDecodingLoading=new f(!1);$answer=new f("");$language=new f("en");$model=new f("");$answerLoading=new f(!1);$locationEnabled=new f(null);$answerError=new f(!1);$answerErrorMessage=new f("");$isQuestion=new f(!1);$inputTemplateRendered=new f(!1);currentPageValue=1;isAnswerWidgetCreatedValue=!1;renderingEngineValue=j.mustache;parsedData=new Bi(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,ra.deleteCookie(this.sessionId),ra.deleteCookie("ms_visitorid")):this.sessionIdValue=ra.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue($.removeXSSRiskyTags(e))}setSearchLocation(e){this.$searchLocationChange.setValue($.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,(!te.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){te.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&&(!te.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){this.facetsWereSet=!0,te.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){te.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchFacetsCachedTabs(e){te.deepEqual(e,this.searchFacetsCachedTabs??[])||this.$searchFacetsCachedTabs.setValue(e)}setSearchRelatedSearches(e){te.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){te.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($.removeXSSRiskyTags(e))}setLocationEnabled(e){this.$locationEnabled.setValue(e)}setSearchResultUnparsedData(e){this.searchResultUnparsed=e}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCached(){return this.$searchFacetsCached.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCached.getValue())):null}get searchFacetsCachedTabs(){return this.$searchFacetsCachedTabs.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCachedTabs.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get searchLocation(){return this.$searchLocationChange.getValue()}get searchRadius(){return this.$searchRadiusChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get model(){return this.$model.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get searchLocationConfig(){return this.$searchLocationConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}get answerFullData(){return this.$answerData.getValue()}get answerLoading(){return this.$answerLoading.getValue()}get isQuestion(){return this.$isQuestion.getValue()}get answerError(){return this.$answerError.getValue()}get answerErrorMessage(){return this.$answerErrorMessage.getValue()}get locationDecodingLoading(){return this.$locationDecodingLoading.getValue()}get searchLat(){return this.$searchLatChange.getValue()}get searchLong(){return this.$searchLongChange.getValue()}get inputTemplateRendered(){return this.$inputTemplateRendered.getValue()}get locationError(){return this.$locationError.getValue()}get inputWidgetTemplateData(){return this.$inputWidgetTemplateData.getValue()}get locationWidgetTemplateData(){return this.$locationWidgetTemplateData.getValue()}get searchLocationCoordinatesDecoded(){return this.$searchLocationCoordinatesDecoded.getValue()}get locationEnabled(){return this.$locationEnabled.getValue()}get searchResultUnparsedData(){return this.searchResultUnparsed}}class tt{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,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 ys{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 Ui(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=$.removeXSSRiskyTags(e[s].split(":")?.[0]),r=$.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[1])),n=$.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=$.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),r=parseInt(a),n=isNaN(r)?1:r;let o=parseInt($.removeXSSRiskyTags(s[this.routeName+"[itemsPerPage]"]));return isNaN(o)&&(o=10),{query:$.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:n,itemsPerPage:t??o,order:$.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[],model:$.removeXSSRiskyTags(s[this.routeName+"[model]"])||"",location:{address:$.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][address]"]||"")),radius:$.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][radius]"]||"")),lat:$.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lat]"]||"")),lon:$.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lon]"]||""))}}}}class Ui{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 je={question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class ws 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}}function na(i){}function Wi(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=na,onError:t=na,onRetry:s=na,onComment:a}=i;let r="",n=!0,o,l="",h="";function g(p){const x=n?p.replace(/^\xEF\xBB\xBF/,""):p,[v,R]=Yi(`${r}${x}`);for(const Q of v)L(Q);r=R,n=!1}function L(p){if(p===""){T();return}if(p.startsWith(":")){a&&a(p.slice(p.startsWith(": ")?2:1));return}const x=p.indexOf(":");if(x!==-1){const v=p.slice(0,x),R=p[x+1]===" "?2:1,Q=p.slice(x+R);y(v,Q,p);return}y(p,"",p)}function y(p,x,v){switch(p){case"event":h=x;break;case"data":l=`${l}${x}
58
- `;break;case"id":o=x.includes("\0")?void 0:x;break;case"retry":/^\d+$/.test(x)?s(parseInt(x,10)):t(new ws(`Invalid \`retry\` value: "${x}"`,{type:"invalid-retry",value:x,line:v}));break;default:t(new ws(`Unknown field "${p.length>20?`${p.slice(0,20)}\u2026`:p}"`,{type:"unknown-field",field:p,value:x,line:v}));break}}function T(){l.length>0&&e({id:o,event:h||void 0,data:l.endsWith(`
59
- `)?l.slice(0,-1):l}),o=void 0,l="",h=""}function C(p={}){r&&p.consume&&L(r),n=!0,o=void 0,l="",h="",r=""}return{feed:g,reset:C}}function Yi(i){const e=[];let t="",s=0;for(;s<i.length;){const a=i.indexOf("\r",s),r=i.indexOf(`
60
- `,s);let n=-1;if(a!==-1&&r!==-1?n=Math.min(a,r):a!==-1?a===i.length-1?n=-1:n=a:r!==-1&&(n=r),n===-1){t=i.slice(s);break}else{const o=i.slice(s,n);e.push(o),s=n+1,i[s-1]==="\r"&&i[s]===`
61
- `&&s++}}return[e,t]}class Ms 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(Cs(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(Cs(this),t)}}function Ji(i){const e=globalThis.DOMException;return typeof e=="function"?new e(i,"SyntaxError"):new SyntaxError(i)}function oa(i){return i instanceof Error?"errors"in i&&Array.isArray(i.errors)?i.errors.map(oa).join(", "):"cause"in i&&i.cause instanceof Error?`${i}: ${oa(i.cause)}`:i.message:`${i}`}function Cs(i){return{type:i.type,message:i.message,code:i.code,defaultPrevented:i.defaultPrevented,cancelable:i.cancelable,timeStamp:i.timeStamp}}var bs=i=>{throw TypeError(i)},ca=(i,e,t)=>e.has(i)||bs("Cannot "+t),M=(i,e,t)=>(ca(i,e,"read from private field"),t?t.call(i):e.get(i)),P=(i,e,t)=>e.has(i)?bs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),E=(i,e,t,s)=>(ca(i,e,"write to private field"),e.set(i,t),t),Le=(i,e,t)=>(ca(i,e,"access private method"),t),X,Te,Re,vt,At,at,Ne,st,we,Oe,Pe,Fe,it,ne,la,ha,ua,xs,da,ga,rt,pa,ma;class Et extends EventTarget{constructor(e,t){var s,a;super(),P(this,ne),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,P(this,X),P(this,Te),P(this,Re),P(this,vt),P(this,At),P(this,at),P(this,Ne),P(this,st,null),P(this,we),P(this,Oe),P(this,Pe,null),P(this,Fe,null),P(this,it,null),P(this,ha,async r=>{var n;M(this,Oe).reset();const{body:o,redirected:l,status:h,headers:g}=r;if(h===204){Le(this,ne,rt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(l?E(this,Re,new URL(r.url)):E(this,Re,void 0),h!==200){Le(this,ne,rt).call(this,`Non-200 status code (${h})`,h);return}if(!(g.get("content-type")||"").startsWith("text/event-stream")){Le(this,ne,rt).call(this,'Invalid content type, expected "text/event-stream"',h);return}if(M(this,X)===this.CLOSED)return;E(this,X,this.OPEN);const L=new Event("open");if((n=M(this,it))==null||n.call(this,L),this.dispatchEvent(L),typeof o!="object"||!o||!("getReader"in o)){Le(this,ne,rt).call(this,"Invalid response body, expected a web ReadableStream",h),this.close();return}const y=new TextDecoder,T=o.getReader();let C=!0;do{const{done:p,value:x}=await T.read();x&&M(this,Oe).feed(y.decode(x,{stream:!p})),p&&(C=!1,M(this,Oe).reset(),Le(this,ne,pa).call(this))}while(C)}),P(this,ua,r=>{E(this,we,void 0),!(r.name==="AbortError"||r.type==="aborted")&&Le(this,ne,pa).call(this,oa(r))}),P(this,da,r=>{typeof r.id=="string"&&E(this,st,r.id);const n=new MessageEvent(r.event||"message",{data:r.data,origin:M(this,Re)?M(this,Re).origin:M(this,Te).origin,lastEventId:r.id||""});M(this,Fe)&&(!r.event||r.event==="message")&&M(this,Fe).call(this,n),this.dispatchEvent(n)}),P(this,ga,r=>{E(this,at,r)}),P(this,ma,()=>{E(this,Ne,void 0),M(this,X)===this.CONNECTING&&Le(this,ne,la).call(this)});try{if(e instanceof URL)E(this,Te,e);else if(typeof e=="string")E(this,Te,new URL(e,Gi()));else throw new Error("Invalid URL")}catch{throw Ji("An invalid or illegal string was specified")}E(this,Oe,Wi({onEvent:M(this,da),onRetry:M(this,ga)})),E(this,X,this.CONNECTING),E(this,at,3e3),E(this,At,(s=t?.fetch)!=null?s:globalThis.fetch),E(this,vt,(a=t?.withCredentials)!=null?a:!1),Le(this,ne,la).call(this)}get readyState(){return M(this,X)}get url(){return M(this,Te).href}get withCredentials(){return M(this,vt)}get onerror(){return M(this,Pe)}set onerror(e){E(this,Pe,e)}get onmessage(){return M(this,Fe)}set onmessage(e){E(this,Fe,e)}get onopen(){return M(this,it)}set onopen(e){E(this,it,e)}addEventListener(e,t,s){const a=t;super.addEventListener(e,a,s)}removeEventListener(e,t,s){const a=t;super.removeEventListener(e,a,s)}close(){M(this,Ne)&&clearTimeout(M(this,Ne)),M(this,X)!==this.CLOSED&&(M(this,we)&&M(this,we).abort(),E(this,X,this.CLOSED),E(this,we,void 0))}}X=new WeakMap,Te=new WeakMap,Re=new WeakMap,vt=new WeakMap,At=new WeakMap,at=new WeakMap,Ne=new WeakMap,st=new WeakMap,we=new WeakMap,Oe=new WeakMap,Pe=new WeakMap,Fe=new WeakMap,it=new WeakMap,ne=new WeakSet,la=function(){E(this,X,this.CONNECTING),E(this,we,new AbortController),M(this,At)(M(this,Te),Le(this,ne,xs).call(this)).then(M(this,ha)).catch(M(this,ua))},ha=new WeakMap,ua=new WeakMap,xs=function(){var i;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...M(this,st)?{"Last-Event-ID":M(this,st)}:void 0},cache:"no-store",signal:(i=M(this,we))==null?void 0:i.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},da=new WeakMap,ga=new WeakMap,rt=function(i,e){var t;M(this,X)!==this.CLOSED&&E(this,X,this.CLOSED);const s=new Ms("error",{code:e,message:i});(t=M(this,Pe))==null||t.call(this,s),this.dispatchEvent(s)},pa=function(i,e){var t;if(M(this,X)===this.CLOSED)return;E(this,X,this.CONNECTING);const s=new Ms("error",{code:e,message:i});(t=M(this,Pe))==null||t.call(this,s),this.dispatchEvent(s),E(this,Ne,setTimeout(M(this,ma),M(this,at)))},ma=new WeakMap,Et.CONNECTING=0,Et.OPEN=1,Et.CLOSED=2;function Gi(){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 fe{static subscribedToClickEvent=!1;static attachAnalyticsScript(e){window._msq=window._msq||[];const t=e||"https://static.searchstax.com/studio-js/v4/js/studio-analytics.js";if(!document.querySelector(`script[src="${t}"]`)){var s=document.createElement("script");s.type="text/javascript",s.src=t;var a=document.getElementsByTagName("script")[0];a.parentNode&&a.parentNode.insertBefore(s,a)}}static msq=()=>typeof window<"u"&&window?._msq?window?._msq:[];static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language,model:e.model};return new Promise((s,a)=>{const 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 Zi{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=tt.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=new Proxy(new URLSearchParams(window?.location.search??""),{get:(l,h)=>l.get(h)??""}),n=r.languageVariant?"&fq=_language:"+r.languageVariant:"",o=e.model??this.dataLayer.model;return"?q="+encodeURIComponent(e.query.trim())+"&start="+s+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(l=>l.type==="or"||l.type==="showUnavailable"),!0)+this.generateLocationQuery(e.location)+this.generateFacetQuery(e.facets.filter(l=>l.type==="and"||l.type==="tabs"),!1)+a+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!t}`+(o?`&model=${o}`:"")+"&language="+this.dataLayer.language+n}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.searchObject.page!==1)return;const s=new Et(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===je.question||r.data===je.notQuestion){r.data===je.question?(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setIsQuestion(!0)):(a.setAnswerLoading(!1),this.dataLayer.setIsQuestion(!1)),a.setAnswerData("");return}if(r.data===je.close){fe.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){const n=r.data.split("[comment]: <> ({")[1].split("})")[0],o=JSON.parse("{"+n+"}");this.dataLayer.answerWidgetShowMoreLimit=o.displayShowMoreAfter,o.showMoreEnabled||(this.dataLayer.answerWidgetShowMoreLimit=1e17),t("")}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 Ki=Object.prototype.toString,ze=Array.isArray||function(i){return Ki.call(i)==="[object Array]"};function La(i){return typeof i=="function"}function Xi(i){return ze(i)?"array":typeof i}function fa(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function ks(i,e){return i!=null&&typeof i=="object"&&e in i}function er(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var tr=RegExp.prototype.test;function ar(i,e){return tr.call(i,e)}var sr=/\S/;function ir(i){return!ar(sr,i)}var rr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function nr(i){return String(i).replace(/[&<>"'`=\/]/g,function(e){return rr[e]})}var or=/\s*/,cr=/\s+/,Ss=/\s*=/,lr=/\s*\}/,hr=/#|\^|\/|>|\{|&|=|!/;function ur(i,e){if(!i)return[];var t=!1,s=[],a=[],r=[],n=!1,o=!1,l="",h=0;function g(){if(n&&!o)for(;r.length;)delete a[r.pop()];else r=[];n=!1,o=!1}var L,y,T;function C(se){if(typeof se=="string"&&(se=se.split(cr,2)),!ze(se)||se.length!==2)throw new Error("Invalid tags: "+se);L=new RegExp(fa(se[0])+"\\s*"),y=new RegExp("\\s*"+fa(se[1])),T=new RegExp("\\s*"+fa("}"+se[1]))}C(e||b.tags);for(var p=new nt(i),x,v,R,Q,D,q;!p.eos();){if(x=p.pos,R=p.scanUntil(L),R)for(var ae=0,ue=R.length;ae<ue;++ae)Q=R.charAt(ae),ir(Q)?(r.push(a.length),l+=Q):(o=!0,t=!0,l+=" "),a.push(["text",Q,x,x+1]),x+=1,Q===`
62
- `&&(g(),l="",h=0,t=!1);if(!p.scan(L))break;if(n=!0,v=p.scan(hr)||"name",p.scan(or),v==="="?(R=p.scanUntil(Ss),p.scan(Ss),p.scanUntil(y)):v==="{"?(R=p.scanUntil(T),p.scan(lr),p.scanUntil(y),v="&"):R=p.scanUntil(y),!p.scan(y))throw new Error("Unclosed tag at "+p.pos);if(v==">"?D=[v,R,x,p.pos,l,h,t]:D=[v,R,x,p.pos],h++,a.push(D),v==="#"||v==="^")s.push(D);else if(v==="/"){if(q=s.pop(),!q)throw new Error('Unopened section "'+R+'" at '+x);if(q[1]!==R)throw new Error('Unclosed section "'+q[1]+'" at '+x)}else v==="name"||v==="{"||v==="&"?o=!0:v==="="&&C(R)}if(g(),q=s.pop(),q)throw new Error('Unclosed section "'+q[1]+'" at '+p.pos);return gr(dr(a))}function dr(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 gr(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 nt(i){this.string=i,this.tail=i,this.pos=0}nt.prototype.eos=function(){return this.tail===""},nt.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},nt.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 $e(i,e){this.view=i,this.cache={".":this.view},this.parent=e}$e.prototype.push=function(i){return new $e(i,this)},$e.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=ks(a,r[n])||er(a,r[n])),a=a[r[n++]];else a=s.view[i],o=ks(s.view,i);if(o){t=a;break}s=s.parent}e[i]=t}return La(t)&&(t=t.call(this.view)),t};function K(){this.templateCache={_cache:{},set:function(i,e){this._cache[i]=e},get:function(i){return this._cache[i]},clear:function(){this._cache={}}}}K.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()},K.prototype.parse=function(i,e){var t=this.templateCache,s=i+":"+(e||b.tags).join(":"),a=typeof t<"u",r=a?t.get(s):void 0;return r==null&&(r=ur(i,e),a&&t.set(s,r)),r},K.prototype.render=function(i,e,t,s){var a=this.getConfigTags(s),r=this.parse(i,a),n=e instanceof $e?e:new $e(e,void 0);return this.renderTokens(r,n,t,i,s)},K.prototype.renderTokens=function(i,e,t,s,a){for(var r="",n,o,l,h=0,g=i.length;h<g;++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},K.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(ze(o))for(var h=0,g=o.length;h<g;++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(La(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}},K.prototype.renderInverted=function(i,e,t,s,a){var r=e.lookup(i[1]);if(!r||ze(r)&&r.length===0)return this.renderTokens(i[4],e,t,s,a)},K.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>${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(`
63
68
  `),r=0;r<a.length;r++)a[r].length&&(r>0||!t)&&(a[r]=s+a[r]);return a.join(`
64
- `)},K.prototype.renderPartial=function(i,e,t,s){if(t){var a=this.getConfigTags(s),r=La(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 g=this.parse(h,a);return this.renderTokens(g,e,t,h,s)}}},K.prototype.unescapedValue=function(i,e){var t=e.lookup(i[1]);if(t!=null)return t},K.prototype.escapedValue=function(i,e,t){var s=this.getConfigEscape(t)||b.escape,a=e.lookup(i[1]);if(a!=null)return typeof a=="number"&&s===b.escape?String(a):s(a)},K.prototype.rawValue=function(i){return i[1]},K.prototype.getConfigTags=function(i){return ze(i)?i:i&&typeof i=="object"?i.tags:void 0},K.prototype.getConfigEscape=function(i){if(i&&typeof i=="object"&&!ze(i))return i.escape};var b={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){ot.templateCache=i},get templateCache(){return ot.templateCache}},ot=new K;b.clearCache=function(){return ot.clearCache()},b.parse=function(i,e){return ot.parse(i,e)},b.render=function(i,e,t,s){if(typeof i!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+Xi(i)+'" was given as the first argument for mustache#render(template, view, partials)');return ot.render(i,e,t,s)},b.escape=nr,b.Scanner=nt,b.Context=$e,b.Writer=K;const pr={main:{template:`
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:`
65
70
  {{#shouldShowAnswer}}
66
71
  <div class="searchstax-answer-wrap">
67
72
  <div class="searchstax-answer-icon"></div>
@@ -98,7 +103,7 @@ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An err
98
103
  </div>
99
104
  </div>
100
105
  {{/shouldShowAnswer}}
101
- `}},mr={mainTemplate:{template:`
106
+ `}},vr={mainTemplate:{template:`
102
107
  {{#hasExternalPromotions}}
103
108
  <div class="searchstax-external-promotions-container" id="searchstax-external-promotions-container" data-test-id="searchstax-external-promotions-container">
104
109
  External promotions go here
@@ -124,7 +129,7 @@ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An err
124
129
  </p>
125
130
  {{/url}}
126
131
  </div>
127
- `}},Lr={mainTemplateDesktop:{template:`
132
+ `}},Er={mainTemplateDesktop:{template:`
128
133
  {{#hasResultsOrExternalPromotions}}
129
134
  <div class="searchstax-facets-container-desktop"></div>
130
135
  {{/hasResultsOrExternalPromotions}}
@@ -182,7 +187,7 @@ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An err
182
187
  <div class="searchstax-facets-pill-label">{{value}} ({{count}})</div>
183
188
  <div class="searchstax-facets-pill-icon-close"></div>
184
189
  </div>
185
- `,containerClass:"searchstax-facets-pill-facets"}},fr={mainTemplate:{template:`
190
+ `,containerClass:"searchstax-facets-pill-facets"}},Ir={mainTemplate:{template:`
186
191
  {{#results.length}}
187
192
  <div class="searchstax-pagination-container" data-test-id="searchstax-pagination-container">
188
193
  <div class="searchstax-pagination-content">
@@ -200,7 +205,7 @@ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An err
200
205
  <a class="searchstax-pagination-load-more" data-test-id="searchstax-pagination-load-more" tabindex="0">Show More</a>
201
206
  {{/isLastPage}}
202
207
  {{/results.length}}
203
- `,loadMoreButtonClass:"searchstax-pagination-load-more"}},yr={main:{template:`
208
+ `,loadMoreButtonClass:"searchstax-pagination-load-more"}},Dr={main:{template:`
204
209
  {{#hasRelatedSearches}}
205
210
  <div class="searchstax-related-searches-container" data-test-id="searchstax-related-searches-container" id="searchstax-related-searches-container">
206
211
  Related searches: <span id="searchstax-related-searches"></span>
@@ -215,7 +220,7 @@ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An err
215
220
  <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">
216
221
  {{ related_search }}{{^last}}<span>,</span>{{/last}}
217
222
  </span>
218
- `,relatedSearchContainerClass:"searchstax-related-search-item"}},wr={main:{template:`
223
+ `,relatedSearchContainerClass:"searchstax-related-search-item"}},jr={main:{template:`
219
224
  {{#searchExecuted}}
220
225
  <a href="#searchstax-search-results" data-test-id="searchstax-skip" class="searchstax-skip">Skip to results section</a>
221
226
  <h4 class="searchstax-feedback-container" data-test-id="searchstax-feedback-container">
@@ -229,7 +234,7 @@ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An err
229
234
  {{/hasResults}}
230
235
  </h4>
231
236
  {{/searchExecuted}}
232
- `,originalQueryClass:"searchstax-feedback-original-query"}},Mr={mainTemplate:{template:`
237
+ `,originalQueryClass:"searchstax-feedback-original-query"}},Rr={mainTemplate:{template:`
233
238
  <div class="searchstax-search-input-container searchstax-search-input-container-new {{#locationEnabled}}searchstax-alternative-render{{/locationEnabled}}">
234
239
  <div class="searchstax-search-input-wrapper">
235
240
  <input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." aria-label="Search" />
@@ -239,7 +244,7 @@ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An err
239
244
  </div>
240
245
  `,searchInputId:"searchstax-search-input"},autosuggestItemTemplate:{template:`
241
246
  <div class="searchstax-autosuggest-item-term-container">{{{term}}}</div>
242
- `}},Cr={mainTemplate:{template:`
247
+ `}},Nr={mainTemplate:{template:`
243
248
  <div class="searchstax-location-input-container" data-test-id="searchstax-location-input-container">
244
249
  <div class="searchstax-location-input-wrapper">
245
250
  <span class="searchstax-location-input-label">NEAR</span>
@@ -257,7 +262,7 @@ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An err
257
262
  {{/shouldShowLocationDistanceDropdown}}
258
263
  </div>
259
264
  </div>
260
- `,locationInputId:"searchstax-location-input",radiusInputId:"searchstax-location-radius-select",currentLocationActionButtonId:"searchstax-location-get-current-location"}},br={mainTemplate:{template:`
265
+ `,locationInputId:"searchstax-location-input",radiusInputId:"searchstax-location-radius-select",currentLocationActionButtonId:"searchstax-location-get-current-location"}},Or={mainTemplate:{template:`
261
266
  <section aria-label="search results container" tabindex="0">
262
267
  <div class="searchstax-search-results-container" id="searchstax-search-results-container" data-test-id="searchstax-search-results-container">
263
268
  <div class="searchstax-search-results" id="searchstax-search-results"></div>
@@ -329,7 +334,7 @@ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An err
329
334
  </ul>
330
335
  </div>
331
336
  {{/searchExecuted}}
332
- `}},xr={main:{template:`
337
+ `}},Pr={main:{template:`
333
338
  {{#searchExecuted}}
334
339
  {{#hasResultsOrExternalPromotions}}
335
340
  {{#sortOptions.length}}
@@ -346,7 +351,7 @@ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An err
346
351
  {{/sortOptions.length}}
347
352
  {{/hasResultsOrExternalPromotions}}
348
353
  {{/searchExecuted}}
349
- `,selectId:"searchstax-search-order-select"}},V={mainTemplate:{template:`
354
+ `,selectId:"searchstax-search-order-select"}},W={mainTemplate:{template:`
350
355
  <div class="sf-widget-container">
351
356
  <div id="sf-widget" class="sf-main">
352
357
  <a role="button" href="#" id="searchstax-open-feedback" class="sf-open-feedback" tabindex="0" aria-label="Open Search Feedback">[ - ] Search Feedback</a>
@@ -429,4 +434,4 @@ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An err
429
434
 
430
435
  </div>
431
436
  </div>
432
- `,thumbsUpButtonClass:"searchstax-lightweight-widget-thumbs-up",thumbsDownButtonClass:"searchstax-lightweight-widget-thumbs-down"}};class m{static answer=pr;static externalPromotions=mr;static facets=Lr;static pagination=fr;static relatedSearches=yr;static searchFeedback=wr;static searchInput=Mr;static location=Cr;static searchResults=br;static sorting=xr;static feedback=V}class kr{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||m.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||m.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=b.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||m.externalPromotions.mainTemplate?.template;if(this.dataLayer.renderingEngine===j.mustache){this.searchExternalPromotionsMainContainer.innerHTML=b.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 F{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 Sr{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||m.facets.facetItemContainerTemplate?.template;a.innerHTML=b.render(r,e),t.appendChild(a);const n=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerClass||m.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"),g=n.querySelector(".searchstax-facet-title");g&&g.setAttribute("aria-expanded",String(h))}});const o=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListContainerClass||m.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=>te.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||m.facets.facetItemTemplate?.template;a.innerHTML=b.render(n,{...e,isChecked:r});let o=m.facets.facetItemTemplate?.checkTriggerClasses;o=this.config?.templates?.facetItemTemplate?.checkTriggerClasses||o,o.forEach(h=>{a.querySelector("."+h)?.addEventListener("click",g=>{this.onFacetSelect(g,e,a)})});const l=a.querySelector("."+(this.config?.templates?.facetItemTemplate?.inputCheckboxClass||m.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 g=this.extractFacetValue(t);o?h.find(L=>te.deepEqual(L,g)?L:!1)||(this.config.facetingType==="tabs"&&(h=h.filter(L=>L.name!==g.name)),h.push(g)):h=h.filter(L=>!te.deepEqual(L,g)),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||m.facets.showMoreButtonContainerTemplate?.template;a.innerHTML=b.render(r,{...e,focusId:`moreLess${e?.values?.[0]?.value}`});const n=a.querySelector("."+(this.config?.templates?.showMoreButtonContainerTemplate?.showMoreButtonClass||m.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?(F.setAccessibilityText(`More Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),r[t.name]=r[t.name]+a):(F.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&&(!te.deepEqual(this.cachedData??{},e)||t)){this.cachedData=e;const s=this.config?.templates?.mainTemplateDesktop?.template||m.facets.mainTemplateDesktop?.template;if(this.dataLayer.renderingEngine===j.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=b.render(s,{...e});const r=this.searchFacetsMainContainer?.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.facetsContainerClass||m.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||m.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||m.facets.clearFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=b.render(s,{shouldShow:t.facets.length>0});const r=a.querySelector("."+(this.config?.templates?.clearFacetsTemplate?.containerClass||m.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||m.facets.selectedFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=b.render(s,t);const r=a.querySelector("."+(this.config?.templates?.selectedFacetsTemplate?.containerClass||m.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||m.facets.filterByTemplate?.template,s=document?.createElement("div");s.innerHTML=b.render(t,{});const a=s.querySelector("."+(this.config?.templates?.filterByTemplate?.containerClass||m.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(){F.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(){F.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||m.facets.mainTemplateMobile?.template;if(this.dataLayer.renderingEngine===j.mustache){if(t.innerHTML=b.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 m.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||m.facets.mainTemplateMobile.filterByContainerClass));a&&this.createFilterByComponent(a);const r=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.selectedFacetsContainerClass||m.facets.mainTemplateMobile.selectedFacetsContainerClass));r&&(this.createSelectedFacetsComponents(r),this.createClearFacetsComponents(r));const n=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.facetsContainerClass||m.facets.mainTemplateMobile.facetsContainerClass));if(n){n.innerHTML="";for(const o of e.facets)this.createFacetItem(o,n,!0)}}}}}class Tr{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??m.pagination.mainTemplate.previousButtonClass,this.nextButtonClass=this.config?.templates?.mainTemplate?.nextButtonClass??m.pagination.mainTemplate.nextButtonClass,this.loadMoreButtonClass=this.config?.templates?.infiniteScrollTemplate?.loadMoreButtonClass??m.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||m.pagination.mainTemplate?.template;this.dataLayer.isInfiniteScroll&&(t=this.config?.templates?.infiniteScrollTemplate?.template||m.pagination.infiniteScrollTemplate?.template),this.dataLayer.renderingEngine===j.mustache&&(this.searchPaginationMainContainer.innerHTML=b.render(t,e),setTimeout(()=>{this.overridePaginationEvents()},0))}}class vr{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||m.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||m.relatedSearches.relatedSearch.template;if(this.dataLayer.renderingEngine===j.mustache){s.innerHTML=b.render(a,e);const r=s.querySelector("."+(this.config.templates?.relatedSearch?.relatedSearchContainerClass||m.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||m.relatedSearches.main.template;if(this.dataLayer.renderingEngine===j.mustache&&this.searchRelatedSearchesMainContainer){this.searchRelatedSearchesMainContainer.innerHTML="",this.searchRelatedSearchesMainContainer.innerHTML=b.render(t,e);const s=this.searchRelatedSearchesMainContainer?.querySelector(`.${this.relatedSearchesContainerClass}`);if(s)for(const a of e.relatedSearches)this.addRelatedSearchComponent(a,s)}}}class Ar{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||m.searchFeedback.main?.originalQueryClass));e&&e.addEventListener("click",this.onOriginalQueryClick.bind(this))}renderMainTemplate(e){const t=this.config?.templates?.main?.template||m.searchFeedback.main.template;this.dataLayer.renderingEngine===j.mustache&&(this.searchFeedbackMainContainer.innerHTML=b.render(t,e),setTimeout(()=>{this.attachClick()},0))}}class Er{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||m.searchInput.mainTemplate.template,s={...this.dataLayer.parsedData.data,locationEnabled:!!this.dataLayer.locationEnabled};if(this.dataLayer.setInputWidgetTemplateData(s),this.dataLayer.renderingEngine===j.mustache){const n=b.render(t,s);e.innerHTML=n,this.dataLayer.setInputTemplateRendered(!0)}const a=this.config.templates?.mainTemplate?.searchInputId||m.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===j.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)),F.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,F.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"),F.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)),F.setAccessibilityText("No Suggestion selected")},200)}cleanSuggestionTerm(e){return $.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||m.searchInput.autosuggestItemTemplate?.template;return t.innerHTML=b.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?F.setAccessibilityText("Suggestions are available. Use up and down arrows to navigate while focusing input. Use Escape key to escape out of the suggestions",2e3):F.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 Dr{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(()=>{F.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||m.searchResults.noSearchResultTemplate?.template,t=this.dataLayer.searchResultsMetadata?.spellingSuggestion??"";if(this.dataLayer.renderingEngine===j.mustache&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=b.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===j.mustache&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)F.setAccessibilityText("Search has no results"),this.renderNoResultsTemplate();else{F.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||m.searchResults.searchResultTemplate?.template,s=e.map(a=>b.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||m.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||m.searchResults.mainTemplate?.template;this.dataLayer.renderingEngine===j.mustache&&(this.searchResultsMainContainer.innerHTML=b.render(e,{}),setTimeout(()=>{const t=this.config?.templates?.mainTemplate?.searchResultsContainerId?this.config?.templates?.mainTemplate?.searchResultsContainerId:m.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 Ir{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||m.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||m.sorting.main.template;if(this.dataLayer.renderingEngine===j.mustache){this.searchSortingMainContainer.innerHTML=b.render(t,e),this.markOptionSelected();const s=document?.getElementById(this.selectId);s&&s.addEventListener("change",a=>{this.setOrderQuery(a.target.value)})}}}class jr{analyticsKey;containerId;mainContainer;isLightweight;emailOverride;feedbackTextAreaOverride;mainTemplateOverride;lightweightTemplateOverride;focusedElement=null;focusTrapListener=null;lastFocusedElementBeforeModal=null;templateData={feedbackOpen:!1,ratings:[{index:1,isSelected:!1},{index:2,isSelected:!1},{index:3,isSelected:!1},{index:4,isSelected:!1},{index:5,isSelected:!1},{index:6,isSelected:!1},{index:7,isSelected:!1},{index:8,isSelected:!1},{index:9,isSelected:!1},{index:10,isSelected:!1}],emailInput:"",feedbackTextArea:"",charactersLeft:2e3,maxLength:2e3,errors:{rating:!1,email:!1},submitted:!1,thumbsUpActive:!1,thumbsDownActive:!1};thumbsUpValue=10;thumbsDownValue=1;ratedQuestion="";language="";model="";analyticsSrc="";constructor(e){this.analyticsKey=e.analyticsKey,this.containerId=e.containerId??"sf-feedback",this.isLightweight=e.lightweight??!1,this.isLightweight&&this.templateData.ratings.unshift({index:0,isSelected:!1}),this.thumbsUpValue=e.thumbsUpValue??10,this.thumbsDownValue=e.thumbsDownValue??1,this.emailOverride=e.emailOverride,this.feedbackTextAreaOverride=e.feedbackTextAreaOverride,this.mainTemplateOverride=e.mainTemplateOverride,this.lightweightTemplateOverride=e.lightweightTemplateOverride,this.mainContainer=document.getElementById(this.containerId),this.language=e.language??"",this.model=e.model??"",this.analyticsSrc=e.analyticsSrc??"",this.init()}init(){fe.attachAnalyticsScript(this.analyticsSrc),this.renderMainTemplate(this.generateTemplateData())}generateTemplateData(){return this.templateData}renderMainTemplate(e){const t=document.activeElement;(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLAnchorElement)&&(t.type==="radio"||t.type==="button"||t.type==="textarea"||t instanceof HTMLAnchorElement)?this.focusedElement=t:this.focusedElement=null,this.mainContainer;let s=V?.mainTemplate?.template;if(this.mainTemplateOverride&&(s=this.mainTemplateOverride),this.isLightweight&&(s=V.lightweightTemplate?.template,this.lightweightTemplateOverride&&(s=this.lightweightTemplateOverride)),this.mainContainer.innerHTML=b.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=V.mainTemplate?.modalContainerClass;return this.mainContainer?.querySelector(`.${e}`)||null}attachLightweightEvents(){const e=V.lightweightTemplate?.thumbsUpButtonClass,t=V.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=V.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.checkIfValid()})}checkIfValid(){const e=this.mainContainer?.querySelector("#"+V.mainTemplate?.emailInputId);this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,F.setAccessibilityText("Please enter a valid email address.")),this.templateData.ratings.some(t=>t.isSelected)?this.templateData.errors.rating=!1:(this.templateData.errors.rating=!0,F.setAccessibilityText("Please Rate your experience.")),this.templateData.errors.rating||this.templateData.errors.email?this.renderMainTemplate(this.generateTemplateData()):this.submit()}submit(){this.templateData.submitted=!0;const e=this.templateData.ratings.find(t=>t.isSelected)?.index;e!==void 0&&(fe.trackFeedback({trackApiKey:this.analyticsKey,email:this.emailOverride&&this.isLightweight?this.emailOverride():this.templateData.emailInput,rating:e,feedback:this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea,model:this.model?this.model:void 0,language:this.language?this.language:void 0}),this.showCheckmarkAnimation(),F.setAccessibilityText("Feedback has been sent.",1e3),this.mainContainer?.querySelector("."+V.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("#"+V.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,F.setAccessibilityText("Please enter a valid email address.")),this.renderMainTemplate(this.generateTemplateData())},300)}))}attachTextAreaEvents(){const e=this.mainContainer?.querySelector("#"+V.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("."+V.mainTemplate?.charactersRemainingContainerclass);t&&(t.innerText=this.templateData.charactersLeft+"")})}attachRatingEvents(){const e=V.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=V.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=V.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),F.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),F.setAccessibilityText("Feedback form closed",1e3)}showCheckmarkAnimation(){const e=V.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&(t.disabled=!0);const s=V.mainTemplate?.checkmarkClass,a=this.mainContainer?.querySelector("."+s);a&&a.classList.remove("hidden");const r=V.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 Rr{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 jr({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");fe.trackAnswerLinkClick({href:t,answer:this.dataLayer.parsedData.getAnswerData,...this.dataLayer.parsedData.trackingData}).then(()=>{window.open(t,"_blank")}).catch(()=>{window.open(t,"_blank")})}attachLinkTracking(){document.querySelectorAll(".searchstax-answer-link").forEach(e=>{e.getAttribute("listener")!=="true"&&(e.setAttribute("listener","true"),e.addEventListener("click",this.trackLinkClick.bind(this)))})}renderMainTemplate(e){const t=this.config?.templates?.main?.template||m.answer.main.template;this.dataLayer.renderingEngine===j.mustache?(!this.renderedWithShowMore||!e.answerLoading||this.clicked)&&(e.showMoreButtonVisible&&(this.renderedWithShowMore=!0),this.answerContainer.innerHTML=b.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 Ts{dataLayer;config;containerId;currentSelectValue="";locationInput;radiusInput;locationDecode;locationDecodeCoordinatesToAddress;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.locationDecode=e.config.hooks?.locationDecode,this.locationDecodeCoordinatesToAddress=e.config.hooks?.locationDecodeCoordinatesToAddress,this.dataLayer.locationEnabled&&this.dataLayer.$inputTemplateRendered.subscribeUntil(()=>{this.renderMainTemplate(),this.attachSubscriptions()},!0,500)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||m.location.mainTemplate.template,s={...this.dataLayer.parsedData.data};if(this.dataLayer.setLocationWidgetTemplateData(s),this.dataLayer.renderingEngine===j.mustache){const a=b.render(t,s);e.innerHTML=a;const r=this.config.templates?.mainTemplate?.locationInputId||m.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||m.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||m.location.mainTemplate.currentLocationActionButtonId,g=document?.querySelector(`#${h}`);g&&g.addEventListener("click",this.getCurrentLocation.bind(this))}}}setCurrentLocationFields(e){this.dataLayer.setLocationCoordinatesDecoded(e),this.dataLayer.setSearchLocation(this.dataLayer.searchLocationCoordinatesDecoded),this.dataLayer.renderingEngine===j.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 $.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===j.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 Nr{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=j.mustache;constructor(e=j.mustache){e&&(this.renderEngine=e)}setRenderingEngine(e=j.mustache){this.dataLayer.setRenderingEngine(e)}handleHooks(){this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&this.dataLayer.$searchResults.subscribe(e=>{this.dataLayer.searchstaxConfig.hooks.afterSearch(e,this.dataLayer.searchResultUnparsedData)}),setTimeout(()=>{this.dataLayer.$searchObject.subscribe(e=>{e.query!==this.previousQuery&&this.dataLayer.setAnswerData(""),e.query!==""&&e.query!==void 0&&e.query!=="undefined"?(this.search(e),e.query!==this.previousQuery&&this.startSSE(e.query)):this.dataLayer.searchLocationConfig?.locationSearchEnabled&&!this.dataLayer.searchLocationConfig?.locationValuesOverride?this.getMetadata(e):this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue),this.previousQuery=e.query})},10),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&fe.trackSearch({...this.dataLayer.parsedData.trackingData,impressions:this.dataLayer.searchResultsMetadata.impressions})})}startSSE(e){this.eventSource&&(this.eventSource?.close(),this.dataLayer.setAnswerData("")),this.dataLayer.turnAIAnswerGenerationOn===!0&&this.dataLayer.questionURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&(this.eventSource=this.searchHelper?.startSSE(e,this.parseAnswerResultsResponse.bind(this)))}attachAnalyticsScript(e){fe.attachAnalyticsScript(e)}initialize(e){if(this.dataLayer=new qi("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 Zi({...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 ys(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 ys({})}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&&fe.trackRelatedSearches({...this.dataLayer.parsedData.trackingData,impressions:s,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}handleRouter(){if(this.routerEnabled){const e={...this.dataLayer.searchObject};this.dataLayer.isInfiniteScroll&&delete e.page,this.routerHelper.updateUrl(e)}}parseSearchResultsResponseMetadata(e){const t=tt.extractSearchResultsMetadata(e),s=this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue??t.location?.filter?.defaultValue;!this.dataLayer.searchRadius&&s&&this.dataLayer.setSearchRadius(s),this.dataLayer.setSearchResultsMetadata(t)}parseSearchResultsResponse(e){this.handleRouter(),this.dataLayer.setItemsPerPage(parseInt(e.responseHeader.params.rows)),this.dataLayer.setModel(e.responseHeader.params.model);let t=tt.combineResultsWithMetadata(e),s=tt.extractFacets(e);this.dataLayer.setSearchFacets(s),this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&(t=this.dataLayer.searchstaxConfig.hooks.afterSearch(t,e)),this.dataLayer.setSearchExternalPromotions(e.externalLinks??[]),this.parseSearchResultsResponseMetadata(e),this.dataLayer.setSearchResultUnparsedData(e),this.dataLayer.setSearchResults(t)}parseAnswerResultsResponse(e){this.handleRouter(),e!==je.question&&e!==je.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 Er({containerId:e,config:t,searchTrigger:this.executeSearch.bind(this),suggestTrigger:this.executeSuggest.bind(this),dataLayer:this.dataLayer})},200)}addSearchLocationWidget(e,t){this.dataLayer.searchLocationConfig||(t.locationSearchEnabled?(this.dataLayer.setLocationEnabled(!0),this.dataLayer.setSearchLocationConfig(t),t.locationValuesOverride?(this.searchLocationWidget=new Ts({containerId:e,config:t,dataLayer:this.dataLayer}),t?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(t?.locationValuesOverride?.locationFilterDefaultValue)):this.dataLayer.$searchResultsMetadata.subscribeUntilHasValue(()=>{this.searchLocationWidget=new Ts({containerId:e,config:t,dataLayer:this.dataLayer})},0)):this.dataLayer.setLocationEnabled(!1))}addAnswerWidget(e,t){this.dataLayer.turnAIAnswerGenerationOn=!0,t.testString||this.startSSE(this.dataLayer.searchObject.query),this.dataLayer.setAnswerData(t.testString??""),this.answerWidget=new Rr({containerId:e,config:t,dataLayer:this.dataLayer})}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new Dr({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 Tr({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper})}addSearchFeedbackWidget(e,t){this.searchFeedbackConfig=t,this.searchFeedbackWidget=new Ar({containerId:e,config:t,dataLayer:this.dataLayer,searchTrigger:this.executeSearch.bind(this)})}addSearchSortingWidget(e,t){this.searchSortingConfig=t,this.searchSortingWidget=new Ir({containerId:e,config:t,dataLayer:this.dataLayer})}addRelatedSearchesWidget(e,t){this.relatedSearchesConfig=t,this.relatedSearchesWidget=new vr({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 kr({containerId:e,config:t,dataLayer:this.dataLayer})}addFacetsWidget(e,t){this.searchFacetsConfig=t,this.searchFacetsWidget=new Sr({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper},this.cacheFacets.bind(this))}executeSearch(e,t){const s={...this.dataLayer.searchObject};s.query=$.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&&fe.trackRelatedSearchClick({...this.dataLayer.parsedData.trackingData,relatedSearch:e,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}executeLinkClick(e){let t=tt.findResultByUniqueId(e,this.dataLayer.searchResults??[]);t&&(this.searchResultsConfig?.hooks?.afterLinkClick&&(t=this.searchResultsConfig.hooks.afterLinkClick(t)),t&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&fe.trackClick({result:t,...this.dataLayer.parsedData.trackingData}).then(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}).catch(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}))}setPage(e){this.searchPaginationWidget?.goToPage(e)}setCookiesDisabled(e){this.dataLayer.setCookiesDisabled(e)}changeResultTemplate(e){this.searchResultsConfig&&(this.searchResultsConfig.templates=this.searchResultsConfig?.templates?{...this.searchResultsConfig?.templates,...e}:e,this.searchResultsWidget?.changeTemplate())}}export{Nr as Searchstax};
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};