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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,73 +1,73 @@
1
- (function(Na){"use strict";var F=(i=>(i[i.mustache=0]="mustache",i[i.vue=1]="vue",i[i.react=2]="react",i[i.angular=3]="angular",i))(F||{});function Ft(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ee=Ft();function Pa(i){Ee=i}var Ke={exec:()=>null};function v(i,e=""){let t=typeof i=="string"?i:i.source;const a={replace:(s,n)=>{let r=typeof n=="string"?n:n.source;return r=r.replace(te.caret,"$1"),t=t.replace(s,r),a},getRegex:()=>new RegExp(t,e)};return a}var te={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:i=>new RegExp(`^( {0,3}${i})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}#`),htmlBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}<(?:[a-z].*>|!--)`,"i")},Ys=/^(?:[ \t]*(?:\n|$))+/,Js=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Gs=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Xe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Zs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,zt=/(?:[*+-]|\d{1,9}[.)])/,Oa=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_a=v(Oa).replace(/bull/g,zt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ks=v(Oa).replace(/bull/g,zt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),$t=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Xs=/^[^\n]+/,Bt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ei=v(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Bt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ti=v(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,zt).getRegex(),Lt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Vt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ai=v("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Vt).replace("tag",Lt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Fa=v($t).replace("hr",Xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Lt).getRegex(),si=v(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Fa).getRegex(),Ht={blockquote:si,code:Js,def:ei,fences:Gs,heading:Zs,hr:Xe,html:ai,lheading:_a,list:ti,newline:Ys,paragraph:Fa,table:Ke,text:Xs},za=v("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Lt).getRegex(),ii={...Ht,lheading:Ks,table:za,paragraph:v($t).replace("hr",Xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",za).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Lt).getRegex()},ni={...Ht,html:v(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Vt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ke,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:v($t).replace("hr",Xe).replace("heading",` *#{1,6} *[^
2
- ]`).replace("lheading",_a).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ri=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,oi=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$a=/^( {2,}|\\)\n(?!\s*$)/,li=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,yt=/[\p{P}\p{S}]/u,Ut=/[\s\p{P}\p{S}]/u,Ba=/[^\s\p{P}\p{S}]/u,ci=v(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ut).getRegex(),Va=/(?!~)[\p{P}\p{S}]/u,hi=/(?!~)[\s\p{P}\p{S}]/u,ui=/(?:[^\s\p{P}\p{S}]|~)/u,di=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Ha=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,gi=v(Ha,"u").replace(/punct/g,yt).getRegex(),pi=v(Ha,"u").replace(/punct/g,Va).getRegex(),Ua="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",fi=v(Ua,"gu").replace(/notPunctSpace/g,Ba).replace(/punctSpace/g,Ut).replace(/punct/g,yt).getRegex(),mi=v(Ua,"gu").replace(/notPunctSpace/g,ui).replace(/punctSpace/g,hi).replace(/punct/g,Va).getRegex(),Li=v("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ba).replace(/punctSpace/g,Ut).replace(/punct/g,yt).getRegex(),yi=v(/\\(punct)/,"gu").replace(/punct/g,yt).getRegex(),wi=v(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ci=v(Vt).replace("(?:-->|$)","-->").getRegex(),Mi=v("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ci).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),wt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,bi=v(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",wt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Qa=v(/^!?\[(label)\]\[(ref)\]/).replace("label",wt).replace("ref",Bt).getRegex(),qa=v(/^!?\[(ref)\](?:\[\])?/).replace("ref",Bt).getRegex(),Si=v("reflink|nolink(?!\\()","g").replace("reflink",Qa).replace("nolink",qa).getRegex(),Qt={_backpedal:Ke,anyPunctuation:yi,autolink:wi,blockSkip:di,br:$a,code:oi,del:Ke,emStrongLDelim:gi,emStrongRDelimAst:fi,emStrongRDelimUnd:Li,escape:ri,link:bi,nolink:qa,punctuation:ci,reflink:Qa,reflinkSearch:Si,tag:Mi,text:li,url:Ke},Ti={...Qt,link:v(/^!?\[(label)\]\((.*?)\)/).replace("label",wt).getRegex(),reflink:v(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",wt).getRegex()},qt={...Qt,emStrongRDelimAst:mi,emStrongLDelim:pi,url:v(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},xi={...qt,br:v($a).replace("{2,}","*").getRegex(),text:v(qt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ct={normal:Ht,gfm:ii,pedantic:ni},et={normal:Qt,gfm:qt,breaks:xi,pedantic:Ti},ki={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Wa=i=>ki[i];function pe(i,e){if(e){if(te.escapeTest.test(i))return i.replace(te.escapeReplace,Wa)}else if(te.escapeTestNoEncode.test(i))return i.replace(te.escapeReplaceNoEncode,Wa);return i}function Ya(i){try{i=encodeURI(i).replace(te.percentDecode,"%")}catch{return null}return i}function Ja(i,e){const t=i.replace(te.findPipe,(n,r,o)=>{let c=!1,h=r;for(;--h>=0&&o[h]==="\\";)c=!c;return c?"|":" |"}),a=t.split(te.splitPipe);let s=0;if(a[0].trim()||a.shift(),a.length>0&&!a.at(-1)?.trim()&&a.pop(),e)if(a.length>e)a.splice(e);else for(;a.length<e;)a.push("");for(;s<a.length;s++)a[s]=a[s].trim().replace(te.slashPipe,"|");return a}function tt(i,e,t){const a=i.length;if(a===0)return"";let s=0;for(;s<a&&i.charAt(a-s-1)===e;)s++;return i.slice(0,a-s)}function Ai(i,e){if(i.indexOf(e[1])===-1)return-1;let t=0;for(let a=0;a<i.length;a++)if(i[a]==="\\")a++;else if(i[a]===e[0])t++;else if(i[a]===e[1]&&(t--,t<0))return a;return t>0?-2:-1}function Ga(i,e,t,a,s){const n=e.href,r=e.title||null,o=i[1].replace(s.other.outputLinkReplace,"$1");a.state.inLink=!0;const c={type:i[0].charAt(0)==="!"?"image":"link",raw:t,href:n,title:r,text:o,tokens:a.inlineTokens(o)};return a.state.inLink=!1,c}function Ei(i,e,t){const a=i.match(t.other.indentCodeCompensation);if(a===null)return e;const s=a[1];return e.split(`
3
- `).map(n=>{const r=n.match(t.other.beginningSpace);if(r===null)return n;const[o]=r;return o.length>=s.length?n.slice(s.length):n}).join(`
4
- `)}var Mt=class{options;rules;lexer;constructor(i){this.options=i||Ee}space(i){const e=this.rules.block.newline.exec(i);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(i){const e=this.rules.block.code.exec(i);if(e){const t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:tt(t,`
5
- `)}}}fences(i){const e=this.rules.block.fences.exec(i);if(e){const t=e[0],a=Ei(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:a}}}heading(i){const e=this.rules.block.heading.exec(i);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){const a=tt(t,"#");(this.options.pedantic||!a||this.rules.other.endingSpaceChar.test(a))&&(t=a.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(i){const e=this.rules.block.hr.exec(i);if(e)return{type:"hr",raw:tt(e[0],`
6
- `)}}blockquote(i){const e=this.rules.block.blockquote.exec(i);if(e){let t=tt(e[0],`
1
+ (function(_a){"use strict";var F=(i=>(i[i.mustache=0]="mustache",i[i.vue=1]="vue",i[i.react=2]="react",i[i.angular=3]="angular",i))(F||{});function zt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var je=zt();function Fa(i){je=i}var tt={exec:()=>null};function D(i,e=""){let t=typeof i=="string"?i:i.source;const s={replace:(a,n)=>{let r=typeof n=="string"?n:n.source;return r=r.replace(se.caret,"$1"),t=t.replace(a,r),s},getRegex:()=>new RegExp(t,e)};return s}var se={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")},ai=/^(?:[ \t]*(?:\n|$))+/,si=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ii=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,at=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ni=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,$t=/(?:[*+-]|\d{1,9}[.)])/,za=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,$a=D(za).replace(/bull/g,$t).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(),ri=D(za).replace(/bull/g,$t).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(),Vt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,oi=/^[^\n]+/,Bt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,li=D(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Bt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ci=D(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,$t).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",Ht=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,hi=D("^ {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",Ht).replace("tag",Mt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Va=D(Vt).replace("hr",at).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(),ui=D(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Va).getRegex(),Ut={blockquote:ui,code:si,def:li,fences:ii,heading:ni,hr:at,html:hi,lheading:$a,list:ci,newline:ai,paragraph:Va,table:tt,text:oi},Ba=D("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",at).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(),di={...Ut,lheading:ri,table:Ba,paragraph:D(Vt).replace("hr",at).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ba).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()},gi={...Ut,html:D(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ht).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:tt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:D(Vt).replace("hr",at).replace("heading",` *#{1,6} *[^
2
+ ]`).replace("lheading",$a).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},fi=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,pi=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ha=/^( {2,}|\\)\n(?!\s*$)/,mi=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ct=/[\p{P}\p{S}]/u,Qt=/[\s\p{P}\p{S}]/u,Ua=/[^\s\p{P}\p{S}]/u,Li=D(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Qt).getRegex(),Qa=/(?!~)[\p{P}\p{S}]/u,yi=/(?!~)[\s\p{P}\p{S}]/u,wi=/(?:[^\s\p{P}\p{S}]|~)/u,Mi=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,qa=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ci=D(qa,"u").replace(/punct/g,Ct).getRegex(),bi=D(qa,"u").replace(/punct/g,Qa).getRegex(),Wa="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Ti=D(Wa,"gu").replace(/notPunctSpace/g,Ua).replace(/punctSpace/g,Qt).replace(/punct/g,Ct).getRegex(),Si=D(Wa,"gu").replace(/notPunctSpace/g,wi).replace(/punctSpace/g,yi).replace(/punct/g,Qa).getRegex(),xi=D("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ua).replace(/punctSpace/g,Qt).replace(/punct/g,Ct).getRegex(),ki=D(/\\(punct)/,"gu").replace(/punct/g,Ct).getRegex(),Ai=D(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ei=D(Ht).replace("(?:-->|$)","-->").getRegex(),vi=D("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ei).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),bt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Ii=D(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",bt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ya=D(/^!?\[(label)\]\[(ref)\]/).replace("label",bt).replace("ref",Bt).getRegex(),Ja=D(/^!?\[(ref)\](?:\[\])?/).replace("ref",Bt).getRegex(),Di=D("reflink|nolink(?!\\()","g").replace("reflink",Ya).replace("nolink",Ja).getRegex(),qt={_backpedal:tt,anyPunctuation:ki,autolink:Ai,blockSkip:Mi,br:Ha,code:pi,del:tt,emStrongLDelim:Ci,emStrongRDelimAst:Ti,emStrongRDelimUnd:xi,escape:fi,link:Ii,nolink:Ja,punctuation:Li,reflink:Ya,reflinkSearch:Di,tag:vi,text:mi,url:tt},ji={...qt,link:D(/^!?\[(label)\]\((.*?)\)/).replace("label",bt).getRegex(),reflink:D(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",bt).getRegex()},Wt={...qt,emStrongRDelimAst:Si,emStrongLDelim:bi,url:D(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Ri={...Wt,br:D(Ha).replace("{2,}","*").getRegex(),text:D(Wt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Tt={normal:Ut,gfm:di,pedantic:gi},st={normal:qt,gfm:Wt,breaks:Ri,pedantic:ji},Ni={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ga=i=>Ni[i];function fe(i,e){if(e){if(se.escapeTest.test(i))return i.replace(se.escapeReplace,Ga)}else if(se.escapeTestNoEncode.test(i))return i.replace(se.escapeReplaceNoEncode,Ga);return i}function Ka(i){try{i=encodeURI(i).replace(se.percentDecode,"%")}catch{return null}return i}function Za(i,e){const t=i.replace(se.findPipe,(n,r,o)=>{let c=!1,h=r;for(;--h>=0&&o[h]==="\\";)c=!c;return c?"|":" |"}),s=t.split(se.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(se.slashPipe,"|");return s}function it(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 Oi(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 Xa(i,e,t,s,a){const n=e.href,r=e.title||null,o=i[1].replace(a.other.outputLinkReplace,"$1");s.state.inLink=!0;const c={type:i[0].charAt(0)==="!"?"image":"link",raw:t,href:n,title:r,text:o,tokens:s.inlineTokens(o)};return s.state.inLink=!1,c}function Pi(i,e,t){const s=i.match(t.other.indentCodeCompensation);if(s===null)return e;const a=s[1];return e.split(`
3
+ `).map(n=>{const r=n.match(t.other.beginningSpace);if(r===null)return n;const[o]=r;return o.length>=a.length?n.slice(a.length):n}).join(`
4
+ `)}var St=class{options;rules;lexer;constructor(i){this.options=i||je}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:it(t,`
5
+ `)}}}fences(i){const e=this.rules.block.fences.exec(i);if(e){const t=e[0],s=Pi(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=it(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:it(e[0],`
6
+ `)}}blockquote(i){const e=this.rules.block.blockquote.exec(i);if(e){let t=it(e[0],`
7
7
  `).split(`
8
- `),a="",s="";const n=[];for(;t.length>0;){let r=!1;const o=[];let c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))o.push(t[c]),r=!0;else if(!r)o.push(t[c]);else break;t=t.slice(c);const h=o.join(`
8
+ `),s="",a="";const n=[];for(;t.length>0;){let r=!1;const o=[];let c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))o.push(t[c]),r=!0;else if(!r)o.push(t[c]);else break;t=t.slice(c);const h=o.join(`
9
9
  `),d=h.replace(this.rules.other.blockquoteSetextReplace,`
10
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");a=a?`${a}
11
- ${h}`:h,s=s?`${s}
12
- ${d}`:d;const L=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,n,!0),this.lexer.state.top=L,t.length===0)break;const m=n.at(-1);if(m?.type==="code")break;if(m?.type==="blockquote"){const R=m,A=R.raw+`
10
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
11
+ ${h}`:h,a=a?`${a}
12
+ ${d}`:d;const y=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,n,!0),this.lexer.state.top=y,t.length===0)break;const L=n.at(-1);if(L?.type==="code")break;if(L?.type==="blockquote"){const N=L,k=N.raw+`
13
13
  `+t.join(`
14
- `),S=this.blockquote(A);n[n.length-1]=S,a=a.substring(0,a.length-R.raw.length)+S.raw,s=s.substring(0,s.length-R.text.length)+S.text;break}else if(m?.type==="list"){const R=m,A=R.raw+`
14
+ `),T=this.blockquote(k);n[n.length-1]=T,s=s.substring(0,s.length-N.raw.length)+T.raw,a=a.substring(0,a.length-N.text.length)+T.text;break}else if(L?.type==="list"){const N=L,k=N.raw+`
15
15
  `+t.join(`
16
- `),S=this.list(A);n[n.length-1]=S,a=a.substring(0,a.length-m.raw.length)+S.raw,s=s.substring(0,s.length-R.raw.length)+S.raw,t=A.substring(n.at(-1).raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:a,tokens:n,text:s}}}list(i){let e=this.rules.block.list.exec(i);if(e){let t=e[1].trim();const a=t.length>1,s={type:"list",raw:"",ordered:a,start:a?+t.slice(0,-1):"",loose:!1,items:[]};t=a?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=a?t:"[*+-]");const n=this.rules.other.listItemRegex(t);let r=!1;for(;i;){let c=!1,h="",d="";if(!(e=n.exec(i))||this.rules.block.hr.test(i))break;h=e[0],i=i.substring(h.length);let L=e[2].split(`
18
- `,1)[0].replace(this.rules.other.listReplaceTabs,j=>" ".repeat(3*j.length)),m=i.split(`
19
- `,1)[0],R=!L.trim(),A=0;if(this.options.pedantic?(A=2,d=L.trimStart()):R?A=e[1].length+1:(A=e[2].search(this.rules.other.nonSpaceChar),A=A>4?1:A,d=L.slice(A),A+=e[1].length),R&&this.rules.other.blankLine.test(m)&&(h+=m+`
20
- `,i=i.substring(m.length+1),c=!0),!c){const j=this.rules.other.nextBulletRegex(A),_=this.rules.other.hrRegex(A),le=this.rules.other.fencesBeginRegex(A),B=this.rules.other.headingBeginRegex(A),p=this.rules.other.htmlBeginRegex(A);for(;i;){const g=i.split(`
21
- `,1)[0];let C;if(m=g,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),C=m):C=m.replace(this.rules.other.tabCharGlobal," "),le.test(m)||B.test(m)||p.test(m)||j.test(m)||_.test(m))break;if(C.search(this.rules.other.nonSpaceChar)>=A||!m.trim())d+=`
22
- `+C.slice(A);else{if(R||L.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||le.test(L)||B.test(L)||_.test(L))break;d+=`
23
- `+m}!R&&!m.trim()&&(R=!0),h+=g+`
24
- `,i=i.substring(g.length+1),L=C.slice(A)}}s.loose||(r?s.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(r=!0));let S=null,$;this.options.gfm&&(S=this.rules.other.listIsTask.exec(d),S&&($=S[0]!=="[ ] ",d=d.replace(this.rules.other.listReplaceTask,""))),s.items.push({type:"list_item",raw:h,task:!!S,checked:$,loose:!1,text:d,tokens:[]}),s.raw+=h}const o=s.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let c=0;c<s.items.length;c++)if(this.lexer.state.top=!1,s.items[c].tokens=this.lexer.blockTokens(s.items[c].text,[]),!s.loose){const h=s.items[c].tokens.filter(L=>L.type==="space"),d=h.length>0&&h.some(L=>this.rules.other.anyLine.test(L.raw));s.loose=d}if(s.loose)for(let c=0;c<s.items.length;c++)s.items[c].loose=!0;return s}}html(i){const e=this.rules.block.html.exec(i);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(i){const e=this.rules.block.def.exec(i);if(e){const t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),a=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:a,title:s}}}table(i){const e=this.rules.block.table.exec(i);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const t=Ja(e[1]),a=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
- `):[],n={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===a.length){for(const r of a)this.rules.other.tableAlignRight.test(r)?n.align.push("right"):this.rules.other.tableAlignCenter.test(r)?n.align.push("center"):this.rules.other.tableAlignLeft.test(r)?n.align.push("left"):n.align.push(null);for(let r=0;r<t.length;r++)n.header.push({text:t[r],tokens:this.lexer.inline(t[r]),header:!0,align:n.align[r]});for(const r of s)n.rows.push(Ja(r,n.header.length).map((o,c)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:n.align[c]})));return n}}lheading(i){const e=this.rules.block.lheading.exec(i);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(i){const e=this.rules.block.paragraph.exec(i);if(e){const t=e[1].charAt(e[1].length-1)===`
26
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(i){const e=this.rules.block.text.exec(i);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(i){const e=this.rules.inline.escape.exec(i);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(i){const e=this.rules.inline.tag.exec(i);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(i){const e=this.rules.inline.link.exec(i);if(e){const t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;const n=tt(t.slice(0,-1),"\\");if((t.length-n.length)%2===0)return}else{const n=Ai(e[2],"()");if(n===-2)return;if(n>-1){const o=(e[0].indexOf("!")===0?5:4)+e[1].length+n;e[2]=e[2].substring(0,n),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let a=e[2],s="";if(this.options.pedantic){const n=this.rules.other.pedanticHrefTitle.exec(a);n&&(a=n[1],s=n[3])}else s=e[3]?e[3].slice(1,-1):"";return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?a=a.slice(1):a=a.slice(1,-1)),Ga(e,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(i,e){let t;if((t=this.rules.inline.reflink.exec(i))||(t=this.rules.inline.nolink.exec(i))){const a=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[a.toLowerCase()];if(!s){const n=t[0].charAt(0);return{type:"text",raw:n,text:n}}return Ga(t,s,t[0],this.lexer,this.rules)}}emStrong(i,e,t=""){let a=this.rules.inline.emStrongLDelim.exec(i);if(!a||a[3]&&t.match(this.rules.other.unicodeAlphaNumeric))return;if(!(a[1]||a[2]||"")||!t||this.rules.inline.punctuation.exec(t)){const n=[...a[0]].length-1;let r,o,c=n,h=0;const d=a[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,e=e.slice(-1*i.length+n);(a=d.exec(e))!=null;){if(r=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!r)continue;if(o=[...r].length,a[3]||a[4]){c+=o;continue}else if((a[5]||a[6])&&n%3&&!((n+o)%3)){h+=o;continue}if(c-=o,c>0)continue;o=Math.min(o,o+c+h);const L=[...a[0]][0].length,m=i.slice(0,n+a.index+L+o);if(Math.min(n,o)%2){const A=m.slice(1,-1);return{type:"em",raw:m,text:A,tokens:this.lexer.inlineTokens(A)}}const R=m.slice(2,-2);return{type:"strong",raw:m,text:R,tokens:this.lexer.inlineTokens(R)}}}}codespan(i){const e=this.rules.inline.code.exec(i);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," ");const a=this.rules.other.nonSpaceChar.test(t),s=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return a&&s&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(i){const e=this.rules.inline.br.exec(i);if(e)return{type:"br",raw:e[0]}}del(i){const e=this.rules.inline.del.exec(i);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(i){const e=this.rules.inline.autolink.exec(i);if(e){let t,a;return e[2]==="@"?(t=e[1],a="mailto:"+t):(t=e[1],a=t),{type:"link",raw:e[0],text:t,href:a,tokens:[{type:"text",raw:t,text:t}]}}}url(i){let e;if(e=this.rules.inline.url.exec(i)){let t,a;if(e[2]==="@")t=e[0],a="mailto:"+t;else{let s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==e[0]);t=e[0],e[1]==="www."?a="http://"+e[0]:a=e[0]}return{type:"link",raw:e[0],text:t,href:a,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(i){const e=this.rules.inline.text.exec(i);if(e){const t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},Me=class ja{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ee,this.options.tokenizer=this.options.tokenizer||new Mt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={other:te,block:Ct.normal,inline:et.normal};this.options.pedantic?(t.block=Ct.pedantic,t.inline=et.pedantic):this.options.gfm&&(t.block=Ct.gfm,this.options.breaks?t.inline=et.breaks:t.inline=et.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ct,inline:et}}static lex(e,t){return new ja(t).lex(e)}static lexInline(e,t){return new ja(t).inlineTokens(e)}lex(e){e=e.replace(te.carriageReturn,`
27
- `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const a=this.inlineQueue[t];this.inlineTokens(a.src,a.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],a=!1){for(this.options.pedantic&&(e=e.replace(te.tabCharGlobal," ").replace(te.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(r=>(s=r.call({lexer:this},e,t))?(e=e.substring(s.raw.length),t.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);const r=t.at(-1);s.raw.length===1&&r!==void 0?r.raw+=`
28
- `:t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);const r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=`
29
- `+s.raw,r.text+=`
30
- `+s.text,this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);const r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=`
31
- `+s.raw,r.text+=`
32
- `+s.raw,this.inlineQueue.at(-1).src=r.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),t.push(s);continue}let n=e;if(this.options.extensions?.startBlock){let r=1/0;const o=e.slice(1);let c;this.options.extensions.startBlock.forEach(h=>{c=h.call({lexer:this},o),typeof c=="number"&&c>=0&&(r=Math.min(r,c))}),r<1/0&&r>=0&&(n=e.substring(0,r+1))}if(this.state.top&&(s=this.tokenizer.paragraph(n))){const r=t.at(-1);a&&r?.type==="paragraph"?(r.raw+=`
33
- `+s.raw,r.text+=`
34
- `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s),a=n.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);const r=t.at(-1);r?.type==="text"?(r.raw+=`
35
- `+s.raw,r.text+=`
36
- `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if(e){const r="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(r);break}else throw new Error(r)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let a=e,s=null;if(this.tokens.links){const o=Object.keys(this.tokens.links);if(o.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)o.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,s.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(s=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let n=!1,r="";for(;e;){n||(r=""),n=!1;let o;if(this.options.extensions?.inline?.some(h=>(o=h.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);const h=t.at(-1);o.type==="text"&&h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,a,r)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let c=e;if(this.options.extensions?.startInline){let h=1/0;const d=e.slice(1);let L;this.options.extensions.startInline.forEach(m=>{L=m.call({lexer:this},d),typeof L=="number"&&L>=0&&(h=Math.min(h,L))}),h<1/0&&h>=0&&(c=e.substring(0,h+1))}if(o=this.tokenizer.inlineText(c)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(r=o.raw.slice(-1)),n=!0;const h=t.at(-1);h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(e){const h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return t}},bt=class{options;parser;constructor(i){this.options=i||Ee}space(i){return""}code({text:i,lang:e,escaped:t}){const a=(e||"").match(te.notSpaceStart)?.[0],s=i.replace(te.endingNewline,"")+`
37
- `;return a?'<pre><code class="language-'+pe(a)+'">'+(t?s:pe(s,!0))+`</code></pre>
38
- `:"<pre><code>"+(t?s:pe(s,!0))+`</code></pre>
16
+ `),T=this.list(k);n[n.length-1]=T,s=s.substring(0,s.length-L.raw.length)+T.raw,a=a.substring(0,a.length-N.raw.length)+T.raw,t=k.substring(n.at(-1).raw.length).split(`
17
+ `);continue}}return{type:"blockquote",raw:s,tokens:n,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 n=this.rules.other.listItemRegex(t);let r=!1;for(;i;){let c=!1,h="",d="";if(!(e=n.exec(i))||this.rules.block.hr.test(i))break;h=e[0],i=i.substring(h.length);let y=e[2].split(`
18
+ `,1)[0].replace(this.rules.other.listReplaceTabs,R=>" ".repeat(3*R.length)),L=i.split(`
19
+ `,1)[0],N=!y.trim(),k=0;if(this.options.pedantic?(k=2,d=y.trimStart()):N?k=e[1].length+1:(k=e[2].search(this.rules.other.nonSpaceChar),k=k>4?1:k,d=y.slice(k),k+=e[1].length),N&&this.rules.other.blankLine.test(L)&&(h+=L+`
20
+ `,i=i.substring(L.length+1),c=!0),!c){const R=this.rules.other.nextBulletRegex(k),H=this.rules.other.hrRegex(k),le=this.rules.other.fencesBeginRegex(k),_=this.rules.other.headingBeginRegex(k),m=this.rules.other.htmlBeginRegex(k);for(;i;){const g=i.split(`
21
+ `,1)[0];let C;if(L=g,this.options.pedantic?(L=L.replace(this.rules.other.listReplaceNesting," "),C=L):C=L.replace(this.rules.other.tabCharGlobal," "),le.test(L)||_.test(L)||m.test(L)||R.test(L)||H.test(L))break;if(C.search(this.rules.other.nonSpaceChar)>=k||!L.trim())d+=`
22
+ `+C.slice(k);else{if(N||y.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||le.test(y)||_.test(y)||H.test(y))break;d+=`
23
+ `+L}!N&&!L.trim()&&(N=!0),h+=g+`
24
+ `,i=i.substring(g.length+1),y=C.slice(k)}}a.loose||(r?a.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(r=!0));let T=null,P;this.options.gfm&&(T=this.rules.other.listIsTask.exec(d),T&&(P=T[0]!=="[ ] ",d=d.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:h,task:!!T,checked:P,loose:!1,text:d,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 c=0;c<a.items.length;c++)if(this.lexer.state.top=!1,a.items[c].tokens=this.lexer.blockTokens(a.items[c].text,[]),!a.loose){const h=a.items[c].tokens.filter(y=>y.type==="space"),d=h.length>0&&h.some(y=>this.rules.other.anyLine.test(y.raw));a.loose=d}if(a.loose)for(let c=0;c<a.items.length;c++)a.items[c].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=Za(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
+ `):[],n={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===s.length){for(const r of s)this.rules.other.tableAlignRight.test(r)?n.align.push("right"):this.rules.other.tableAlignCenter.test(r)?n.align.push("center"):this.rules.other.tableAlignLeft.test(r)?n.align.push("left"):n.align.push(null);for(let r=0;r<t.length;r++)n.header.push({text:t[r],tokens:this.lexer.inline(t[r]),header:!0,align:n.align[r]});for(const r of a)n.rows.push(Za(r,n.header.length).map((o,c)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:n.align[c]})));return n}}lheading(i){const e=this.rules.block.lheading.exec(i);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(i){const e=this.rules.block.paragraph.exec(i);if(e){const t=e[1].charAt(e[1].length-1)===`
26
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(i){const e=this.rules.block.text.exec(i);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(i){const e=this.rules.inline.escape.exec(i);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(i){const e=this.rules.inline.tag.exec(i);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(i){const e=this.rules.inline.link.exec(i);if(e){const t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;const n=it(t.slice(0,-1),"\\");if((t.length-n.length)%2===0)return}else{const n=Oi(e[2],"()");if(n===-2)return;if(n>-1){const o=(e[0].indexOf("!")===0?5:4)+e[1].length+n;e[2]=e[2].substring(0,n),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let s=e[2],a="";if(this.options.pedantic){const n=this.rules.other.pedanticHrefTitle.exec(s);n&&(s=n[1],a=n[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)),Xa(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 n=t[0].charAt(0);return{type:"text",raw:n,text:n}}return Xa(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))return;if(!(s[1]||s[2]||"")||!t||this.rules.inline.punctuation.exec(t)){const n=[...s[0]].length-1;let r,o,c=n,h=0;const d=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,e=e.slice(-1*i.length+n);(s=d.exec(e))!=null;){if(r=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!r)continue;if(o=[...r].length,s[3]||s[4]){c+=o;continue}else if((s[5]||s[6])&&n%3&&!((n+o)%3)){h+=o;continue}if(c-=o,c>0)continue;o=Math.min(o,o+c+h);const y=[...s[0]][0].length,L=i.slice(0,n+s.index+y+o);if(Math.min(n,o)%2){const k=L.slice(1,-1);return{type:"em",raw:L,text:k,tokens:this.lexer.inlineTokens(k)}}const N=L.slice(2,-2);return{type:"strong",raw:L,text:N,tokens:this.lexer.inlineTokens(N)}}}}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 Oa{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||je,this.options.tokenizer=this.options.tokenizer||new St,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:se,block:Tt.normal,inline:st.normal};this.options.pedantic?(t.block=Tt.pedantic,t.inline=st.pedantic):this.options.gfm&&(t.block=Tt.gfm,this.options.breaks?t.inline=st.breaks:t.inline=st.gfm),this.tokenizer.rules=t}static get rules(){return{block:Tt,inline:st}}static lex(e,t){return new Oa(t).lex(e)}static lexInline(e,t){return new Oa(t).inlineTokens(e)}lex(e){e=e.replace(se.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(se.tabCharGlobal," ").replace(se.spaceLine,""));e;){let a;if(this.options.extensions?.block?.some(r=>(a=r.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 r=t.at(-1);a.raw.length===1&&r!==void 0?r.raw+=`
28
+ `:t.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);const r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=`
29
+ `+a.raw,r.text+=`
30
+ `+a.text,this.inlineQueue.at(-1).src=r.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 r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=`
31
+ `+a.raw,r.text+=`
32
+ `+a.raw,this.inlineQueue.at(-1).src=r.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title});continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),t.push(a);continue}let n=e;if(this.options.extensions?.startBlock){let r=1/0;const o=e.slice(1);let c;this.options.extensions.startBlock.forEach(h=>{c=h.call({lexer:this},o),typeof c=="number"&&c>=0&&(r=Math.min(r,c))}),r<1/0&&r>=0&&(n=e.substring(0,r+1))}if(this.state.top&&(a=this.tokenizer.paragraph(n))){const r=t.at(-1);s&&r?.type==="paragraph"?(r.raw+=`
33
+ `+a.raw,r.text+=`
34
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(a),s=n.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);const r=t.at(-1);r?.type==="text"?(r.raw+=`
35
+ `+a.raw,r.text+=`
36
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(a);continue}if(e){const r="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(r);break}else throw new Error(r)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let 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 n=!1,r="";for(;e;){n||(r=""),n=!1;let o;if(this.options.extensions?.inline?.some(h=>(o=h.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);const h=t.at(-1);o.type==="text"&&h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,s,r)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let c=e;if(this.options.extensions?.startInline){let h=1/0;const d=e.slice(1);let y;this.options.extensions.startInline.forEach(L=>{y=L.call({lexer:this},d),typeof y=="number"&&y>=0&&(h=Math.min(h,y))}),h<1/0&&h>=0&&(c=e.substring(0,h+1))}if(o=this.tokenizer.inlineText(c)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(r=o.raw.slice(-1)),n=!0;const h=t.at(-1);h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(e){const h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return t}},xt=class{options;parser;constructor(i){this.options=i||je}space(i){return""}code({text:i,lang:e,escaped:t}){const s=(e||"").match(se.notSpaceStart)?.[0],a=i.replace(se.endingNewline,"")+`
37
+ `;return s?'<pre><code class="language-'+fe(s)+'">'+(t?a:fe(a,!0))+`</code></pre>
38
+ `:"<pre><code>"+(t?a:fe(a,!0))+`</code></pre>
39
39
  `}blockquote({tokens:i}){return`<blockquote>
40
40
  ${this.parser.parse(i)}</blockquote>
41
41
  `}html({text:i}){return i}heading({tokens:i,depth:e}){return`<h${e}>${this.parser.parseInline(i)}</h${e}>
42
42
  `}hr(i){return`<hr>
43
- `}list(i){const e=i.ordered,t=i.start;let a="";for(let r=0;r<i.items.length;r++){const o=i.items[r];a+=this.listitem(o)}const s=e?"ol":"ul",n=e&&t!==1?' start="'+t+'"':"";return"<"+s+n+`>
44
- `+a+"</"+s+`>
45
- `}listitem(i){let e="";if(i.task){const t=this.checkbox({checked:!!i.checked});i.loose?i.tokens[0]?.type==="paragraph"?(i.tokens[0].text=t+" "+i.tokens[0].text,i.tokens[0].tokens&&i.tokens[0].tokens.length>0&&i.tokens[0].tokens[0].type==="text"&&(i.tokens[0].tokens[0].text=t+" "+pe(i.tokens[0].tokens[0].text),i.tokens[0].tokens[0].escaped=!0)):i.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:!0}):e+=t+" "}return e+=this.parser.parse(i.tokens,!!i.loose),`<li>${e}</li>
43
+ `}list(i){const e=i.ordered,t=i.start;let s="";for(let r=0;r<i.items.length;r++){const o=i.items[r];s+=this.listitem(o)}const a=e?"ol":"ul",n=e&&t!==1?' start="'+t+'"':"";return"<"+a+n+`>
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+" "+fe(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
- `}table(i){let e="",t="";for(let s=0;s<i.header.length;s++)t+=this.tablecell(i.header[s]);e+=this.tablerow({text:t});let a="";for(let s=0;s<i.rows.length;s++){const n=i.rows[s];t="";for(let r=0;r<n.length;r++)t+=this.tablecell(n[r]);a+=this.tablerow({text:t})}return a&&(a=`<tbody>${a}</tbody>`),`<table>
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 n=i.rows[a];t="";for(let r=0;r<n.length;r++)t+=this.tablecell(n[r]);s+=this.tablerow({text:t})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
48
48
  <thead>
49
49
  `+e+`</thead>
50
- `+a+`</table>
50
+ `+s+`</table>
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>${pe(i,!0)}</code>`}br(i){return"<br>"}del({tokens:i}){return`<del>${this.parser.parseInline(i)}</del>`}link({href:i,title:e,tokens:t}){const a=this.parser.parseInline(t),s=Ya(i);if(s===null)return a;i=s;let n='<a href="'+i+'"';return e&&(n+=' title="'+pe(e)+'"'),n+=">"+a+"</a>",n}image({href:i,title:e,text:t,tokens:a}){a&&(t=this.parser.parseInline(a,this.parser.textRenderer));const s=Ya(i);if(s===null)return pe(t);i=s;let n=`<img src="${i}" alt="${t}"`;return e&&(n+=` title="${pe(e)}"`),n+=">",n}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:pe(i.text)}},Wt=class{strong({text:i}){return i}em({text:i}){return i}codespan({text:i}){return i}del({text:i}){return i}html({text:i}){return i}text({text:i}){return i}link({text:i}){return""+i}image({text:i}){return""+i}br(){return""}},be=class Ra{options;renderer;textRenderer;constructor(e){this.options=e||Ee,this.options.renderer=this.options.renderer||new bt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Wt}static parse(e,t){return new Ra(t).parse(e)}static parseInline(e,t){return new Ra(t).parseInline(e)}parse(e,t=!0){let a="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions?.renderers?.[n.type]){const o=n,c=this.options.extensions.renderers[o.type].call({parser:this},o);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){a+=c||"";continue}}const r=n;switch(r.type){case"space":{a+=this.renderer.space(r);continue}case"hr":{a+=this.renderer.hr(r);continue}case"heading":{a+=this.renderer.heading(r);continue}case"code":{a+=this.renderer.code(r);continue}case"table":{a+=this.renderer.table(r);continue}case"blockquote":{a+=this.renderer.blockquote(r);continue}case"list":{a+=this.renderer.list(r);continue}case"html":{a+=this.renderer.html(r);continue}case"paragraph":{a+=this.renderer.paragraph(r);continue}case"text":{let o=r,c=this.renderer.text(o);for(;s+1<e.length&&e[s+1].type==="text";)o=e[++s],c+=`
55
- `+this.renderer.text(o);t?a+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c,escaped:!0}]}):a+=c;continue}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return a}parseInline(e,t=this.renderer){let a="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions?.renderers?.[n.type]){const o=this.options.extensions.renderers[n.type].call({parser:this},n);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type)){a+=o||"";continue}}const r=n;switch(r.type){case"escape":{a+=t.text(r);break}case"html":{a+=t.html(r);break}case"link":{a+=t.link(r);break}case"image":{a+=t.image(r);break}case"strong":{a+=t.strong(r);break}case"em":{a+=t.em(r);break}case"codespan":{a+=t.codespan(r);break}case"br":{a+=t.br(r);break}case"del":{a+=t.del(r);break}case"text":{a+=t.text(r);break}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return a}},St=class{options;block;constructor(i){this.options=i||Ee}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(i){return i}postprocess(i){return i}processAllTokens(i){return i}provideLexer(){return this.block?Me.lex:Me.lexInline}provideParser(){return this.block?be.parse:be.parseInline}},vi=class{defaults=Ft();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=be;Renderer=bt;TextRenderer=Wt;Lexer=Me;Tokenizer=Mt;Hooks=St;constructor(...i){this.use(...i)}walkTokens(i,e){let t=[];for(const a of i)switch(t=t.concat(e.call(this,a)),a.type){case"table":{const s=a;for(const n of s.header)t=t.concat(this.walkTokens(n.tokens,e));for(const n of s.rows)for(const r of n)t=t.concat(this.walkTokens(r.tokens,e));break}case"list":{const s=a;t=t.concat(this.walkTokens(s.items,e));break}default:{const s=a;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(n=>{const r=s[n].flat(1/0);t=t.concat(this.walkTokens(r,e))}):s.tokens&&(t=t.concat(this.walkTokens(s.tokens,e)))}}return t}use(...i){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return i.forEach(t=>{const a={...t};if(a.async=this.defaults.async||a.async||!1,t.extensions&&(t.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){const n=e.renderers[s.name];n?e.renderers[s.name]=function(...r){let o=s.renderer.apply(this,r);return o===!1&&(o=n.apply(this,r)),o}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const n=e[s.level];n?n.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),a.extensions=e),t.renderer){const s=this.defaults.renderer||new bt(this.defaults);for(const n in t.renderer){if(!(n in s))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;const r=n,o=t.renderer[r],c=s[r];s[r]=(...h)=>{let d=o.apply(s,h);return d===!1&&(d=c.apply(s,h)),d||""}}a.renderer=s}if(t.tokenizer){const s=this.defaults.tokenizer||new Mt(this.defaults);for(const n in t.tokenizer){if(!(n in s))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const r=n,o=t.tokenizer[r],c=s[r];s[r]=(...h)=>{let d=o.apply(s,h);return d===!1&&(d=c.apply(s,h)),d}}a.tokenizer=s}if(t.hooks){const s=this.defaults.hooks||new St;for(const n in t.hooks){if(!(n in s))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;const r=n,o=t.hooks[r],c=s[r];St.passThroughHooks.has(n)?s[r]=h=>{if(this.defaults.async)return Promise.resolve(o.call(s,h)).then(L=>c.call(s,L));const d=o.call(s,h);return c.call(s,d)}:s[r]=(...h)=>{let d=o.apply(s,h);return d===!1&&(d=c.apply(s,h)),d}}a.hooks=s}if(t.walkTokens){const s=this.defaults.walkTokens,n=t.walkTokens;a.walkTokens=function(r){let o=[];return o.push(n.call(this,r)),s&&(o=o.concat(s.call(this,r))),o}}this.defaults={...this.defaults,...a}}),this}setOptions(i){return this.defaults={...this.defaults,...i},this}lexer(i,e){return Me.lex(i,e??this.defaults)}parser(i,e){return be.parse(i,e??this.defaults)}parseMarkdown(i){return(t,a)=>{const s={...a},n={...this.defaults,...s},r=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&s.async===!1)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return r(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));n.hooks&&(n.hooks.options=n,n.hooks.block=i);const o=n.hooks?n.hooks.provideLexer():i?Me.lex:Me.lexInline,c=n.hooks?n.hooks.provideParser():i?be.parse:be.parseInline;if(n.async)return Promise.resolve(n.hooks?n.hooks.preprocess(t):t).then(h=>o(h,n)).then(h=>n.hooks?n.hooks.processAllTokens(h):h).then(h=>n.walkTokens?Promise.all(this.walkTokens(h,n.walkTokens)).then(()=>h):h).then(h=>c(h,n)).then(h=>n.hooks?n.hooks.postprocess(h):h).catch(r);try{n.hooks&&(t=n.hooks.preprocess(t));let h=o(t,n);n.hooks&&(h=n.hooks.processAllTokens(h)),n.walkTokens&&this.walkTokens(h,n.walkTokens);let d=c(h,n);return n.hooks&&(d=n.hooks.postprocess(d)),d}catch(h){return r(h)}}}onError(i,e){return t=>{if(t.message+=`
56
- Please report this to https://github.com/markedjs/marked.`,i){const a="<p>An error occurred:</p><pre>"+pe(t.message+"",!0)+"</pre>";return e?Promise.resolve(a):a}if(e)return Promise.reject(t);throw t}}},ve=new vi;function I(i,e){return ve.parse(i,e)}I.options=I.setOptions=function(i){return ve.setOptions(i),I.defaults=ve.defaults,Pa(I.defaults),I},I.getDefaults=Ft,I.defaults=Ee,I.use=function(...i){return ve.use(...i),I.defaults=ve.defaults,Pa(I.defaults),I},I.walkTokens=function(i,e){return ve.walkTokens(i,e)},I.parseInline=ve.parseInline,I.Parser=be,I.parser=be.parse,I.Renderer=bt,I.TextRenderer=Wt,I.Lexer=Me,I.lexer=Me.lex,I.Tokenizer=Mt,I.Hooks=St,I.parse=I,I.options,I.setOptions,I.use,I.walkTokens,I.parseInline,be.parse,Me.lex;function Za(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,a=Array(e);t<e;t++)a[t]=i[t];return a}function Ii(i){if(Array.isArray(i))return i}function Di(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var a,s,n,r,o=[],c=!0,h=!1;try{if(n=(t=t.call(i)).next,e!==0)for(;!(c=(a=n.call(t)).done)&&(o.push(a.value),o.length!==e);c=!0);}catch(d){h=!0,s=d}finally{try{if(!c&&t.return!=null&&(r=t.return(),Object(r)!==r))return}finally{if(h)throw s}}return o}}function ji(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
57
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ri(i,e){return Ii(i)||Di(i,e)||Ni(i,e)||ji()}function Ni(i,e){if(i){if(typeof i=="string")return Za(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Za(i,e):void 0}}const Ka=Object.entries,Xa=Object.setPrototypeOf,Pi=Object.isFrozen,Oi=Object.getPrototypeOf,_i=Object.getOwnPropertyDescriptor;let ae=Object.freeze,re=Object.seal,Pe=Object.create,es=typeof Reflect<"u"&&Reflect,Yt=es.apply,Jt=es.construct;ae||(ae=function(e){return e}),re||(re=function(e){return e}),Yt||(Yt=function(e,t){for(var a=arguments.length,s=new Array(a>2?a-2:0),n=2;n<a;n++)s[n-2]=arguments[n];return e.apply(t,s)}),Jt||(Jt=function(e){for(var t=arguments.length,a=new Array(t>1?t-1:0),s=1;s<t;s++)a[s-1]=arguments[s];return new e(...a)});const Oe=q(Array.prototype.forEach),Fi=q(Array.prototype.lastIndexOf),ts=q(Array.prototype.pop),_e=q(Array.prototype.push),zi=q(Array.prototype.splice),se=Array.isArray,at=q(String.prototype.toLowerCase),Gt=q(String.prototype.toString),as=q(String.prototype.match),Fe=q(String.prototype.replace),ss=q(String.prototype.indexOf),$i=q(String.prototype.trim),Bi=q(Number.prototype.toString),Vi=q(Boolean.prototype.toString),is=typeof BigInt>"u"?null:q(BigInt.prototype.toString),ns=typeof Symbol>"u"?null:q(Symbol.prototype.toString),z=q(Object.prototype.hasOwnProperty),st=q(Object.prototype.toString),X=q(RegExp.prototype.test),it=Hi(TypeError);function q(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,a=new Array(t>1?t-1:0),s=1;s<t;s++)a[s-1]=arguments[s];return Yt(i,e,a)}}function Hi(i){return function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return Jt(i,t)}}function b(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:at;if(Xa&&Xa(i,null),!se(e))return i;let a=e.length;for(;a--;){let s=e[a];if(typeof s=="string"){const n=t(s);n!==s&&(Pi(e)||(e[a]=n),s=n)}i[s]=!0}return i}function Ui(i){for(let e=0;e<i.length;e++)z(i,e)||(i[e]=null);return i}function ee(i){const e=Pe(null);for(const a of Ka(i)){var t=Ri(a,2);const s=t[0],n=t[1];z(i,s)&&(se(n)?e[s]=Ui(n):n&&typeof n=="object"&&n.constructor===Object?e[s]=ee(n):e[s]=n)}return e}function Qi(i){switch(typeof i){case"string":return i;case"number":return Bi(i);case"boolean":return Vi(i);case"bigint":return is?is(i):"0";case"symbol":return ns?ns(i):"Symbol()";case"undefined":return st(i);case"function":case"object":{if(i===null)return st(i);const e=i,t=fe(e,"toString");if(typeof t=="function"){const a=t(e);return typeof a=="string"?a:st(a)}return st(i)}default:return st(i)}}function fe(i,e){for(;i!==null;){const a=_i(i,e);if(a){if(a.get)return q(a.get);if(typeof a.value=="function")return q(a.value)}i=Oi(i)}function t(){return null}return t}function qi(i){try{return X(i,""),!0}catch{return!1}}const rs=ae(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Zt=ae(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Kt=ae(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Wi=ae(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Xt=ae(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Yi=ae(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),os=ae(["#text"]),ls=ae(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ea=ae(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),cs=ae(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Tt=ae(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ji=re(/{{[\w\W]*|^[\w\W]*}}/g),Gi=re(/<%[\w\W]*|^[\w\W]*%>/g),Zi=re(/\${[\w\W]*/g),Ki=re(/^data-[\-\w.\u00B7-\uFFFF]+$/),Xi=re(/^aria-[\-\w]+$/),hs=re(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),en=re(/^(?:\w+script|data):/i),tn=re(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),an=re(/^html$/i),sn=re(/^[a-z][.\w]*(-[.\w]+)+$/i),me={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},nn=function(){return typeof window>"u"?null:window},rn=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let a=null;const s="data-tt-policy-suffix";t&&t.hasAttribute(s)&&(a=t.getAttribute(s));const n="dompurify"+(a?"#"+a:"");try{return e.createPolicy(n,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+n+" could not be created."),null}},us=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ds(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:nn();const e=y=>ds(y);if(e.version="3.4.7",e.removed=[],!i||!i.document||i.document.nodeType!==me.document||!i.Element)return e.isSupported=!1,e;let t=i.document;const a=t,s=a.currentScript;i.DocumentFragment;const n=i.HTMLTemplateElement,r=i.Node,o=i.Element,c=i.NodeFilter,h=i.NamedNodeMap;h===void 0&&(i.NamedNodeMap||i.MozNamedAttrMap),i.HTMLFormElement;const d=i.DOMParser,L=i.trustedTypes,m=o.prototype,R=fe(m,"cloneNode"),A=fe(m,"remove"),S=fe(m,"nextSibling"),$=fe(m,"childNodes"),j=fe(m,"parentNode"),_=fe(m,"shadowRoot"),le=fe(m,"attributes"),B=r&&r.prototype?fe(r.prototype,"nodeType"):null,p=r&&r.prototype?fe(r.prototype,"nodeName"):null;if(typeof n=="function"){const y=t.createElement("template");y.content&&y.content.ownerDocument&&(t=y.content.ownerDocument)}let g,C="";const E=t,V=E.implementation,ue=E.createNodeIterator,fa=E.createDocumentFragment,ma=E.getElementsByTagName,La=a.importNode;let N=us();e.isSupported=typeof Ka=="function"&&typeof j=="function"&&V&&V.createHTMLDocument!==void 0;const je=Ji,Et=Gi,vt=Zi,Kn=Ki,Xn=Xi,er=en,xs=tn,tr=sn;let ks=hs,H=null;const ya=b({},[...rs,...Zt,...Kt,...Xt,...os]);let W=null;const wa=b({},[...ls,...ea,...cs,...Tt]);let U=Object.seal(Pe(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),dt=null,It=null;const ke=Object.seal(Pe(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let As=!0,Ca=!0,Es=!1,vs=!0,Ae=!1,gt=!0,Re=!1,Ma=!1,ba=!1,We=!1,Dt=!1,jt=!1,Is=!0,Ds=!1;const js="user-content-";let Sa=!0,pt=!1,Ye={},ye=null;const Ta=b({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Rs=null;const Ns=b({},["audio","video","img","source","image","track"]);let xa=null;const Ps=b({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Rt="http://www.w3.org/1998/Math/MathML",Nt="http://www.w3.org/2000/svg",we="http://www.w3.org/1999/xhtml";let Je=we,ka=!1,Aa=null;const ar=b({},[Rt,Nt,we],Gt);let Ea=b({},["mi","mo","mn","ms","mtext"]),va=b({},["annotation-xml"]);const sr=b({},["title","style","font","a","script"]);let ft=null;const ir=["application/xhtml+xml","text/html"],nr="text/html";let Q=null,Ge=null;const rr=t.createElement("form"),Os=function(l){return l instanceof RegExp||l instanceof Function},Ia=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ge&&Ge===l)return;(!l||typeof l!="object")&&(l={}),l=ee(l),ft=ir.indexOf(l.PARSER_MEDIA_TYPE)===-1?nr:l.PARSER_MEDIA_TYPE,Q=ft==="application/xhtml+xml"?Gt:at,H=z(l,"ALLOWED_TAGS")&&se(l.ALLOWED_TAGS)?b({},l.ALLOWED_TAGS,Q):ya,W=z(l,"ALLOWED_ATTR")&&se(l.ALLOWED_ATTR)?b({},l.ALLOWED_ATTR,Q):wa,Aa=z(l,"ALLOWED_NAMESPACES")&&se(l.ALLOWED_NAMESPACES)?b({},l.ALLOWED_NAMESPACES,Gt):ar,xa=z(l,"ADD_URI_SAFE_ATTR")&&se(l.ADD_URI_SAFE_ATTR)?b(ee(Ps),l.ADD_URI_SAFE_ATTR,Q):Ps,Rs=z(l,"ADD_DATA_URI_TAGS")&&se(l.ADD_DATA_URI_TAGS)?b(ee(Ns),l.ADD_DATA_URI_TAGS,Q):Ns,ye=z(l,"FORBID_CONTENTS")&&se(l.FORBID_CONTENTS)?b({},l.FORBID_CONTENTS,Q):Ta,dt=z(l,"FORBID_TAGS")&&se(l.FORBID_TAGS)?b({},l.FORBID_TAGS,Q):ee({}),It=z(l,"FORBID_ATTR")&&se(l.FORBID_ATTR)?b({},l.FORBID_ATTR,Q):ee({}),Ye=z(l,"USE_PROFILES")?l.USE_PROFILES&&typeof l.USE_PROFILES=="object"?ee(l.USE_PROFILES):l.USE_PROFILES:!1,As=l.ALLOW_ARIA_ATTR!==!1,Ca=l.ALLOW_DATA_ATTR!==!1,Es=l.ALLOW_UNKNOWN_PROTOCOLS||!1,vs=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ae=l.SAFE_FOR_TEMPLATES||!1,gt=l.SAFE_FOR_XML!==!1,Re=l.WHOLE_DOCUMENT||!1,We=l.RETURN_DOM||!1,Dt=l.RETURN_DOM_FRAGMENT||!1,jt=l.RETURN_TRUSTED_TYPE||!1,ba=l.FORCE_BODY||!1,Is=l.SANITIZE_DOM!==!1,Ds=l.SANITIZE_NAMED_PROPS||!1,Sa=l.KEEP_CONTENT!==!1,pt=l.IN_PLACE||!1,ks=qi(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:hs,Je=typeof l.NAMESPACE=="string"?l.NAMESPACE:we,Ea=z(l,"MATHML_TEXT_INTEGRATION_POINTS")&&l.MATHML_TEXT_INTEGRATION_POINTS&&typeof l.MATHML_TEXT_INTEGRATION_POINTS=="object"?ee(l.MATHML_TEXT_INTEGRATION_POINTS):b({},["mi","mo","mn","ms","mtext"]),va=z(l,"HTML_INTEGRATION_POINTS")&&l.HTML_INTEGRATION_POINTS&&typeof l.HTML_INTEGRATION_POINTS=="object"?ee(l.HTML_INTEGRATION_POINTS):b({},["annotation-xml"]);const u=z(l,"CUSTOM_ELEMENT_HANDLING")&&l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING=="object"?ee(l.CUSTOM_ELEMENT_HANDLING):Pe(null);if(U=Pe(null),z(u,"tagNameCheck")&&Os(u.tagNameCheck)&&(U.tagNameCheck=u.tagNameCheck),z(u,"attributeNameCheck")&&Os(u.attributeNameCheck)&&(U.attributeNameCheck=u.attributeNameCheck),z(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(U.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),Ae&&(Ca=!1),Dt&&(We=!0),Ye&&(H=b({},os),W=Pe(null),Ye.html===!0&&(b(H,rs),b(W,ls)),Ye.svg===!0&&(b(H,Zt),b(W,ea),b(W,Tt)),Ye.svgFilters===!0&&(b(H,Kt),b(W,ea),b(W,Tt)),Ye.mathMl===!0&&(b(H,Xt),b(W,cs),b(W,Tt))),ke.tagCheck=null,ke.attributeCheck=null,z(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?ke.tagCheck=l.ADD_TAGS:se(l.ADD_TAGS)&&(H===ya&&(H=ee(H)),b(H,l.ADD_TAGS,Q))),z(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?ke.attributeCheck=l.ADD_ATTR:se(l.ADD_ATTR)&&(W===wa&&(W=ee(W)),b(W,l.ADD_ATTR,Q))),z(l,"ADD_URI_SAFE_ATTR")&&se(l.ADD_URI_SAFE_ATTR)&&b(xa,l.ADD_URI_SAFE_ATTR,Q),z(l,"FORBID_CONTENTS")&&se(l.FORBID_CONTENTS)&&(ye===Ta&&(ye=ee(ye)),b(ye,l.FORBID_CONTENTS,Q)),z(l,"ADD_FORBID_CONTENTS")&&se(l.ADD_FORBID_CONTENTS)&&(ye===Ta&&(ye=ee(ye)),b(ye,l.ADD_FORBID_CONTENTS,Q)),Sa&&(H["#text"]=!0),Re&&b(H,["html","head","body"]),H.table&&(b(H,["tbody"]),delete dt.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw it('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw it('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');g=l.TRUSTED_TYPES_POLICY,C=g.createHTML("")}else g===void 0&&(g=rn(L,s)),g!==null&&typeof C=="string"&&(C=g.createHTML(""));(N.uponSanitizeElement.length>0||N.uponSanitizeAttribute.length>0)&&H===ya&&(H=ee(H)),N.uponSanitizeAttribute.length>0&&W===wa&&(W=ee(W)),ae&&ae(l),Ge=l},_s=b({},[...Zt,...Kt,...Wi]),Fs=b({},[...Xt,...Yi]),or=function(l){let u=j(l);(!u||!u.tagName)&&(u={namespaceURI:Je,tagName:"template"});const f=at(l.tagName),D=at(u.tagName);return Aa[l.namespaceURI]?l.namespaceURI===Nt?u.namespaceURI===we?f==="svg":u.namespaceURI===Rt?f==="svg"&&(D==="annotation-xml"||Ea[D]):!!_s[f]:l.namespaceURI===Rt?u.namespaceURI===we?f==="math":u.namespaceURI===Nt?f==="math"&&va[D]:!!Fs[f]:l.namespaceURI===we?u.namespaceURI===Nt&&!va[D]||u.namespaceURI===Rt&&!Ea[D]?!1:!Fs[f]&&(sr[f]||!_s[f]):!!(ft==="application/xhtml+xml"&&Aa[l.namespaceURI]):!1},de=function(l){_e(e.removed,{element:l});try{j(l).removeChild(l)}catch{A(l)}},Ne=function(l,u){try{_e(e.removed,{attribute:u.getAttributeNode(l),from:u})}catch{_e(e.removed,{attribute:null,from:u})}if(u.removeAttribute(l),l==="is")if(We||Dt)try{de(u)}catch{}else try{u.setAttribute(l,"")}catch{}},zs=function(l){let u=null,f=null;if(ba)l="<remove></remove>"+l;else{const P=as(l,/^[\r\n\t ]+/);f=P&&P[0]}ft==="application/xhtml+xml"&&Je===we&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");const D=g?g.createHTML(l):l;if(Je===we)try{u=new d().parseFromString(D,ft)}catch{}if(!u||!u.documentElement){u=V.createDocument(Je,"template",null);try{u.documentElement.innerHTML=ka?C:D}catch{}}const x=u.body||u.documentElement;return l&&f&&x.insertBefore(t.createTextNode(f),x.childNodes[0]||null),Je===we?ma.call(u,Re?"html":"body")[0]:Re?u.documentElement:x},$s=function(l){return ue.call(l.ownerDocument||l,l,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Bs=function(l){l.normalize();const u=ue.call(l.ownerDocument||l,l,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let f=u.nextNode();for(;f;){let D=f.data;Oe([je,Et,vt],x=>{D=Fe(D,x," ")}),f.data=D,f=u.nextNode()}},Pt=function(l){const u=p?p(l):null;return typeof u!="string"||Q(u)!=="form"?!1:typeof l.nodeName!="string"||typeof l.textContent!="string"||typeof l.removeChild!="function"||l.attributes!==le(l)||typeof l.removeAttribute!="function"||typeof l.setAttribute!="function"||typeof l.namespaceURI!="string"||typeof l.insertBefore!="function"||typeof l.hasChildNodes!="function"||l.nodeType!==B(l)||l.childNodes!==$(l)},mt=function(l){if(!B||typeof l!="object"||l===null)return!1;try{return B(l)===me.documentFragment}catch{return!1}},Ot=function(l){if(!B||typeof l!="object"||l===null)return!1;try{return typeof B(l)=="number"}catch{return!1}};function Te(y,l,u){Oe(y,f=>{f.call(e,l,u,Ge)})}const Vs=function(l){let u=null;if(Te(N.beforeSanitizeElements,l,null),Pt(l))return de(l),!0;const f=Q(l.nodeName);if(Te(N.uponSanitizeElement,l,{tagName:f,allowedTags:H}),gt&&l.hasChildNodes()&&!Ot(l.firstElementChild)&&X(/<[/\w!]/g,l.innerHTML)&&X(/<[/\w!]/g,l.textContent)||gt&&l.namespaceURI===we&&f==="style"&&Ot(l.firstElementChild)||l.nodeType===me.progressingInstruction||gt&&l.nodeType===me.comment&&X(/<[/\w]/g,l.data))return de(l),!0;if(dt[f]||!(ke.tagCheck instanceof Function&&ke.tagCheck(f))&&!H[f]){if(!dt[f]&&Us(f)&&(U.tagNameCheck instanceof RegExp&&X(U.tagNameCheck,f)||U.tagNameCheck instanceof Function&&U.tagNameCheck(f)))return!1;if(Sa&&!ye[f]){const x=j(l),P=$(l);if(P&&x){const ce=P.length;for(let Ce=ce-1;Ce>=0;--Ce){const ge=R(P[Ce],!0);x.insertBefore(ge,S(l))}}}return de(l),!0}return(B?B(l):l.nodeType)===me.element&&!or(l)||(f==="noscript"||f==="noembed"||f==="noframes")&&X(/<\/no(script|embed|frames)/i,l.innerHTML)?(de(l),!0):(Ae&&l.nodeType===me.text&&(u=l.textContent,Oe([je,Et,vt],x=>{u=Fe(u,x," ")}),l.textContent!==u&&(_e(e.removed,{element:l.cloneNode()}),l.textContent=u)),Te(N.afterSanitizeElements,l,null),!1)},Hs=function(l,u,f){if(It[u]||Is&&(u==="id"||u==="name")&&(f in t||f in rr))return!1;const D=W[u]||ke.attributeCheck instanceof Function&&ke.attributeCheck(u,l);if(!(Ca&&!It[u]&&X(Kn,u))){if(!(As&&X(Xn,u))){if(!D||It[u]){if(!(Us(l)&&(U.tagNameCheck instanceof RegExp&&X(U.tagNameCheck,l)||U.tagNameCheck instanceof Function&&U.tagNameCheck(l))&&(U.attributeNameCheck instanceof RegExp&&X(U.attributeNameCheck,u)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(u,l))||u==="is"&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&X(U.tagNameCheck,f)||U.tagNameCheck instanceof Function&&U.tagNameCheck(f))))return!1}else if(!xa[u]){if(!X(ks,Fe(f,xs,""))){if(!((u==="src"||u==="xlink:href"||u==="href")&&l!=="script"&&ss(f,"data:")===0&&Rs[l])){if(!(Es&&!X(er,Fe(f,xs,"")))){if(f)return!1}}}}}}return!0},lr=b({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Us=function(l){return!lr[at(l)]&&X(tr,l)},Qs=function(l){Te(N.beforeSanitizeAttributes,l,null);const u=l.attributes;if(!u||Pt(l))return;const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0};let D=u.length;for(;D--;){const x=u[D],P=x.name,ce=x.namespaceURI,Ce=x.value,ge=Q(P),Da=Ce;let K=P==="value"?Da:$i(Da);if(f.attrName=ge,f.attrValue=K,f.keepAttr=!0,f.forceKeepAttr=void 0,Te(N.uponSanitizeAttribute,l,f),K=f.attrValue,Ds&&(ge==="id"||ge==="name")&&ss(K,js)!==0&&(Ne(P,l),K=js+K),gt&&X(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,K)){Ne(P,l);continue}if(ge==="attributename"&&as(K,"href")){Ne(P,l);continue}if(f.forceKeepAttr)continue;if(!f.keepAttr){Ne(P,l);continue}if(!vs&&X(/\/>/i,K)){Ne(P,l);continue}Ae&&Oe([je,Et,vt],Ws=>{K=Fe(K,Ws," ")});const qs=Q(l.nodeName);if(!Hs(qs,ge,K)){Ne(P,l);continue}if(g&&typeof L=="object"&&typeof L.getAttributeType=="function"&&!ce)switch(L.getAttributeType(qs,ge)){case"TrustedHTML":{K=g.createHTML(K);break}case"TrustedScriptURL":{K=g.createScriptURL(K);break}}if(K!==Da)try{ce?l.setAttributeNS(ce,P,K):l.setAttribute(P,K),Pt(l)?de(l):ts(e.removed)}catch{Ne(P,l)}}Te(N.afterSanitizeAttributes,l,null)},_t=function(l){let u=null;const f=$s(l);for(Te(N.beforeSanitizeShadowDOM,l,null);u=f.nextNode();)if(Te(N.uponSanitizeShadowNode,u,null),Vs(u),Qs(u),mt(u.content)&&_t(u.content),(B?B(u):u.nodeType)===me.element){const x=_?_(u):u.shadowRoot;mt(x)&&(Ze(x),_t(x))}Te(N.afterSanitizeShadowDOM,l,null)},Ze=function(l){const u=B?B(l):l.nodeType;if(u===me.element){const x=_?_(l):l.shadowRoot;mt(x)&&(Ze(x),_t(x))}const f=$?$(l):l.childNodes;if(!f)return;const D=[];Oe(f,x=>{_e(D,x)});for(const x of D)Ze(x);if(u===me.element){const x=p?p(l):null;if(typeof x=="string"&&Q(x)==="template"){const P=l.content;mt(P)&&Ze(P)}}};return e.sanitize=function(y){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,f=null,D=null,x=null;if(ka=!y,ka&&(y="<!-->"),typeof y!="string"&&!Ot(y)&&(y=Qi(y),typeof y!="string"))throw it("dirty is not a string, aborting");if(!e.isSupported)return y;if(Ma||Ia(l),e.removed=[],typeof y=="string"&&(pt=!1),pt){const Ce=p?p(y):y.nodeName;if(typeof Ce=="string"){const ge=Q(Ce);if(!H[ge]||dt[ge])throw it("root node is forbidden and cannot be sanitized in-place")}if(Pt(y))throw it("root node is clobbered and cannot be sanitized in-place");Ze(y)}else if(Ot(y))u=zs("<!---->"),f=u.ownerDocument.importNode(y,!0),f.nodeType===me.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?u=f:u.appendChild(f),Ze(f);else{if(!We&&!Ae&&!Re&&y.indexOf("<")===-1)return g&&jt?g.createHTML(y):y;if(u=zs(y),!u)return We?null:jt?C:""}u&&ba&&de(u.firstChild);const P=$s(pt?y:u);for(;D=P.nextNode();)Vs(D),Qs(D),mt(D.content)&&_t(D.content);if(pt)return Ae&&Bs(y),y;if(We){if(Ae&&Bs(u),Dt)for(x=fa.call(u.ownerDocument);u.firstChild;)x.appendChild(u.firstChild);else x=u;return(W.shadowroot||W.shadowrootmode)&&(x=La.call(a,x,!0)),x}let ce=Re?u.outerHTML:u.innerHTML;return Re&&H["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&X(an,u.ownerDocument.doctype.name)&&(ce="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
58
- `+ce),Ae&&Oe([je,Et,vt],Ce=>{ce=Fe(ce,Ce," ")}),g&&jt?g.createHTML(ce):ce},e.setConfig=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ia(y),Ma=!0},e.clearConfig=function(){Ge=null,Ma=!1},e.isValidAttribute=function(y,l,u){Ge||Ia({});const f=Q(y),D=Q(l);return Hs(f,D,u)},e.addHook=function(y,l){typeof l=="function"&&_e(N[y],l)},e.removeHook=function(y,l){if(l!==void 0){const u=Fi(N[y],l);return u===-1?void 0:zi(N[y],u,1)[0]}return ts(N[y])},e.removeHooks=function(y){N[y]=[]},e.removeAllHooks=function(){N=us()},e}var gs=ds();class on{dataLayer;constructor(e){this.dataLayer=e}get answerWidgetShowMoreLimit(){return this.dataLayer.answerWidgetShowMoreLimit??100}get currentPage(){return this.dataLayer.searchObject?.page}get totalPages(){return this.resultsPerPage===0?0:Math.ceil(this.totalResults/this.resultsPerPage)}get totalResults(){return this.dataLayer.searchResultsMetadata?.totalResultsValue||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){return this.dataLayer.searchResultsMetadata?.sorting.options||[]}get selectedSortOption(){return this.dataLayer.searchResultsMetadata?.sorting.selectedSortOption||""}get startResultIndex(){return(this.dataLayer.searchObject?.page-1)*this.resultsPerPage+1}get endResultIndex(){const e=(this.dataLayer.searchObject?.page-1)*this.resultsPerPage+(this.resultsPerPage??0);return e>this.totalResults?this.totalResults:e}get isFirstPage(){return this.dataLayer.searchObject?.page===1}get isLastPage(){return this.dataLayer.searchObject?.page>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){return this.dataLayer.searchResultsMetadata?.autoCorrectedQuery||""}get originalQuery(){return this.dataLayer.searchObject?.query||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswerLoadMore(){return this.dataLayer.getAnswerData.split(" ").length>this.answerWidgetShowMoreLimit}get answerTruncated(){return this.dataLayer.getAnswerData.split(" ").slice(0,this.answerWidgetShowMoreLimit).join(" ")+"..."}get fullAnswerFormatted(){return gs.sanitize(I.parse(this.dataLayer.getAnswerData)).replace(/<a /g,'<a target="_blank" class="searchstax-answer-link" rel="noopener noreferrer" ')}get answerLoading(){return this.dataLayer.answerLoading}get shouldShowAnswerError(){return this.dataLayer.answerError}get locationError(){return this.dataLayer.locationError}get shouldShowAnswer(){return(this.dataLayer.getAnswerData!==""||this.dataLayer.parsedData.answerLoading||this.shouldShowAnswerError)&&this.dataLayer.searchObject.query!=="*"}get searchTerm(){return this.dataLayer.searchResultsMetadata?.autoCorrectedQuery||this.dataLayer.searchObject?.query||""}get locationSearchEnabled(){return this.dataLayer.locationEnabled??!1}get locationSearchDistanceEnabled(){return(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationDistanceEnabled?this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationDistanceEnabled:this.dataLayer.searchResultsMetadata?.location?.filter?.enabled)??!1}get locationSearchDistanceValues(){const e=this.dataLayer.searchLocationConfig?.locationValuesOverride?.filterValues??this.dataLayer.searchResultsMetadata?.location?.filter?.values,t=this.dataLayer.searchLocationConfig?.locationValuesOverride?.filterUnit??this.dataLayer.searchResultsMetadata?.location?.unit;return!e||e.length===0?[]:e.map(s=>({label:s==="any"?"Any Distance":s+" "+(t??""),value:s,isSelected:s===this.dataLayer.searchRadius})).sort((s,n)=>{const r=s.value==="any"?0:parseFloat(s.value),o=n.value==="any"?0:parseFloat(n.value);return r-o})}get shouldShowLocationDistanceDropdown(){return this.locationSearchDistanceEnabled&&this.locationSearchDistanceValues.length>1}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get answerErrorMessage(){return gs.sanitize(I.parse(this.dataLayer.answerErrorMessage)).replace("<br>","")}get searchExecuted(){return this.dataLayer.searchObject?.query!==void 0&&this.dataLayer.searchObject?.query!=="undefined"&&this.dataLayer.searchObject?.query!==""}get selectedFacets(){const e=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return e?(this.dataLayer.searchObject?.facets??[]).map(s=>{const n=s.name,r=s.value,o=e.find(c=>c.name===n);if(o){const c=o.values.find(h=>h.type==="range"?!1:h.type==="checkbox"?'"'+h.value+'"'===r:!1);if(c)return c}return null}).filter(s=>s!==null):[]}get cachedANDFacets(){let e="";for(const t of this.dataLayer.searchObject.facets)(t.type==="and"||t.type==="tabs")&&(e+=JSON.stringify(t));return e}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalPages:this.totalPages,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,selectedFacets:this.selectedFacets,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,answerTruncated:this.answerTruncated,fullAnswerFormatted:this.fullAnswerFormatted,shouldShowAnswerLoadMore:this.shouldShowAnswerLoadMore,answerLoading:this.answerLoading,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption,shouldShowAnswerError:this.shouldShowAnswerError,answerErrorMessage:this.answerErrorMessage,locationSearchEnabled:this.locationSearchEnabled,locationSearchDistanceEnabled:this.locationSearchDistanceEnabled,locationSearchDistanceValues:this.locationSearchDistanceValues,shouldShowLocationDistanceDropdown:this.shouldShowLocationDistanceDropdown,locationError:this.locationError}}get trackingData(){return{searchTerm:this.searchTerm,trackApiKey:this.dataLayer.searchstaxConfig?.trackApiKey??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:this.dataLayer.searchResultsMetadata?.recordsPerPageValue??0,totalResults:this.dataLayer.searchResultsMetadata?.totalResultsValue??0,currentPage:this.dataLayer.currentPage,latencyVal:this.dataLayer.searchResultsMetadata?.latency??0,...this.dataLayer.model?{model:this.dataLayer.model}:{}}}}class oe{static deepEqual(e,t){const a=Object.keys(e),s=Object.keys(t);if(a.length!==s.length)return!1;for(const n of a){const r=e[n],o=t[n],c=this.isObject(r)&&this.isObject(o);if(c&&!this.deepEqual(r,o)||!c&&r!==o)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class M{value;observers={};constructor(e){this.value=e,this.observers={}}subscribe(e,t){const a=Math.random().toString(36).substring(2,15),s=t||a;return this.observers[s]=e,e(this.value),s}unsubscribe(e){this.observers[e]&&delete this.observers[e]}subscribeOnce(e){const t=Math.random().toString(36).substring(2,15),a=s=>{e(s),this.unsubscribe(t)};this.subscribe(a,t)}subscribeTwice(e){const t=Math.random().toString(36).substring(2,15);let a=0;const s=n=>{a++,e(n),a>=2&&this.unsubscribe(t)};this.subscribe(s,t)}subscribeUntil(e,t,a=6e3,s=!0){const n=Math.random().toString(36).substring(2,15),r=o=>{o===t&&(e(o),this.unsubscribe(n))};return this.value===t?(e(this.value),null):(this.subscribe(r,n),setTimeout(()=>{s&&this.observers[n]&&e(this.value),this.unsubscribe(n)},a),n)}subscribeUntilHasValue(e,t=6e3,a=!0){const s=Math.random().toString(36).substring(2,15),n=r=>{r!=null&&(e(r),this.unsubscribe(s))};return this.value!==null&&this.value!==void 0?(e(this.value),null):(this.subscribe(n,s),t>0&&setTimeout(()=>{a&&this.observers[s]&&e(this.value),this.unsubscribe(s)},t),n)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){for(const e in this.observers)if(Object.prototype.hasOwnProperty.call(this.observers,e)){const t=this.observers[e];typeof t=="function"&&t(this.value)}}}class ta{static getOrSetCookie(e,t){let a=this.getCookie(e);return a==null&&(a=t??this.makeid(25),this.setCookie(e,a,{secure:!0,"max-age":3600})),a}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=a.length;for(let n=0;n<e;n++)t+=a.charAt(Math.floor(Math.random()*s));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,a){const s={path:"/",...a};a.expires instanceof Date&&(s.expires=a.expires.toUTCString());let n=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const r in s){n+="; "+r;const o=s[r];o!==!0&&(n+="="+o)}typeof document<"u"&&(document.cookie=n)}}class G{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",a=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(a,""):""}}class ln{$searchTermChange=new M("");$searchLocationChange=new M("");$searchLocationCoordinatesDecoded=new M("");$searchLatChange=new M("");$searchLongChange=new M("");$searchRadiusChange=new M(void 0);$loadingChange=new M(!1);$locationError=new M(!1);$searchResults=new M(null);$searchResultsMetadata=new M(null);$searchAutosuggest=new M(null);$searchFacets=new M(null);$searchFacetsCached=new M(null);$searchFacetsCachedTabs=new M(null);$searchstaxConfig=new M(null);$autosuggestResults=new M(null);$itemsPerPage=new M(void 0);$searchObject=new M({query:"",itemsPerPage:void 0,page:99999999,order:"",facets:[],additionalProps:[],location:{term:void 0,radius:void 0,lat:void 0,lon:void 0},model:""});$searchRelatedSearches=new M(null);$searchInputConfig=new M(null);$searchLocationConfig=new M(null);$searchExternalPromotions=new M(null);$facetsTemplateData=new M(null);$selectedFacetsTemplateData=new M(null);$paginationData=new M(null);$answerData=new M(null);$searchFeedbackData=new M(null);$inputWidgetTemplateData=new M(null);$locationWidgetTemplateData=new M(null);$searchSortingData=new M(null);$searchRelatedSearchesData=new M(null);$searchExternalPromotionsData=new M(null);$cookiesDisabled=new M(null);$locationDecodingLoading=new M(!1);$answer=new M("");$language=new M("en");$model=new M("");$answerLoading=new M(!1);$locationEnabled=new M(null);$answerError=new M(!1);$answerErrorMessage=new M("");$isQuestion=new M(!1);$inputTemplateRendered=new M(!1);currentPageValue=1;isAnswerWidgetCreatedValue=!1;renderingEngineValue=F.mustache;parsedData=new on(this);sessionId;sessionIdValue=null;autoCorrect=!0;forceNotCorrect=!1;lastSearchValue="";turnAIAnswerGenerationOn=!1;questionURL="";isInfiniteScroll=!1;firstSearchHappened=!1;facetsWereSet=!1;answerWidgetShowMoreLimit=100;searchHelper;searchResultUnparsed;constructor(e,t){this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,ta.deleteCookie(this.sessionId),ta.deleteCookie("ms_visitorid")):this.sessionIdValue=ta.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(G.removeXSSRiskyTags(e))}setSearchLocation(e){this.$searchLocationChange.setValue(G.removeXSSRiskyTags(e))}setSearchRadius(e){this.$searchRadiusChange.setValue(e)}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setIsAnswerWidgetCreated(e){this.isAnswerWidgetCreatedValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){this.firstSearchHappened=!0,(!oe.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){oe.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){let t=e;t={...t,itemsPerPage:this.itemsPerPage,model:this.model},this.searchstaxConfig?.hooks?.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!oe.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&(this.searchObject.itemsPerPage!==t.itemsPerPage&&t.itemsPerPage!==void 0&&this.setItemsPerPage(t.itemsPerPage),this.$searchObject.setValue(t))}setSearchFacets(e){this.facetsWereSet=!0,oe.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){oe.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchFacetsCachedTabs(e){oe.deepEqual(e,this.searchFacetsCachedTabs??[])||this.$searchFacetsCachedTabs.setValue(e)}setSearchRelatedSearches(e){oe.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){oe.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setModel(e){this.$model.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setSearchLocationConfig(e){this.$searchLocationConfig.setValue(e)}setAutosuggestResults(e){this.$autosuggestResults.setValue(e)}setFacetsTemplateData(e){this.$facetsTemplateData.setValue(e)}setSelectedFacetsTemplateData(e){this.$selectedFacetsTemplateData.setValue(e)}setPaginationData(e){this.$paginationData.setValue(e)}setAnswerFullData(e){this.$answerData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}setAnswerLoading(e){this.$answerLoading.setValue(e)}setAnswerError(e){this.$answerError.setValue(e)}setIsQuestion(e){this.$isQuestion.setValue(e)}setAnswerErrorMessage(e){this.$answerErrorMessage.setValue(e)}setLocationDecodingLoading(e){this.$locationDecodingLoading.setValue(e)}setSearchLat(e){this.$searchLatChange.setValue(e)}setSearchLong(e){this.$searchLongChange.setValue(e)}setInputTemplateRendered(e){this.$inputTemplateRendered.setValue(e)}setLocationError(e){this.$locationError.setValue(e)}setInputWidgetTemplateData(e){this.$inputWidgetTemplateData.setValue(e)}setLocationWidgetTemplateData(e){this.$locationWidgetTemplateData.setValue(e)}setLocationCoordinatesDecoded(e){this.$searchLocationCoordinatesDecoded.setValue(G.removeXSSRiskyTags(e))}setLocationEnabled(e){this.$locationEnabled.setValue(e)}setSearchResultUnparsedData(e){this.searchResultUnparsed=e}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCached(){return this.$searchFacetsCached.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCached.getValue())):null}get searchFacetsCachedTabs(){return this.$searchFacetsCachedTabs.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCachedTabs.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get searchLocation(){return this.$searchLocationChange.getValue()}get searchRadius(){return this.$searchRadiusChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get model(){return this.$model.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get searchLocationConfig(){return this.$searchLocationConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}get answerFullData(){return this.$answerData.getValue()}get answerLoading(){return this.$answerLoading.getValue()}get isQuestion(){return this.$isQuestion.getValue()}get answerError(){return this.$answerError.getValue()}get answerErrorMessage(){return this.$answerErrorMessage.getValue()}get locationDecodingLoading(){return this.$locationDecodingLoading.getValue()}get searchLat(){return this.$searchLatChange.getValue()}get searchLong(){return this.$searchLongChange.getValue()}get inputTemplateRendered(){return this.$inputTemplateRendered.getValue()}get locationError(){return this.$locationError.getValue()}get inputWidgetTemplateData(){return this.$inputWidgetTemplateData.getValue()}get locationWidgetTemplateData(){return this.$locationWidgetTemplateData.getValue()}get searchLocationCoordinatesDecoded(){return this.$searchLocationCoordinatesDecoded.getValue()}get locationEnabled(){return this.$locationEnabled.getValue()}get searchResultUnparsedData(){return this.searchResultUnparsed}}class nt{static combineResultsWithMetadata(e){const t=[],a=parseInt(e.response.start+"");return e.response.docs.forEach((s,n)=>{const r=s[e.responseHeader.params.uniqueId]??"",o={custom:null,uniqueId:r,position:a+1+n,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",s,e,r):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",s,e,r):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",s,e,r):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,r):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,r,!0):null,promoted:s["[elevated]"]?s["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",s,e,r):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",s,e,r):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",s,e,r):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",s,e,r):null,distance:this.doesMapExist("distance",e)&&this.getValueByKey("distance",s,e,r)!=="Infinity"&&this.getValueByKey("distance",s,e,r)?Math.floor(this.getValueByKey("distance",s,e,r)):null,unit:e.metadata.locationSearch?.unit??"",unmappedFields:this.getUnmappedFields(s,e,r),allFields:this.getAllFields(s,e)};t.push(o)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const a of e.metadata.facets){let s={values:[]};if(s.name=a.name,s.label=a.label,a.name in e.facet_counts.facet_fields){const n=e.facet_counts.facet_fields[a.name];for(let r=0;r<n.length;r+=2){const o={};o.value=n[r],o.parentName=s.name,o.count=n[r+1],o.type="checkbox",s.values.push(o)}}s.values.length>0&&t.push(s)}return t}static extractSearchResultsMetadata(e){let t="",a={selectedSortOption:"",options:[]},s={enabled:!1,field:"",unit:"",filter:{enabled:!1,values:[],label:"",defaultValue:""}};if(e.metadata.locationSearch&&(s={enabled:e.metadata.locationSearch.enabled,field:e.metadata.locationSearch.field,unit:e.metadata.locationSearch.unit,filter:{enabled:e.metadata.locationSearch.filter?.enabled??!1,values:e.metadata.locationSearch.filter?.values??[],label:e.metadata.locationSearch.filter?.label??"",defaultValue:e.metadata.locationSearch.filter?.defaultValue??""}}),e.metadata.results.find(n=>n.result_card==="date")?.name,a.options=[],e.metadata.sorts?.length){const n=e.metadata.sorts.map(r=>({value:r.label,key:r.name+" "+r.order}));a.options=[{key:"",value:"Relevance"},...n]}return t=e?.spellcheck?.suggestions?.[1]?.suggestion?.[0]??"",typeof t!="string"&&(t=t?.word??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:t,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:a,location:s,isLocationMapped:this.doesMapExist("distance",e)}}static getImpressions(e){const t=[],a=this.combineResultsWithMetadata(e);for(const s in a){const n=a[s],r={};r.cDocId=this.getDataForAnalytics(n.uniqueId),n.title&&(r.cDocTitle=this.getDataForAnalytics(n.titleTracking)),r.position=n.position,t.push(r)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(a=>a.uniqueId===e)??null}static getUnmappedFields(e,t,a){const s=t.metadata.results.filter(r=>r.result_card==="").map(r=>r.name),n=[];for(const r of s)if(Object.keys(e).includes(r)){const o=Array.isArray(e[r])?this.getHighlightedResults(r,e[r].join(", "),a,t):this.getHighlightedResults(r,e[r]+"",a,t);n.push({key:r,value:o,isImage:this.checkIfImage(e[r])})}return n}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const a=t.metadata.results.map(n=>n.name),s=[];for(const n of Object.keys(e))a.indexOf(n)!==-1&&s.push({key:n,value:e[n],isImage:this.checkIfImage(e[n])});return s}static doesMapExist(e,t){return t.metadata.results.find(a=>a.result_card===e)!==void 0}static getValueByKey(e,t,a,s,n=!1){const r=a.metadata.results.find(c=>c.result_card===e);if(r===void 0)return null;const o=t[r.name];return o===void 0?null:typeof o=="string"?n?o:this.getHighlightedResults(r.name,o,s,a):typeof o=="number"?o:Array.isArray(o)?n?o.join(", "):this.getHighlightedResults(r.name,o.join(", "),s,a):null}static getHighlightedResults(e,t,a,s){if(s.highlighting&&a in s.highlighting){let n=s.highlighting[a];if(n&&e in n){let r=n[e];const o=this.cleanValue(r);if(o!=="")return o}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class ps{routeName="searchstax";ignoredKeys=[];queryStringHelper;titleParser;constructor(e){e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new cn(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let a=typeof document<"u"?document?.title:"";this.titleParser&&(a=this.titleParser(e)),typeof document<"u"&&(document.title=a),window?.location.href!==t&&window?.history.replaceState(window.history.state,a,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window?.location.href??"")?window?.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):window?.location.href+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},a=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=a+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.itemsPerPage&&e.itemsPerPage!==10&&(t[this.routeName+"[itemsPerPage]"]=e.itemsPerPage+""),e.location)for(const s in e.location){const n=e.location[s];n&&(t[this.routeName+`[location][${s}]`]=n)}if(e.facets)for(const s in e.facets){const n=e.facets[s].type+":"+encodeURIComponent(e.facets[s].name)+":"+encodeURIComponent(e.facets[s].value);t[this.routeName+`[facets][${s}]`]=n}if(e.model&&(t[this.routeName+"[model]"]=e.model),this.queryStringHelper.urlHasQueryParams(window?.location.href??"")){const s=this.queryStringHelper.urlToParams(window?.location.href??"");for(const n in s)n.startsWith(this.routeName)&&delete s[n];return{...s,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const a in e)a.startsWith(this.routeName)||(t[a]=e[a]);return t}extractArrayOfFacetsFromQueryParameters(e){const t=[];for(const a in e)if(a.startsWith(this.routeName+"[facets]")){const s=G.removeXSSRiskyTags(e[a].split(":")?.[0]),n=G.removeXSSRiskyTags(decodeURIComponent(e[a].split(":")?.[1])),r=G.removeXSSRiskyTags(decodeURIComponent(e[a].split(":")?.[2]));t.push({type:s,name:n,value:r})}return t}urlToSearchObject(e,t){const a=this.queryStringHelper.urlToParams(e),s=G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[page]"])),n=parseInt(s),r=isNaN(n)?1:n;let o=parseInt(G.removeXSSRiskyTags(a[this.routeName+"[itemsPerPage]"]));return isNaN(o)&&(o=10),{query:G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[query]"]))||"",page:r,itemsPerPage:t??o,order:G.removeXSSRiskyTags(a[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(a)||[],model:G.removeXSSRiskyTags(a[this.routeName+"[model]"])||"",location:{address:G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[location][address]"]||"")),radius:G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[location][radius]"]||"")),lat:G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[location][lat]"]||"")),lon:G.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[location][lon]"]||""))}}}}class cn{routeName="";constructor(e){this.routeName=e}stringify=(e,t)=>{const a=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(a).map(s=>{const n=a[s];return Array.isArray(n)?n.map(r=>`${s}=${r}`).join("&"):`${s}=${n}`}).join("&")};filterOutIgnoredKeys(e,t){const a=t||[],s={};return Object.keys(e).forEach(n=>{a.includes(n)||e[n]!==""&&(s[n]=e[n])}),s}urlToParams(e){const t={},a=e.split("?")[1];return a&&a.split("&").forEach(s=>{const[n,r]=s.split("=");t[n]=r}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const ze={question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class aa extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const fs=10,hn=13,Ie=32;function sa(i){}function un(i){if(typeof i=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=sa,onError:t=sa,onRetry:a=sa,onComment:s,maxBufferSize:n}=i,r=[];let o=0,c=!0,h,d="",L=0,m,R=!1;function A(p){if(R)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,p.charCodeAt(0)===239&&p.charCodeAt(1)===187&&p.charCodeAt(2)===191&&(p=p.slice(3))),r.length===0){const E=$(p);E!==""&&(r.push(E),o=E.length),S();return}if(p.indexOf(`
59
- `)===-1&&p.indexOf("\r")===-1){r.push(p),o+=p.length,S();return}r.push(p);const g=r.join("");r.length=0,o=0;const C=$(g);C!==""&&(r.push(C),o=C.length),S()}function S(){n!==void 0&&(o+d.length<=n||(R=!0,r.length=0,o=0,h=void 0,d="",L=0,m=void 0,t(new aa(`Buffered data exceeded max buffer size of ${n} characters`,{type:"max-buffer-size-exceeded"}))))}function $(p){let g=0;if(p.indexOf("\r")===-1){let C=p.indexOf(`
60
- `,g);for(;C!==-1;){if(g===C){L>0&&e({id:h,event:m,data:d}),h=void 0,d="",L=0,m=void 0,g=C+1,C=p.indexOf(`
61
- `,g);continue}const E=p.charCodeAt(g);if(ms(p,g,E)){const V=p.charCodeAt(g+5)===Ie?g+6:g+5,ue=p.slice(V,C);if(L===0&&p.charCodeAt(C+1)===fs){e({id:h,event:m,data:ue}),h=void 0,d="",m=void 0,g=C+2,C=p.indexOf(`
62
- `,g);continue}d=L===0?ue:`${d}
63
- ${ue}`,L++}else Ls(p,g,E)?m=p.slice(p.charCodeAt(g+6)===Ie?g+7:g+6,C)||void 0:j(p,g,C);g=C+1,C=p.indexOf(`
64
- `,g)}return p.slice(g)}for(;g<p.length;){const C=p.indexOf("\r",g),E=p.indexOf(`
65
- `,g);let V=-1;if(C!==-1&&E!==-1?V=C<E?C:E:C!==-1?C===p.length-1?V=-1:V=C:E!==-1&&(V=E),V===-1)break;j(p,g,V),g=V+1,p.charCodeAt(g-1)===hn&&p.charCodeAt(g)===fs&&g++}return p.slice(g)}function j(p,g,C){if(g===C){le();return}const E=p.charCodeAt(g);if(ms(p,g,E)){const N=p.charCodeAt(g+5)===Ie?g+6:g+5,je=p.slice(N,C);d=L===0?je:`${d}
66
- ${je}`,L++;return}if(Ls(p,g,E)){m=p.slice(p.charCodeAt(g+6)===Ie?g+7:g+6,C)||void 0;return}if(E===105&&p.charCodeAt(g+1)===100&&p.charCodeAt(g+2)===58){const N=p.slice(p.charCodeAt(g+3)===Ie?g+4:g+3,C);h=N.includes("\0")?void 0:N;return}if(E===58){if(s){const N=p.slice(g,C);s(N.slice(p.charCodeAt(g+1)===Ie?2:1))}return}const V=p.slice(g,C),ue=V.indexOf(":");if(ue===-1){_(V,"",V);return}const fa=V.slice(0,ue),ma=V.charCodeAt(ue+1)===Ie?2:1,La=V.slice(ue+ma);_(fa,La,V)}function _(p,g,C){switch(p){case"event":m=g||void 0;break;case"data":d=L===0?g:`${d}
67
- ${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.test(g)?a(parseInt(g,10)):t(new aa(`Invalid \`retry\` value: "${g}"`,{type:"invalid-retry",value:g,line:C}));break;default:t(new aa(`Unknown field "${p.length>20?`${p.slice(0,20)}…`:p}"`,{type:"unknown-field",field:p,value:g,line:C}));break}}function le(){L>0&&e({id:h,event:m,data:d}),h=void 0,d="",L=0,m=void 0}function B(p={}){if(p.consume&&r.length>0){const g=r.join("");j(g,0,g.length)}c=!0,h=void 0,d="",L=0,m=void 0,r.length=0,o=0,R=!1}return{feed:A,reset:B}}function ms(i,e,t){return t===100&&i.charCodeAt(e+1)===97&&i.charCodeAt(e+2)===116&&i.charCodeAt(e+3)===97&&i.charCodeAt(e+4)===58}function Ls(i,e,t){return t===101&&i.charCodeAt(e+1)===118&&i.charCodeAt(e+2)===101&&i.charCodeAt(e+3)===110&&i.charCodeAt(e+4)===116&&i.charCodeAt(e+5)===58}class ys extends Event{constructor(e,t){var a,s;super(e),this.code=(a=t?.code)!=null?a:void 0,this.message=(s=t?.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,t,a){return a(ws(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(ws(this),t)}}function dn(i){const e=globalThis.DOMException;return typeof e=="function"?new e(i,"SyntaxError"):new SyntaxError(i)}function ia(i){return i instanceof Error?"errors"in i&&Array.isArray(i.errors)?i.errors.map(ia).join(", "):"cause"in i&&i.cause instanceof Error?`${i}: ${ia(i.cause)}`:i.message:`${i}`}function ws(i){return{type:i.type,message:i.message,code:i.code,defaultPrevented:i.defaultPrevented,cancelable:i.cancelable,timeStamp:i.timeStamp}}var Cs=i=>{throw TypeError(i)},na=(i,e,t)=>e.has(i)||Cs("Cannot "+t),T=(i,e,t)=>(na(i,e,"read from private field"),t?t.call(i):e.get(i)),Y=(i,e,t)=>e.has(i)?Cs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),O=(i,e,t,a)=>(na(i,e,"write to private field"),e.set(i,t),t),Se=(i,e,t)=>(na(i,e,"access private method"),t),ne,De,$e,xt,kt,rt,Be,ot,xe,Ve,He,Ue,lt,he,ra,oa,la,Ms,ca,ha,ct,ua,da;class At extends EventTarget{constructor(e,t){var a,s;super(),Y(this,he),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Y(this,ne),Y(this,De),Y(this,$e),Y(this,xt),Y(this,kt),Y(this,rt),Y(this,Be),Y(this,ot,null),Y(this,xe),Y(this,Ve),Y(this,He,null),Y(this,Ue,null),Y(this,lt,null),Y(this,oa,async n=>{var r;T(this,Ve).reset();const{body:o,redirected:c,status:h,headers:d}=n;if(h===204){Se(this,he,ct).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?O(this,$e,new URL(n.url)):O(this,$e,void 0),h!==200){Se(this,he,ct).call(this,`Non-200 status code (${h})`,h);return}if(!(d.get("content-type")||"").startsWith("text/event-stream")){Se(this,he,ct).call(this,'Invalid content type, expected "text/event-stream"',h);return}if(T(this,ne)===this.CLOSED)return;O(this,ne,this.OPEN);const L=new Event("open");if((r=T(this,lt))==null||r.call(this,L),this.dispatchEvent(L),typeof o!="object"||!o||!("getReader"in o)){Se(this,he,ct).call(this,"Invalid response body, expected a web ReadableStream",h),this.close();return}const m=new TextDecoder,R=o.getReader();let A=!0;do{const{done:S,value:$}=await R.read();$&&T(this,Ve).feed(m.decode($,{stream:!S})),S&&(A=!1,T(this,Ve).reset(),Se(this,he,ua).call(this))}while(A)}),Y(this,la,n=>{O(this,xe,void 0),!(n.name==="AbortError"||n.type==="aborted")&&Se(this,he,ua).call(this,ia(n))}),Y(this,ca,n=>{typeof n.id=="string"&&O(this,ot,n.id);const r=new MessageEvent(n.event||"message",{data:n.data,origin:T(this,$e)?T(this,$e).origin:T(this,De).origin,lastEventId:n.id||""});T(this,Ue)&&(!n.event||n.event==="message")&&T(this,Ue).call(this,r),this.dispatchEvent(r)}),Y(this,ha,n=>{O(this,rt,n)}),Y(this,da,()=>{O(this,Be,void 0),T(this,ne)===this.CONNECTING&&Se(this,he,ra).call(this)});try{if(e instanceof URL)O(this,De,e);else if(typeof e=="string")O(this,De,new URL(e,gn()));else throw new Error("Invalid URL")}catch{throw dn("An invalid or illegal string was specified")}O(this,Ve,un({onEvent:T(this,ca),onRetry:T(this,ha)})),O(this,ne,this.CONNECTING),O(this,rt,3e3),O(this,kt,(a=t?.fetch)!=null?a:globalThis.fetch),O(this,xt,(s=t?.withCredentials)!=null?s:!1),Se(this,he,ra).call(this)}get readyState(){return T(this,ne)}get url(){return T(this,De).href}get withCredentials(){return T(this,xt)}get onerror(){return T(this,He)}set onerror(e){O(this,He,e)}get onmessage(){return T(this,Ue)}set onmessage(e){O(this,Ue,e)}get onopen(){return T(this,lt)}set onopen(e){O(this,lt,e)}addEventListener(e,t,a){const s=t;super.addEventListener(e,s,a)}removeEventListener(e,t,a){const s=t;super.removeEventListener(e,s,a)}close(){T(this,Be)&&clearTimeout(T(this,Be)),T(this,ne)!==this.CLOSED&&(T(this,xe)&&T(this,xe).abort(),O(this,ne,this.CLOSED),O(this,xe,void 0))}}ne=new WeakMap,De=new WeakMap,$e=new WeakMap,xt=new WeakMap,kt=new WeakMap,rt=new WeakMap,Be=new WeakMap,ot=new WeakMap,xe=new WeakMap,Ve=new WeakMap,He=new WeakMap,Ue=new WeakMap,lt=new WeakMap,he=new WeakSet,ra=function(){O(this,ne,this.CONNECTING),O(this,xe,new AbortController),T(this,kt)(T(this,De),Se(this,he,Ms).call(this)).then(T(this,oa)).catch(T(this,la))},oa=new WeakMap,la=new WeakMap,Ms=function(){var i;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...T(this,ot)?{"Last-Event-ID":T(this,ot)}:void 0},cache:"no-store",signal:(i=T(this,xe))==null?void 0:i.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},ca=new WeakMap,ha=new WeakMap,ct=function(i,e){var t;T(this,ne)!==this.CLOSED&&O(this,ne,this.CLOSED);const a=new ys("error",{code:e,message:i});(t=T(this,He))==null||t.call(this,a),this.dispatchEvent(a)},ua=function(i,e){var t;if(T(this,ne)===this.CLOSED)return;O(this,ne,this.CONNECTING);const a=new ys("error",{code:e,message:i});(t=T(this,He))==null||t.call(this,a),this.dispatchEvent(a),O(this,Be,setTimeout(T(this,da),T(this,rt)))},da=new WeakMap,At.CONNECTING=0,At.OPEN=1,At.CLOSED=2;function gn(){const i="document"in globalThis?globalThis.document:void 0;return i&&typeof i=="object"&&"baseURI"in i&&typeof i.baseURI=="string"?i.baseURI:void 0}class Le{static subscribedToClickEvent=!1;static attachAnalyticsScript(e){window._msq=window._msq||[];const a=e||"https://static.searchstax.com/studio-js/v4/js/studio-analytics.js";if(!document.querySelector(`script[src="${a}"]`)){var n=document.createElement("script");n.type="text/javascript",n.src=a;var r=document.getElementsByTagName("script")[0];r.parentNode&&r.parentNode.insertBefore(n,r)}}static msq=()=>typeof window<"u"&&window?._msq?window?._msq:[];static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language,model:e.model};return new Promise((a,s)=>{const n=["trackClick",t];t.key?this.msq().push(n,(function(r,o){JSON.stringify(r)===JSON.stringify(t)&&o?a():s()}).bind(this)):s()})}static trackAnswerLinkClick(e){const t={key:e.trackApiKey,question:e.searchTerm,session:e.session,href:e.href,language:e.language,model:e.model,answer:e.answer};return new Promise((a,s)=>{const n=["answerSourceClick",t];t.key?this.msq().push(n,(function(r,o){JSON.stringify(r)===JSON.stringify(t)&&o?a():s()}).bind(this)):s()})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,model:e.model,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches,language:e.language,model:e.model};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,latency:e.latencyVal,language:e.language,model:e.model,impressions:e.impressions,pageNo:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}static trackAnswerData(e){const t={session:e.session,key:e.trackApiKey,question:e.searchTerm,answer:e.answer,language:e.language,model:e.model,is_question:e.isQuestion+"",has_show_more:e.hasShowMore};setTimeout(()=>{t.key&&this.msq().push(["trackquestionanswer",t])},0)}static trackShowMoreClick(e){const t={session:e.session,key:e.trackApiKey,language:e.language,model:e.model,question:e.searchTerm};setTimeout(()=>{t.key&&this.msq().push(["answershowmoreclick",t])},0)}static trackFeedback(e){setTimeout(()=>{this.msq().push(["trackSearchSatisfaction",{key:e.trackApiKey,email:e.email,score:e.rating,comments:e.feedback,language:e.language,model:e.model}])},0)}}class pn{cachedQuery="";cachedANDFacets="";url="";relatedSearches="";suggester="";authHeader;authHeaderRelated;trackApiKey="";session="";searchAuthType;searchAuth="";controllerSearch;signalSearch;controllerSuggest;signalSuggest;_authToken="";resolveFn;dataLayer;constructor(e,t){this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json"),this._authToken=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`,this.authHeader.append("Authorization",this._authToken),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let a=[];if(!t)e.forEach(function(s){const n=s.name+':"'+s.value+'"';a=a.concat("fq="+decodeURIComponent(n).replace(" "," "))});else{const s={};e.forEach(function(r){const o=r.name+":"+r.value,c=decodeURIComponent(o).replace(" "," ").split(":");s[c[0]]?s[c[0]].push(c[1]):s[c[0]]=[c[1]]});let n="";for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){const o=s[r],c=r;for(const h of o)n+=n===""?` ${c}:"${h}"`:` OR ${c}:"${h}"`}a=a.concat("fq="+n.trim())}return a=a.map(s=>s.replace(/&/g,"%26").replace(/\+/g,"%2B")),a.length?"&"+a.join("&"):""}generateLocationQuery(e){let t="";if(e.lat&&e.lon){const a=Math.floor(parseFloat(e.lat)*100)/100,s=Math.floor(parseFloat(e.lon)*100)/100;t+=`&pt=${a},${s}`}return e.radius&&t!==""&&e.radius!=="any"&&(t+=`&distanceFilter=${e.radius}`),t}getRelatedSearches(e,t,a,s){const n=new Headers;n.append("Accept","application/json"),n.append("Authorization",a),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:n,credentials:"same-origin"}).then(r=>r.json()).then(r=>{s(r)})}cacheFacets(e){return new Promise(t=>{if(this.resolveFn=t,this.dataLayer.searchObject.query!==this.cachedQuery||this.cachedANDFacets+e!==this.dataLayer.parsedData.cachedANDFacets+e){this.cachedANDFacets=this.dataLayer.parsedData.cachedANDFacets+e,this.cachedQuery=this.dataLayer.searchObject.query;const a=[this.dataLayer.searchObject.facets.filter(s=>e?!1:s.type==="and"||s.type==="tabs")].flat();this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:a,additionalProps:this.dataLayer.searchObject.additionalProps,location:this.dataLayer.searchObject.location,model:this.dataLayer.model},this.cacheFacetsCallback.bind(this),!0,!1,e)}else this.resolveFn()})}cacheFacetsCallback(e,t){let a=nt.extractFacets(e);t?this.dataLayer.setSearchFacetsCachedTabs(a):this.dataLayer.setSearchFacetsCached(a),this.resolveFn&&this.resolveFn()}search(e,t,a=!1,s=!1,n=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=this.url+this.generateQueryParams(e,s),o={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};a&&delete o.signal,fetch(r,o).then(c=>c.json()).then(c=>{this.dataLayer.setLoading(!1),t(c,n)}).catch(()=>{this.dataLayer.setLoading(!1)})}}generateQueryParams(e,t){let a=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),s=e.order?`&sort=${e.order}`:"";const n=e.itemsPerPage!==void 0?`&rows=${e.itemsPerPage}`:"",r=new Proxy(new URLSearchParams(window?.location.search??""),{get:(h,d)=>h.get(d)??""}),o=r.languageVariant?"&fq=_language:"+r.languageVariant:"",c=e.model??this.dataLayer.model;return"?q="+encodeURIComponent(e.query.trim())+"&start="+a+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(h=>h.type==="or"||h.type==="showUnavailable"),!0)+this.generateLocationQuery(e.location)+this.generateFacetQuery(e.facets.filter(h=>h.type==="and"||h.type==="tabs"),!1)+s+n+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!t}`+(c?`&model=${c}`:"")+"&language="+this.dataLayer.language+o}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.searchObject.page!==1)return;const a=this.dataLayer;a.setAnswerLoading(!1),a.setAnswerErrorMessage(""),a.setAnswerError(!1);const s=new At(this.dataLayer.questionURL+this.generateQueryParams(this.dataLayer.searchObject),{fetch:(n,r)=>fetch(n,{...r,headers:{...r?.headers,Authorization:this._authToken}})});return s.onmessage=n=>{if(n.data===ze.question||n.data===ze.notQuestion){n.data===ze.question?(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setIsQuestion(!0)):(a.setAnswerLoading(!1),this.dataLayer.setIsQuestion(!1)),a.setAnswerData("");return}if(n.data===ze.close){Le.trackAnswerData({...a.parsedData.trackingData,answer:a.$answer.getValue(),isQuestion:this.dataLayer.isQuestion,hasShowMore:this.dataLayer.parsedData.shouldShowAnswerLoadMore}),a.setAnswerLoading(!1),s.close();return}if(n.data.indexOf("[!CAUTION]")!==-1){a.setAnswerError(!0),a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),s.close();return}if(n.data.indexOf("[comment]: <> ({")!==-1)try{const r=n.data.split("[comment]: <> ({");if(r.length<2){t(n.data);return}const o=r[1].split("})");if(o.length<2){t(n.data);return}const c=o[0],h=JSON.parse("{"+c+"}");this.dataLayer.answerWidgetShowMoreLimit=h.displayShowMoreAfter,h.showMoreEnabled||(this.dataLayer.answerWidgetShowMoreLimit=1e17);const d=o.slice(1).join("})");t(d)}catch{t(n.data)}else t(n.data)},s.addEventListener("error",n=>{(n.code===401||n.code===500)&&(a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),a.setAnswerError(!0))}),s.onerror=()=>{a.setAnswerLoading(!1),s.close()},s}suggest(e,t,a){if(this.controllerSuggest&&this.controllerSuggest.abort(),this.suggester.trim()==="")return;this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const s=this.suggester+"?q="+e.trim()+this.toQueryString(a)+"&language="+this.dataLayer.language;fetch(s,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(n=>n.json()).then(n=>{t(n)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const a of e)t.push(encodeURIComponent(a.key)+"="+encodeURIComponent(a.value));return"&"+t.join("&")}}var fn=Object.prototype.toString,Qe=Array.isArray||function(e){return fn.call(e)==="[object Array]"};function ga(i){return typeof i=="function"}function mn(i){return Qe(i)?"array":typeof i}function pa(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function bs(i,e){return i!=null&&typeof i=="object"&&e in i}function Ln(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var yn=RegExp.prototype.test;function wn(i,e){return yn.call(i,e)}var Cn=/\S/;function Mn(i){return!wn(Cn,i)}var bn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function Sn(i){return String(i).replace(/[&<>"'`=\/]/g,function(t){return bn[t]})}var Tn=/\s*/,xn=/\s+/,Ss=/\s*=/,kn=/\s*\}/,An=/#|\^|\/|>|\{|&|=|!/;function En(i,e){if(!i)return[];var t=!1,a=[],s=[],n=[],r=!1,o=!1,c="",h=0;function d(){if(r&&!o)for(;n.length;)delete s[n.pop()];else n=[];r=!1,o=!1}var L,m,R;function A(E){if(typeof E=="string"&&(E=E.split(xn,2)),!Qe(E)||E.length!==2)throw new Error("Invalid tags: "+E);L=new RegExp(pa(E[0])+"\\s*"),m=new RegExp("\\s*"+pa(E[1])),R=new RegExp("\\s*"+pa("}"+E[1]))}A(e||k.tags);for(var S=new ht(i),$,j,_,le,B,p;!S.eos();){if($=S.pos,_=S.scanUntil(L),_)for(var g=0,C=_.length;g<C;++g)le=_.charAt(g),Mn(le)?(n.push(s.length),c+=le):(o=!0,t=!0,c+=" "),s.push(["text",le,$,$+1]),$+=1,le===`
68
- `&&(d(),c="",h=0,t=!1);if(!S.scan(L))break;if(r=!0,j=S.scan(An)||"name",S.scan(Tn),j==="="?(_=S.scanUntil(Ss),S.scan(Ss),S.scanUntil(m)):j==="{"?(_=S.scanUntil(R),S.scan(kn),S.scanUntil(m),j="&"):_=S.scanUntil(m),!S.scan(m))throw new Error("Unclosed tag at "+S.pos);if(j==">"?B=[j,_,$,S.pos,c,h,t]:B=[j,_,$,S.pos],h++,s.push(B),j==="#"||j==="^")a.push(B);else if(j==="/"){if(p=a.pop(),!p)throw new Error('Unopened section "'+_+'" at '+$);if(p[1]!==_)throw new Error('Unclosed section "'+p[1]+'" at '+$)}else j==="name"||j==="{"||j==="&"?o=!0:j==="="&&A(_)}if(d(),p=a.pop(),p)throw new Error('Unclosed section "'+p[1]+'" at '+S.pos);return In(vn(s))}function vn(i){for(var e=[],t,a,s=0,n=i.length;s<n;++s)t=i[s],t&&(t[0]==="text"&&a&&a[0]==="text"?(a[1]+=t[1],a[3]=t[3]):(e.push(t),a=t));return e}function In(i){for(var e=[],t=e,a=[],s,n,r=0,o=i.length;r<o;++r)switch(s=i[r],s[0]){case"#":case"^":t.push(s),a.push(s),t=s[4]=[];break;case"/":n=a.pop(),n[5]=s[2],t=a.length>0?a[a.length-1][4]:e;break;default:t.push(s)}return e}function ht(i){this.string=i,this.tail=i,this.pos=0}ht.prototype.eos=function(){return this.tail===""},ht.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return"";var a=t[0];return this.tail=this.tail.substring(a.length),this.pos+=a.length,a},ht.prototype.scanUntil=function(e){var t=this.tail.search(e),a;switch(t){case-1:a=this.tail,this.tail="";break;case 0:a="";break;default:a=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=a.length,a};function qe(i,e){this.view=i,this.cache={".":this.view},this.parent=e}qe.prototype.push=function(e){return new qe(e,this)},qe.prototype.lookup=function(e){var t=this.cache,a;if(t.hasOwnProperty(e))a=t[e];else{for(var s=this,n,r,o,c=!1;s;){if(e.indexOf(".")>0)for(n=s.view,r=e.split("."),o=0;n!=null&&o<r.length;)o===r.length-1&&(c=bs(n,r[o])||Ln(n,r[o])),n=n[r[o++]];else n=s.view[e],c=bs(s.view,e);if(c){a=n;break}s=s.parent}t[e]=a}return ga(a)&&(a=a.call(this.view)),a};function ie(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}ie.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()},ie.prototype.parse=function(e,t){var a=this.templateCache,s=e+":"+(t||k.tags).join(":"),n=typeof a<"u",r=n?a.get(s):void 0;return r==null&&(r=En(e,t),n&&a.set(s,r)),r},ie.prototype.render=function(e,t,a,s){var n=this.getConfigTags(s),r=this.parse(e,n),o=t instanceof qe?t:new qe(t,void 0);return this.renderTokens(r,o,a,e,s)},ie.prototype.renderTokens=function(e,t,a,s,n){for(var r="",o,c,h,d=0,L=e.length;d<L;++d)h=void 0,o=e[d],c=o[0],c==="#"?h=this.renderSection(o,t,a,s,n):c==="^"?h=this.renderInverted(o,t,a,s,n):c===">"?h=this.renderPartial(o,t,a,n):c==="&"?h=this.unescapedValue(o,t):c==="name"?h=this.escapedValue(o,t,n):c==="text"&&(h=this.rawValue(o)),h!==void 0&&(r+=h);return r},ie.prototype.renderSection=function(e,t,a,s,n){var r=this,o="",c=t.lookup(e[1]);function h(m){return r.render(m,t,a,n)}if(c){if(Qe(c))for(var d=0,L=c.length;d<L;++d)o+=this.renderTokens(e[4],t.push(c[d]),a,s,n);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")o+=this.renderTokens(e[4],t.push(c),a,s,n);else if(ga(c)){if(typeof s!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(t.view,s.slice(e[3],e[5]),h),c!=null&&(o+=c)}else o+=this.renderTokens(e[4],t,a,s,n);return o}},ie.prototype.renderInverted=function(e,t,a,s,n){var r=t.lookup(e[1]);if(!r||Qe(r)&&r.length===0)return this.renderTokens(e[4],t,a,s,n)},ie.prototype.indentPartial=function(e,t,a){for(var s=t.replace(/[^ \t]/g,""),n=e.split(`
69
- `),r=0;r<n.length;r++)n[r].length&&(r>0||!a)&&(n[r]=s+n[r]);return n.join(`
70
- `)},ie.prototype.renderPartial=function(e,t,a,s){if(a){var n=this.getConfigTags(s),r=ga(a)?a(e[1]):a[e[1]];if(r!=null){var o=e[6],c=e[5],h=e[4],d=r;c==0&&h&&(d=this.indentPartial(r,h,o));var L=this.parse(d,n);return this.renderTokens(L,t,a,d,s)}}},ie.prototype.unescapedValue=function(e,t){var a=t.lookup(e[1]);if(a!=null)return a},ie.prototype.escapedValue=function(e,t,a){var s=this.getConfigEscape(a)||k.escape,n=t.lookup(e[1]);if(n!=null)return typeof n=="number"&&s===k.escape?String(n):s(n)},ie.prototype.rawValue=function(e){return e[1]},ie.prototype.getConfigTags=function(e){return Qe(e)?e:e&&typeof e=="object"?e.tags:void 0},ie.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!Qe(e))return e.escape};var k={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(i){ut.templateCache=i},get templateCache(){return ut.templateCache}},ut=new ie;k.clearCache=function(){return ut.clearCache()},k.parse=function(e,t){return ut.parse(e,t)},k.render=function(e,t,a,s){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+mn(e)+'" was given as the first argument for mustache#render(template, view, partials)');return ut.render(e,t,a,s)},k.escape=Sn,k.Scanner=ht,k.Context=qe,k.Writer=ie;const Dn={main:{template:`
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>${fe(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=Ka(i);if(a===null)return s;i=a;let n='<a href="'+i+'"';return e&&(n+=' title="'+fe(e)+'"'),n+=">"+s+"</a>",n}image({href:i,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));const a=Ka(i);if(a===null)return fe(t);i=a;let n=`<img src="${i}" alt="${t}"`;return e&&(n+=` title="${fe(e)}"`),n+=">",n}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:fe(i.text)}},Yt=class{strong({text:i}){return i}em({text:i}){return i}codespan({text:i}){return i}del({text:i}){return i}html({text:i}){return i}text({text:i}){return i}link({text:i}){return""+i}image({text:i}){return""+i}br(){return""}},Ce=class Pa{options;renderer;textRenderer;constructor(e){this.options=e||je,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 Yt}static parse(e,t){return new Pa(t).parse(e)}static parseInline(e,t){return new Pa(t).parseInline(e)}parse(e,t=!0){let s="";for(let a=0;a<e.length;a++){const n=e[a];if(this.options.extensions?.renderers?.[n.type]){const o=n,c=this.options.extensions.renderers[o.type].call({parser:this},o);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){s+=c||"";continue}}const r=n;switch(r.type){case"space":{s+=this.renderer.space(r);continue}case"hr":{s+=this.renderer.hr(r);continue}case"heading":{s+=this.renderer.heading(r);continue}case"code":{s+=this.renderer.code(r);continue}case"table":{s+=this.renderer.table(r);continue}case"blockquote":{s+=this.renderer.blockquote(r);continue}case"list":{s+=this.renderer.list(r);continue}case"html":{s+=this.renderer.html(r);continue}case"paragraph":{s+=this.renderer.paragraph(r);continue}case"text":{let o=r,c=this.renderer.text(o);for(;a+1<e.length&&e[a+1].type==="text";)o=e[++a],c+=`
55
+ `+this.renderer.text(o);t?s+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c,escaped:!0}]}):s+=c;continue}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return s}parseInline(e,t=this.renderer){let s="";for(let a=0;a<e.length;a++){const n=e[a];if(this.options.extensions?.renderers?.[n.type]){const o=this.options.extensions.renderers[n.type].call({parser:this},n);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type)){s+=o||"";continue}}const r=n;switch(r.type){case"escape":{s+=t.text(r);break}case"html":{s+=t.html(r);break}case"link":{s+=t.link(r);break}case"image":{s+=t.image(r);break}case"strong":{s+=t.strong(r);break}case"em":{s+=t.em(r);break}case"codespan":{s+=t.codespan(r);break}case"br":{s+=t.br(r);break}case"del":{s+=t.del(r);break}case"text":{s+=t.text(r);break}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return s}},kt=class{options;block;constructor(i){this.options=i||je}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(i){return i}postprocess(i){return i}processAllTokens(i){return i}provideLexer(){return this.block?Me.lex:Me.lexInline}provideParser(){return this.block?Ce.parse:Ce.parseInline}},_i=class{defaults=zt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ce;Renderer=xt;TextRenderer=Yt;Lexer=Me;Tokenizer=St;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 n of a.header)t=t.concat(this.walkTokens(n.tokens,e));for(const n of a.rows)for(const r of n)t=t.concat(this.walkTokens(r.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(n=>{const r=a[n].flat(1/0);t=t.concat(this.walkTokens(r,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 n=e.renderers[a.name];n?e.renderers[a.name]=function(...r){let o=a.renderer.apply(this,r);return o===!1&&(o=n.apply(this,r)),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 n=e[a.level];n?n.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 n in t.renderer){if(!(n in a))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;const r=n,o=t.renderer[r],c=a[r];a[r]=(...h)=>{let d=o.apply(a,h);return d===!1&&(d=c.apply(a,h)),d||""}}s.renderer=a}if(t.tokenizer){const a=this.defaults.tokenizer||new St(this.defaults);for(const n in t.tokenizer){if(!(n in a))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const r=n,o=t.tokenizer[r],c=a[r];a[r]=(...h)=>{let d=o.apply(a,h);return d===!1&&(d=c.apply(a,h)),d}}s.tokenizer=a}if(t.hooks){const a=this.defaults.hooks||new kt;for(const n in t.hooks){if(!(n in a))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;const r=n,o=t.hooks[r],c=a[r];kt.passThroughHooks.has(n)?a[r]=h=>{if(this.defaults.async)return Promise.resolve(o.call(a,h)).then(y=>c.call(a,y));const d=o.call(a,h);return c.call(a,d)}:a[r]=(...h)=>{let d=o.apply(a,h);return d===!1&&(d=c.apply(a,h)),d}}s.hooks=a}if(t.walkTokens){const a=this.defaults.walkTokens,n=t.walkTokens;s.walkTokens=function(r){let o=[];return o.push(n.call(this,r)),a&&(o=o.concat(a.call(this,r))),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 Ce.parse(i,e??this.defaults)}parseMarkdown(i){return(t,s)=>{const a={...s},n={...this.defaults,...a},r=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&a.async===!1)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return r(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));n.hooks&&(n.hooks.options=n,n.hooks.block=i);const o=n.hooks?n.hooks.provideLexer():i?Me.lex:Me.lexInline,c=n.hooks?n.hooks.provideParser():i?Ce.parse:Ce.parseInline;if(n.async)return Promise.resolve(n.hooks?n.hooks.preprocess(t):t).then(h=>o(h,n)).then(h=>n.hooks?n.hooks.processAllTokens(h):h).then(h=>n.walkTokens?Promise.all(this.walkTokens(h,n.walkTokens)).then(()=>h):h).then(h=>c(h,n)).then(h=>n.hooks?n.hooks.postprocess(h):h).catch(r);try{n.hooks&&(t=n.hooks.preprocess(t));let h=o(t,n);n.hooks&&(h=n.hooks.processAllTokens(h)),n.walkTokens&&this.walkTokens(h,n.walkTokens);let d=c(h,n);return n.hooks&&(d=n.hooks.postprocess(d)),d}catch(h){return r(h)}}}onError(i,e){return t=>{if(t.message+=`
56
+ Please report this to https://github.com/markedjs/marked.`,i){const s="<p>An error occurred:</p><pre>"+fe(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},Re=new _i;function j(i,e){return Re.parse(i,e)}j.options=j.setOptions=function(i){return Re.setOptions(i),j.defaults=Re.defaults,Fa(j.defaults),j},j.getDefaults=zt,j.defaults=je,j.use=function(...i){return Re.use(...i),j.defaults=Re.defaults,Fa(j.defaults),j},j.walkTokens=function(i,e){return Re.walkTokens(i,e)},j.parseInline=Re.parseInline,j.Parser=Ce,j.parser=Ce.parse,j.Renderer=xt,j.TextRenderer=Yt,j.Lexer=Me,j.lexer=Me.lex,j.Tokenizer=St,j.Hooks=kt,j.parse=j,j.options,j.setOptions,j.use,j.walkTokens,j.parseInline,Ce.parse,Me.lex;function es(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,s=Array(e);t<e;t++)s[t]=i[t];return s}function Fi(i){if(Array.isArray(i))return i}function zi(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var s,a,n,r,o=[],c=!0,h=!1;try{if(n=(t=t.call(i)).next,e!==0)for(;!(c=(s=n.call(t)).done)&&(o.push(s.value),o.length!==e);c=!0);}catch(d){h=!0,a=d}finally{try{if(!c&&t.return!=null&&(r=t.return(),Object(r)!==r))return}finally{if(h)throw a}}return o}}function $i(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
57
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vi(i,e){return Fi(i)||zi(i,e)||Bi(i,e)||$i()}function Bi(i,e){if(i){if(typeof i=="string")return es(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?es(i,e):void 0}}const ts=Object.entries,as=Object.setPrototypeOf,Hi=Object.isFrozen,Ui=Object.getPrototypeOf,Qi=Object.getOwnPropertyDescriptor;let ee=Object.freeze,te=Object.seal,$e=Object.create,ss=typeof Reflect<"u"&&Reflect,Jt=ss.apply,Gt=ss.construct;ee||(ee=function(e){return e}),te||(te=function(e){return e}),Jt||(Jt=function(e,t){for(var s=arguments.length,a=new Array(s>2?s-2:0),n=2;n<s;n++)a[n-2]=arguments[n];return e.apply(t,a)}),Gt||(Gt=function(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];return new e(...s)});const nt=Q(Array.prototype.forEach),qi=Q(Array.prototype.lastIndexOf),is=Q(Array.prototype.pop),Ve=Q(Array.prototype.push),Wi=Q(Array.prototype.splice),Se=Array.isArray,rt=Q(String.prototype.toLowerCase),Kt=Q(String.prototype.toString),ns=Q(String.prototype.match),ot=Q(String.prototype.replace),rs=Q(String.prototype.indexOf),Yi=Q(String.prototype.trim),Ji=Q(Number.prototype.toString),Gi=Q(Boolean.prototype.toString),os=typeof BigInt>"u"?null:Q(BigInt.prototype.toString),ls=typeof Symbol>"u"?null:Q(Symbol.prototype.toString),G=Q(Object.prototype.hasOwnProperty),lt=Q(Object.prototype.toString),ae=Q(RegExp.prototype.test),Ne=Ki(TypeError);function Q(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 Jt(i,e,s)}}function Ki(i){return function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return Gt(i,t)}}function A(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:rt;if(as&&as(i,null),!Se(e))return i;let s=e.length;for(;s--;){let a=e[s];if(typeof a=="string"){const n=t(a);n!==a&&(Hi(e)||(e[s]=n),a=n)}i[a]=!0}return i}function Zi(i){for(let e=0;e<i.length;e++)G(i,e)||(i[e]=null);return i}function ie(i){const e=$e(null);for(const s of ts(i)){var t=Vi(s,2);const a=t[0],n=t[1];G(i,a)&&(Se(n)?e[a]=Zi(n):n&&typeof n=="object"&&n.constructor===Object?e[a]=ie(n):e[a]=n)}return e}function Xi(i){switch(typeof i){case"string":return i;case"number":return Ji(i);case"boolean":return Gi(i);case"bigint":return os?os(i):"0";case"symbol":return ls?ls(i):"Symbol()";case"undefined":return lt(i);case"function":case"object":{if(i===null)return lt(i);const e=i,t=pe(e,"toString");if(typeof t=="function"){const s=t(e);return typeof s=="string"?s:lt(s)}return lt(i)}default:return lt(i)}}function pe(i,e){for(;i!==null;){const s=Qi(i,e);if(s){if(s.get)return Q(s.get);if(typeof s.value=="function")return Q(s.value)}i=Ui(i)}function t(){return null}return t}function en(i){try{return ae(i,""),!0}catch{return!1}}const cs=ee(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Zt=ee(["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"]),Xt=ee(["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"]),tn=ee(["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"]),ea=ee(["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"]),an=ee(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),hs=ee(["#text"]),us=ee(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ta=ee(["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"]),ds=ee(["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"]),At=ee(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),sn=te(/{{[\w\W]*|^[\w\W]*}}/g),nn=te(/<%[\w\W]*|^[\w\W]*%>/g),rn=te(/\${[\w\W]*/g),on=te(/^data-[\-\w.\u00B7-\uFFFF]+$/),ln=te(/^aria-[\-\w]+$/),gs=te(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),cn=te(/^(?:\w+script|data):/i),hn=te(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),un=te(/^html$/i),dn=te(/^[a-z][.\w]*(-[.\w]+)+$/i),fs=te(/<[/\w!]/g),gn=te(/<[/\w]/g),fn=te(/<\/no(script|embed|frames)/i),pn=te(/\/>/i),me={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},mn=function(){return typeof window>"u"?null:window},Ln=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null;const a="data-tt-policy-suffix";t&&t.hasAttribute(a)&&(s=t.getAttribute(a));const n="dompurify"+(s?"#"+s:"");try{return e.createPolicy(n,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+n+" could not be created."),null}},ps=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},xe=function(e,t,s,a){return G(e,t)&&Se(e[t])?A(a.base?ie(a.base):{},e[t],a.transform):s};function ms(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mn();const e=p=>ms(p);if(e.version="3.4.11",e.removed=[],!i||!i.document||i.document.nodeType!==me.document||!i.Element)return e.isSupported=!1,e;let t=i.document;const s=t,a=s.currentScript;i.DocumentFragment;const n=i.HTMLTemplateElement,r=i.Node,o=i.Element,c=i.NodeFilter,h=i.NamedNodeMap;h===void 0&&(i.NamedNodeMap||i.MozNamedAttrMap),i.HTMLFormElement;const d=i.DOMParser,y=i.trustedTypes,L=o.prototype,N=pe(L,"cloneNode"),k=pe(L,"remove"),T=pe(L,"nextSibling"),P=pe(L,"childNodes"),R=pe(L,"parentNode"),H=pe(L,"shadowRoot"),le=pe(L,"attributes"),_=r&&r.prototype?pe(r.prototype,"nodeType"):null,m=r&&r.prototype?pe(r.prototype,"nodeName"):null;if(typeof n=="function"){const p=t.createElement("template");p.content&&p.content.ownerDocument&&(t=p.content.ownerDocument)}let g,C="",I,q=!1,ce=0;const Dt=function(){if(ce>0)throw Ne('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ae=function(l){Dt(),ce++;try{return g.createHTML(l)}finally{ce--}},ma=function(l){Dt(),ce++;try{return g.createScriptURL(l)}finally{ce--}},Ee=function(){return q||(I=Ln(y,a),q=!0),I},_e=t,La=_e.implementation,vs=_e.createNodeIterator,cr=_e.createDocumentFragment,hr=_e.getElementsByTagName,ur=s.importNode;let U=ps();e.isSupported=typeof ts=="function"&&typeof R=="function"&&La&&La.createHTMLDocument!==void 0;const dr=sn,gr=nn,fr=rn,pr=on,mr=ln,Lr=cn,Is=hn,yr=dn;let Ds=gs,z=null;const js=A({},[...cs,...Zt,...Xt,...ea,...hs]);let $=null;const Rs=A({},[...us,...ta,...ds,...At]);let V=Object.seal($e(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),mt=null,Ns=null;const ve=Object.seal($e(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Os=!0,ya=!0,Ps=!1,_s=!0,Ie=!1,Lt=!0,Fe=!1,wa=!1,Ma=null,Ca=null,ba=!1,Ge=!1,jt=!1,Rt=!1,Fs=!0,zs=!1;const $s="user-content-";let Ta=!0,Sa=!1,Ke={},ye=null;const xa=A({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Vs=null;const Bs=A({},["audio","video","img","source","image","track"]);let ka=null;const Hs=A({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Nt="http://www.w3.org/1998/Math/MathML",Ot="http://www.w3.org/2000/svg",we="http://www.w3.org/1999/xhtml";let Ze=we,Aa=!1,Ea=null;const wr=A({},[Nt,Ot,we],Kt),Us=ee(["mi","mo","mn","ms","mtext"]);let va=A({},Us);const Qs=ee(["annotation-xml"]);let Ia=A({},Qs);const Mr=A({},["title","style","font","a","script"]);let yt=null;const Cr=["application/xhtml+xml","text/html"],br="text/html";let B=null,Xe=null;const Tr=t.createElement("form"),qs=function(l){return l instanceof RegExp||l instanceof Function},Da=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Xe&&Xe===l)return;(!l||typeof l!="object")&&(l={}),l=ie(l),yt=Cr.indexOf(l.PARSER_MEDIA_TYPE)===-1?br:l.PARSER_MEDIA_TYPE,B=yt==="application/xhtml+xml"?Kt:rt,z=xe(l,"ALLOWED_TAGS",js,{transform:B}),$=xe(l,"ALLOWED_ATTR",Rs,{transform:B}),Ea=xe(l,"ALLOWED_NAMESPACES",wr,{transform:Kt}),ka=xe(l,"ADD_URI_SAFE_ATTR",Hs,{transform:B,base:Hs}),Vs=xe(l,"ADD_DATA_URI_TAGS",Bs,{transform:B,base:Bs}),ye=xe(l,"FORBID_CONTENTS",xa,{transform:B}),mt=xe(l,"FORBID_TAGS",ie({}),{transform:B}),Ns=xe(l,"FORBID_ATTR",ie({}),{transform:B}),Ke=G(l,"USE_PROFILES")?l.USE_PROFILES&&typeof l.USE_PROFILES=="object"?ie(l.USE_PROFILES):l.USE_PROFILES:!1,Os=l.ALLOW_ARIA_ATTR!==!1,ya=l.ALLOW_DATA_ATTR!==!1,Ps=l.ALLOW_UNKNOWN_PROTOCOLS||!1,_s=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ie=l.SAFE_FOR_TEMPLATES||!1,Lt=l.SAFE_FOR_XML!==!1,Fe=l.WHOLE_DOCUMENT||!1,Ge=l.RETURN_DOM||!1,jt=l.RETURN_DOM_FRAGMENT||!1,Rt=l.RETURN_TRUSTED_TYPE||!1,ba=l.FORCE_BODY||!1,Fs=l.SANITIZE_DOM!==!1,zs=l.SANITIZE_NAMED_PROPS||!1,Ta=l.KEEP_CONTENT!==!1,Sa=l.IN_PLACE||!1,Ds=en(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:gs,Ze=typeof l.NAMESPACE=="string"?l.NAMESPACE:we,va=G(l,"MATHML_TEXT_INTEGRATION_POINTS")&&l.MATHML_TEXT_INTEGRATION_POINTS&&typeof l.MATHML_TEXT_INTEGRATION_POINTS=="object"?ie(l.MATHML_TEXT_INTEGRATION_POINTS):A({},Us),Ia=G(l,"HTML_INTEGRATION_POINTS")&&l.HTML_INTEGRATION_POINTS&&typeof l.HTML_INTEGRATION_POINTS=="object"?ie(l.HTML_INTEGRATION_POINTS):A({},Qs);const u=G(l,"CUSTOM_ELEMENT_HANDLING")&&l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING=="object"?ie(l.CUSTOM_ELEMENT_HANDLING):$e(null);if(V=$e(null),G(u,"tagNameCheck")&&qs(u.tagNameCheck)&&(V.tagNameCheck=u.tagNameCheck),G(u,"attributeNameCheck")&&qs(u.attributeNameCheck)&&(V.attributeNameCheck=u.attributeNameCheck),G(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(V.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),te(V),Ie&&(ya=!1),jt&&(Ge=!0),Ke&&(z=A({},hs),$=$e(null),Ke.html===!0&&(A(z,cs),A($,us)),Ke.svg===!0&&(A(z,Zt),A($,ta),A($,At)),Ke.svgFilters===!0&&(A(z,Xt),A($,ta),A($,At)),Ke.mathMl===!0&&(A(z,ea),A($,ds),A($,At))),ve.tagCheck=null,ve.attributeCheck=null,G(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?ve.tagCheck=l.ADD_TAGS:Se(l.ADD_TAGS)&&(z===js&&(z=ie(z)),A(z,l.ADD_TAGS,B))),G(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?ve.attributeCheck=l.ADD_ATTR:Se(l.ADD_ATTR)&&($===Rs&&($=ie($)),A($,l.ADD_ATTR,B))),G(l,"ADD_URI_SAFE_ATTR")&&Se(l.ADD_URI_SAFE_ATTR)&&A(ka,l.ADD_URI_SAFE_ATTR,B),G(l,"FORBID_CONTENTS")&&Se(l.FORBID_CONTENTS)&&(ye===xa&&(ye=ie(ye)),A(ye,l.FORBID_CONTENTS,B)),G(l,"ADD_FORBID_CONTENTS")&&Se(l.ADD_FORBID_CONTENTS)&&(ye===xa&&(ye=ie(ye)),A(ye,l.ADD_FORBID_CONTENTS,B)),Ta&&(z["#text"]=!0),Fe&&A(z,["html","head","body"]),z.table&&(A(z,["tbody"]),delete mt.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ne('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ne('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const f=g;g=l.TRUSTED_TYPES_POLICY;try{C=Ae("")}catch(w){throw g=f,w}}else l.TRUSTED_TYPES_POLICY===null?(g=void 0,C=""):(g===void 0&&(g=Ee()),g&&typeof C=="string"&&(C=Ae("")));ee&&ee(l),Xe=l},Ws=A({},[...Zt,...Xt,...tn]),Ys=A({},[...ea,...an]),Sr=function(l,u,f){return u.namespaceURI===we?l==="svg":u.namespaceURI===Nt?l==="svg"&&(f==="annotation-xml"||va[f]):!!Ws[l]},xr=function(l,u,f){return u.namespaceURI===we?l==="math":u.namespaceURI===Ot?l==="math"&&Ia[f]:!!Ys[l]},kr=function(l,u,f){return u.namespaceURI===Ot&&!Ia[f]||u.namespaceURI===Nt&&!va[f]?!1:!Ys[l]&&(Mr[l]||!Ws[l])},Ar=function(l){let u=R(l);(!u||!u.tagName)&&(u={namespaceURI:Ze,tagName:"template"});const f=rt(l.tagName),w=rt(u.tagName);return Ea[l.namespaceURI]?l.namespaceURI===Ot?Sr(f,u,w):l.namespaceURI===Nt?xr(f,u,w):l.namespaceURI===we?kr(f,u,w):!!(yt==="application/xhtml+xml"&&Ea[l.namespaceURI]):!1},De=function(l){Ve(e.removed,{element:l});try{R(l).removeChild(l)}catch{if(k(l),!R(l))throw Ne("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Js=function(l){const u=P(l);if(u){const w=[];nt(u,S=>{Ve(w,S)}),nt(w,S=>{try{k(S)}catch{}})}const f=le(l);if(f)for(let w=f.length-1;w>=0;--w){const S=f[w],v=S&&S.name;if(typeof v=="string")try{l.removeAttribute(v)}catch{}}},ze=function(l,u){try{Ve(e.removed,{attribute:u.getAttributeNode(l),from:u})}catch{Ve(e.removed,{attribute:null,from:u})}if(u.removeAttribute(l),l==="is")if(Ge||jt)try{De(u)}catch{}else try{u.setAttribute(l,"")}catch{}},Er=function(l){const u=le(l);if(u)for(let f=u.length-1;f>=0;--f){const w=u[f],S=w&&w.name;if(!(typeof S!="string"||$[B(S)]))try{l.removeAttribute(S)}catch{}}},vr=function(l){const u=[l];for(;u.length>0;){const f=u.pop();(_?_(f):f.nodeType)===me.element&&Er(f);const S=P(f);if(S)for(let v=S.length-1;v>=0;--v)u.push(S[v])}},Gs=function(l){let u=null,f=null;if(ba)l="<remove></remove>"+l;else{const v=ns(l,/^[\r\n\t ]+/);f=v&&v[0]}yt==="application/xhtml+xml"&&Ze===we&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");const w=g?Ae(l):l;if(Ze===we)try{u=new d().parseFromString(w,yt)}catch{}if(!u||!u.documentElement){u=La.createDocument(Ze,"template",null);try{u.documentElement.innerHTML=Aa?C:w}catch{}}const S=u.body||u.documentElement;return l&&f&&S.insertBefore(t.createTextNode(f),S.childNodes[0]||null),Ze===we?hr.call(u,Fe?"html":"body")[0]:Fe?u.documentElement:S},Ks=function(l){return vs.call(l.ownerDocument||l,l,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Pt=function(l){return l=ot(l,dr," "),l=ot(l,gr," "),l=ot(l,fr," "),l},ja=function(l){var u;l.normalize();const f=vs.call(l.ownerDocument||l,l,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let w=f.nextNode();for(;w;)w.data=Pt(w.data),w=f.nextNode();const S=(u=l.querySelectorAll)===null||u===void 0?void 0:u.call(l,"template");S&&nt(S,v=>{et(v.content)&&ja(v.content)})},_t=function(l){const u=m?m(l):null;return typeof u!="string"||B(u)!=="form"?!1:typeof l.nodeName!="string"||typeof l.textContent!="string"||typeof l.removeChild!="function"||l.attributes!==le(l)||typeof l.removeAttribute!="function"||typeof l.setAttribute!="function"||typeof l.namespaceURI!="string"||typeof l.insertBefore!="function"||typeof l.hasChildNodes!="function"||l.nodeType!==_(l)||l.childNodes!==P(l)},et=function(l){if(!_||typeof l!="object"||l===null)return!1;try{return _(l)===me.documentFragment}catch{return!1}},wt=function(l){if(!_||typeof l!="object"||l===null)return!1;try{return typeof _(l)=="number"}catch{return!1}};function Te(p,l,u){p.length!==0&&nt(p,f=>{f.call(e,l,u,Xe)})}const Ir=function(l,u){return!!(Lt&&l.hasChildNodes()&&!wt(l.firstElementChild)&&ae(fs,l.textContent)&&ae(fs,l.innerHTML)||Lt&&l.namespaceURI===we&&u==="style"&&wt(l.firstElementChild)||l.nodeType===me.processingInstruction||Lt&&l.nodeType===me.comment&&ae(gn,l.data))},Dr=function(l,u){if(!mt[u]&&ei(u)&&(V.tagNameCheck instanceof RegExp&&ae(V.tagNameCheck,u)||V.tagNameCheck instanceof Function&&V.tagNameCheck(u)))return!1;if(Ta&&!ye[u]){const f=R(l),w=P(l);if(w&&f){const S=w.length;for(let v=S-1;v>=0;--v){const X=Sa?w[v]:N(w[v],!0);f.insertBefore(X,T(l))}}}return De(l),!0},Zs=function(l){if(Te(U.beforeSanitizeElements,l,null),_t(l))return De(l),!0;const u=B(m?m(l):l.nodeName);if(Te(U.uponSanitizeElement,l,{tagName:u,allowedTags:z}),Ir(l,u))return De(l),!0;if(mt[u]||!(ve.tagCheck instanceof Function&&ve.tagCheck(u))&&!z[u])return Dr(l,u);if((_?_(l):l.nodeType)===me.element&&!Ar(l)||(u==="noscript"||u==="noembed"||u==="noframes")&&ae(fn,l.innerHTML))return De(l),!0;if(Ie&&l.nodeType===me.text){const w=Pt(l.textContent);l.textContent!==w&&(Ve(e.removed,{element:l.cloneNode()}),l.textContent=w)}return Te(U.afterSanitizeElements,l,null),!1},Xs=function(l,u,f){if(Ns[u]||Fs&&(u==="id"||u==="name")&&(f in t||f in Tr))return!1;const w=$[u]||ve.attributeCheck instanceof Function&&ve.attributeCheck(u,l);if(!(ya&&ae(pr,u))){if(!(Os&&ae(mr,u))){if(w){if(!ka[u]){if(!ae(Ds,ot(f,Is,""))){if(!((u==="src"||u==="xlink:href"||u==="href")&&l!=="script"&&rs(f,"data:")===0&&Vs[l])){if(!(Ps&&!ae(Lr,ot(f,Is,"")))){if(f)return!1}}}}}else if(!(ei(l)&&(V.tagNameCheck instanceof RegExp&&ae(V.tagNameCheck,l)||V.tagNameCheck instanceof Function&&V.tagNameCheck(l))&&(V.attributeNameCheck instanceof RegExp&&ae(V.attributeNameCheck,u)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(u,l))||u==="is"&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&ae(V.tagNameCheck,f)||V.tagNameCheck instanceof Function&&V.tagNameCheck(f))))return!1}}return!0},jr=A({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ei=function(l){return!jr[rt(l)]&&ae(yr,l)},Rr=function(l,u,f,w){if(g&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!f)switch(y.getAttributeType(l,u)){case"TrustedHTML":return Ae(w);case"TrustedScriptURL":return ma(w)}return w},Nr=function(l,u,f,w){try{f?l.setAttributeNS(f,u,w):l.setAttribute(u,w),_t(l)?De(l):is(e.removed)}catch{ze(u,l)}},ti=function(l){Te(U.beforeSanitizeAttributes,l,null);const u=l.attributes;if(!u||_t(l))return;const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$,forceKeepAttr:void 0};let w=u.length;const S=B(l.nodeName);for(;w--;){const v=u[w],X=v.name,W=v.namespaceURI,ue=v.value,ge=B(X),Na=ue;let re=X==="value"?Na:Yi(Na);if(f.attrName=ge,f.attrValue=re,f.keepAttr=!0,f.forceKeepAttr=void 0,Te(U.uponSanitizeAttribute,l,f),re=f.attrValue,zs&&(ge==="id"||ge==="name")&&rs(re,$s)!==0&&(ze(X,l),re=$s+re),Lt&&ae(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,re)){ze(X,l);continue}if(ge==="attributename"&&ns(re,"href")){ze(X,l);continue}if(!f.forceKeepAttr){if(!f.keepAttr){ze(X,l);continue}if(!_s&&ae(pn,re)){ze(X,l);continue}if(Ie&&(re=Pt(re)),!Xs(S,ge,re)){ze(X,l);continue}re=Rr(S,ge,W,re),re!==Na&&Nr(l,X,W,re)}}Te(U.afterSanitizeAttributes,l,null)},Ft=function(l){let u=null;const f=Ks(l);for(Te(U.beforeSanitizeShadowDOM,l,null);u=f.nextNode();)if(Te(U.uponSanitizeShadowNode,u,null),Zs(u),ti(u),et(u.content)&&Ft(u.content),(_?_(u):u.nodeType)===me.element){const S=H(u);et(S)&&(Ra(S),Ft(S))}Te(U.afterSanitizeShadowDOM,l,null)},Ra=function(l){const u=[{node:l,shadow:null}];for(;u.length>0;){const f=u.pop();if(f.shadow){Ft(f.shadow);continue}const w=f.node,v=(_?_(w):w.nodeType)===me.element,X=P(w);if(X)for(let W=X.length-1;W>=0;--W)u.push({node:X[W],shadow:null});if(v){const W=m?m(w):null;if(typeof W=="string"&&B(W)==="template"){const ue=w.content;et(ue)&&u.push({node:ue,shadow:null})}}if(v){const W=H(w);et(W)&&u.push({node:null,shadow:W},{node:W,shadow:null})}}};return e.sanitize=function(p){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,f=null,w=null,S=null;if(Aa=!p,Aa&&(p="<!-->"),typeof p!="string"&&!wt(p)&&(p=Xi(p),typeof p!="string"))throw Ne("dirty is not a string, aborting");if(!e.isSupported)return p;wa?(z=Ma,$=Ca):Da(l),(U.uponSanitizeElement.length>0||U.uponSanitizeAttribute.length>0)&&(z=ie(z)),U.uponSanitizeAttribute.length>0&&($=ie($)),e.removed=[];const v=Sa&&typeof p!="string"&&wt(p);if(v){const ue=m?m(p):p.nodeName;if(typeof ue=="string"){const ge=B(ue);if(!z[ge]||mt[ge])throw Ne("root node is forbidden and cannot be sanitized in-place")}if(_t(p))throw Ne("root node is clobbered and cannot be sanitized in-place");try{Ra(p)}catch(ge){throw Js(p),ge}}else if(wt(p))u=Gs("<!---->"),f=u.ownerDocument.importNode(p,!0),f.nodeType===me.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?u=f:u.appendChild(f),Ra(f);else{if(!Ge&&!Ie&&!Fe&&p.indexOf("<")===-1)return g&&Rt?Ae(p):p;if(u=Gs(p),!u)return Ge?null:Rt?C:""}u&&ba&&De(u.firstChild);const X=Ks(v?p:u);try{for(;w=X.nextNode();)Zs(w),ti(w),et(w.content)&&Ft(w.content)}catch(ue){throw v&&Js(p),ue}if(v)return nt(e.removed,ue=>{ue.element&&vr(ue.element)}),Ie&&ja(p),p;if(Ge){if(Ie&&ja(u),jt)for(S=cr.call(u.ownerDocument);u.firstChild;)S.appendChild(u.firstChild);else S=u;return($.shadowroot||$.shadowrootmode)&&(S=ur.call(s,S,!0)),S}let W=Fe?u.outerHTML:u.innerHTML;return Fe&&z["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&ae(un,u.ownerDocument.doctype.name)&&(W="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
58
+ `+W),Ie&&(W=Pt(W)),g&&Rt?Ae(W):W},e.setConfig=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Da(p),wa=!0,Ma=z,Ca=$},e.clearConfig=function(){Xe=null,wa=!1,Ma=null,Ca=null,g=I,C=""},e.isValidAttribute=function(p,l,u){Xe||Da({});const f=B(p),w=B(l);return Xs(f,w,u)},e.addHook=function(p,l){typeof l=="function"&&G(U,p)&&Ve(U[p],l)},e.removeHook=function(p,l){if(G(U,p)){if(l!==void 0){const u=qi(U[p],l);return u===-1?void 0:Wi(U[p],u,1)[0]}return is(U[p])}},e.removeHooks=function(p){G(U,p)&&(U[p]=[])},e.removeAllHooks=function(){U=ps()},e}var Ls=ms();class yn{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 Ls.sanitize(j.parse(this.dataLayer.getAnswerData)).replace(/<a /g,'<a target="_blank" class="searchstax-answer-link" rel="noopener noreferrer" ')}get answerLoading(){return this.dataLayer.answerLoading}get shouldShowAnswerError(){return this.dataLayer.answerError}get locationError(){return this.dataLayer.locationError}get shouldShowAnswer(){return(this.dataLayer.getAnswerData!==""||this.dataLayer.parsedData.answerLoading||this.shouldShowAnswerError)&&this.dataLayer.searchObject.query!=="*"}get searchTerm(){return this.dataLayer.searchResultsMetadata?.autoCorrectedQuery||this.dataLayer.searchObject?.query||""}get locationSearchEnabled(){return this.dataLayer.locationEnabled??!1}get locationSearchDistanceEnabled(){return(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationDistanceEnabled?this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationDistanceEnabled:this.dataLayer.searchResultsMetadata?.location?.filter?.enabled)??!1}get locationSearchDistanceValues(){const e=this.dataLayer.searchLocationConfig?.locationValuesOverride?.filterValues??this.dataLayer.searchResultsMetadata?.location?.filter?.values,t=this.dataLayer.searchLocationConfig?.locationValuesOverride?.filterUnit??this.dataLayer.searchResultsMetadata?.location?.unit;return!e||e.length===0?[]:e.map(a=>({label:a==="any"?"Any Distance":a+" "+(t??""),value:a,isSelected:a===this.dataLayer.searchRadius})).sort((a,n)=>{const r=a.value==="any"?0:parseFloat(a.value),o=n.value==="any"?0:parseFloat(n.value);return r-o})}get shouldShowLocationDistanceDropdown(){return this.locationSearchDistanceEnabled&&this.locationSearchDistanceValues.length>1}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get answerErrorMessage(){return Ls.sanitize(j.parse(this.dataLayer.answerErrorMessage)).replace("<br>","")}get searchExecuted(){return this.dataLayer.searchObject?.query!==void 0&&this.dataLayer.searchObject?.query!=="undefined"&&this.dataLayer.searchObject?.query!==""}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalPages:this.totalPages,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,answerTruncated:this.answerTruncated,fullAnswerFormatted:this.fullAnswerFormatted,shouldShowAnswerLoadMore:this.shouldShowAnswerLoadMore,answerLoading:this.answerLoading,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption,shouldShowAnswerError:this.shouldShowAnswerError,answerErrorMessage:this.answerErrorMessage,locationSearchEnabled:this.locationSearchEnabled,locationSearchDistanceEnabled:this.locationSearchDistanceEnabled,locationSearchDistanceValues:this.locationSearchDistanceValues,shouldShowLocationDistanceDropdown:this.shouldShowLocationDistanceDropdown,locationError:this.locationError}}get trackingData(){return{searchTerm:this.searchTerm,trackApiKey:this.dataLayer.searchstaxConfig?.trackApiKey??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:this.dataLayer.searchResultsMetadata?.recordsPerPageValue??0,totalResults:this.dataLayer.searchResultsMetadata?.totalResultsValue??0,currentPage:this.dataLayer.currentPage,latencyVal:this.dataLayer.searchResultsMetadata?.latency??0,...this.dataLayer.model?{model:this.dataLayer.model}:{}}}}class he{static deepEqual(e,t){const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(const n of s){const r=e[n],o=t[n],c=this.isObject(r)&&this.isObject(o);if(c&&!this.deepEqual(r,o)||!c&&r!==o)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class b{value;observers={};constructor(e){this.value=e,this.observers={}}subscribe(e,t){const s=Math.random().toString(36).substring(2,15),a=t||s;return this.observers[a]=e,e(this.value),a}unsubscribe(e){this.observers[e]&&delete this.observers[e]}subscribeOnce(e){const t=Math.random().toString(36).substring(2,15),s=a=>{e(a),this.unsubscribe(t)};this.subscribe(s,t)}subscribeTwice(e){const t=Math.random().toString(36).substring(2,15);let s=0;const a=n=>{s++,e(n),s>=2&&this.unsubscribe(t)};this.subscribe(a,t)}subscribeUntil(e,t,s=6e3,a=!0){const n=Math.random().toString(36).substring(2,15),r=o=>{o===t&&(e(o),this.unsubscribe(n))};return this.value===t?(e(this.value),null):(this.subscribe(r,n),setTimeout(()=>{a&&this.observers[n]&&e(this.value),this.unsubscribe(n)},s),n)}subscribeUntilHasValue(e,t=6e3,s=!0){const a=Math.random().toString(36).substring(2,15),n=r=>{r!=null&&(e(r),this.unsubscribe(a))};return this.value!==null&&this.value!==void 0?(e(this.value),null):(this.subscribe(n,a),t>0&&setTimeout(()=>{s&&this.observers[a]&&e(this.value),this.unsubscribe(a)},t),n)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){for(const e in this.observers)if(Object.prototype.hasOwnProperty.call(this.observers,e)){const t=this.observers[e];typeof t=="function"&&t(this.value)}}}class aa{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 n=0;n<e;n++)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 n=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const r in a){n+="; "+r;const o=a[r];o!==!0&&(n+="="+o)}typeof document<"u"&&(document.cookie=n)}}class K{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 wn{$searchTermChange=new b("");$searchLocationChange=new b("");$searchLocationCoordinatesDecoded=new b("");$searchLatChange=new b("");$searchLongChange=new b("");$searchRadiusChange=new b(void 0);$loadingChange=new b(!1);$locationError=new b(!1);$searchResults=new b(null);$searchResultsMetadata=new b(null);$searchAutosuggest=new b(null);$searchFacets=new b(null);$searchFacetsCachedand=new b(null);$searchFacetsCachedor=new b(null);$searchFacetsCachedtabs=new b(null);$searchstaxConfig=new b(null);$autosuggestResults=new b(null);$itemsPerPage=new b(void 0);$searchObject=new b({query:"",itemsPerPage:void 0,page:99999999,order:"",facets:[],additionalProps:[],location:{term:void 0,radius:void 0,lat:void 0,lon:void 0},model:""});$searchRelatedSearches=new b(null);$searchInputConfig=new b(null);$searchLocationConfig=new b(null);$searchExternalPromotions=new b(null);$facetsTemplateData=new b(null);$selectedFacetsTemplateData=new b(null);$paginationData=new b(null);$answerData=new b(null);$searchFeedbackData=new b(null);$inputWidgetTemplateData=new b(null);$locationWidgetTemplateData=new b(null);$searchSortingData=new b(null);$searchRelatedSearchesData=new b(null);$searchExternalPromotionsData=new b(null);$cookiesDisabled=new b(null);$locationDecodingLoading=new b(!1);$answer=new b("");$language=new b("en");$model=new b("");$answerLoading=new b(!1);$locationEnabled=new b(null);$answerError=new b(!1);$answerErrorMessage=new b("");$isQuestion=new b(!1);$inputTemplateRendered=new b(!1);currentPageValue=1;isAnswerWidgetCreatedValue=!1;renderingEngineValue=F.mustache;parsedData=new yn(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,aa.deleteCookie(this.sessionId),aa.deleteCookie("ms_visitorid")):this.sessionIdValue=aa.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(K.removeXSSRiskyTags(e))}setSearchLocation(e){this.$searchLocationChange.setValue(K.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,(!he.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){he.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&&(!he.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,he.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){he.deepEqual(e,this.searchFacetsCachedand??[])||this.$searchFacetsCachedand.setValue(e)}setSearchFacetsCachedor(e){he.deepEqual(e,this.searchFacetsCachedor??[])||this.$searchFacetsCachedor.setValue(e)}setSearchFacetsCachedtabs(e){he.deepEqual(e,this.searchFacetsCachedtabs??[])||this.$searchFacetsCachedtabs.setValue(e)}setSearchRelatedSearches(e){he.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){he.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(K.removeXSSRiskyTags(e))}setLocationEnabled(e){this.$locationEnabled.setValue(e)}setSearchResultUnparsedData(e){this.searchResultUnparsed=e}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCachedand(){return this.$searchFacetsCachedand.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCachedand.getValue())):null}get searchFacetsCachedtabs(){return this.$searchFacetsCachedtabs.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCachedtabs.getValue())):null}get searchFacetsCachedor(){return this.$searchFacetsCachedor.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCachedor.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get searchLocation(){return this.$searchLocationChange.getValue()}get searchRadius(){return this.$searchRadiusChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get model(){return this.$model.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get searchLocationConfig(){return this.$searchLocationConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}get answerFullData(){return this.$answerData.getValue()}get answerLoading(){return this.$answerLoading.getValue()}get isQuestion(){return this.$isQuestion.getValue()}get answerError(){return this.$answerError.getValue()}get answerErrorMessage(){return this.$answerErrorMessage.getValue()}get locationDecodingLoading(){return this.$locationDecodingLoading.getValue()}get searchLat(){return this.$searchLatChange.getValue()}get searchLong(){return this.$searchLongChange.getValue()}get inputTemplateRendered(){return this.$inputTemplateRendered.getValue()}get locationError(){return this.$locationError.getValue()}get inputWidgetTemplateData(){return this.$inputWidgetTemplateData.getValue()}get locationWidgetTemplateData(){return this.$locationWidgetTemplateData.getValue()}get searchLocationCoordinatesDecoded(){return this.$searchLocationCoordinatesDecoded.getValue()}get locationEnabled(){return this.$locationEnabled.getValue()}get searchResultUnparsedData(){return this.searchResultUnparsed}}class ct{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,n)=>{const r=a[e.responseHeader.params.uniqueId]??"",o={custom:null,uniqueId:r,position:s+1+n,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e,r):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e,r):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e,r):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,r):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",a,e,r,!0):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e,r):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e,r):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e,r):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e,r):null,distance:this.doesMapExist("distance",e)&&this.getValueByKey("distance",a,e,r)!=="Infinity"&&this.getValueByKey("distance",a,e,r)?Math.floor(this.getValueByKey("distance",a,e,r)):null,unit:e.metadata.locationSearch?.unit??"",unmappedFields:this.getUnmappedFields(a,e,r),allFields:this.getAllFields(a,e)};t.push(o)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const s of e.metadata.facets){let a={values:[]};if(a.name=s.name,a.label=s.label,s.name in e.facet_counts.facet_fields){const n=e.facet_counts.facet_fields[s.name];for(let r=0;r<n.length;r+=2){const o={};o.value=n[r],o.parentName=a.name,o.count=n[r+1],o.type="checkbox",a.values.push(o)}}a.values.length>0&&t.push(a)}return t}static extractSearchResultsMetadata(e){let t="",s={selectedSortOption:"",options:[]},a={enabled:!1,field:"",unit:"",filter:{enabled:!1,values:[],label:"",defaultValue:""}};if(e.metadata.locationSearch&&(a={enabled:e.metadata.locationSearch.enabled,field:e.metadata.locationSearch.field,unit:e.metadata.locationSearch.unit,filter:{enabled:e.metadata.locationSearch.filter?.enabled??!1,values:e.metadata.locationSearch.filter?.values??[],label:e.metadata.locationSearch.filter?.label??"",defaultValue:e.metadata.locationSearch.filter?.defaultValue??""}}),e.metadata.results.find(n=>n.result_card==="date")?.name,s.options=[],e.metadata.sorts?.length){const n=e.metadata.sorts.map(r=>({value:r.label,key:r.name+" "+r.order}));s.options=[{key:"",value:"Relevance"},...n]}return t=e?.spellcheck?.suggestions?.[1]?.suggestion?.[0]??"",typeof t!="string"&&(t=t?.word??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:t,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:s,location:a,isLocationMapped:this.doesMapExist("distance",e)}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const n=s[a],r={};r.cDocId=this.getDataForAnalytics(n.uniqueId),n.title&&(r.cDocTitle=this.getDataForAnalytics(n.titleTracking)),r.position=n.position,t.push(r)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(s=>s.uniqueId===e)??null}static getUnmappedFields(e,t,s){const a=t.metadata.results.filter(r=>r.result_card==="").map(r=>r.name),n=[];for(const r of a)if(Object.keys(e).includes(r)){const o=Array.isArray(e[r])?this.getHighlightedResults(r,e[r].join(", "),s,t):this.getHighlightedResults(r,e[r]+"",s,t);n.push({key:r,value:o,isImage:this.checkIfImage(e[r])})}return n}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const s=t.metadata.results.map(n=>n.name),a=[];for(const n of Object.keys(e))s.indexOf(n)!==-1&&a.push({key:n,value:e[n],isImage:this.checkIfImage(e[n])});return a}static doesMapExist(e,t){return t.metadata.results.find(s=>s.result_card===e)!==void 0}static getValueByKey(e,t,s,a,n=!1){const r=s.metadata.results.find(c=>c.result_card===e);if(r===void 0)return null;const o=t[r.name];return o===void 0?null:typeof o=="string"?n?o:this.getHighlightedResults(r.name,o,a,s):typeof o=="number"?o:Array.isArray(o)?n?o.join(", "):this.getHighlightedResults(r.name,o.join(", "),a,s):null}static getHighlightedResults(e,t,s,a){if(a.highlighting&&s in a.highlighting){let n=a.highlighting[s];if(n&&e in n){let r=n[e];const o=this.cleanValue(r);if(o!=="")return o}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class 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 Mn(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 n=e.location[a];n&&(t[this.routeName+`[location][${a}]`]=n)}if(e.facets)for(const a in e.facets){const n=e.facets[a].type+":"+encodeURIComponent(e.facets[a].name)+":"+encodeURIComponent(e.facets[a].value);t[this.routeName+`[facets][${a}]`]=n}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 n in a)n.startsWith(this.routeName)&&delete a[n];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=K.removeXSSRiskyTags(e[s].split(":")?.[0]),n=K.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[1])),r=K.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[2]));t.push({type:a,name:n,value:r})}return t}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=K.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),n=parseInt(a),r=isNaN(n)?1:n;let o=parseInt(K.removeXSSRiskyTags(s[this.routeName+"[itemsPerPage]"]));return{query:K.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:r,itemsPerPage:t??o,order:K.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[],model:K.removeXSSRiskyTags(s[this.routeName+"[model]"])||"",location:{address:K.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][address]"]||"")),radius:K.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][radius]"]||"")),lat:K.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lat]"]||"")),lon:K.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lon]"]||""))}}}}class Mn{routeName="";constructor(e){this.routeName=e}stringify=(e,t)=>{const s=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(s).map(a=>{const n=s[a];return Array.isArray(n)?n.map(r=>`${a}=${r}`).join("&"):`${a}=${n}`}).join("&")};filterOutIgnoredKeys(e,t){const s=t||[],a={};return Object.keys(e).forEach(n=>{s.includes(n)||e[n]!==""&&(a[n]=e[n])}),a}urlToParams(e){const t={},s=e.split("?")[1];return s&&s.split("&").forEach(a=>{const[n,r]=a.split("=");t[n]=r}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const Be={question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class sa 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 ws=10,Cn=13,Oe=32;function ia(i){}function bn(i){if(typeof i=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=ia,onError:t=ia,onRetry:s=ia,onComment:a,maxBufferSize:n}=i,r=[];let o=0,c=!0,h,d="",y=0,L,N=!1;function k(m){if(N)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,m.charCodeAt(0)===239&&m.charCodeAt(1)===187&&m.charCodeAt(2)===191&&(m=m.slice(3))),r.length===0){const I=P(m);I!==""&&(r.push(I),o=I.length),T();return}if(m.indexOf(`
59
+ `)===-1&&m.indexOf("\r")===-1){r.push(m),o+=m.length,T();return}r.push(m);const g=r.join("");r.length=0,o=0;const C=P(g);C!==""&&(r.push(C),o=C.length),T()}function T(){n!==void 0&&(o+d.length<=n||(N=!0,r.length=0,o=0,h=void 0,d="",y=0,L=void 0,t(new sa(`Buffered data exceeded max buffer size of ${n} characters`,{type:"max-buffer-size-exceeded"}))))}function P(m){let g=0;if(m.indexOf("\r")===-1){let C=m.indexOf(`
60
+ `,g);for(;C!==-1;){if(g===C){y>0&&e({id:h,event:L,data:d}),h=void 0,d="",y=0,L=void 0,g=C+1,C=m.indexOf(`
61
+ `,g);continue}const I=m.charCodeAt(g);if(Ms(m,g,I)){const q=m.charCodeAt(g+5)===Oe?g+6:g+5,ce=m.slice(q,C);if(y===0&&m.charCodeAt(C+1)===ws){e({id:h,event:L,data:ce}),h=void 0,d="",L=void 0,g=C+2,C=m.indexOf(`
62
+ `,g);continue}d=y===0?ce:`${d}
63
+ ${ce}`,y++}else Cs(m,g,I)?L=m.slice(m.charCodeAt(g+6)===Oe?g+7:g+6,C)||void 0:R(m,g,C);g=C+1,C=m.indexOf(`
64
+ `,g)}return m.slice(g)}for(;g<m.length;){const C=m.indexOf("\r",g),I=m.indexOf(`
65
+ `,g);let q=-1;if(C!==-1&&I!==-1?q=C<I?C:I:C!==-1?C===m.length-1?q=-1:q=C:I!==-1&&(q=I),q===-1)break;R(m,g,q),g=q+1,m.charCodeAt(g-1)===Cn&&m.charCodeAt(g)===ws&&g++}return m.slice(g)}function R(m,g,C){if(g===C){le();return}const I=m.charCodeAt(g);if(Ms(m,g,I)){const Ee=m.charCodeAt(g+5)===Oe?g+6:g+5,_e=m.slice(Ee,C);d=y===0?_e:`${d}
66
+ ${_e}`,y++;return}if(Cs(m,g,I)){L=m.slice(m.charCodeAt(g+6)===Oe?g+7:g+6,C)||void 0;return}if(I===105&&m.charCodeAt(g+1)===100&&m.charCodeAt(g+2)===58){const Ee=m.slice(m.charCodeAt(g+3)===Oe?g+4:g+3,C);h=Ee.includes("\0")?void 0:Ee;return}if(I===58){if(a){const Ee=m.slice(g,C);a(Ee.slice(m.charCodeAt(g+1)===Oe?2:1))}return}const q=m.slice(g,C),ce=q.indexOf(":");if(ce===-1){H(q,"",q);return}const Dt=q.slice(0,ce),Ae=q.charCodeAt(ce+1)===Oe?2:1,ma=q.slice(ce+Ae);H(Dt,ma,q)}function H(m,g,C){switch(m){case"event":L=g||void 0;break;case"data":d=y===0?g:`${d}
67
+ ${g}`,y++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.test(g)?s(parseInt(g,10)):t(new sa(`Invalid \`retry\` value: "${g}"`,{type:"invalid-retry",value:g,line:C}));break;default:t(new sa(`Unknown field "${m.length>20?`${m.slice(0,20)}…`:m}"`,{type:"unknown-field",field:m,value:g,line:C}));break}}function le(){y>0&&e({id:h,event:L,data:d}),h=void 0,d="",y=0,L=void 0}function _(m={}){if(m.consume&&r.length>0){const g=r.join("");R(g,0,g.length)}c=!0,h=void 0,d="",y=0,L=void 0,r.length=0,o=0,N=!1}return{feed:k,reset:_}}function Ms(i,e,t){return t===100&&i.charCodeAt(e+1)===97&&i.charCodeAt(e+2)===116&&i.charCodeAt(e+3)===97&&i.charCodeAt(e+4)===58}function Cs(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 bs 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(Ts(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(Ts(this),t)}}function Tn(i){const e=globalThis.DOMException;return typeof e=="function"?new e(i,"SyntaxError"):new SyntaxError(i)}function na(i){return i instanceof Error?"errors"in i&&Array.isArray(i.errors)?i.errors.map(na).join(", "):"cause"in i&&i.cause instanceof Error?`${i}: ${na(i.cause)}`:i.message:`${i}`}function Ts(i){return{type:i.type,message:i.message,code:i.code,defaultPrevented:i.defaultPrevented,cancelable:i.cancelable,timeStamp:i.timeStamp}}var Ss=i=>{throw TypeError(i)},ra=(i,e,t)=>e.has(i)||Ss("Cannot "+t),x=(i,e,t)=>(ra(i,e,"read from private field"),t?t.call(i):e.get(i)),Y=(i,e,t)=>e.has(i)?Ss("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),O=(i,e,t,s)=>(ra(i,e,"write to private field"),e.set(i,t),t),be=(i,e,t)=>(ra(i,e,"access private method"),t),oe,Pe,He,Et,vt,ht,Ue,ut,ke,Qe,qe,We,dt,de,oa,la,ca,xs,ha,ua,gt,da,ga;class It extends EventTarget{constructor(e,t){var s,a;super(),Y(this,de),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Y(this,oe),Y(this,Pe),Y(this,He),Y(this,Et),Y(this,vt),Y(this,ht),Y(this,Ue),Y(this,ut,null),Y(this,ke),Y(this,Qe),Y(this,qe,null),Y(this,We,null),Y(this,dt,null),Y(this,la,async n=>{var r;x(this,Qe).reset();const{body:o,redirected:c,status:h,headers:d}=n;if(h===204){be(this,de,gt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?O(this,He,new URL(n.url)):O(this,He,void 0),h!==200){be(this,de,gt).call(this,`Non-200 status code (${h})`,h);return}if(!(d.get("content-type")||"").startsWith("text/event-stream")){be(this,de,gt).call(this,'Invalid content type, expected "text/event-stream"',h);return}if(x(this,oe)===this.CLOSED)return;O(this,oe,this.OPEN);const y=new Event("open");if((r=x(this,dt))==null||r.call(this,y),this.dispatchEvent(y),typeof o!="object"||!o||!("getReader"in o)){be(this,de,gt).call(this,"Invalid response body, expected a web ReadableStream",h),this.close();return}const L=new TextDecoder,N=o.getReader();let k=!0;do{const{done:T,value:P}=await N.read();P&&x(this,Qe).feed(L.decode(P,{stream:!T})),T&&(k=!1,x(this,Qe).reset(),be(this,de,da).call(this))}while(k)}),Y(this,ca,n=>{O(this,ke,void 0),!(n.name==="AbortError"||n.type==="aborted")&&be(this,de,da).call(this,na(n))}),Y(this,ha,n=>{typeof n.id=="string"&&O(this,ut,n.id);const r=new MessageEvent(n.event||"message",{data:n.data,origin:x(this,He)?x(this,He).origin:x(this,Pe).origin,lastEventId:n.id||""});x(this,We)&&(!n.event||n.event==="message")&&x(this,We).call(this,r),this.dispatchEvent(r)}),Y(this,ua,n=>{O(this,ht,n)}),Y(this,ga,()=>{O(this,Ue,void 0),x(this,oe)===this.CONNECTING&&be(this,de,oa).call(this)});try{if(e instanceof URL)O(this,Pe,e);else if(typeof e=="string")O(this,Pe,new URL(e,Sn()));else throw new Error("Invalid URL")}catch{throw Tn("An invalid or illegal string was specified")}O(this,Qe,bn({onEvent:x(this,ha),onRetry:x(this,ua)})),O(this,oe,this.CONNECTING),O(this,ht,3e3),O(this,vt,(s=t?.fetch)!=null?s:globalThis.fetch),O(this,Et,(a=t?.withCredentials)!=null?a:!1),be(this,de,oa).call(this)}get readyState(){return x(this,oe)}get url(){return x(this,Pe).href}get withCredentials(){return x(this,Et)}get onerror(){return x(this,qe)}set onerror(e){O(this,qe,e)}get onmessage(){return x(this,We)}set onmessage(e){O(this,We,e)}get onopen(){return x(this,dt)}set onopen(e){O(this,dt,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,Ue)&&clearTimeout(x(this,Ue)),x(this,oe)!==this.CLOSED&&(x(this,ke)&&x(this,ke).abort(),O(this,oe,this.CLOSED),O(this,ke,void 0))}}oe=new WeakMap,Pe=new WeakMap,He=new WeakMap,Et=new WeakMap,vt=new WeakMap,ht=new WeakMap,Ue=new WeakMap,ut=new WeakMap,ke=new WeakMap,Qe=new WeakMap,qe=new WeakMap,We=new WeakMap,dt=new WeakMap,de=new WeakSet,oa=function(){O(this,oe,this.CONNECTING),O(this,ke,new AbortController),x(this,vt)(x(this,Pe),be(this,de,xs).call(this)).then(x(this,la)).catch(x(this,ca))},la=new WeakMap,ca=new WeakMap,xs=function(){var i;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...x(this,ut)?{"Last-Event-ID":x(this,ut)}:void 0},cache:"no-store",signal:(i=x(this,ke))==null?void 0:i.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},ha=new WeakMap,ua=new WeakMap,gt=function(i,e){var t;x(this,oe)!==this.CLOSED&&O(this,oe,this.CLOSED);const s=new bs("error",{code:e,message:i});(t=x(this,qe))==null||t.call(this,s),this.dispatchEvent(s)},da=function(i,e){var t;if(x(this,oe)===this.CLOSED)return;O(this,oe,this.CONNECTING);const s=new bs("error",{code:e,message:i});(t=x(this,qe))==null||t.call(this,s),this.dispatchEvent(s),O(this,Ue,setTimeout(x(this,ga),x(this,ht)))},ga=new WeakMap,It.CONNECTING=0,It.OPEN=1,It.CLOSED=2;function Sn(){const i="document"in globalThis?globalThis.document:void 0;return i&&typeof i=="object"&&"baseURI"in i&&typeof i.baseURI=="string"?i.baseURI:void 0}class Le{static subscribedToClickEvent=!1;static attachAnalyticsScript(e){window._msq=window._msq||[];const s=e||"https://static.searchstax.com/studio-js/v4/js/studio-analytics.js";if(!document.querySelector(`script[src="${s}"]`)){var n=document.createElement("script");n.type="text/javascript",n.src=s;var r=document.getElementsByTagName("script")[0];r.parentNode&&r.parentNode.insertBefore(n,r)}}static msq=()=>typeof window<"u"&&window?._msq?window?._msq:[];static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language,model:e.model};return new Promise((s,a)=>{const n=["trackClick",t];t.key?this.msq().push(n,(function(r,o){JSON.stringify(r)===JSON.stringify(t)&&o?s():a()}).bind(this)):a()})}static trackAnswerLinkClick(e){const t={key:e.trackApiKey,question:e.searchTerm,session:e.session,href:e.href,language:e.language,model:e.model,answer:e.answer};return new Promise((s,a)=>{const n=["answerSourceClick",t];t.key?this.msq().push(n,(function(r,o){JSON.stringify(r)===JSON.stringify(t)&&o?s():a()}).bind(this)):a()})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,model:e.model,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches,language:e.language,model:e.model};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,latency:e.latencyVal,language:e.language,model:e.model,impressions:e.impressions,pageNo:1,shownHits:e.totalRelatredSearches,totalHits:e.totalRelatredSearches};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}static trackAnswerData(e){const t={session:e.session,key:e.trackApiKey,question:e.searchTerm,answer:e.answer,language:e.language,model:e.model,is_question:e.isQuestion+"",has_show_more:e.hasShowMore};setTimeout(()=>{t.key&&this.msq().push(["trackquestionanswer",t])},0)}static trackShowMoreClick(e){const t={session:e.session,key:e.trackApiKey,language:e.language,model:e.model,question:e.searchTerm};setTimeout(()=>{t.key&&this.msq().push(["answershowmoreclick",t])},0)}static trackFeedback(e){setTimeout(()=>{this.msq().push(["trackSearchSatisfaction",{key:e.trackApiKey,email:e.email,score:e.rating,comments:e.feedback,language:e.language,model:e.model}])},0)}}class xn{cachedQuery="";cachedQueryOR="";cachedQueryTabs="";cachedANDFacets="";cachedORFacets="";cachedTabsFacets="";url="";relatedSearches="";suggester="";authHeader;authHeaderRelated;trackApiKey="";session="";searchAuthType;searchAuth="";controllerSearch;signalSearch;controllerSuggest;signalSuggest;_authToken="";resolveFn;dataLayer;constructor(e,t){this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json"),this._authToken=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`,this.authHeader.append("Authorization",this._authToken),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let s=[];if(!t)e.forEach(function(a){const n=a.name+':"'+a.value+'"';s=s.concat("fq="+decodeURIComponent(n).replace(" "," "))});else{const a={};e.forEach(function(r){const o=r.name+":"+r.value,c=decodeURIComponent(o).replace(" "," ").split(":");a[c[0]]?a[c[0]].push(c[1]):a[c[0]]=[c[1]]});let n="";for(const r in a)if(Object.prototype.hasOwnProperty.call(a,r)){const o=a[r],c=r;for(const h of o)n+=n===""?` ${c}:"${h}"`:` OR ${c}:"${h}"`}s=s.concat("fq="+n.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 n=new Headers;n.append("Accept","application/json"),n.append("Authorization",s),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:n,credentials:"same-origin"}).then(r=>r.json()).then(r=>{a(r)})}cacheFacets(e,t){return new Promise(s=>{if(this.resolveFn=s,e==="or"||e==="showUnavailable"){const a=this.dataLayer.searchObject.facets.filter(n=>n.type==="tabs"||n.type==="and");if(this.cachedQueryOR===this.dataLayer.searchObject.query&&this.dataLayer.searchObject.facets?.length>0&&a.length===0){this.resolveFn();return}else this.cachedORFacets=JSON.stringify(this.dataLayer.searchObject.facets.filter(n=>n.type==="or")),this.cachedQueryOR=this.dataLayer.searchObject.query,this.cacheFacetsCallback(void 0,e)}else if(e==="tabs")if(this.cachedTabsFacets&&this.cachedQueryTabs===this.dataLayer.searchObject.query&&this.dataLayer.searchObject.facets?.length>0){this.resolveFn();return}else this.cachedTabsFacets=JSON.stringify(this.dataLayer.searchObject.facets.filter(a=>a.type==="tabs")),this.cachedQueryTabs=this.dataLayer.searchObject.query,this.cacheFacetsCallback(void 0,e);else e?this.resolveFn():(this.cachedANDFacets=JSON.stringify(this.dataLayer.searchObject.facets.filter(a=>a.type==="and")),this.cachedORFacets=JSON.stringify(this.dataLayer.searchObject.facets.filter(a=>a.type==="or"||a.type==="showUnavailable")),this.cachedTabsFacets=JSON.stringify(this.dataLayer.searchObject.facets.filter(a=>a.type==="tabs")),this.cachedQueryOR=this.dataLayer.searchObject.query,this.cachedQueryTabs=this.dataLayer.searchObject.query,t?.includes("tabs")&&this.search({query:this.cachedQueryTabs,itemsPerPage:void 0,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps,location:this.dataLayer.searchObject.location,model:this.dataLayer.model},this.cacheFacetsCallback.bind(this),!0,!1,"tabs"),(t?.includes("or")||t?.includes("showUnavailable"))&&this.search({query:this.cachedQueryTabs,itemsPerPage:void 0,page:1,order:"",facets:[...this.dataLayer.searchObject.facets.filter(a=>a.type==="and"||a.type==="tabs")],additionalProps:this.dataLayer.searchObject.additionalProps,location:this.dataLayer.searchObject.location,model:this.dataLayer.model},this.cacheFacetsCallback.bind(this),!0,!1,"or"),this.resolveFn())})}cacheFacetsCallback(e,t){let s=this.dataLayer.searchFacets??[];e&&(s=ct.extractFacets(e)),t==="or"?this.dataLayer.setSearchFacetsCachedor(s):t==="tabs"?this.dataLayer.setSearchFacetsCachedtabs(s):this.dataLayer.setSearchFacetsCached(s),this.resolveFn&&this.resolveFn()}search(e,t,s=!1,a=!1,n){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=this.url+this.generateQueryParams(e,a),o={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};s&&delete o.signal,fetch(r,o).then(c=>c.json()).then(c=>{this.dataLayer.setLoading(!1),t(c,n)}).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 n=e.itemsPerPage!==void 0?`&rows=${e.itemsPerPage}`:"",r=new Proxy(new URLSearchParams(window?.location.search??""),{get:(h,d)=>h.get(d)??""}),o=r.languageVariant?"&fq=_language:"+r.languageVariant:"",c=e.model??this.dataLayer.model;return"?q="+encodeURIComponent(e.query.trim())+"&start="+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+n+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!t}`+(c?`&model=${c}`:"")+"&language="+this.dataLayer.language+o}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.searchObject.page!==1)return;const s=this.dataLayer;s.setAnswerLoading(!1),s.setAnswerErrorMessage(""),s.setAnswerError(!1);const a=new It(this.dataLayer.questionURL+this.generateQueryParams(this.dataLayer.searchObject),{fetch:(n,r)=>fetch(n,{...r,headers:{...r?.headers,Authorization:this._authToken}})});return a.onmessage=n=>{if(n.data===Be.question||n.data===Be.notQuestion){n.data===Be.question?(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setIsQuestion(!0)):(s.setAnswerLoading(!1),this.dataLayer.setIsQuestion(!1)),s.setAnswerData("");return}if(n.data===Be.close){Le.trackAnswerData({...s.parsedData.trackingData,answer:s.$answer.getValue(),isQuestion:this.dataLayer.isQuestion,hasShowMore:this.dataLayer.parsedData.shouldShowAnswerLoadMore}),s.setAnswerLoading(!1),a.close();return}if(n.data.indexOf("[!CAUTION]")!==-1){s.setAnswerError(!0),s.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),a.close();return}if(n.data.indexOf("[comment]: <> ({")!==-1)try{const r=n.data.split("[comment]: <> ({");if(r.length<2){t(n.data);return}const o=r[1].split("})");if(o.length<2){t(n.data);return}const c=o[0],h=JSON.parse("{"+c+"}");this.dataLayer.answerWidgetShowMoreLimit=h.displayShowMoreAfter,h.showMoreEnabled||(this.dataLayer.answerWidgetShowMoreLimit=1e17);const d=o.slice(1).join("})");t(d)}catch{t(n.data)}else t(n.data)},a.addEventListener("error",n=>{(n.code===401||n.code===500)&&(s.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),s.setAnswerError(!0))}),a.onerror=()=>{s.setAnswerLoading(!1),a.close()},a}suggest(e,t,s){if(this.controllerSuggest&&this.controllerSuggest.abort(),this.suggester.trim()==="")return;this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const a=this.suggester+"?q="+e.trim()+this.toQueryString(s)+"&language="+this.dataLayer.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(n=>n.json()).then(n=>{t(n)}).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 kn=Object.prototype.toString,Ye=Array.isArray||function(e){return kn.call(e)==="[object Array]"};function fa(i){return typeof i=="function"}function An(i){return Ye(i)?"array":typeof i}function pa(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function ks(i,e){return i!=null&&typeof i=="object"&&e in i}function En(i,e){return i!=null&&typeof i!="object"&&i.hasOwnProperty&&i.hasOwnProperty(e)}var vn=RegExp.prototype.test;function In(i,e){return vn.call(i,e)}var Dn=/\S/;function jn(i){return!In(Dn,i)}var Rn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function Nn(i){return String(i).replace(/[&<>"'`=\/]/g,function(t){return Rn[t]})}var On=/\s*/,Pn=/\s+/,As=/\s*=/,_n=/\s*\}/,Fn=/#|\^|\/|>|\{|&|=|!/;function zn(i,e){if(!i)return[];var t=!1,s=[],a=[],n=[],r=!1,o=!1,c="",h=0;function d(){if(r&&!o)for(;n.length;)delete a[n.pop()];else n=[];r=!1,o=!1}var y,L,N;function k(I){if(typeof I=="string"&&(I=I.split(Pn,2)),!Ye(I)||I.length!==2)throw new Error("Invalid tags: "+I);y=new RegExp(pa(I[0])+"\\s*"),L=new RegExp("\\s*"+pa(I[1])),N=new RegExp("\\s*"+pa("}"+I[1]))}k(e||E.tags);for(var T=new ft(i),P,R,H,le,_,m;!T.eos();){if(P=T.pos,H=T.scanUntil(y),H)for(var g=0,C=H.length;g<C;++g)le=H.charAt(g),jn(le)?(n.push(a.length),c+=le):(o=!0,t=!0,c+=" "),a.push(["text",le,P,P+1]),P+=1,le===`
68
+ `&&(d(),c="",h=0,t=!1);if(!T.scan(y))break;if(r=!0,R=T.scan(Fn)||"name",T.scan(On),R==="="?(H=T.scanUntil(As),T.scan(As),T.scanUntil(L)):R==="{"?(H=T.scanUntil(N),T.scan(_n),T.scanUntil(L),R="&"):H=T.scanUntil(L),!T.scan(L))throw new Error("Unclosed tag at "+T.pos);if(R==">"?_=[R,H,P,T.pos,c,h,t]:_=[R,H,P,T.pos],h++,a.push(_),R==="#"||R==="^")s.push(_);else if(R==="/"){if(m=s.pop(),!m)throw new Error('Unopened section "'+H+'" at '+P);if(m[1]!==H)throw new Error('Unclosed section "'+m[1]+'" at '+P)}else R==="name"||R==="{"||R==="&"?o=!0:R==="="&&k(H)}if(d(),m=s.pop(),m)throw new Error('Unclosed section "'+m[1]+'" at '+T.pos);return Vn($n(a))}function $n(i){for(var e=[],t,s,a=0,n=i.length;a<n;++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 Vn(i){for(var e=[],t=e,s=[],a,n,r=0,o=i.length;r<o;++r)switch(a=i[r],a[0]){case"#":case"^":t.push(a),s.push(a),t=a[4]=[];break;case"/":n=s.pop(),n[5]=a[2],t=s.length>0?s[s.length-1][4]:e;break;default:t.push(a)}return e}function ft(i){this.string=i,this.tail=i,this.pos=0}ft.prototype.eos=function(){return this.tail===""},ft.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return"";var s=t[0];return this.tail=this.tail.substring(s.length),this.pos+=s.length,s},ft.prototype.scanUntil=function(e){var t=this.tail.search(e),s;switch(t){case-1:s=this.tail,this.tail="";break;case 0:s="";break;default:s=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=s.length,s};function Je(i,e){this.view=i,this.cache={".":this.view},this.parent=e}Je.prototype.push=function(e){return new Je(e,this)},Je.prototype.lookup=function(e){var t=this.cache,s;if(t.hasOwnProperty(e))s=t[e];else{for(var a=this,n,r,o,c=!1;a;){if(e.indexOf(".")>0)for(n=a.view,r=e.split("."),o=0;n!=null&&o<r.length;)o===r.length-1&&(c=ks(n,r[o])||En(n,r[o])),n=n[r[o++]];else n=a.view[e],c=ks(a.view,e);if(c){s=n;break}a=a.parent}t[e]=s}return fa(s)&&(s=s.call(this.view)),s};function ne(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}ne.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()},ne.prototype.parse=function(e,t){var s=this.templateCache,a=e+":"+(t||E.tags).join(":"),n=typeof s<"u",r=n?s.get(a):void 0;return r==null&&(r=zn(e,t),n&&s.set(a,r)),r},ne.prototype.render=function(e,t,s,a){var n=this.getConfigTags(a),r=this.parse(e,n),o=t instanceof Je?t:new Je(t,void 0);return this.renderTokens(r,o,s,e,a)},ne.prototype.renderTokens=function(e,t,s,a,n){for(var r="",o,c,h,d=0,y=e.length;d<y;++d)h=void 0,o=e[d],c=o[0],c==="#"?h=this.renderSection(o,t,s,a,n):c==="^"?h=this.renderInverted(o,t,s,a,n):c===">"?h=this.renderPartial(o,t,s,n):c==="&"?h=this.unescapedValue(o,t):c==="name"?h=this.escapedValue(o,t,n):c==="text"&&(h=this.rawValue(o)),h!==void 0&&(r+=h);return r},ne.prototype.renderSection=function(e,t,s,a,n){var r=this,o="",c=t.lookup(e[1]);function h(L){return r.render(L,t,s,n)}if(c){if(Ye(c))for(var d=0,y=c.length;d<y;++d)o+=this.renderTokens(e[4],t.push(c[d]),s,a,n);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")o+=this.renderTokens(e[4],t.push(c),s,a,n);else if(fa(c)){if(typeof a!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(t.view,a.slice(e[3],e[5]),h),c!=null&&(o+=c)}else o+=this.renderTokens(e[4],t,s,a,n);return o}},ne.prototype.renderInverted=function(e,t,s,a,n){var r=t.lookup(e[1]);if(!r||Ye(r)&&r.length===0)return this.renderTokens(e[4],t,s,a,n)},ne.prototype.indentPartial=function(e,t,s){for(var a=t.replace(/[^ \t]/g,""),n=e.split(`
69
+ `),r=0;r<n.length;r++)n[r].length&&(r>0||!s)&&(n[r]=a+n[r]);return n.join(`
70
+ `)},ne.prototype.renderPartial=function(e,t,s,a){if(s){var n=this.getConfigTags(a),r=fa(s)?s(e[1]):s[e[1]];if(r!=null){var o=e[6],c=e[5],h=e[4],d=r;c==0&&h&&(d=this.indentPartial(r,h,o));var y=this.parse(d,n);return this.renderTokens(y,t,s,d,a)}}},ne.prototype.unescapedValue=function(e,t){var s=t.lookup(e[1]);if(s!=null)return s},ne.prototype.escapedValue=function(e,t,s){var a=this.getConfigEscape(s)||E.escape,n=t.lookup(e[1]);if(n!=null)return typeof n=="number"&&a===E.escape?String(n):a(n)},ne.prototype.rawValue=function(e){return e[1]},ne.prototype.getConfigTags=function(e){return Ye(e)?e:e&&typeof e=="object"?e.tags:void 0},ne.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!Ye(e))return e.escape};var E={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){pt.templateCache=i},get templateCache(){return pt.templateCache}},pt=new ne;E.clearCache=function(){return pt.clearCache()},E.parse=function(e,t){return pt.parse(e,t)},E.render=function(e,t,s,a){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+An(e)+'" was given as the first argument for mustache#render(template, view, partials)');return pt.render(e,t,s,a)},E.escape=Nn,E.Scanner=ft,E.Context=Je,E.Writer=ne;const Bn={main:{template:`
71
71
  {{#shouldShowAnswer}}
72
72
  <div class="searchstax-answer-wrap">
73
73
  <div class="searchstax-answer-icon"></div>
@@ -104,7 +104,7 @@ ${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
104
104
  </div>
105
105
  </div>
106
106
  {{/shouldShowAnswer}}
107
- `}},jn={mainTemplate:{template:`
107
+ `}},Hn={mainTemplate:{template:`
108
108
  {{#hasExternalPromotions}}
109
109
  <div class="searchstax-external-promotions-container" id="searchstax-external-promotions-container" data-test-id="searchstax-external-promotions-container">
110
110
  External promotions go here
@@ -130,7 +130,7 @@ ${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
130
130
  </p>
131
131
  {{/url}}
132
132
  </div>
133
- `}},Rn={mainTemplateDesktop:{template:`
133
+ `}},Un={mainTemplateDesktop:{template:`
134
134
  {{#hasResultsOrExternalPromotions}}
135
135
  <div class="searchstax-facets-container-desktop"></div>
136
136
  {{/hasResultsOrExternalPromotions}}
@@ -188,7 +188,7 @@ ${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
188
188
  <div class="searchstax-facets-pill-label">{{value}} ({{count}})</div>
189
189
  <div class="searchstax-facets-pill-icon-close"></div>
190
190
  </div>
191
- `,containerClass:"searchstax-facets-pill-facets"}},Nn={mainTemplate:{template:`
191
+ `,containerClass:"searchstax-facets-pill-facets"}},Qn={mainTemplate:{template:`
192
192
  {{#results.length}}
193
193
  <div class="searchstax-pagination-container" data-test-id="searchstax-pagination-container">
194
194
  <div class="searchstax-pagination-content">
@@ -206,7 +206,7 @@ ${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
206
206
  <a class="searchstax-pagination-load-more" data-test-id="searchstax-pagination-load-more" tabindex="0">Show More</a>
207
207
  {{/isLastPage}}
208
208
  {{/results.length}}
209
- `,loadMoreButtonClass:"searchstax-pagination-load-more"}},Pn={main:{template:`
209
+ `,loadMoreButtonClass:"searchstax-pagination-load-more"}},qn={main:{template:`
210
210
  {{#hasRelatedSearches}}
211
211
  <div class="searchstax-related-searches-container" data-test-id="searchstax-related-searches-container" id="searchstax-related-searches-container">
212
212
  Related searches: <span id="searchstax-related-searches"></span>
@@ -221,7 +221,7 @@ ${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
221
221
  <span role="link" class="searchstax-related-search searchstax-related-search-item" data-test-id="searchstax-related-search-item" aria-label="Related search: {{related_search}}" tabindex="0">
222
222
  {{ related_search }}{{^last}}<span>,</span>{{/last}}
223
223
  </span>
224
- `,relatedSearchContainerClass:"searchstax-related-search-item"}},On={main:{template:`
224
+ `,relatedSearchContainerClass:"searchstax-related-search-item"}},Wn={main:{template:`
225
225
  {{#searchExecuted}}
226
226
  <a href="#searchstax-search-results" data-test-id="searchstax-skip" class="searchstax-skip">Skip to results section</a>
227
227
  <h4 class="searchstax-feedback-container" data-test-id="searchstax-feedback-container">
@@ -235,7 +235,7 @@ ${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
235
235
  {{/hasResults}}
236
236
  </h4>
237
237
  {{/searchExecuted}}
238
- `,originalQueryClass:"searchstax-feedback-original-query"}},_n={mainTemplate:{template:`
238
+ `,originalQueryClass:"searchstax-feedback-original-query"}},Yn={mainTemplate:{template:`
239
239
  <div class="searchstax-search-input-container searchstax-search-input-container-new {{#locationEnabled}}searchstax-alternative-render{{/locationEnabled}}">
240
240
  <div class="searchstax-search-input-wrapper">
241
241
  <input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." aria-label="Search" />
@@ -247,7 +247,7 @@ ${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
247
247
  </div>
248
248
  `,searchInputId:"searchstax-search-input"},autosuggestItemTemplate:{template:`
249
249
  <div class="searchstax-autosuggest-item-term-container">{{{term}}}</div>
250
- `}},Fn={mainTemplate:{template:`
250
+ `}},Jn={mainTemplate:{template:`
251
251
  <div class="searchstax-location-input-container" data-test-id="searchstax-location-input-container">
252
252
  <div class="searchstax-location-input-wrapper">
253
253
  <span class="searchstax-location-input-label">NEAR</span>
@@ -265,7 +265,7 @@ ${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
265
265
  {{/shouldShowLocationDistanceDropdown}}
266
266
  </div>
267
267
  </div>
268
- `,locationInputId:"searchstax-location-input",radiusInputId:"searchstax-location-radius-select",currentLocationActionButtonId:"searchstax-location-get-current-location"}},zn={mainTemplate:{template:`
268
+ `,locationInputId:"searchstax-location-input",radiusInputId:"searchstax-location-radius-select",currentLocationActionButtonId:"searchstax-location-get-current-location"}},Gn={mainTemplate:{template:`
269
269
  <section aria-label="search results container" tabindex="0">
270
270
  <div class="searchstax-search-results-container" id="searchstax-search-results-container" data-test-id="searchstax-search-results-container">
271
271
  <div class="searchstax-search-results" id="searchstax-search-results"></div>
@@ -337,7 +337,7 @@ ${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
337
337
  </ul>
338
338
  </div>
339
339
  {{/searchExecuted}}
340
- `}},$n={main:{template:`
340
+ `}},Kn={main:{template:`
341
341
  {{#searchExecuted}}
342
342
  {{#hasResultsOrExternalPromotions}}
343
343
  {{#sortOptions.length}}
@@ -437,4 +437,4 @@ ${g}`,L++;break;case"id":h=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.t
437
437
 
438
438
  </div>
439
439
  </div>
440
- `,thumbsUpButtonClass:"searchstax-lightweight-widget-thumbs-up",thumbsDownButtonClass:"searchstax-lightweight-widget-thumbs-down"}};class w{static answer=Dn;static externalPromotions=jn;static facets=Rn;static pagination=Nn;static relatedSearches=Pn;static searchFeedback=On;static searchInput=_n;static location=Fn;static searchResults=zn;static sorting=$n;static feedback=Z}class Bn{dataLayer;config;containerId;externalPromotionsContainerId;searchExternalPromotionsMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.externalPromotionsContainerId=this.config.templates?.mainTemplate?.externalPromotionsContainerId||w.externalPromotions.mainTemplate.externalPromotionsContainerId,typeof document<"u"&&(this.searchExternalPromotionsMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}initializeSubscriptions(){this.dataLayer.$searchExternalPromotions.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data,externalPromotions:this.dataLayer.parsedData.externalPromotions};return this.dataLayer.setExternalPromotionsData(e),e}addExternalSearch(e){const t=typeof document<"u"?document?.getElementById(this.externalPromotionsContainerId):null;if(t){const a=this.config?.templates?.externalPromotion?.template||w.externalPromotions.externalPromotion?.template;if(typeof document<"u"){const s=document?.createElement("div");s.classList.add("searchstax-external-promotion"),s.addEventListener("click",n=>{this.trackClick(e,n)}),s.innerHTML=k.render(a,e),t.appendChild(s)}}}trackClick(e,t){t.stopPropagation(),t.preventDefault(),window?.open(e.url,"_blank")}renderMainTemplate(e){const t=this.config?.templates?.mainTemplate?.template||w.externalPromotions.mainTemplate?.template;if(this.dataLayer.renderingEngine===F.mustache){this.searchExternalPromotionsMainContainer.innerHTML=k.render(t,e);const a=typeof document<"u"?document?.getElementById(this.externalPromotionsContainerId):null;a&&(a.innerHTML="");for(const s of e.externalPromotions)this.addExternalSearch(s)}}}class J{static addAccessibilityNotificationContainerToBody(){if(!document.getElementById("searchAccessibilityContainer")){const t=document.createElement("div");t.setAttribute("aria-live","polite"),t.setAttribute("id","searchAccessibilityContainer"),document.body.appendChild(t)}}static setAccessibilityText(e,t,a){this.addAccessibilityNotificationContainerToBody();const s=a??"searchAccessibility",n=document.getElementById(s);n&&n.remove();const r=document.createElement("span");r.setAttribute("id",s),r.innerHTML=e;const o=document.getElementById("searchAccessibilityContainer");o&&setTimeout(()=>{o.appendChild(r)},t??100)}}class Vn{dataLayer;config;containerId;routerHelper;cachedPhrase="";cachedANDFacets="";isCached=!1;overlayOpened=!1;facetPaginationStep;facetPaginationStepMobile;searchFacetsMainContainer=null;searchFacetsMobileContainer=null;searchFacetsDesktopContainer=null;facetLimits={};facetLimitsMobile={};deactivatedFacets={};focusedElement=null;cachedData=null;cacheFacets;constructor(e,t){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.routerHelper=e.routerHelper,this.cacheFacets=t,this.facetPaginationStep=this.config.itemsPerPageDesktop,this.facetPaginationStepMobile=this.config.itemsPerPageMobile,typeof document<"u"&&(this.searchFacetsMainContainer=document?.getElementById(this.containerId)),this.needCache&&t(this.config.facetingType==="tabs"),this.initializeSubscriptions()}get needCache(){return this.config.facetingType==="showUnavailable"||this.config.facetingType==="or"||this.config.facetingType==="tabs"}get needDisabling(){return this.config.facetingType==="showUnavailable"}initializeSubscriptions(){this.needCache&&(this.dataLayer.$searchFacetsCached.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$searchFacetsCachedTabs.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())})),this.dataLayer.$searchResults.subscribe(e=>{e&&(this.needCache&&!this.isCached&&(this.dataLayer.searchFacets&&!this.dataLayer.searchFacetsCached&&this.dataLayer.setSearchFacetsCached(this.dataLayer.searchFacets),this.cacheFacets(this.config.facetingType==="tabs")),this.renderMainTemplate(this.generateTemplateData()))}),this.dataLayer.$searchObject.subscribe(e=>{this.cachedPhrase!==e.query||this.cachedANDFacets!==this.dataLayer.parsedData.cachedANDFacets?(this.cachedANDFacets=this.dataLayer.parsedData.cachedANDFacets,this.cachedPhrase=e.query,this.isCached=!1):this.isCached=!0})}extractFacetValue(e){return{type:this.config.facetingType,name:e.parentName,value:e.value}}applyFacetLimits(e,t){const a=t?this.facetPaginationStepMobile:this.facetPaginationStep,s=t?this.facetLimits:this.facetLimitsMobile;return e.forEach(n=>{s[n.name]||(s[n.name]=a)}),e.map(n=>({...n,values:n.values.slice(0,s[n.name]),showingAllFacets:n.values.length<=s[n.name],hasMoreFacets:n.values.length>a}))}generateTemplateData(e){if(this.generateSelectedFacetsData(),this.dataLayer.searchFacets){let t=this.dataLayer.searchFacets;this.config.hooks?.beforeFacetsRender&&(t=this.config.hooks.beforeFacetsRender(t)),this.needCache&&this.dataLayer.searchFacetsCached&&(t=this.dataLayer.searchFacetsCached,this.config.facetingType==="tabs"&&this.dataLayer.searchFacetsCachedTabs&&(t=this.dataLayer.searchFacetsCachedTabs),this.needDisabling&&(t=t.map(s=>{const n=this.dataLayer.searchFacets?.find(r=>r.name===s.name);return n?{...s,values:s.values.map(o=>{const c=n.values.find(h=>o.type==="range"?!1:o.type==="checkbox"?h.value===o.value:!1);return{...o,disabled:!c,isMobile:e}})}:{...s,values:s.values.map(o=>({...o,disabled:!0})),isMobile:e}}))),this.config.specificFacets&&(t=t.filter(s=>this.config.specificFacets?.includes(s.name)));const a={facets:this.applyFacetLimits(t,e),...this.dataLayer.parsedData.data,isMobile:e};return this.dataLayer.setFacetsTemplateData(a),a}else{const t={facets:[],...this.dataLayer.parsedData.data,isMobile:e};return this.dataLayer.setFacetsTemplateData(t),t}}createFacetItem(e,t,a){if(typeof document<"u"){const s=document?.createElement("div");s.classList.add("searchstax-facet-container"),this.deactivatedFacets[e.name]||s.classList.add("active");const n=this.config?.templates?.facetItemContainerTemplate?.template||w.facets.facetItemContainerTemplate?.template;s.innerHTML=k.render(n,e),t.appendChild(s);const r=s.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerClass||w.facets.facetItemContainerTemplate?.facetListTitleContainerClass));r?.addEventListener("click",()=>{s.classList.toggle("active");const c=s.classList.contains("active"),h=r.querySelector(".searchstax-facet-title");h&&h.setAttribute("aria-expanded",String(c))}),r?.querySelector("."+this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerInner)?.addEventListener("keydown",c=>{if(c.code==="Enter"||c.code==="Space"){c.preventDefault(),s.classList.toggle("active");const h=s.classList.contains("active"),d=r.querySelector(".searchstax-facet-title");d&&d.setAttribute("aria-expanded",String(h))}});const o=s.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListContainerClass||w.facets.facetItemContainerTemplate?.facetListContainerClass));o&&(e.values.forEach(c=>{this.createFacetListItem(c,o,e.name)}),e.hasMoreFacets&&this.createHasMoreComponent(e,o,a))}}isChecked(e){return!!this.dataLayer.searchObject.facets?.find(t=>oe.deepEqual(t,this.extractFacetValue(e)))}createFacetListItem(e,t,a){if(typeof document<"u"){const s=document?.createElement("div");s.classList.add("searchstax-facet-value-container"),e.disabled&&s.classList.add("searchstax-facet-value-disabled");const n=this.isChecked(e),r=this.config?.templates?.facetItemTemplate?.template||w.facets.facetItemTemplate?.template;s.innerHTML=k.render(r,{...e,isChecked:n});let o=w.facets.facetItemTemplate?.checkTriggerClasses;o=this.config?.templates?.facetItemTemplate?.checkTriggerClasses||o,o.forEach(h=>{s.querySelector("."+h)?.addEventListener("click",L=>{this.onFacetSelect(L,e,s)})});const c=s.querySelector("."+(this.config?.templates?.facetItemTemplate?.inputCheckboxClass||w.facets.facetItemTemplate?.inputCheckboxClass));c?.addEventListener("click",h=>{this.onFacetSelect(h,e,s,!0)}),c&&c?.setAttribute("data-test-value",`${encodeURIComponent(a)}:&quot;${encodeURIComponent(e.value)}&quot;`),t.appendChild(s)}}onFacetSelect=(e,t,a,s,n)=>{if(e.stopPropagation(),!t.disabled){const r=a.querySelector("input");let o=s?r.checked:!r.checked;n!==void 0&&(o=!n),r.checked=o;const c=this.dataLayer.searchObject;let h=[...c.facets];const d=this.extractFacetValue(t);o?h.find(m=>oe.deepEqual(m,d)?m:!1)||(this.config.facetingType==="tabs"&&(h=h.filter(m=>m.name!==d.name)),h.push(d)):h=h.filter(L=>!oe.deepEqual(L,d)),setTimeout(()=>{this.dataLayer.setSearchObject({...c,facets:h,page:1}),this.config.facetingType==="tabs"&&this.renderMainTemplate(this.generateTemplateData(),!0)},0)}};createHasMoreComponent(e,t,a){if(typeof document<"u"){const s=document?.createElement("div");s.classList.add("searchstax-facet-show-more-container");const n=this.config?.templates?.showMoreButtonContainerTemplate?.template||w.facets.showMoreButtonContainerTemplate?.template;s.innerHTML=k.render(n,{...e,focusId:`moreLess${e?.values?.[0]?.value}`});const r=s.querySelector("."+(this.config?.templates?.showMoreButtonContainerTemplate?.showMoreButtonClass||w.facets.showMoreButtonContainerTemplate?.showMoreButtonClass));r&&(this.attachOnclickToShowMore(e,r,a),t&&t.appendChild(r))}}attachOnclickToShowMore(e,t,a){t.addEventListener("click",s=>{this.onShowMoreLessClick(s,e,a)}),t.addEventListener("keydown",s=>{s.code==="Space"&&s.preventDefault()}),t.addEventListener("keyup",s=>{(s.code==="Space"||s.code==="Enter")&&(s.preventDefault(),this.onShowMoreLessClick(s,e,a))})}onShowMoreLessClick(e,t,a){e.preventDefault();const s=a?this.facetPaginationStepMobile:this.facetPaginationStep,n=a?this.facetLimits:this.facetLimitsMobile;n[t.name]===void 0?n[t.name]=s*2:n[t.name]<=t.values.length?(J.setAccessibilityText(`More Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),n[t.name]=n[t.name]+s):(J.setAccessibilityText(`Less Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),n[t.name]=s),this.generateTemplateData(a),this.renderMainTemplate(this.generateTemplateData())}renderMainTemplate(e,t){if(e&&(!oe.deepEqual(this.cachedData??{},e)||t)){this.cachedData=e;const a=this.config?.templates?.mainTemplateDesktop?.template||w.facets.mainTemplateDesktop?.template;if(this.dataLayer.renderingEngine===F.mustache&&this.searchFacetsMainContainer){const s=document.activeElement;s instanceof HTMLInputElement&&s.type==="checkbox"||s?.classList.contains("searchstax-facet-show-more-button")||s?.classList.contains("searchstax-facet-show-less-button")?this.focusedElement=s:this.focusedElement=null,this.searchFacetsMainContainer.innerHTML=k.render(a,{...e});const n=this.searchFacetsMainContainer?.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.facetsContainerClass||w.facets.mainTemplateDesktop.facetsContainerClass));if(n){n.innerHTML="";for(const r of e.facets)this.createFacetItem(r,n);if(this.searchFacetsMainContainer){const r=this.searchFacetsMainContainer.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.selectedFacetsContainerClass||w.facets.mainTemplateDesktop.selectedFacetsContainerClass));r&&(this.createSelectedFacetsComponents(r),this.createClearFacetsComponents(r))}if(this.focusedElement){if(this.focusedElement.classList.contains("searchstax-facet-show-more-button")||this.focusedElement.classList.contains("searchstax-facet-show-less-button")){const c=this.focusedElement.getAttribute("data-focus"),h=this.searchFacetsMainContainer.querySelector(`[data-focus="${c}"]`);h instanceof HTMLElement&&h.focus(),this.focusedElement=null;return}const r=this.focusedElement.getAttribute("data-test-value"),o=this.searchFacetsMainContainer.querySelector(`[data-test-value="${r}"]`);o instanceof HTMLInputElement&&o.focus(),this.focusedElement=null}}}setTimeout(()=>{document.querySelectorAll(".searchstax-facet-title").forEach(n=>{n.setAttribute("aria-expanded",String(!0)),n.setAttribute("tabindex","0"),n.setAttribute("role","button")})},100),this.renderMobileTemplate(this.generateTemplateData(!0))}else this.generateSelectedFacetsData()}generateSelectedFacetsData(){const e=[],t=this.dataLayer.searchObject.facets;for(const a of t){const s=decodeURIComponent(a.name),n=decodeURIComponent(a.value);if(this.dataLayer.searchFacets){const o=(this.needCache?this.dataLayer.searchFacetsCached:this.dataLayer.searchFacets)?.find(c=>c.name===s);if(o){const c=o.values.find(h=>h.type==="range"?!1:h.type==="checkbox"?`"${h.value}"`==`"${n}"`:!1);c&&e.push(c)}}}this.dataLayer.setSelectedFacetsTemplateData(e)}createSelectedFacetsComponents(e){this.generateSelectedFacetsData(),this.dataLayer.selectedFacetsTemplateData?.forEach(t=>{this.createSelectedFacetsComponent(e,t)})}createClearFacetsComponents(e){if(typeof document<"u"){const t=this.dataLayer.searchObject,a=this.config?.templates?.clearFacetsTemplate?.template||w.facets.clearFacetsTemplate?.template,s=document?.createElement("div");s.innerHTML=k.render(a,{shouldShow:t.facets.length>0});const n=s.querySelector("."+(this.config?.templates?.clearFacetsTemplate?.containerClass||w.facets.clearFacetsTemplate?.containerClass));n&&(n.addEventListener("click",()=>{this.removeSelectedFacets()}),n.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.removeSelectedFacets()}),e.appendChild(n))}}createSelectedFacetsComponent(e,t){if(typeof document<"u"){const a=this.config?.templates?.selectedFacetsTemplate?.template||w.facets.selectedFacetsTemplate?.template,s=document?.createElement("div");s.innerHTML=k.render(a,t);const n=s.querySelector("."+(this.config?.templates?.selectedFacetsTemplate?.containerClass||w.facets.selectedFacetsTemplate?.containerClass));n&&(n.addEventListener("click",()=>{this.unselectFacet(t)}),n.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.unselectFacet(t)}),e.appendChild(n))}}unselectFacet(e){const t=this.dataLayer.searchObject;let a=[...t.facets];e.type==="checkbox"&&(a=a.filter(s=>JSON.stringify(s)!==JSON.stringify(this.extractFacetValue(e)))),setTimeout(()=>{this.dataLayer.setSearchObject({...t,facets:a}),this.generateSelectedFacetsData()},0)}removeSelectedFacets(){const e=this.dataLayer.searchObject;this.dataLayer.setSearchObject({...e,facets:[]})}createFilterByComponent(e){if(typeof document<"u"){const t=this.config?.templates?.filterByTemplate?.template||w.facets.filterByTemplate?.template,a=document?.createElement("div");a.innerHTML=k.render(t,{});const s=a.querySelector("."+(this.config?.templates?.filterByTemplate?.containerClass||w.facets.filterByTemplate?.containerClass));s&&(e.prepend(s),s.addEventListener("click",this.openOverlay.bind(this)),s.addEventListener("keyup",n=>{(n.code==="Space"||n.code==="Enter")&&this.openOverlay()}))}}openOverlay(){J.setAccessibilityText("Facet overlay opened. Tab to select facets."),this.overlayOpened=!0,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.add("searchstax-show"))}closeOverlay(){J.setAccessibilityText("Facet overlay closed"),this.overlayOpened=!1,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.remove("searchstax-show"))}renderMobileTemplate(e){if(e&&typeof document<"u"){const t=document?.createElement("div");t.classList.add("searchstax-facets-container-mobile");const a=this.config?.templates?.mainTemplateMobile?.template||w.facets.mainTemplateMobile?.template;if(this.dataLayer.renderingEngine===F.mustache){if(t.innerHTML=k.render(a,{...e,overlayOpened:this.overlayOpened}),this.searchFacetsMainContainer?.appendChild(t),this.config?.templates?.mainTemplateMobile)for(const o of this.config?.templates?.mainTemplateMobile?.closeOverlayTriggerClasses||[]){const c=t.querySelector("."+o);c&&(c.addEventListener("click",this.closeOverlay.bind(this)),c.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}else for(const o of w.facets.mainTemplateMobile.closeOverlayTriggerClasses){const c=t.querySelector("."+o);c&&(c.addEventListener("click",this.closeOverlay.bind(this)),c.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}const s=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.filterByContainerClass||w.facets.mainTemplateMobile.filterByContainerClass));s&&this.createFilterByComponent(s);const n=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.selectedFacetsContainerClass||w.facets.mainTemplateMobile.selectedFacetsContainerClass));n&&(this.createSelectedFacetsComponents(n),this.createClearFacetsComponents(n));const r=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.facetsContainerClass||w.facets.mainTemplateMobile.facetsContainerClass));if(r){r.innerHTML="";for(const o of e.facets)this.createFacetItem(o,r,!0)}}}}}class Hn{dataLayer;config;containerId;previousButtonClass;nextButtonClass;loadMoreButtonClass;routerHelper;searchPaginationMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.routerHelper=e.routerHelper,this.previousButtonClass=this.config?.templates?.mainTemplate?.previousButtonClass??w.pagination.mainTemplate.previousButtonClass,this.nextButtonClass=this.config?.templates?.mainTemplate?.nextButtonClass??w.pagination.mainTemplate.nextButtonClass,this.loadMoreButtonClass=this.config?.templates?.infiniteScrollTemplate?.loadMoreButtonClass??w.pagination.infiniteScrollTemplate.loadMoreButtonClass,typeof document<"u"&&(this.searchPaginationMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}get isFirstPage(){return this.dataLayer.searchObject?.page===1}get isLastPage(){return this.dataLayer.parsedData.data.isLastPage}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data,previousPageLink:this.routerHelper?.searchObjectToUrl({...this.dataLayer.searchObject,page:this.dataLayer.searchObject?.page-1}),nextPageLink:this.routerHelper?.searchObjectToUrl({...this.dataLayer.searchObject,page:this.dataLayer.searchObject?.page+1})};return this.dataLayer.setPaginationData(e),e}goToPage(e,t){const a=this.dataLayer.searchObject;a&&(a.page=e,this.dataLayer.setSearchObject(a));const s=document.querySelector(".searchstax-page-layout-result-container");if(s instanceof HTMLElement){const n=s.querySelector('[tabindex="0"]');n instanceof HTMLElement&&n.focus()}else document.body.tabIndex=-1,document.body.focus();t||(s instanceof HTMLElement?s.scrollIntoView({block:"start",behavior:"auto"}):window?.scrollTo(0,0))}nextPage(e){e?.preventDefault(),e?.stopPropagation(),this.isLastPage||this.goToPage(this.dataLayer.searchObject?.page+1,this.dataLayer.isInfiniteScroll)}previousPage(e){e?.preventDefault(),e?.stopPropagation(),this.isFirstPage||this.goToPage(this.dataLayer.searchObject?.page-1)}overridePaginationEvents(){if(this.searchPaginationMainContainer){const e=this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass),t=this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass),a=this.searchPaginationMainContainer.querySelector("."+this.loadMoreButtonClass);e&&(e.addEventListener("click",this.previousPage.bind(this)),e.addEventListener("keydown",s=>{(s.code==="Space"||s.code==="Enter")&&this.previousPage(s)})),t&&(t.addEventListener("click",this.nextPage.bind(this)),t.addEventListener("keydown",s=>{(s.code==="Space"||s.code==="Enter")&&this.nextPage(s)})),a&&(a.addEventListener("click",this.nextPage.bind(this)),a.addEventListener("keydown",s=>{(s.code==="Space"||s.code==="Enter")&&this.nextPage(s)}))}}renderMainTemplate(e){this.searchPaginationMainContainer&&(this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass)?.removeEventListener("click",this.previousPage),this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass)?.removeEventListener("click",this.nextPage));let t=this.config?.templates?.mainTemplate?.template||w.pagination.mainTemplate?.template;this.dataLayer.isInfiniteScroll&&(t=this.config?.templates?.infiniteScrollTemplate?.template||w.pagination.infiniteScrollTemplate?.template),this.dataLayer.renderingEngine===F.mustache&&(this.searchPaginationMainContainer.innerHTML=k.render(t,e),setTimeout(()=>{this.overridePaginationEvents()},0))}}class Un{dataLayer;config;containerId;relatedSearchesContainerClass;searchRelatedSearchesMainContainer=null;track;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.relatedSearchesContainerClass=this.config.templates?.main?.relatedSearchesContainerClass||w.relatedSearches.main.relatedSearchesContainerClass,typeof document<"u"&&(this.searchRelatedSearchesMainContainer=document?.getElementById(this.containerId)),this.track=e.trackRelatedSearchClick,this.initializeSubscriptions()}initializeSubscriptions(){this.dataLayer.$searchRelatedSearches.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setRelatedSearchesData(e),e}addRelatedSearchComponent(e,t){if(typeof document<"u"){const a=document?.createElement("div"),s=this.config?.templates?.relatedSearch?.template||w.relatedSearches.relatedSearch.template;if(this.dataLayer.renderingEngine===F.mustache){a.innerHTML=k.render(s,e);const n=a.querySelector("."+(this.config.templates?.relatedSearch?.relatedSearchContainerClass||w.relatedSearches.relatedSearch.relatedSearchContainerClass));n&&(t.appendChild(n),n.addEventListener("click",()=>{this.executeSearch(e)}),n.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.executeSearch(e)}))}}}executeSearch(e){const t=this.dataLayer.searchObject;t.query=e.related_search,this.dataLayer.setSearchObject(t),this.track(e)}renderMainTemplate(e){const t=this.config?.templates?.main?.template||w.relatedSearches.main.template;if(this.dataLayer.renderingEngine===F.mustache&&this.searchRelatedSearchesMainContainer){this.searchRelatedSearchesMainContainer.innerHTML="",this.searchRelatedSearchesMainContainer.innerHTML=k.render(t,e);const a=this.searchRelatedSearchesMainContainer?.querySelector(`.${this.relatedSearchesContainerClass}`);if(a)for(const s of e.relatedSearches)this.addRelatedSearchComponent(s,a)}}}class Qn{dataLayer;config;containerId;searchFeedbackMainContainer=null;searchTrigger;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.searchTrigger=e.searchTrigger,typeof document<"u"&&(this.searchFeedbackMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions()}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setSearchFeedbackData(e),e}onOriginalQueryClick(e){e.stopPropagation(),e.preventDefault();const t=e.target?.innerHTML;this.searchTrigger(t,!0)}attachClick(){const e=this.searchFeedbackMainContainer?.querySelector("."+(this.config?.templates?.main?.originalQueryClass||w.searchFeedback.main?.originalQueryClass));e&&e.addEventListener("click",this.onOriginalQueryClick.bind(this))}renderMainTemplate(e){const t=this.config?.templates?.main?.template||w.searchFeedback.main.template;this.dataLayer.renderingEngine===F.mustache&&(this.searchFeedbackMainContainer.innerHTML=k.render(t,e),setTimeout(()=>{this.attachClick()},0))}}class qn{searchHelper;dataLayer;config;suggestAfterMinChars;containerId;currentInputValue="";autosuggestResults;suppressNextEnter=!1;searchInput;actionButton;autosuggestContainer;clearButton;separatorIcon;buttonState="search";selectedAutosuggestItem=-1;suggestTrigger;searchTrigger;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.searchTrigger=e.searchTrigger,this.suggestTrigger=e.suggestTrigger,this.containerId=e.containerId,this.suggestAfterMinChars=e.config.suggestAfterMinChars,this.suggestAfterMinChars===void 0&&this.getSuggestAfterValue(),this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())},200)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||w.searchInput.mainTemplate.template,a={...this.dataLayer.parsedData.data,locationEnabled:!!this.dataLayer.locationEnabled,hasInputValue:!1};if(this.dataLayer.setInputWidgetTemplateData(a),this.dataLayer.renderingEngine===F.mustache){const r=k.render(t,a);e.innerHTML=r,this.dataLayer.setInputTemplateRendered(!0)}const s=this.config.templates?.mainTemplate?.searchInputId||w.searchInput.mainTemplate.searchInputId,n=document?.querySelector(`#${s}`);if(n)this.searchInput=n,n.addEventListener("keyup",this.inputKeyupEvent.bind(this)),n.addEventListener("blur",this.hideAutosuggest.bind(this)),n.addEventListener("paste",this.inputPasteEvent.bind(this));else throw new Error("Input not found")}}createAutosuggestContainer(){this.dataLayer.renderingEngine===F.mustache&&typeof document<"u"&&(this.autosuggestContainer=document?.createElement("div"),this.autosuggestContainer.classList.add("searchstax-autosuggest-container"),this.autosuggestContainer.addEventListener("mouseleave",()=>{this.resetAutosuggestSelection(),this.markActiveAutosuggestItem()}),this.searchInput?.after(this.autosuggestContainer))}getSuggestAfterValue(){this.dataLayer.searchHelper&&this.dataLayer.searchHelper.suggest("*",e=>{this.suggestAfterMinChars=e.metadata.minPrefixChars},[])}actionButtonInit(){typeof document<"u"&&(this.actionButton=document?.getElementById("searchstax-search-input-action-button"),this.actionButton&&this.actionButton.addEventListener("click",()=>{this.executeSearch(this.searchInput?.value??"")}),this.clearButton=document?.getElementById("searchstax-clear-input-action-button"),this.separatorIcon=document?.getElementById("searchstax-separator-icon"),this.clearButton&&this.clearButton.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.clearInput()}))}updateClearButtonVisibility(e){const t=e.length>0;t?(this.clearButton?.classList.remove("hidden"),this.separatorIcon?.classList.remove("hidden")):(this.clearButton?.classList.add("hidden"),this.separatorIcon?.classList.add("hidden"));const a=this.dataLayer.inputWidgetTemplateData;a&&this.dataLayer.setInputWidgetTemplateData({...a,hasInputValue:t})}attachSubscriptions(){this.dataLayer.$searchTermChange.subscribe(()=>{this.handleSearchTermChange()}),this.dataLayer.$loadingChange.subscribe(()=>{this.handleLoadingChange()}),this.dataLayer.$searchAutosuggest.subscribe(e=>{e&&this.appendSuggestions(e)}),this.dataLayer.$searchObject.subscribe(e=>{e.query!=="undefined"&&e.query!==void 0&&e.query!=="*"&&this.searchInput&&(this.searchInput.value=this.cleanSuggestionTerm(e.query??""),this.updateClearButtonVisibility(this.searchInput.value))})}handleLoadingChange(){this.dataLayer.loading?this.updateActionButtonState("loading"):this.handleSearchTermChange()}handleSearchTermChange(){this.updateActionButtonState("search")}updateActionButtonState(e){if(this.buttonState=e,this.actionButton)switch(this.actionButton.classList.remove("searchstax-spinner-icon"),this.actionButton.classList.remove("searchstax-search-icon"),e){case"loading":this.actionButton.classList.add("searchstax-spinner-icon");break;case"search":this.actionButton.classList.add("searchstax-search-icon"),this.actionButton.setAttribute("aria-label","search");break}}selectPreviousAutosuggestItem(e){this.selectedAutosuggestItem>0?this.selectedAutosuggestItem--:this.selectedAutosuggestItem===0?(this.selectedAutosuggestItem=-1,e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),J.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=this.autosuggestResults.suggestions.length-1,this.markActiveAutosuggestItem()}selectNextAutosuggestItem(){this.selectedAutosuggestItem<this.autosuggestResults.suggestions.length-1?this.selectedAutosuggestItem++:this.selectedAutosuggestItem===this.autosuggestResults.suggestions.length-1?(this.selectedAutosuggestItem=-1,J.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=0,this.markActiveAutosuggestItem()}resetAutosuggestSelection(){this.selectedAutosuggestItem=-1,this.markActiveAutosuggestItem()}clearInput(){this.suppressNextEnter=!0,this.searchInput&&(this.searchInput.value="",this.currentInputValue=""),this.updateClearButtonVisibility(""),this.hideAutosuggest(),this.searchInput?.focus()}markActiveAutosuggestItem(){if(typeof document<"u"){const e=document?.getElementsByClassName("searchstax-autosuggest-item");for(let t=0;t<e.length;t++){const a=e[t];t===this.selectedAutosuggestItem?(a.classList.add("active"),J.setAccessibilityText(`Selected suggestion: ${a.innerText}`)):a.classList.remove("active")}}}inputKeyupEvent(e){const t=e.key;if(this.currentInputValue=e.target.value,t==="Enter"){if(this.suppressNextEnter){this.suppressNextEnter=!1;return}this.suggestionChosen()}else this.suppressNextEnter=!1,t==="Escape"?this.hideAutosuggest(e.target):t==="ArrowUp"?this.selectPreviousAutosuggestItem(e.target):t==="ArrowDown"?this.selectNextAutosuggestItem():this.autosuggestHandling(e);this.handleSearchTermChange(),this.updateClearButtonVisibility(this.currentInputValue)}autosuggestHandling(e){this.suggestAfterMinChars&&e.target&&e.target.value.length>=this.suggestAfterMinChars?this.executeSuggest(e.target.value):this.hideAutosuggest()}inputPasteEvent(e){setTimeout(()=>{this.autosuggestHandling(e),this.handleSearchTermChange(),this.updateClearButtonVisibility(e.target.value)},0)}executeSuggest(e){this.suggestTrigger(e)}executeSearch(e){this.hideAutosuggest(),this.searchTrigger(e===""?"*":e)}suggestionChosen(){this.selectedAutosuggestItem>-1?this.autosuggestItemClicked(this.autosuggestResults.suggestions[this.selectedAutosuggestItem]):this.executeSearch(this.currentInputValue)}hideAutosuggest(e){setTimeout(()=>{this.dataLayer.setAutosuggestResults({numFound:0,suggestions:[]}),this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.add("hidden")),this.resetAutosuggestSelection(),e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),J.setAccessibilityText("No Suggestion selected")},200)}cleanSuggestionTerm(e){return G.removeXSSRiskyTags(e.replace(/(<([^>]+)>)/gi,"")).trim()}autosuggestItemClicked(e){this.searchInput.value=this.cleanSuggestionTerm(e.term??""),this.executeSearch(this.cleanSuggestionTerm(e.term))}createAutosuggestItem(e){const t=document?.createElement("div");t.classList.add("searchstax-autosuggest-item"),t.addEventListener("click",()=>{this.autosuggestItemClicked(e)}),t.addEventListener("mouseenter",()=>{this.onSuggestionEnter(e)});const a=this.config.templates?.autosuggestItemTemplate?.template||w.searchInput.autosuggestItemTemplate?.template;return t.innerHTML=k.render(a,e),t}onSuggestionEnter(e){this.selectedAutosuggestItem=this.autosuggestResults?.suggestions.indexOf(e)||0,this.markActiveAutosuggestItem()}appendSuggestions(e){this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.remove("hidden"));for(const t in e.suggest)if(Object.prototype.hasOwnProperty.call(e.suggest,t)){const a=e.suggest[t];for(const s in a)if(Object.prototype.hasOwnProperty.call(a,s)){const n=a[s];n.numFound?J.setAccessibilityText("Suggestions are available. Use up and down arrows to navigate while focusing input. Use Escape key to escape out of the suggestions",2e3):J.setAccessibilityText("",0),this.autosuggestResults=n,this.dataLayer.setAutosuggestResults(n),n.numFound>0?n.suggestions.forEach(r=>{this.autosuggestContainer&&typeof document<"u"&&this.autosuggestContainer.appendChild(this.createAutosuggestItem(r))}):this.autosuggestContainer&&this.autosuggestContainer.classList.add("hidden")}}}}class Wn{dataLayer;config;linkClickCallback;searchCallback;containerId;searchResultsMainContainer;searchResultsContainer;searchResultLinks=[];constructor(e){this.linkClickCallback=e.linkClickCallback,this.searchCallback=e.searchTrigger,this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId;const t=document?.getElementById(this.containerId);if(t)this.searchResultsMainContainer=t;else throw new Error(`Search Results Main Container with id ${this.containerId} not found`);this.dataLayer.setIsInfiniteScroll(e.config.renderMethod==="infiniteScroll"),this.initializeSubscriptions(),this.renderMainTemplate()}initializeSubscriptions(){this.dataLayer.$searchObject.subscribe(()=>{J.setAccessibilityText("Searching...")}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.searchResultsContainer&&this.renderResults(e)})}changeTemplate(){this.dataLayer.searchResults&&this.renderResults(this.dataLayer.searchResults)}renderNoResultsTemplate(){const e=this.config?.templates?.noSearchResultTemplate?.template||w.searchResults.noSearchResultTemplate?.template,t=this.dataLayer.searchResultsMetadata?.spellingSuggestion??"";if(this.dataLayer.renderingEngine===F.mustache&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=k.render(e,{spellingSuggestion:t,...this.dataLayer.parsedData.data,searchCallback:this.searchCallback.bind(this)})),t&&this.searchResultsContainer){const a=this.searchResultsContainer.querySelector("a");a&&a.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.searchCallback(t)})}}renderResults(e){if(this.dataLayer.renderingEngine===F.mustache&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)J.setAccessibilityText("Search has no results"),this.renderNoResultsTemplate();else{J.setAccessibilityText(`Showing ${this.dataLayer.parsedData.startResultIndex} through ${this.dataLayer.parsedData.endResultIndex} results from ${this.dataLayer.parsedData.totalResults}. Press tab to navigate through results`);const t=this.config?.templates?.searchResultTemplate?.template||w.searchResults.searchResultTemplate?.template,a=e.map(s=>k.render(t,s));this.config?.renderMethod==="infiniteScroll"&&this.dataLayer.searchObject.page>1?this.searchResultsContainer.innerHTML+=a.join(""):this.searchResultsContainer.innerHTML=a.join(""),this.searchResultLinks=Array.from(this.searchResultsContainer.querySelectorAll(`[${this.uniqueIdAttribute}]`)),this.attachLinkClickEvents()}}removeLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.removeEventListener("click",()=>{}),e.removeEventListener("keydown",()=>{})})}get uniqueIdAttribute(){return this.config?.templates?.searchResultTemplate?.searchResultUniqueIdAttribute||w.searchResults.searchResultTemplate?.searchResultUniqueIdAttribute}attachLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const a=e.getAttribute(this.uniqueIdAttribute)??"";a&&this.linkClickCallback(a)}),e.addEventListener("keydown",t=>{if(t.code==="Space"||t.code==="Enter"){const a=e.getAttribute(this.uniqueIdAttribute)??"";a&&this.linkClickCallback(a)}})})}renderMainTemplate(){const e=this.config?.templates?.mainTemplate?.template||w.searchResults.mainTemplate?.template;this.dataLayer.renderingEngine===F.mustache&&(this.searchResultsMainContainer.innerHTML=k.render(e,{}),setTimeout(()=>{const t=this.config?.templates?.mainTemplate?.searchResultsContainerId?this.config?.templates?.mainTemplate?.searchResultsContainerId:w.searchResults.mainTemplate?.searchResultsContainerId,a=document?.getElementById(t);if(a)this.searchResultsContainer=a;else throw new Error(`Search Results Container with id ${t} not found`)},0))}}class Yn{dataLayer;config;containerId;selectId;searchSortingMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.selectId=this.config.templates?.main?.selectId||w.sorting.main.selectId,this.searchSortingMainContainer=document?.getElementById(this.containerId),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setSearchSortingData(e),e}setOrderQuery(e){const t=this.dataLayer.searchObject;t&&(t.order=e,this.dataLayer.setSearchObject(t))}markOptionSelected(){const e=document?.getElementById(this.selectId);if(e){const t=e.querySelector(`option[value="${decodeURIComponent(this.dataLayer.searchObject.order)}"]`);t&&(t.selected=!0)}}renderMainTemplate(e){const t=this.config?.templates?.main?.template||w.sorting.main.template;if(this.dataLayer.renderingEngine===F.mustache){this.searchSortingMainContainer.innerHTML=k.render(t,e),this.markOptionSelected();const a=document?.getElementById(this.selectId);a&&a.addEventListener("change",s=>{this.setOrderQuery(s.target.value)})}}}class Jn{analyticsKey;containerId;mainContainer;isLightweight;emailOverride;feedbackTextAreaOverride;mainTemplateOverride;lightweightTemplateOverride;focusedElement=null;focusTrapListener=null;lastFocusedElementBeforeModal=null;templateData={feedbackOpen:!1,ratings:[{index:1,isSelected:!1},{index:2,isSelected:!1},{index:3,isSelected:!1},{index:4,isSelected:!1},{index:5,isSelected:!1},{index:6,isSelected:!1},{index:7,isSelected:!1},{index:8,isSelected:!1},{index:9,isSelected:!1},{index:10,isSelected:!1}],emailInput:"",feedbackTextArea:"",charactersLeft:2e3,maxLength:2e3,errors:{rating:!1,email:!1},submitted:!1,thumbsUpActive:!1,thumbsDownActive:!1};thumbsUpValue=10;thumbsDownValue=1;ratedQuestion="";language="";model="";analyticsSrc="";constructor(e){this.analyticsKey=e.analyticsKey,this.containerId=e.containerId??"sf-feedback",this.isLightweight=e.lightweight??!1,this.isLightweight&&this.templateData.ratings.unshift({index:0,isSelected:!1}),this.thumbsUpValue=e.thumbsUpValue??10,this.thumbsDownValue=e.thumbsDownValue??1,this.emailOverride=e.emailOverride,this.feedbackTextAreaOverride=e.feedbackTextAreaOverride,this.mainTemplateOverride=e.mainTemplateOverride,this.lightweightTemplateOverride=e.lightweightTemplateOverride,this.mainContainer=document.getElementById(this.containerId),this.language=e.language??"",this.model=e.model??"",this.analyticsSrc=e.analyticsSrc??"",this.init()}init(){Le.attachAnalyticsScript(this.analyticsSrc),this.renderMainTemplate(this.generateTemplateData())}generateTemplateData(){return this.templateData}renderMainTemplate(e){const t=document.activeElement;(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLAnchorElement)&&(t.type==="radio"||t.type==="button"||t.type==="textarea"||t instanceof HTMLAnchorElement)?this.focusedElement=t:this.focusedElement=null,this.mainContainer;let a=Z?.mainTemplate?.template;if(this.mainTemplateOverride&&(a=this.mainTemplateOverride),this.isLightweight&&(a=Z.lightweightTemplate?.template,this.lightweightTemplateOverride&&(a=this.lightweightTemplateOverride)),this.mainContainer.innerHTML=k.render(a,e),this.focusedElement&&this.mainContainer){const s=this.focusedElement.type==="radio"?this.focusedElement.getAttribute("id"):this.focusedElement.getAttribute("class"),n=this.focusedElement.type==="radio"?"id":"class",r=this.mainContainer.querySelector(`[${n}="${s}"]`);(r instanceof HTMLInputElement||r instanceof HTMLButtonElement||r instanceof HTMLTextAreaElement||r instanceof HTMLAnchorElement)&&r.focus(),this.focusedElement=null}this.attachEvents()}attachEvents(){this.isLightweight?this.attachLightweightEvents():(this.attachOpenModalEvent(),this.closeModalEvent(),this.attachRatingEvents(),this.attachTextAreaEvents(),this.attachEmailInputEvents(),this.attachSubmitButtonEvents())}attachFocusTrap(){this.focusTrapListener&&document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=e=>{if(!this.templateData.feedbackOpen)return;const t=this.getModalElement();if(!t)return;const a=this.getFocusableElements(t);if(a.length===0)return;const s=a[0],n=a[a.length-1];e.key==="Tab"&&(e.shiftKey?(document.activeElement===s||!t.contains(document.activeElement))&&(e.preventDefault(),n?.focus()):(document.activeElement===n||!t.contains(document.activeElement))&&(e.preventDefault(),s?.focus())),e.key==="Escape"&&(e.preventDefault(),this.closeFeedbackModal())},document.addEventListener("keydown",this.focusTrapListener)}getFocusableElements(e){const t=["button:not([disabled])","input:not([disabled])","textarea:not([disabled])","select:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(e.querySelectorAll(t))}getModalElement(){const e=Z.mainTemplate?.modalContainerClass;return this.mainContainer?.querySelector(`.${e}`)||null}attachLightweightEvents(){const e=Z.lightweightTemplate?.thumbsUpButtonClass,t=Z.lightweightTemplate?.thumbsDownButtonClass,a=this.mainContainer?.querySelector("."+e),s=this.mainContainer?.querySelector("."+t);a&&a.addEventListener("click",()=>{const n=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[this.templateData.ratings.length-1].isSelected&&this.ratedQuestion===n||(this.templateData.thumbsUpActive=!0,this.templateData.thumbsDownActive=!1,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsUpValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=n,this.submit())}),s&&s.addEventListener("click",()=>{const n=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[0].isSelected&&this.ratedQuestion===n||(this.templateData.thumbsUpActive=!1,this.templateData.thumbsDownActive=!0,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsDownValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=n,this.submit())})}attachSubmitButtonEvents(){const e=Z.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.checkIfValid()})}checkIfValid(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.emailInputId);this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,J.setAccessibilityText("Please enter a valid email address.")),this.templateData.ratings.some(s=>s.isSelected)?this.templateData.errors.rating=!1:(this.templateData.errors.rating=!0,J.setAccessibilityText("Please Rate your experience.")),this.templateData.errors.rating||this.templateData.errors.email?this.renderMainTemplate(this.generateTemplateData()):this.submit()}submit(){this.templateData.submitted=!0;const e=this.templateData.ratings.find(t=>t.isSelected)?.index;e!==void 0&&(Le.trackFeedback({trackApiKey:this.analyticsKey,email:this.emailOverride&&this.isLightweight?this.emailOverride():this.templateData.emailInput,rating:e,feedback:this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea,model:this.model?this.model:void 0,language:this.language?this.language:void 0}),this.showCheckmarkAnimation(),J.setAccessibilityText("Feedback has been sent.",1e3),this.mainContainer?.querySelector("."+Z.mainTemplate?.checkmarkClass)?setTimeout(()=>{this.closeFeedbackModal(),this.renderMainTemplate(this.generateTemplateData())},2e3):(setTimeout(()=>{this.closeFeedbackModal()},500),this.renderMainTemplate(this.generateTemplateData())))}validateEmail(e){return e===""?!0:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}attachEmailInputEvents(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.emailInputId);e&&(e.addEventListener("input",()=>{this.templateData.emailInput=e.value}),e.addEventListener("blur",()=>{setTimeout(()=>{this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,J.setAccessibilityText("Please enter a valid email address.")),this.renderMainTemplate(this.generateTemplateData())},300)}))}attachTextAreaEvents(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.feedbackTextAreaId);e&&e.addEventListener("input",()=>{this.templateData.feedbackTextArea=e.value,this.templateData.charactersLeft=this.templateData.maxLength-e.value.length;const t=this.mainContainer?.querySelector("."+Z.mainTemplate?.charactersRemainingContainerclass);t&&(t.innerText=this.templateData.charactersLeft+"")})}attachRatingEvents(){const e=Z.mainTemplate?.ratingInputclass,t=this.mainContainer?.querySelectorAll("."+e);t&&t.forEach(a=>{a.addEventListener("click",s=>{const n=s.target.value;this.templateData.ratings.forEach(r=>{r.isSelected=r.index+""===n}),this.templateData.errors.rating=!1,this.renderMainTemplate(this.generateTemplateData())})})}attachOpenModalEvent(){const e=Z.mainTemplate?.openModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",a=>{a.preventDefault(),this.toggleModal()})}toggleModal(){this.templateData.feedbackOpen?this.closeFeedbackModal():this.openFeedbackModal()}closeModalEvent(){const e=Z.mainTemplate?.closeModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.closeFeedbackModal()})}openFeedbackModal(){this.lastFocusedElementBeforeModal=document.activeElement,this.templateData.feedbackOpen=!0,this.renderMainTemplate(this.generateTemplateData()),setTimeout(()=>{const e=this.getModalElement();if(e){const t=this.getFocusableElements(e);t.length>0&&t[0].focus()}this.attachFocusTrap()},0),J.setAccessibilityText("Feedback form opened",1e3)}closeFeedbackModal(){this.templateData.feedbackOpen=!1,this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null),this.renderMainTemplate(this.generateTemplateData()),this.lastFocusedElementBeforeModal&&(this.lastFocusedElementBeforeModal.focus(),this.lastFocusedElementBeforeModal=null),J.setAccessibilityText("Feedback form closed",1e3)}showCheckmarkAnimation(){const e=Z.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&(t.disabled=!0);const a=Z.mainTemplate?.checkmarkClass,s=this.mainContainer?.querySelector("."+a);s&&s.classList.remove("hidden");const n=Z.mainTemplate?.submitButtonTextClass,r=this.mainContainer?.querySelector("."+n);r&&r.classList.add("visibility"),setTimeout(()=>{s&&s.classList.add("hidden"),r&&r.classList.remove("visibility"),t&&(t.disabled=!1)},2e3)}destroy(){this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null)}}class Gn{dataLayer;config;containerId;answerContainer=null;showMoreVisible=!1;renderFeedbackWidget=!1;clicked=!1;renderedWithShowMore=!1;showMoreListenerAttached=!1;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.renderFeedbackWidget=this.config.feedbackwidget?.renderFeedbackWidget||!1,this.config.showMoreAfterWordCount&&(this.dataLayer.answerWidgetShowMoreLimit=this.config.showMoreAfterWordCount),typeof document<"u"&&(this.answerContainer=document?.getElementById(this.containerId),this.attachShowMoreClickListener()),this.config.testString?(this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())):this.initializeSubscriptions(),this.dataLayer.setIsAnswerWidgetCreated(!0)}initializeSubscriptions(){this.dataLayer.$answer.subscribe(()=>{this.clicked?this.showMoreVisible=!1:this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerLoading.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerError.subscribe(e=>{e&&setTimeout(()=>{this.renderMainTemplate(this.generateTemplateData())},100)}),this.dataLayer.$searchObject.subscribe(()=>{this.clicked=!1,this.renderedWithShowMore=!1,this.showMoreVisible=!1}),this.dataLayer.$paginationData.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answer.subscribe(e=>{e&&setTimeout(()=>{this.initializeWidget()},600)}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.$answer.getValue()&&setTimeout(()=>{this.initializeWidget()},600)})}searchstaxFeedbackTextAreaOverride(){return"Question: "+(this.dataLayer.searchObject.query==="undefined"?"":this.dataLayer.searchObject.query)+" Answer: "+this.dataLayer.parsedData.getAnswerData}initializeWidget(){this.renderFeedbackWidget&&document.getElementById("feedbackWidgetContainer")&&!this.dataLayer.answerLoading&&new Jn({analyticsKey:this.dataLayer.parsedData.trackingData.trackApiKey,containerId:"feedbackWidgetContainer",lightweight:!0,model:this.dataLayer.parsedData.trackingData.model,language:this.dataLayer.parsedData.trackingData.language,emailOverride:this.config.feedbackwidget?.emailOverride,feedbackTextAreaOverride:this.config.feedbackwidget?.searchstaxFeedbackTextAreaOverride??this.searchstaxFeedbackTextAreaOverride.bind(this),thumbsUpValue:this.config.feedbackwidget?.thumbsUpValue??10,thumbsDownValue:this.config.feedbackwidget?.thumbsDownValue??0,lightweightTemplateOverride:this.config.feedbackwidget?.lightweightTemplateOverride})}showMore(e){e.preventDefault(),this.clicked=!0,this.showMoreVisible=!1,Le.trackShowMoreClick({...this.dataLayer.parsedData.trackingData}),this.renderMainTemplate(this.generateTemplateData()),this.config.testString||setTimeout(()=>{this.initializeWidget()},600)}attachShowMoreClickListener(){!this.answerContainer||this.showMoreListenerAttached||(this.showMoreListenerAttached=!0,this.answerContainer.addEventListener("click",e=>{e.target?.closest?.(".searchstax-answer-load-more-button")&&this.showMore(e)}))}trackLinkClick(e){e.preventDefault(),e.stopPropagation();const a=e.target.getAttribute("href");Le.trackAnswerLinkClick({href:a,answer:this.dataLayer.parsedData.getAnswerData,...this.dataLayer.parsedData.trackingData}).then(()=>{window.open(a,"_blank")}).catch(()=>{window.open(a,"_blank")})}attachLinkTracking(){document.querySelectorAll(".searchstax-answer-link").forEach(t=>{t.getAttribute("listener")!=="true"&&(t.setAttribute("listener","true"),t.addEventListener("click",this.trackLinkClick.bind(this)))})}renderMainTemplate(e){const t=this.config?.templates?.main?.template||w.answer.main.template;this.dataLayer.renderingEngine===F.mustache?(!this.renderedWithShowMore||!e.answerLoading||this.clicked)&&(e.showMoreButtonVisible&&(this.renderedWithShowMore=!0),this.answerContainer.innerHTML=k.render(t,e),setTimeout(()=>{this.attachLinkTracking()},100)):setTimeout(()=>{this.attachLinkTracking()},500)}generateTemplateData(){this.config.testString&&this.dataLayer.setAnswerData(this.config.testString??"");const e={...this.dataLayer.parsedData.data,showMoreButtonVisible:this.showMoreVisible};return this.config.testString&&(e.searchExecuted=!0),this.dataLayer.setAnswerFullData(e),e}}class Ts{dataLayer;config;containerId;currentSelectValue="";locationInput;radiusInput;locationDecode;locationDecodeCoordinatesToAddress;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.locationDecode=e.config.hooks?.locationDecode,this.locationDecodeCoordinatesToAddress=e.config.hooks?.locationDecodeCoordinatesToAddress,this.dataLayer.locationEnabled&&this.dataLayer.$inputTemplateRendered.subscribeUntil(()=>{this.renderMainTemplate(),this.attachSubscriptions()},!0,500)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||w.location.mainTemplate.template,a={...this.dataLayer.parsedData.data};if(this.dataLayer.setLocationWidgetTemplateData(a),this.dataLayer.renderingEngine===F.mustache){const s=k.render(t,a);e.innerHTML=s;const n=this.config.templates?.mainTemplate?.locationInputId||w.location.mainTemplate.locationInputId,r=document?.querySelector(`#${n}`);if(r)this.locationInput=r,r.addEventListener("blur",this.blurEvent.bind(this)),r.addEventListener("focus",this.focusEvent.bind(this));else throw new Error("Input not found");const o=this.config.templates?.mainTemplate?.radiusInputId||w.location.mainTemplate.radiusInputId,c=document?.querySelector(`#${o}`);c instanceof HTMLSelectElement&&(this.radiusInput=c,c.addEventListener("change",this.radiusSelectChangeEvent.bind(this)));const h=this.config.templates?.mainTemplate?.currentLocationActionButtonId||w.location.mainTemplate.currentLocationActionButtonId,d=document?.querySelector(`#${h}`);d&&d.addEventListener("click",this.getCurrentLocation.bind(this))}}}setCurrentLocationFields(e){this.dataLayer.setLocationCoordinatesDecoded(e),this.dataLayer.setSearchLocation(this.dataLayer.searchLocationCoordinatesDecoded),this.dataLayer.renderingEngine===F.mustache&&this.locationInput&&(this.locationInput.value=this.dataLayer.searchLocationCoordinatesDecoded)}getCurrentLocation(){navigator.geolocation?navigator.geolocation.getCurrentPosition(e=>{const t=e.coords.latitude.toString(),a=e.coords.longitude.toString(),s=Math.floor(parseFloat(t)*100)/100,n=Math.floor(parseFloat(a)*100)/100;this.dataLayer.setSearchLat(s+""),this.dataLayer.setSearchLong(n+"");const r=this.locationDecodeCoordinatesToAddress;r?r(s+"",n+"").then(o=>{this.setCurrentLocationFields(o.address||"Current Location")}).catch(()=>{this.setCurrentLocationFields("Current Location")}):this.setCurrentLocationFields("Current Location")},()=>{console.error("Unable to retrieve your location")}):console.error("Geolocation is not supported by this browser.")}setRadiusValue(e){this.dataLayer.setSearchRadius(e)}radiusSelectChangeEvent(e){this.currentSelectValue=e.target.value,this.setRadiusValue(this.currentSelectValue)}attachSubscriptions(){this.dataLayer.$searchObject.subscribe(e=>{this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(e.location.address??"")),this.radiusInput&&e.location.radius&&(this.radiusInput.value=e.location.radius||"")})}cleanSuggestionTerm(e){return G.removeXSSRiskyTags(e.replace(/(<([^>]+)>)/gi,"")).trim()}triggerGeocoder(e){const t=this.locationDecode;this.dataLayer.setLocationDecodingLoading(!0),e&&this.dataLayer.searchLocation!==e&&e!==this.dataLayer.searchLocationCoordinatesDecoded?t(e).then(a=>{this.dataLayer.setSearchLocation(a.address||""),this.dataLayer.setSearchLat(a.lat||""),this.dataLayer.setSearchLong(a.lon||""),this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(a.address||"")),this.dataLayer.renderingEngine===F.mustache&&a.error&&this.locationInput&&this.locationInput.classList.add("searchstax-input-location-error"),a.error?this.dataLayer.setLocationError(!0):this.dataLayer.setLocationError(!1),this.dataLayer.setLocationDecodingLoading(!1)}).catch(()=>{this.dataLayer.setLocationDecodingLoading(!1)}):e===""&&(this.dataLayer.setSearchLocation(void 0),this.dataLayer.setSearchLat(void 0),this.dataLayer.setSearchLong(void 0),this.dataLayer.setLocationDecodingLoading(!1))}focusEvent(e){e.target.classList.remove("searchstax-input-location-error"),this.dataLayer.setLocationError(!1)}blurEvent(e){const a=e.target.value;this.triggerGeocoder(a)}}class Zn{routerEnabled=!1;cachedQuery="";routerHelper;searchHelper;searchResultsConfig;searchPaginationConfig;searchFeedbackConfig;searchSortingConfig;searchFacetsConfig;relatedSearchesConfig;externalPromotionsConfig;searchInputWidget;searchLocationWidget;searchResultsWidget;searchFacetsWidget;searchPaginationWidget;searchFeedbackWidget;searchSortingWidget;relatedSearchesWidget;externalPromotionsWidget;answerWidget;locationObserver=null;dataLayer;firstRequest=!0;previousQuery="";eventSource=null;renderEngine=F.mustache;constructor(e=F.mustache){e&&(this.renderEngine=e)}setRenderingEngine(e=F.mustache){this.dataLayer.setRenderingEngine(e)}handleHooks(){this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&this.dataLayer.$searchResults.subscribe(e=>{this.dataLayer.searchstaxConfig.hooks.afterSearch(e,this.dataLayer.searchResultUnparsedData)}),setTimeout(()=>{this.dataLayer.$searchObject.subscribe(e=>{e.query!==this.previousQuery&&this.dataLayer.setAnswerData(""),e.query!==""&&e.query!==void 0&&e.query!=="undefined"?(this.search(e),e.query!==this.previousQuery&&this.startSSE(e.query)):this.dataLayer.searchLocationConfig?.locationSearchEnabled&&!this.dataLayer.searchLocationConfig?.locationValuesOverride?this.getMetadata(e):this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue),this.previousQuery=e.query})},10),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&Le.trackSearch({...this.dataLayer.parsedData.trackingData,impressions:this.dataLayer.searchResultsMetadata.impressions})})}startSSE(e){this.eventSource&&(this.eventSource?.close(),this.dataLayer.setAnswerData("")),this.dataLayer.turnAIAnswerGenerationOn===!0&&this.dataLayer.questionURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&(this.eventSource=this.searchHelper?.startSSE(e,this.parseAnswerResultsResponse.bind(this)))}attachAnalyticsScript(e){Le.attachAnalyticsScript(e)}initialize(e){if(this.dataLayer=new ln("searchstax_session_id",e.sessionId),this.renderEngine&&this.dataLayer.setRenderingEngine(this.renderEngine),this.handleHooks(),e.questionURL&&(this.dataLayer.questionURL=e.questionURL),e.analyticsBaseUrl&&typeof window<"u"&&(window.analyticsBaseUrl=e.analyticsBaseUrl,window._msq=e._msq||[],this.attachAnalyticsScript(e.analyticsSrc)),e.autoCorrect===!1&&(this.dataLayer.autoCorrect=!1),e.language&&this.dataLayer.setLanguage(e.language),e.model&&this.dataLayer.setModel(e.model),this.dataLayer.searchstaxConfig||(this.dataLayer.setSearchstaxConfig(e),this.searchHelper=new pn({...e,sessionId:this.dataLayer.sessionId},this.dataLayer),this.dataLayer.searchHelper=this.searchHelper),e.router?.enabled===void 0||e.router?.enabled===!0){this.routerEnabled=!0,this.routerHelper=new ps(e.router?e.router:{enabled:!0});const t=this.routerHelper.urlToSearchObject(window?.location.href??"");this.dataLayer.searchObject.itemsPerPage?t.itemsPerPage=this.dataLayer.searchObject.itemsPerPage:t.itemsPerPage&&this.dataLayer.setItemsPerPage(t.itemsPerPage),t.model&&this.dataLayer.setModel(t.model),t.location&&(t.location.address&&this.dataLayer.setSearchLocation(t.location.address),t.location.lat&&this.dataLayer.setSearchLat(t.location.lat),t.location.lon&&this.dataLayer.setSearchLong(t.location.lon),t.location.radius&&this.dataLayer.setSearchRadius(t.location.radius)),this.dataLayer.setSearchObject(t),addEventListener("popstate",()=>{this.routerHelper&&this.dataLayer.setSearchObject(this.routerHelper.urlToSearchObject(window?.location.href??"",this.dataLayer.searchObject.itemsPerPage))})}else this.routerHelper=new ps({})}getMetadata(e){this.searchHelper&&(e.query==="undefined"||e.query===void 0)&&this.dataLayer.setSearchObject({...e,query:"*"})}search(e){if(this.searchHelper){const t=this.dataLayer.forceNotCorrect;this.searchHelper.url&&(this.searchHelper.search(e,this.parseSearchResultsResponse.bind(this),this.firstRequest,t),this.firstRequest=!1),this.getRelatedSearches()}}getRelatedSearches(){this.searchHelper&&this.relatedSearchesConfig&&this.relatedSearchesConfig?.relatedSearchesURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&this.searchHelper.getRelatedSearches(this.dataLayer.searchObject,this.relatedSearchesConfig.relatedSearchesURL,this.relatedSearchesConfig.relatedSearchesAPIKey,this.parseRelatedSearchesResponse.bind(this))}parseRelatedSearchesResponse(e){const a=(e.response?.docs??[]).map((n,r)=>({...n,position:r+1})),s=[];for(const n of a)s.push({relatedSearch:n.related_search,position:n.position});this.dataLayer.setSearchRelatedSearches(a),this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&s.length&&Le.trackRelatedSearches({...this.dataLayer.parsedData.trackingData,impressions:s,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}handleRouter(){if(this.routerEnabled){const e={...this.dataLayer.searchObject};this.dataLayer.isInfiniteScroll&&delete e.page,this.routerHelper.updateUrl(e)}}parseSearchResultsResponseMetadata(e){const t=nt.extractSearchResultsMetadata(e),a=this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue??t.location?.filter?.defaultValue;!this.dataLayer.searchRadius&&a&&this.dataLayer.setSearchRadius(a),this.dataLayer.setSearchResultsMetadata(t)}parseSearchResultsResponse(e){this.handleRouter(),this.dataLayer.setItemsPerPage(parseInt(e.responseHeader.params.rows)),this.dataLayer.setModel(e.responseHeader.params.model);let t=nt.combineResultsWithMetadata(e),a=nt.extractFacets(e);this.dataLayer.setSearchFacets(a),this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&(t=this.dataLayer.searchstaxConfig.hooks.afterSearch(t,e)),this.dataLayer.setSearchExternalPromotions(e.externalLinks??[]),this.parseSearchResultsResponseMetadata(e),this.dataLayer.setSearchResultUnparsedData(e),this.dataLayer.setSearchResults(t)}parseAnswerResultsResponse(e){this.handleRouter(),e!==ze.question&&e!==ze.notQuestion&&(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setAnswerData(this.dataLayer.getAnswerData+e))}cacheFacets(e){e?this.searchHelper?.cacheFacets(!0).then(()=>{}):this.searchHelper?.cacheFacets().then(()=>{})}parseSuggestSuggestResponse(e){let t=e;this.dataLayer.searchInputConfig?.hooks?.afterAutosuggest&&(t=this.dataLayer.searchInputConfig.hooks.afterAutosuggest(e)),this.dataLayer.setSearchAutosuggest(t)}suggest(e,t){this.searchHelper&&this.searchHelper.suggest(e,this.parseSuggestSuggestResponse.bind(this),t)}changeLanguage(e){this.searchHelper&&this.dataLayer.setLanguage(e)}addSearchInputWidget(e,t){this.dataLayer.searchInputConfig||this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.dataLayer.setSearchInputConfig(t),this.searchInputWidget=new qn({containerId:e,config:t,searchTrigger:this.executeSearch.bind(this),suggestTrigger:this.executeSuggest.bind(this),dataLayer:this.dataLayer})},200)}addSearchLocationWidget(e,t){this.dataLayer.searchLocationConfig||(t.locationSearchEnabled?(this.dataLayer.setLocationEnabled(!0),this.dataLayer.setSearchLocationConfig(t),t.locationValuesOverride?(this.searchLocationWidget=new Ts({containerId:e,config:t,dataLayer:this.dataLayer}),t?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(t?.locationValuesOverride?.locationFilterDefaultValue)):this.dataLayer.$searchResultsMetadata.subscribeUntilHasValue(()=>{this.searchLocationWidget=new Ts({containerId:e,config:t,dataLayer:this.dataLayer})},0)):this.dataLayer.setLocationEnabled(!1))}addAnswerWidget(e,t){this.dataLayer.turnAIAnswerGenerationOn=!0,t.testString||this.startSSE(this.dataLayer.searchObject.query),this.dataLayer.setAnswerData(t.testString??""),this.answerWidget=new Gn({containerId:e,config:t,dataLayer:this.dataLayer})}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new Wn({containerId:e,linkClickCallback:this.executeLinkClick.bind(this),searchTrigger:this.executeSearch.bind(this),config:t,dataLayer:this.dataLayer}))}addPaginationWidget(e,t){this.searchPaginationConfig=t,this.searchPaginationWidget=new Hn({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper})}addSearchFeedbackWidget(e,t){this.searchFeedbackConfig=t,this.searchFeedbackWidget=new Qn({containerId:e,config:t,dataLayer:this.dataLayer,searchTrigger:this.executeSearch.bind(this)})}addSearchSortingWidget(e,t){this.searchSortingConfig=t,this.searchSortingWidget=new Yn({containerId:e,config:t,dataLayer:this.dataLayer})}addRelatedSearchesWidget(e,t){this.relatedSearchesConfig=t,this.relatedSearchesWidget=new Un({containerId:e,config:t,dataLayer:this.dataLayer,trackRelatedSearchClick:this.trackRelatedSearchClick.bind(this)}),setTimeout(()=>{this.getRelatedSearches()},0)}addExternalPromotionsWidget(e,t){this.externalPromotionsConfig=t,this.externalPromotionsWidget=new Bn({containerId:e,config:t,dataLayer:this.dataLayer})}addFacetsWidget(e,t){this.searchFacetsConfig=t,this.searchFacetsWidget=new Vn({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper},this.cacheFacets.bind(this))}executeSearch(e,t){const a={...this.dataLayer.searchObject};a.query=G.removeXSSRiskyTags(e),a.page=1,a.facets=[],a.location={...a.location},this.locationObserver&&this.dataLayer.$locationDecodingLoading.unsubscribe(this.locationObserver),this.locationObserver=this.dataLayer.$locationDecodingLoading.subscribeUntil(()=>{a.location.address=this.dataLayer.searchLocation,a.location.radius=this.dataLayer.searchRadius,a.location.lat=this.dataLayer.searchLat,a.location.lon=this.dataLayer.searchLong,this.dataLayer.forceNotCorrect=!!t;let s=this.routerHelper?.searchObjectToParams(a);s&&(s=this.routerHelper?.extractParamsThatDoNotStartWithRouteName(s)),s&&(a.additionalProps=Object.keys(s).map(n=>s?{key:n,value:s[n]}:{key:"",value:""})),this.dataLayer.setSearchObject(a),this.dataLayer.lastSearchValue=a.query},!1)}executeSuggest(e){let t={term:e,queryParams:[]};this.dataLayer.searchInputConfig?.hooks?.beforeAutosuggest&&(t=this.dataLayer.searchInputConfig.hooks.beforeAutosuggest(t)),t&&t.term!==void 0&&t.queryParams!==void 0&&this.suggest(t.term,t.queryParams)}trackRelatedSearchClick(e){this.dataLayer.searchResultsMetadata&&this.dataLayer.searchRelatedSearches&&!this.dataLayer.cookiesDisabled&&Le.trackRelatedSearchClick({...this.dataLayer.parsedData.trackingData,relatedSearch:e,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}executeLinkClick(e){let t=nt.findResultByUniqueId(e,this.dataLayer.searchResults??[]);t&&(this.searchResultsConfig?.hooks?.afterLinkClick&&(t=this.searchResultsConfig.hooks.afterLinkClick(t)),t&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&Le.trackClick({result:t,...this.dataLayer.parsedData.trackingData}).then(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}).catch(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}))}setPage(e){this.searchPaginationWidget?.goToPage(e)}setCookiesDisabled(e){this.dataLayer.setCookiesDisabled(e)}changeResultTemplate(e){this.searchResultsConfig&&(this.searchResultsConfig.templates=this.searchResultsConfig?.templates?{...this.searchResultsConfig?.templates,...e}:e,this.searchResultsWidget?.changeTemplate())}}Na.Searchstax=Zn,Object.defineProperty(Na,Symbol.toStringTag,{value:"Module"})})(this["@searchstaxInc/searchstudioUxJs"]=this["@searchstaxInc/searchstudioUxJs"]||{});
440
+ `,thumbsUpButtonClass:"searchstax-lightweight-widget-thumbs-up",thumbsDownButtonClass:"searchstax-lightweight-widget-thumbs-down"}};class M{static answer=Bn;static externalPromotions=Hn;static facets=Un;static pagination=Qn;static relatedSearches=qn;static searchFeedback=Wn;static searchInput=Yn;static location=Jn;static searchResults=Gn;static sorting=Kn;static feedback=Z}class Zn{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",n=>{this.trackClick(e,n)}),a.innerHTML=E.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===F.mustache){this.searchExternalPromotionsMainContainer.innerHTML=E.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 J{static addAccessibilityNotificationContainerToBody(){if(!document.getElementById("searchAccessibilityContainer")){const t=document.createElement("div");t.setAttribute("aria-live","polite"),t.setAttribute("id","searchAccessibilityContainer"),document.body.appendChild(t)}}static setAccessibilityText(e,t,s){this.addAccessibilityNotificationContainerToBody();const a=s??"searchAccessibility",n=document.getElementById(a);n&&n.remove();const r=document.createElement("span");r.setAttribute("id",a),r.innerHTML=e;const o=document.getElementById("searchAccessibilityContainer");o&&setTimeout(()=>{o.appendChild(r)},t??100)}}class Xn{dataLayer;config;containerId;routerHelper;cachedPhrase="";cachedANDFacets="";overlayOpened=!1;facetPaginationStep;facetPaginationStepMobile;searchFacetsMainContainer=null;searchFacetsMobileContainer=null;searchFacetsDesktopContainer=null;facetLimits={};facetLimitsMobile={};deactivatedFacets={};focusedElement=null;cachedData=null;cacheFacets;constructor(e,t){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.routerHelper=e.routerHelper,this.cacheFacets=t,this.facetPaginationStep=this.config.itemsPerPageDesktop,this.facetPaginationStepMobile=this.config.itemsPerPageMobile,typeof document<"u"&&(this.searchFacetsMainContainer=document?.getElementById(this.containerId)),t(this.config.facetingType),this.initializeSubscriptions()}get needDisabling(){return this.config.facetingType==="showUnavailable"}initializeSubscriptions(){this.dataLayer.$searchFacetsCachedand.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$searchFacetsCachedtabs.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$searchFacetsCachedor.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$searchResults.subscribe(e=>{e&&(this.cacheFacets(this.config.facetingType),this.renderMainTemplate(this.generateTemplateData()))})}extractFacetValue(e){return{type:this.config.facetingType,name:e.parentName,value:e.value}}applyFacetLimits(e,t){const s=t?this.facetPaginationStepMobile:this.facetPaginationStep,a=t?this.facetLimits:this.facetLimitsMobile;return e.forEach(n=>{a[n.name]||(a[n.name]=s)}),e.map(n=>({...n,values:n.values.slice(0,a[n.name]),showingAllFacets:n.values.length<=a[n.name],hasMoreFacets:n.values.length>s}))}generateTemplateData(e){if(this.generateSelectedFacetsData(),this.dataLayer.searchFacets){let t=this.dataLayer.searchFacets;this.config.hooks?.beforeFacetsRender&&(t=this.config.hooks.beforeFacetsRender(t)),this.componentFacets&&(t=this.componentFacets,this.needDisabling&&(t=t.map(a=>{const n=this.dataLayer.searchFacets?.find(r=>r.name===a.name);return n?{...a,values:a.values.map(o=>{const c=n.values.find(h=>o.type==="range"?!1:o.type==="checkbox"?h.value===o.value:!1);return{...o,disabled:!c,isMobile:e}})}:{...a,values:a.values.map(o=>({...o,disabled:!0})),isMobile:e}}))),this.config.specificFacets&&(t=t.filter(a=>this.config.specificFacets?.includes(a.name)));const s={facets:this.applyFacetLimits(t,e),...this.dataLayer.parsedData.data,isMobile:e};return this.dataLayer.setFacetsTemplateData(s),s}else{const t={facets:[],...this.dataLayer.parsedData.data,isMobile:e};return this.dataLayer.setFacetsTemplateData(t),t}}createFacetItem(e,t,s){if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-facet-container"),this.deactivatedFacets[e.name]||a.classList.add("active");const n=this.config?.templates?.facetItemContainerTemplate?.template||M.facets.facetItemContainerTemplate?.template;a.innerHTML=E.render(n,e),t.appendChild(a);const r=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerClass||M.facets.facetItemContainerTemplate?.facetListTitleContainerClass));r?.addEventListener("click",()=>{a.classList.toggle("active");const c=a.classList.contains("active"),h=r.querySelector(".searchstax-facet-title");h&&h.setAttribute("aria-expanded",String(c))}),r?.querySelector("."+this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerInner)?.addEventListener("keydown",c=>{if(c.code==="Enter"||c.code==="Space"){c.preventDefault(),a.classList.toggle("active");const h=a.classList.contains("active"),d=r.querySelector(".searchstax-facet-title");d&&d.setAttribute("aria-expanded",String(h))}});const o=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListContainerClass||M.facets.facetItemContainerTemplate?.facetListContainerClass));o&&(e.values.forEach(c=>{this.createFacetListItem(c,o,e.name)}),e.hasMoreFacets&&this.createHasMoreComponent(e,o,s))}}isChecked(e){return!!this.dataLayer.searchObject.facets?.find(t=>he.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 n=this.isChecked(e),r=this.config?.templates?.facetItemTemplate?.template||M.facets.facetItemTemplate?.template;a.innerHTML=E.render(r,{...e,isChecked:n});let o=M.facets.facetItemTemplate?.checkTriggerClasses;o=this.config?.templates?.facetItemTemplate?.checkTriggerClasses||o,o.forEach(h=>{a.querySelector("."+h)?.addEventListener("click",y=>{this.onFacetSelect(y,e,a)})});const c=a.querySelector("."+(this.config?.templates?.facetItemTemplate?.inputCheckboxClass||M.facets.facetItemTemplate?.inputCheckboxClass));c?.addEventListener("click",h=>{this.onFacetSelect(h,e,a,!0)}),c&&c?.setAttribute("data-test-value",`${encodeURIComponent(s)}:&quot;${encodeURIComponent(e.value)}&quot;`),t.appendChild(a)}}onFacetSelect=(e,t,s,a,n)=>{if(e.stopPropagation(),!t.disabled){const r=s.querySelector("input");let o=a?r.checked:!r.checked;n!==void 0&&(o=!n),r.checked=o;const c=this.dataLayer.searchObject;let h=[...c.facets];const d=this.extractFacetValue(t);o?h.find(L=>he.deepEqual(L,d)?L:!1)||(this.config.facetingType==="tabs"&&(h=h.filter(L=>L.name!==d.name)),h.push(d)):h=h.filter(y=>!he.deepEqual(y,d)),setTimeout(()=>{this.dataLayer.setSearchObject({...c,facets:h,page:1}),this.config.facetingType==="tabs"&&this.renderMainTemplate(this.generateTemplateData(),!0)},0)}};createHasMoreComponent(e,t,s){if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-facet-show-more-container");const n=this.config?.templates?.showMoreButtonContainerTemplate?.template||M.facets.showMoreButtonContainerTemplate?.template;a.innerHTML=E.render(n,{...e,focusId:`moreLess${e?.values?.[0]?.value}`});const r=a.querySelector("."+(this.config?.templates?.showMoreButtonContainerTemplate?.showMoreButtonClass||M.facets.showMoreButtonContainerTemplate?.showMoreButtonClass));r&&(this.attachOnclickToShowMore(e,r,s),t&&t.appendChild(r))}}attachOnclickToShowMore(e,t,s){t.addEventListener("click",a=>{this.onShowMoreLessClick(a,e,s)}),t.addEventListener("keydown",a=>{a.code==="Space"&&a.preventDefault()}),t.addEventListener("keyup",a=>{(a.code==="Space"||a.code==="Enter")&&(a.preventDefault(),this.onShowMoreLessClick(a,e,s))})}onShowMoreLessClick(e,t,s){e.preventDefault();const a=s?this.facetPaginationStepMobile:this.facetPaginationStep,n=s?this.facetLimits:this.facetLimitsMobile;n[t.name]===void 0?n[t.name]=a*2:n[t.name]<=t.values.length?(J.setAccessibilityText(`More Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),n[t.name]=n[t.name]+a):(J.setAccessibilityText(`Less Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),n[t.name]=a),this.generateTemplateData(s),this.renderMainTemplate(this.generateTemplateData())}renderMainTemplate(e,t){if(e&&(!he.deepEqual(this.cachedData??{},e)||t)){this.cachedData=e;const s=this.config?.templates?.mainTemplateDesktop?.template||M.facets.mainTemplateDesktop?.template;if(this.dataLayer.renderingEngine===F.mustache&&this.searchFacetsMainContainer){const a=document.activeElement;a instanceof HTMLInputElement&&a.type==="checkbox"||a?.classList.contains("searchstax-facet-show-more-button")||a?.classList.contains("searchstax-facet-show-less-button")?this.focusedElement=a:this.focusedElement=null,this.searchFacetsMainContainer.innerHTML=E.render(s,{...e});const n=this.searchFacetsMainContainer?.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.facetsContainerClass||M.facets.mainTemplateDesktop.facetsContainerClass));if(n){n.innerHTML="";for(const r of e.facets)this.createFacetItem(r,n);if(this.searchFacetsMainContainer){const r=this.searchFacetsMainContainer.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.selectedFacetsContainerClass||M.facets.mainTemplateDesktop.selectedFacetsContainerClass));r&&(this.createSelectedFacetsComponents(r),this.createClearFacetsComponents(r))}if(this.focusedElement){if(this.focusedElement.classList.contains("searchstax-facet-show-more-button")||this.focusedElement.classList.contains("searchstax-facet-show-less-button")){const c=this.focusedElement.getAttribute("data-focus"),h=this.searchFacetsMainContainer.querySelector(`[data-focus="${c}"]`);h instanceof HTMLElement&&h.focus(),this.focusedElement=null;return}const r=this.focusedElement.getAttribute("data-test-value"),o=this.searchFacetsMainContainer.querySelector(`[data-test-value="${r}"]`);o instanceof HTMLInputElement&&o.focus(),this.focusedElement=null}}}setTimeout(()=>{document.querySelectorAll(".searchstax-facet-title").forEach(n=>{n.setAttribute("aria-expanded",String(!0)),n.setAttribute("tabindex","0"),n.setAttribute("role","button")})},100),this.renderMobileTemplate(this.generateTemplateData(!0))}else this.generateSelectedFacetsData()}get componentFacets(){const e=this.config.facetingType;return e==="and"?this.dataLayer.searchFacetsCachedand:e==="or"?this.dataLayer.searchFacetsCachedor:e==="tabs"?this.dataLayer.searchFacetsCachedtabs:e==="showUnavailable"?this.dataLayer.searchFacetsCachedand:null}generateSelectedFacetsData(){const e=[],t=this.dataLayer.searchObject.facets;for(const s of t){const a=decodeURIComponent(s.name),n=decodeURIComponent(s.value);if(this.dataLayer.searchFacets){const o=this.componentFacets?.find(c=>c.name===a);if(o){const c=o.values.find(h=>h.type==="range"?!1:h.type==="checkbox"?`"${h.value}"`==`"${n}"`:!1);c&&e.push(c)}}}this.dataLayer.setSelectedFacetsTemplateData(e)}createSelectedFacetsComponents(e){this.generateSelectedFacetsData(),this.dataLayer.selectedFacetsTemplateData?.forEach(t=>{this.createSelectedFacetsComponent(e,t)})}createClearFacetsComponents(e){if(typeof document<"u"){const t=this.dataLayer.searchObject,s=this.config?.templates?.clearFacetsTemplate?.template||M.facets.clearFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=E.render(s,{shouldShow:t.facets.length>0});const n=a.querySelector("."+(this.config?.templates?.clearFacetsTemplate?.containerClass||M.facets.clearFacetsTemplate?.containerClass));n&&(n.addEventListener("click",()=>{this.removeSelectedFacets()}),n.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.removeSelectedFacets()}),e.appendChild(n))}}createSelectedFacetsComponent(e,t){if(typeof document<"u"){const s=this.config?.templates?.selectedFacetsTemplate?.template||M.facets.selectedFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=E.render(s,t);const n=a.querySelector("."+(this.config?.templates?.selectedFacetsTemplate?.containerClass||M.facets.selectedFacetsTemplate?.containerClass));n&&(n.addEventListener("click",()=>{this.unselectFacet(t)}),n.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.unselectFacet(t)}),e.appendChild(n))}}unselectFacet(e){const t=this.dataLayer.searchObject;let 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=E.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",n=>{(n.code==="Space"||n.code==="Enter")&&this.openOverlay()}))}}openOverlay(){J.setAccessibilityText("Facet overlay opened. Tab to select facets."),this.overlayOpened=!0,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.add("searchstax-show"))}closeOverlay(){J.setAccessibilityText("Facet overlay closed"),this.overlayOpened=!1,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.remove("searchstax-show"))}renderMobileTemplate(e){if(e&&typeof document<"u"){const t=document?.createElement("div");t.classList.add("searchstax-facets-container-mobile");const s=this.config?.templates?.mainTemplateMobile?.template||M.facets.mainTemplateMobile?.template;if(this.dataLayer.renderingEngine===F.mustache){if(t.innerHTML=E.render(s,{...e,overlayOpened:this.overlayOpened}),this.searchFacetsMainContainer?.appendChild(t),this.config?.templates?.mainTemplateMobile)for(const o of this.config?.templates?.mainTemplateMobile?.closeOverlayTriggerClasses||[]){const c=t.querySelector("."+o);c&&(c.addEventListener("click",this.closeOverlay.bind(this)),c.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}else for(const o of M.facets.mainTemplateMobile.closeOverlayTriggerClasses){const c=t.querySelector("."+o);c&&(c.addEventListener("click",this.closeOverlay.bind(this)),c.addEventListener("keyup",h=>{(h.code==="Space"||h.code==="Enter")&&this.closeOverlay()}))}const a=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.filterByContainerClass||M.facets.mainTemplateMobile.filterByContainerClass));a&&this.createFilterByComponent(a);const n=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.selectedFacetsContainerClass||M.facets.mainTemplateMobile.selectedFacetsContainerClass));n&&(this.createSelectedFacetsComponents(n),this.createClearFacetsComponents(n));const r=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.facetsContainerClass||M.facets.mainTemplateMobile.facetsContainerClass));if(r){r.innerHTML="";for(const o of e.facets)this.createFacetItem(o,r,!0)}}}}}class er{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 n=a.querySelector('[tabindex="0"]');n instanceof HTMLElement&&n.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===F.mustache&&(this.searchPaginationMainContainer.innerHTML=E.render(t,e),setTimeout(()=>{this.overridePaginationEvents()},0))}}class tr{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===F.mustache){s.innerHTML=E.render(a,e);const n=s.querySelector("."+(this.config.templates?.relatedSearch?.relatedSearchContainerClass||M.relatedSearches.relatedSearch.relatedSearchContainerClass));n&&(t.appendChild(n),n.addEventListener("click",()=>{this.executeSearch(e)}),n.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.executeSearch(e)}))}}}executeSearch(e){const t=this.dataLayer.searchObject;t.query=e.related_search,this.dataLayer.setSearchObject(t),this.track(e)}renderMainTemplate(e){const t=this.config?.templates?.main?.template||M.relatedSearches.main.template;if(this.dataLayer.renderingEngine===F.mustache&&this.searchRelatedSearchesMainContainer){this.searchRelatedSearchesMainContainer.innerHTML="",this.searchRelatedSearchesMainContainer.innerHTML=E.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===F.mustache&&(this.searchFeedbackMainContainer.innerHTML=E.render(t,e),setTimeout(()=>{this.attachClick()},0))}}class sr{searchHelper;dataLayer;config;suggestAfterMinChars;containerId;currentInputValue="";autosuggestResults;suppressNextEnter=!1;searchInput;actionButton;autosuggestContainer;clearButton;separatorIcon;buttonState="search";selectedAutosuggestItem=-1;suggestTrigger;searchTrigger;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.searchTrigger=e.searchTrigger,this.suggestTrigger=e.suggestTrigger,this.containerId=e.containerId,this.suggestAfterMinChars=e.config.suggestAfterMinChars,this.suggestAfterMinChars===void 0&&this.getSuggestAfterValue(),this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())},200)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||M.searchInput.mainTemplate.template,s={...this.dataLayer.parsedData.data,locationEnabled:!!this.dataLayer.locationEnabled,hasInputValue:!1};if(this.dataLayer.setInputWidgetTemplateData(s),this.dataLayer.renderingEngine===F.mustache){const r=E.render(t,s);e.innerHTML=r,this.dataLayer.setInputTemplateRendered(!0)}const a=this.config.templates?.mainTemplate?.searchInputId||M.searchInput.mainTemplate.searchInputId,n=document?.querySelector(`#${a}`);if(n)this.searchInput=n,n.addEventListener("keyup",this.inputKeyupEvent.bind(this)),n.addEventListener("blur",this.hideAutosuggest.bind(this)),n.addEventListener("paste",this.inputPasteEvent.bind(this));else throw new Error("Input not found")}}createAutosuggestContainer(){this.dataLayer.renderingEngine===F.mustache&&typeof document<"u"&&(this.autosuggestContainer=document?.createElement("div"),this.autosuggestContainer.classList.add("searchstax-autosuggest-container"),this.autosuggestContainer.addEventListener("mouseleave",()=>{this.resetAutosuggestSelection(),this.markActiveAutosuggestItem()}),this.searchInput?.after(this.autosuggestContainer))}getSuggestAfterValue(){this.dataLayer.searchHelper&&this.dataLayer.searchHelper.suggest("*",e=>{this.suggestAfterMinChars=e.metadata.minPrefixChars},[])}actionButtonInit(){typeof document<"u"&&(this.actionButton=document?.getElementById("searchstax-search-input-action-button"),this.actionButton&&this.actionButton.addEventListener("click",()=>{this.executeSearch(this.searchInput?.value??"")}),this.clearButton=document?.getElementById("searchstax-clear-input-action-button"),this.separatorIcon=document?.getElementById("searchstax-separator-icon"),this.clearButton&&this.clearButton.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.clearInput()}))}updateClearButtonVisibility(e){const t=e.length>0;t?(this.clearButton?.classList.remove("hidden"),this.separatorIcon?.classList.remove("hidden")):(this.clearButton?.classList.add("hidden"),this.separatorIcon?.classList.add("hidden"));const s=this.dataLayer.inputWidgetTemplateData;s&&this.dataLayer.setInputWidgetTemplateData({...s,hasInputValue:t})}attachSubscriptions(){this.dataLayer.$searchTermChange.subscribe(()=>{this.handleSearchTermChange()}),this.dataLayer.$loadingChange.subscribe(()=>{this.handleLoadingChange()}),this.dataLayer.$searchAutosuggest.subscribe(e=>{e&&this.appendSuggestions(e)}),this.dataLayer.$searchObject.subscribe(e=>{e.query!=="undefined"&&e.query!==void 0&&e.query!=="*"&&this.searchInput&&(this.searchInput.value=this.cleanSuggestionTerm(e.query??""),this.updateClearButtonVisibility(this.searchInput.value))})}handleLoadingChange(){this.dataLayer.loading?this.updateActionButtonState("loading"):this.handleSearchTermChange()}handleSearchTermChange(){this.updateActionButtonState("search")}updateActionButtonState(e){if(this.buttonState=e,this.actionButton)switch(this.actionButton.classList.remove("searchstax-spinner-icon"),this.actionButton.classList.remove("searchstax-search-icon"),e){case"loading":this.actionButton.classList.add("searchstax-spinner-icon");break;case"search":this.actionButton.classList.add("searchstax-search-icon"),this.actionButton.setAttribute("aria-label","search");break}}selectPreviousAutosuggestItem(e){this.selectedAutosuggestItem>0?this.selectedAutosuggestItem--:this.selectedAutosuggestItem===0?(this.selectedAutosuggestItem=-1,e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),J.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=this.autosuggestResults.suggestions.length-1,this.markActiveAutosuggestItem()}selectNextAutosuggestItem(){this.selectedAutosuggestItem<this.autosuggestResults.suggestions.length-1?this.selectedAutosuggestItem++:this.selectedAutosuggestItem===this.autosuggestResults.suggestions.length-1?(this.selectedAutosuggestItem=-1,J.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=0,this.markActiveAutosuggestItem()}resetAutosuggestSelection(){this.selectedAutosuggestItem=-1,this.markActiveAutosuggestItem()}clearInput(){this.suppressNextEnter=!0,this.searchInput&&(this.searchInput.value="",this.currentInputValue=""),this.updateClearButtonVisibility(""),this.hideAutosuggest(),this.searchInput?.focus()}markActiveAutosuggestItem(){if(typeof document<"u"){const e=document?.getElementsByClassName("searchstax-autosuggest-item");for(let t=0;t<e.length;t++){const s=e[t];t===this.selectedAutosuggestItem?(s.classList.add("active"),J.setAccessibilityText(`Selected suggestion: ${s.innerText}`)):s.classList.remove("active")}}}inputKeyupEvent(e){const t=e.key;if(this.currentInputValue=e.target.value,t==="Enter"){if(this.suppressNextEnter){this.suppressNextEnter=!1;return}this.suggestionChosen()}else this.suppressNextEnter=!1,t==="Escape"?this.hideAutosuggest(e.target):t==="ArrowUp"?this.selectPreviousAutosuggestItem(e.target):t==="ArrowDown"?this.selectNextAutosuggestItem():this.autosuggestHandling(e);this.handleSearchTermChange(),this.updateClearButtonVisibility(this.currentInputValue)}autosuggestHandling(e){this.suggestAfterMinChars&&e.target&&e.target.value.length>=this.suggestAfterMinChars?this.executeSuggest(e.target.value):this.hideAutosuggest()}inputPasteEvent(e){setTimeout(()=>{this.autosuggestHandling(e),this.handleSearchTermChange(),this.updateClearButtonVisibility(e.target.value)},0)}executeSuggest(e){this.suggestTrigger(e)}executeSearch(e){this.hideAutosuggest(),this.searchTrigger(e===""?"*":e)}suggestionChosen(){this.selectedAutosuggestItem>-1?this.autosuggestItemClicked(this.autosuggestResults.suggestions[this.selectedAutosuggestItem]):this.executeSearch(this.currentInputValue)}hideAutosuggest(e){setTimeout(()=>{this.dataLayer.setAutosuggestResults({numFound:0,suggestions:[]}),this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.add("hidden")),this.resetAutosuggestSelection(),e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),J.setAccessibilityText("No Suggestion selected")},200)}cleanSuggestionTerm(e){return K.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=E.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 n=s[a];n.numFound?J.setAccessibilityText("Suggestions are available. Use up and down arrows to navigate while focusing input. Use Escape key to escape out of the suggestions",2e3):J.setAccessibilityText("",0),this.autosuggestResults=n,this.dataLayer.setAutosuggestResults(n),n.numFound>0?n.suggestions.forEach(r=>{this.autosuggestContainer&&typeof document<"u"&&this.autosuggestContainer.appendChild(this.createAutosuggestItem(r))}):this.autosuggestContainer&&this.autosuggestContainer.classList.add("hidden")}}}}class ir{dataLayer;config;linkClickCallback;searchCallback;containerId;searchResultsMainContainer;searchResultsContainer;searchResultLinks=[];constructor(e){this.linkClickCallback=e.linkClickCallback,this.searchCallback=e.searchTrigger,this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId;const t=document?.getElementById(this.containerId);if(t)this.searchResultsMainContainer=t;else throw new Error(`Search Results Main Container with id ${this.containerId} not found`);this.dataLayer.setIsInfiniteScroll(e.config.renderMethod==="infiniteScroll"),this.initializeSubscriptions(),this.renderMainTemplate()}initializeSubscriptions(){this.dataLayer.$searchObject.subscribe(()=>{J.setAccessibilityText("Searching...")}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.searchResultsContainer&&this.renderResults(e)})}changeTemplate(){this.dataLayer.searchResults&&this.renderResults(this.dataLayer.searchResults)}renderNoResultsTemplate(){const e=this.config?.templates?.noSearchResultTemplate?.template||M.searchResults.noSearchResultTemplate?.template,t=this.dataLayer.searchResultsMetadata?.spellingSuggestion??"";if(this.dataLayer.renderingEngine===F.mustache&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=E.render(e,{spellingSuggestion:t,...this.dataLayer.parsedData.data,searchCallback:this.searchCallback.bind(this)})),t&&this.searchResultsContainer){const s=this.searchResultsContainer.querySelector("a");s&&s.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.searchCallback(t)})}}renderResults(e){if(this.dataLayer.renderingEngine===F.mustache&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)J.setAccessibilityText("Search has no results"),this.renderNoResultsTemplate();else{J.setAccessibilityText(`Showing ${this.dataLayer.parsedData.startResultIndex} through ${this.dataLayer.parsedData.endResultIndex} results from ${this.dataLayer.parsedData.totalResults}. Press tab to navigate through results`);const t=this.config?.templates?.searchResultTemplate?.template||M.searchResults.searchResultTemplate?.template,s=e.map(a=>E.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===F.mustache&&(this.searchResultsMainContainer.innerHTML=E.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 nr{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===F.mustache){this.searchSortingMainContainer.innerHTML=E.render(t,e),this.markOptionSelected();const s=document?.getElementById(this.selectId);s&&s.addEventListener("change",a=>{this.setOrderQuery(a.target.value)})}}}class rr{analyticsKey;containerId;mainContainer;isLightweight;emailOverride;feedbackTextAreaOverride;mainTemplateOverride;lightweightTemplateOverride;focusedElement=null;focusTrapListener=null;lastFocusedElementBeforeModal=null;templateData={feedbackOpen:!1,ratings:[{index:1,isSelected:!1},{index:2,isSelected:!1},{index:3,isSelected:!1},{index:4,isSelected:!1},{index:5,isSelected:!1},{index:6,isSelected:!1},{index:7,isSelected:!1},{index:8,isSelected:!1},{index:9,isSelected:!1},{index:10,isSelected:!1}],emailInput:"",feedbackTextArea:"",charactersLeft:2e3,maxLength:2e3,errors:{rating:!1,email:!1},submitted:!1,thumbsUpActive:!1,thumbsDownActive:!1};thumbsUpValue=10;thumbsDownValue=1;ratedQuestion="";language="";model="";analyticsSrc="";constructor(e){this.analyticsKey=e.analyticsKey,this.containerId=e.containerId??"sf-feedback",this.isLightweight=e.lightweight??!1,this.isLightweight&&this.templateData.ratings.unshift({index:0,isSelected:!1}),this.thumbsUpValue=e.thumbsUpValue??10,this.thumbsDownValue=e.thumbsDownValue??1,this.emailOverride=e.emailOverride,this.feedbackTextAreaOverride=e.feedbackTextAreaOverride,this.mainTemplateOverride=e.mainTemplateOverride,this.lightweightTemplateOverride=e.lightweightTemplateOverride,this.mainContainer=document.getElementById(this.containerId),this.language=e.language??"",this.model=e.model??"",this.analyticsSrc=e.analyticsSrc??"",this.init()}init(){Le.attachAnalyticsScript(this.analyticsSrc),this.renderMainTemplate(this.generateTemplateData())}generateTemplateData(){return this.templateData}renderMainTemplate(e){const t=document.activeElement;(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLAnchorElement)&&(t.type==="radio"||t.type==="button"||t.type==="textarea"||t instanceof HTMLAnchorElement)?this.focusedElement=t:this.focusedElement=null,this.mainContainer;let s=Z?.mainTemplate?.template;if(this.mainTemplateOverride&&(s=this.mainTemplateOverride),this.isLightweight&&(s=Z.lightweightTemplate?.template,this.lightweightTemplateOverride&&(s=this.lightweightTemplateOverride)),this.mainContainer.innerHTML=E.render(s,e),this.focusedElement&&this.mainContainer){const a=this.focusedElement.type==="radio"?this.focusedElement.getAttribute("id"):this.focusedElement.getAttribute("class"),n=this.focusedElement.type==="radio"?"id":"class",r=this.mainContainer.querySelector(`[${n}="${a}"]`);(r instanceof HTMLInputElement||r instanceof HTMLButtonElement||r instanceof HTMLTextAreaElement||r instanceof HTMLAnchorElement)&&r.focus(),this.focusedElement=null}this.attachEvents()}attachEvents(){this.isLightweight?this.attachLightweightEvents():(this.attachOpenModalEvent(),this.closeModalEvent(),this.attachRatingEvents(),this.attachTextAreaEvents(),this.attachEmailInputEvents(),this.attachSubmitButtonEvents())}attachFocusTrap(){this.focusTrapListener&&document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=e=>{if(!this.templateData.feedbackOpen)return;const t=this.getModalElement();if(!t)return;const s=this.getFocusableElements(t);if(s.length===0)return;const a=s[0],n=s[s.length-1];e.key==="Tab"&&(e.shiftKey?(document.activeElement===a||!t.contains(document.activeElement))&&(e.preventDefault(),n?.focus()):(document.activeElement===n||!t.contains(document.activeElement))&&(e.preventDefault(),a?.focus())),e.key==="Escape"&&(e.preventDefault(),this.closeFeedbackModal())},document.addEventListener("keydown",this.focusTrapListener)}getFocusableElements(e){const t=["button:not([disabled])","input:not([disabled])","textarea:not([disabled])","select:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(e.querySelectorAll(t))}getModalElement(){const e=Z.mainTemplate?.modalContainerClass;return this.mainContainer?.querySelector(`.${e}`)||null}attachLightweightEvents(){const e=Z.lightweightTemplate?.thumbsUpButtonClass,t=Z.lightweightTemplate?.thumbsDownButtonClass,s=this.mainContainer?.querySelector("."+e),a=this.mainContainer?.querySelector("."+t);s&&s.addEventListener("click",()=>{const n=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[this.templateData.ratings.length-1].isSelected&&this.ratedQuestion===n||(this.templateData.thumbsUpActive=!0,this.templateData.thumbsDownActive=!1,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsUpValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=n,this.submit())}),a&&a.addEventListener("click",()=>{const n=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[0].isSelected&&this.ratedQuestion===n||(this.templateData.thumbsUpActive=!1,this.templateData.thumbsDownActive=!0,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsDownValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=n,this.submit())})}attachSubmitButtonEvents(){const e=Z.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.checkIfValid()})}checkIfValid(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.emailInputId);this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,J.setAccessibilityText("Please enter a valid email address.")),this.templateData.ratings.some(a=>a.isSelected)?this.templateData.errors.rating=!1:(this.templateData.errors.rating=!0,J.setAccessibilityText("Please Rate your experience.")),this.templateData.errors.rating||this.templateData.errors.email?this.renderMainTemplate(this.generateTemplateData()):this.submit()}submit(){this.templateData.submitted=!0;const e=this.templateData.ratings.find(t=>t.isSelected)?.index;e!==void 0&&(Le.trackFeedback({trackApiKey:this.analyticsKey,email:this.emailOverride&&this.isLightweight?this.emailOverride():this.templateData.emailInput,rating:e,feedback:this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea,model:this.model?this.model:void 0,language:this.language?this.language:void 0}),this.showCheckmarkAnimation(),J.setAccessibilityText("Feedback has been sent.",1e3),this.mainContainer?.querySelector("."+Z.mainTemplate?.checkmarkClass)?setTimeout(()=>{this.closeFeedbackModal(),this.renderMainTemplate(this.generateTemplateData())},2e3):(setTimeout(()=>{this.closeFeedbackModal()},500),this.renderMainTemplate(this.generateTemplateData())))}validateEmail(e){return e===""?!0:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}attachEmailInputEvents(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.emailInputId);e&&(e.addEventListener("input",()=>{this.templateData.emailInput=e.value}),e.addEventListener("blur",()=>{setTimeout(()=>{this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,J.setAccessibilityText("Please enter a valid email address.")),this.renderMainTemplate(this.generateTemplateData())},300)}))}attachTextAreaEvents(){const e=this.mainContainer?.querySelector("#"+Z.mainTemplate?.feedbackTextAreaId);e&&e.addEventListener("input",()=>{this.templateData.feedbackTextArea=e.value,this.templateData.charactersLeft=this.templateData.maxLength-e.value.length;const t=this.mainContainer?.querySelector("."+Z.mainTemplate?.charactersRemainingContainerclass);t&&(t.innerText=this.templateData.charactersLeft+"")})}attachRatingEvents(){const e=Z.mainTemplate?.ratingInputclass,t=this.mainContainer?.querySelectorAll("."+e);t&&t.forEach(s=>{s.addEventListener("click",a=>{const n=a.target.value;this.templateData.ratings.forEach(r=>{r.isSelected=r.index+""===n}),this.templateData.errors.rating=!1,this.renderMainTemplate(this.generateTemplateData())})})}attachOpenModalEvent(){const e=Z.mainTemplate?.openModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",s=>{s.preventDefault(),this.toggleModal()})}toggleModal(){this.templateData.feedbackOpen?this.closeFeedbackModal():this.openFeedbackModal()}closeModalEvent(){const e=Z.mainTemplate?.closeModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.closeFeedbackModal()})}openFeedbackModal(){this.lastFocusedElementBeforeModal=document.activeElement,this.templateData.feedbackOpen=!0,this.renderMainTemplate(this.generateTemplateData()),setTimeout(()=>{const e=this.getModalElement();if(e){const t=this.getFocusableElements(e);t.length>0&&t[0].focus()}this.attachFocusTrap()},0),J.setAccessibilityText("Feedback form opened",1e3)}closeFeedbackModal(){this.templateData.feedbackOpen=!1,this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null),this.renderMainTemplate(this.generateTemplateData()),this.lastFocusedElementBeforeModal&&(this.lastFocusedElementBeforeModal.focus(),this.lastFocusedElementBeforeModal=null),J.setAccessibilityText("Feedback form closed",1e3)}showCheckmarkAnimation(){const e=Z.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&(t.disabled=!0);const s=Z.mainTemplate?.checkmarkClass,a=this.mainContainer?.querySelector("."+s);a&&a.classList.remove("hidden");const n=Z.mainTemplate?.submitButtonTextClass,r=this.mainContainer?.querySelector("."+n);r&&r.classList.add("visibility"),setTimeout(()=>{a&&a.classList.add("hidden"),r&&r.classList.remove("visibility"),t&&(t.disabled=!1)},2e3)}destroy(){this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null)}}class or{dataLayer;config;containerId;answerContainer=null;showMoreVisible=!1;renderFeedbackWidget=!1;clicked=!1;renderedWithShowMore=!1;showMoreListenerAttached=!1;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.renderFeedbackWidget=this.config.feedbackwidget?.renderFeedbackWidget||!1,this.config.showMoreAfterWordCount&&(this.dataLayer.answerWidgetShowMoreLimit=this.config.showMoreAfterWordCount),typeof document<"u"&&(this.answerContainer=document?.getElementById(this.containerId),this.attachShowMoreClickListener()),this.config.testString?(this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())):this.initializeSubscriptions(),this.dataLayer.setIsAnswerWidgetCreated(!0)}initializeSubscriptions(){this.dataLayer.$answer.subscribe(()=>{this.clicked?this.showMoreVisible=!1:this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerLoading.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerError.subscribe(e=>{e&&setTimeout(()=>{this.renderMainTemplate(this.generateTemplateData())},100)}),this.dataLayer.$searchObject.subscribe(()=>{this.clicked=!1,this.renderedWithShowMore=!1,this.showMoreVisible=!1}),this.dataLayer.$paginationData.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answer.subscribe(e=>{e&&setTimeout(()=>{this.initializeWidget()},600)}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.$answer.getValue()&&setTimeout(()=>{this.initializeWidget()},600)})}searchstaxFeedbackTextAreaOverride(){return"Question: "+(this.dataLayer.searchObject.query==="undefined"?"":this.dataLayer.searchObject.query)+" Answer: "+this.dataLayer.parsedData.getAnswerData}initializeWidget(){this.renderFeedbackWidget&&document.getElementById("feedbackWidgetContainer")&&!this.dataLayer.answerLoading&&new rr({analyticsKey:this.dataLayer.parsedData.trackingData.trackApiKey,containerId:"feedbackWidgetContainer",lightweight:!0,model:this.dataLayer.parsedData.trackingData.model,language:this.dataLayer.parsedData.trackingData.language,emailOverride:this.config.feedbackwidget?.emailOverride,feedbackTextAreaOverride:this.config.feedbackwidget?.searchstaxFeedbackTextAreaOverride??this.searchstaxFeedbackTextAreaOverride.bind(this),thumbsUpValue:this.config.feedbackwidget?.thumbsUpValue??10,thumbsDownValue:this.config.feedbackwidget?.thumbsDownValue??0,lightweightTemplateOverride:this.config.feedbackwidget?.lightweightTemplateOverride})}showMore(e){e.preventDefault(),this.clicked=!0,this.showMoreVisible=!1,Le.trackShowMoreClick({...this.dataLayer.parsedData.trackingData}),this.renderMainTemplate(this.generateTemplateData()),this.config.testString||setTimeout(()=>{this.initializeWidget()},600)}attachShowMoreClickListener(){!this.answerContainer||this.showMoreListenerAttached||(this.showMoreListenerAttached=!0,this.answerContainer.addEventListener("click",e=>{e.target?.closest?.(".searchstax-answer-load-more-button")&&this.showMore(e)}))}trackLinkClick(e){e.preventDefault(),e.stopPropagation();const s=e.target.getAttribute("href");Le.trackAnswerLinkClick({href:s,answer:this.dataLayer.parsedData.getAnswerData,...this.dataLayer.parsedData.trackingData}).then(()=>{window.open(s,"_blank")}).catch(()=>{window.open(s,"_blank")})}attachLinkTracking(){document.querySelectorAll(".searchstax-answer-link").forEach(t=>{t.getAttribute("listener")!=="true"&&(t.setAttribute("listener","true"),t.addEventListener("click",this.trackLinkClick.bind(this)))})}renderMainTemplate(e){const t=this.config?.templates?.main?.template||M.answer.main.template;this.dataLayer.renderingEngine===F.mustache?(!this.renderedWithShowMore||!e.answerLoading||this.clicked)&&(e.showMoreButtonVisible&&(this.renderedWithShowMore=!0),this.answerContainer.innerHTML=E.render(t,e),setTimeout(()=>{this.attachLinkTracking()},100)):setTimeout(()=>{this.attachLinkTracking()},500)}generateTemplateData(){this.config.testString&&this.dataLayer.setAnswerData(this.config.testString??"");const e={...this.dataLayer.parsedData.data,showMoreButtonVisible:this.showMoreVisible};return this.config.testString&&(e.searchExecuted=!0),this.dataLayer.setAnswerFullData(e),e}}class Es{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===F.mustache){const a=E.render(t,s);e.innerHTML=a;const n=this.config.templates?.mainTemplate?.locationInputId||M.location.mainTemplate.locationInputId,r=document?.querySelector(`#${n}`);if(r)this.locationInput=r,r.addEventListener("blur",this.blurEvent.bind(this)),r.addEventListener("focus",this.focusEvent.bind(this));else throw new Error("Input not found");const o=this.config.templates?.mainTemplate?.radiusInputId||M.location.mainTemplate.radiusInputId,c=document?.querySelector(`#${o}`);c instanceof HTMLSelectElement&&(this.radiusInput=c,c.addEventListener("change",this.radiusSelectChangeEvent.bind(this)));const h=this.config.templates?.mainTemplate?.currentLocationActionButtonId||M.location.mainTemplate.currentLocationActionButtonId,d=document?.querySelector(`#${h}`);d&&d.addEventListener("click",this.getCurrentLocation.bind(this))}}}setCurrentLocationFields(e){this.dataLayer.setLocationCoordinatesDecoded(e),this.dataLayer.setSearchLocation(this.dataLayer.searchLocationCoordinatesDecoded),this.dataLayer.renderingEngine===F.mustache&&this.locationInput&&(this.locationInput.value=this.dataLayer.searchLocationCoordinatesDecoded)}getCurrentLocation(){navigator.geolocation?navigator.geolocation.getCurrentPosition(e=>{const t=e.coords.latitude.toString(),s=e.coords.longitude.toString(),a=Math.floor(parseFloat(t)*100)/100,n=Math.floor(parseFloat(s)*100)/100;this.dataLayer.setSearchLat(a+""),this.dataLayer.setSearchLong(n+"");const r=this.locationDecodeCoordinatesToAddress;r?r(a+"",n+"").then(o=>{this.setCurrentLocationFields(o.address||"Current Location")}).catch(()=>{this.setCurrentLocationFields("Current Location")}):this.setCurrentLocationFields("Current Location")},()=>{console.error("Unable to retrieve your location")}):console.error("Geolocation is not supported by this browser.")}setRadiusValue(e){this.dataLayer.setSearchRadius(e)}radiusSelectChangeEvent(e){this.currentSelectValue=e.target.value,this.setRadiusValue(this.currentSelectValue)}attachSubscriptions(){this.dataLayer.$searchObject.subscribe(e=>{this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(e.location.address??"")),this.radiusInput&&e.location.radius&&(this.radiusInput.value=e.location.radius||"")})}cleanSuggestionTerm(e){return K.removeXSSRiskyTags(e.replace(/(<([^>]+)>)/gi,"")).trim()}triggerGeocoder(e){const t=this.locationDecode;this.dataLayer.setLocationDecodingLoading(!0),e&&this.dataLayer.searchLocation!==e&&e!==this.dataLayer.searchLocationCoordinatesDecoded?t(e).then(s=>{this.dataLayer.setSearchLocation(s.address||""),this.dataLayer.setSearchLat(s.lat||""),this.dataLayer.setSearchLong(s.lon||""),this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(s.address||"")),this.dataLayer.renderingEngine===F.mustache&&s.error&&this.locationInput&&this.locationInput.classList.add("searchstax-input-location-error"),s.error?this.dataLayer.setLocationError(!0):this.dataLayer.setLocationError(!1),this.dataLayer.setLocationDecodingLoading(!1)}).catch(()=>{this.dataLayer.setLocationDecodingLoading(!1)}):e===""&&(this.dataLayer.setSearchLocation(void 0),this.dataLayer.setSearchLat(void 0),this.dataLayer.setSearchLong(void 0),this.dataLayer.setLocationDecodingLoading(!1))}focusEvent(e){e.target.classList.remove("searchstax-input-location-error"),this.dataLayer.setLocationError(!1)}blurEvent(e){const s=e.target.value;this.triggerGeocoder(s)}}class lr{routerEnabled=!1;cachedQuery="";routerHelper;searchHelper;searchResultsConfig;searchPaginationConfig;searchFeedbackConfig;searchSortingConfig;searchFacetsConfig;relatedSearchesConfig;externalPromotionsConfig;searchInputWidget;searchLocationWidget;searchResultsWidget;searchFacetsWidget=[];searchPaginationWidget;searchFeedbackWidget;searchSortingWidget;relatedSearchesWidget;externalPromotionsWidget;answerWidget;locationObserver=null;dataLayer;firstRequest=!0;previousQuery="";eventSource=null;renderEngine=F.mustache;constructor(e=F.mustache){e&&(this.renderEngine=e)}setRenderingEngine(e=F.mustache){this.dataLayer.setRenderingEngine(e)}handleHooks(){this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&this.dataLayer.$searchResults.subscribe(e=>{this.dataLayer.searchstaxConfig.hooks.afterSearch(e,this.dataLayer.searchResultUnparsedData)}),setTimeout(()=>{this.dataLayer.$searchObject.subscribe(e=>{e.query!==this.previousQuery&&this.dataLayer.setAnswerData(""),e.query!==""&&e.query!==void 0&&e.query!=="undefined"?(this.search(e),e.query!==this.previousQuery&&this.startSSE(e.query)):this.dataLayer.searchLocationConfig?.locationSearchEnabled&&!this.dataLayer.searchLocationConfig?.locationValuesOverride?this.getMetadata(e):this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue),this.previousQuery=e.query})},10),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&Le.trackSearch({...this.dataLayer.parsedData.trackingData,impressions:this.dataLayer.searchResultsMetadata.impressions})})}startSSE(e){this.eventSource&&(this.eventSource?.close(),this.dataLayer.setAnswerData("")),this.dataLayer.turnAIAnswerGenerationOn===!0&&this.dataLayer.questionURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&(this.eventSource=this.searchHelper?.startSSE(e,this.parseAnswerResultsResponse.bind(this)))}attachAnalyticsScript(e){Le.attachAnalyticsScript(e)}initialize(e){if(this.dataLayer=new wn("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 xn({...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.getRelatedSearches()}}getRelatedSearches(){this.searchHelper&&this.relatedSearchesConfig&&this.relatedSearchesConfig?.relatedSearchesURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&this.searchHelper.getRelatedSearches(this.dataLayer.searchObject,this.relatedSearchesConfig.relatedSearchesURL,this.relatedSearchesConfig.relatedSearchesAPIKey,this.parseRelatedSearchesResponse.bind(this))}parseRelatedSearchesResponse(e){const s=(e.response?.docs??[]).map((n,r)=>({...n,position:r+1})),a=[];for(const n of s)a.push({relatedSearch:n.related_search,position:n.position});this.dataLayer.setSearchRelatedSearches(s),this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&a.length&&Le.trackRelatedSearches({...this.dataLayer.parsedData.trackingData,impressions:a,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}handleRouter(){if(this.routerEnabled){const e={...this.dataLayer.searchObject};this.dataLayer.isInfiniteScroll&&delete e.page,this.routerHelper.updateUrl(e)}}parseSearchResultsResponseMetadata(e){const t=ct.extractSearchResultsMetadata(e),s=this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue??t.location?.filter?.defaultValue;!this.dataLayer.searchRadius&&s&&this.dataLayer.setSearchRadius(s),this.dataLayer.setSearchResultsMetadata(t)}parseSearchResultsResponse(e){if(this.handleRouter(),!e)return;this.dataLayer.setItemsPerPage(parseInt(e.responseHeader.params.rows)),this.dataLayer.setModel(e.responseHeader.params.model);let t=ct.combineResultsWithMetadata(e),s=ct.extractFacets(e);if(this.dataLayer.setSearchFacets(s),this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&(t=this.dataLayer.searchstaxConfig.hooks.afterSearch(t,e)),this.dataLayer.setSearchExternalPromotions(e.externalLinks??[]),this.parseSearchResultsResponseMetadata(e),this.dataLayer.setSearchResultUnparsedData(e),this.dataLayer.setSearchResults(t),this.firstRequest){const a=[];if(this.searchFacetsWidget.forEach(o=>{o.config.facetingType&&a.push(o.config.facetingType)}),!this.dataLayer.searchObject.facets.some(o=>o.type==="or")){const o=a.indexOf("or");o!==-1&&a.splice(o,1)}this.dataLayer.searchObject.facets.length>0&&this.searchHelper?.cacheFacets(void 0,a)}this.firstRequest=!1}parseAnswerResultsResponse(e){this.handleRouter(),e!==Be.question&&e!==Be.notQuestion&&(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setAnswerData(this.dataLayer.getAnswerData+e))}cacheFacets(e){this.searchHelper?.cacheFacets(e).then(()=>{})}parseSuggestSuggestResponse(e){let t=e;this.dataLayer.searchInputConfig?.hooks?.afterAutosuggest&&(t=this.dataLayer.searchInputConfig.hooks.afterAutosuggest(e)),this.dataLayer.setSearchAutosuggest(t)}suggest(e,t){this.searchHelper&&this.searchHelper.suggest(e,this.parseSuggestSuggestResponse.bind(this),t)}changeLanguage(e){this.searchHelper&&this.dataLayer.setLanguage(e)}addSearchInputWidget(e,t){this.dataLayer.searchInputConfig||this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.dataLayer.setSearchInputConfig(t),this.searchInputWidget=new sr({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 Es({containerId:e,config:t,dataLayer:this.dataLayer}),t?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(t?.locationValuesOverride?.locationFilterDefaultValue)):this.dataLayer.$searchResultsMetadata.subscribeUntilHasValue(()=>{this.searchLocationWidget=new Es({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 or({containerId:e,config:t,dataLayer:this.dataLayer})}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new ir({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 er({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 nr({containerId:e,config:t,dataLayer:this.dataLayer})}addRelatedSearchesWidget(e,t){this.relatedSearchesConfig=t,this.relatedSearchesWidget=new tr({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 Zn({containerId:e,config:t,dataLayer:this.dataLayer})}addFacetsWidget(e,t){this.searchFacetsConfig=t,this.searchFacetsWidget.push(new Xn({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper},this.cacheFacets.bind(this)))}executeSearch(e,t){const s={...this.dataLayer.searchObject};s.query=K.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(n=>a?{key:n,value:a[n]}:{key:"",value:""})),this.dataLayer.setSearchObject(s),this.dataLayer.lastSearchValue=s.query},!1)}executeSuggest(e){let t={term:e,queryParams:[]};this.dataLayer.searchInputConfig?.hooks?.beforeAutosuggest&&(t=this.dataLayer.searchInputConfig.hooks.beforeAutosuggest(t)),t&&t.term!==void 0&&t.queryParams!==void 0&&this.suggest(t.term,t.queryParams)}trackRelatedSearchClick(e){this.dataLayer.searchResultsMetadata&&this.dataLayer.searchRelatedSearches&&!this.dataLayer.cookiesDisabled&&Le.trackRelatedSearchClick({...this.dataLayer.parsedData.trackingData,relatedSearch:e,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}executeLinkClick(e){let t=ct.findResultByUniqueId(e,this.dataLayer.searchResults??[]);t&&(this.searchResultsConfig?.hooks?.afterLinkClick&&(t=this.searchResultsConfig.hooks.afterLinkClick(t)),t&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&Le.trackClick({result:t,...this.dataLayer.parsedData.trackingData}).then(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}).catch(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}))}setPage(e){this.searchPaginationWidget?.goToPage(e)}setCookiesDisabled(e){this.dataLayer.setCookiesDisabled(e)}changeResultTemplate(e){this.searchResultsConfig&&(this.searchResultsConfig.templates=this.searchResultsConfig?.templates?{...this.searchResultsConfig?.templates,...e}:e,this.searchResultsWidget?.changeTemplate())}}_a.Searchstax=lr,Object.defineProperty(_a,Symbol.toStringTag,{value:"Module"})})(this["@searchstaxInc/searchstudioUxJs"]=this["@searchstaxInc/searchstudioUxJs"]||{});