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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,30 +1,30 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var j=(n=>(n[n.mustache=0]="mustache",n[n.vue=1]="vue",n[n.react=2]="react",n[n.angular=3]="angular",n))(j||{});function ha(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ee=ha();function gs(n){Ee=n}var at={exec:()=>null};function k(n,e=""){let t=typeof n=="string"?n:n.source;const s={replace:(a,i)=>{let r=typeof i=="string"?i:i.source;return r=r.replace(J.caret,"$1"),t=t.replace(a,r),s},getRegex:()=>new RegExp(t,e)};return s}var J={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:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i")},Bs=/^(?:[ \t]*(?:\n|$))+/,Hs=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Us=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,rt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Qs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ua=/(?:[*+-]|\d{1,9}[.)])/,ps=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fs=k(ps).replace(/bull/g,ua).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),qs=k(ps).replace(/bull/g,ua).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(),da=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ws=/^[^\n]+/,ga=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ys=k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ga).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Js=k(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ua).getRegex(),At="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",pa=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Gs=k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",pa).replace("tag",At).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ms=k(da).replace("hr",rt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",At).getRegex(),Zs=k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ms).getRegex(),fa={blockquote:Zs,code:Hs,def:Ys,fences:Us,heading:Qs,hr:rt,html:Gs,lheading:fs,list:Js,newline:Bs,paragraph:ms,table:at,text:Ws},Qa=k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",rt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",At).getRegex(),Ks={...fa,lheading:qs,table:Qa,paragraph:k(da).replace("hr",rt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Qa).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",At).getRegex()},Xs={...fa,html:k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",pa).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:at,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:k(da).replace("hr",rt).replace("heading",` *#{1,6} *[^
2
- ]`).replace("lheading",fs).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ei=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ti=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ls=/^( {2,}|\\)\n(?!\s*$)/,ai=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,vt=/[\p{P}\p{S}]/u,ma=/[\s\p{P}\p{S}]/u,ys=/[^\s\p{P}\p{S}]/u,si=k(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ma).getRegex(),ws=/(?!~)[\p{P}\p{S}]/u,ii=/(?!~)[\s\p{P}\p{S}]/u,ni=/(?:[^\s\p{P}\p{S}]|~)/u,ri=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Ms=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,oi=k(Ms,"u").replace(/punct/g,vt).getRegex(),li=k(Ms,"u").replace(/punct/g,ws).getRegex(),Cs="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ci=k(Cs,"gu").replace(/notPunctSpace/g,ys).replace(/punctSpace/g,ma).replace(/punct/g,vt).getRegex(),hi=k(Cs,"gu").replace(/notPunctSpace/g,ni).replace(/punctSpace/g,ii).replace(/punct/g,ws).getRegex(),ui=k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ys).replace(/punctSpace/g,ma).replace(/punct/g,vt).getRegex(),di=k(/\\(punct)/,"gu").replace(/punct/g,vt).getRegex(),gi=k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),pi=k(pa).replace("(?:-->|$)","-->").getRegex(),fi=k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",pi).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Tt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,mi=k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Tt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),bs=k(/^!?\[(label)\]\[(ref)\]/).replace("label",Tt).replace("ref",ga).getRegex(),Ss=k(/^!?\[(ref)\](?:\[\])?/).replace("ref",ga).getRegex(),Li=k("reflink|nolink(?!\\()","g").replace("reflink",bs).replace("nolink",Ss).getRegex(),La={_backpedal:at,anyPunctuation:di,autolink:gi,blockSkip:ri,br:Ls,code:ti,del:at,emStrongLDelim:oi,emStrongRDelimAst:ci,emStrongRDelimUnd:ui,escape:ei,link:mi,nolink:Ss,punctuation:si,reflink:bs,reflinkSearch:Li,tag:fi,text:ai,url:at},yi={...La,link:k(/^!?\[(label)\]\((.*?)\)/).replace("label",Tt).getRegex(),reflink:k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Tt).getRegex()},Zt={...La,emStrongRDelimAst:hi,emStrongLDelim:li,url:k(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},wi={...Zt,br:k(Ls).replace("{2,}","*").getRegex(),text:k(Zt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},yt={normal:fa,gfm:Ks,pedantic:Xs},Qe={normal:La,gfm:Zt,breaks:wi,pedantic:yi},Mi={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},qa=n=>Mi[n];function ue(n,e){if(e){if(J.escapeTest.test(n))return n.replace(J.escapeReplace,qa)}else if(J.escapeTestNoEncode.test(n))return n.replace(J.escapeReplaceNoEncode,qa);return n}function Wa(n){try{n=encodeURI(n).replace(J.percentDecode,"%")}catch{return null}return n}function Ya(n,e){const t=n.replace(J.findPipe,(i,r,o)=>{let c=!1,h=r;for(;--h>=0&&o[h]==="\\";)c=!c;return c?"|":" |"}),s=t.split(J.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(J.slashPipe,"|");return s}function qe(n,e,t){const s=n.length;if(s===0)return"";let a=0;for(;a<s&&n.charAt(s-a-1)===e;)a++;return n.slice(0,s-a)}function Ci(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let s=0;s<n.length;s++)if(n[s]==="\\")s++;else if(n[s]===e[0])t++;else if(n[s]===e[1]&&(t--,t<0))return s;return t>0?-2:-1}function Ja(n,e,t,s,a){const i=e.href,r=e.title||null,o=n[1].replace(a.other.outputLinkReplace,"$1");s.state.inLink=!0;const c={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:r,text:o,tokens:s.inlineTokens(o)};return s.state.inLink=!1,c}function bi(n,e,t){const s=n.match(t.other.indentCodeCompensation);if(s===null)return e;const a=s[1];return e.split(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var P=(n=>(n[n.mustache=0]="mustache",n[n.vue=1]="vue",n[n.react=2]="react",n[n.angular=3]="angular",n))(P||{});function pa(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var De=pa();function xs(n){De=n}var rt={exec:()=>null};function D(n,e=""){let t=typeof n=="string"?n:n.source;const s={replace:(a,i)=>{let r=typeof i=="string"?i:i.source;return r=r.replace(X.caret,"$1"),t=t.replace(a,r),s},getRegex:()=>new RegExp(t,e)};return s}var X={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i")},Ks=/^(?:[ \t]*(?:\n|$))+/,Xs=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ei=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ht=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ti=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,fa=/(?:[*+-]|\d{1,9}[.)])/,ks=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,As=D(ks).replace(/bull/g,fa).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(),ai=D(ks).replace(/bull/g,fa).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(),ma=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,si=/^[^\n]+/,La=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ii=D(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",La).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ni=D(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,fa).getRegex(),Dt="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",ya=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ri=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",ya).replace("tag",Dt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Es=D(ma).replace("hr",ht).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",Dt).getRegex(),oi=D(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Es).getRegex(),wa={blockquote:oi,code:Xs,def:ii,fences:ei,heading:ti,hr:ht,html:ri,lheading:As,list:ni,newline:Ks,paragraph:Es,table:rt,text:si},Ga=D("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ht).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",Dt).getRegex(),li={...wa,lheading:ai,table:Ga,paragraph:D(ma).replace("hr",ht).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ga).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",Dt).getRegex()},ci={...wa,html:D(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ya).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:rt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:D(ma).replace("hr",ht).replace("heading",` *#{1,6} *[^
2
+ ]`).replace("lheading",As).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},hi=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ui=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,vs=/^( {2,}|\\)\n(?!\s*$)/,di=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,It=/[\p{P}\p{S}]/u,Ca=/[\s\p{P}\p{S}]/u,Ds=/[^\s\p{P}\p{S}]/u,gi=D(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ca).getRegex(),Is=/(?!~)[\p{P}\p{S}]/u,pi=/(?!~)[\s\p{P}\p{S}]/u,fi=/(?:[^\s\p{P}\p{S}]|~)/u,mi=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Rs=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Li=D(Rs,"u").replace(/punct/g,It).getRegex(),yi=D(Rs,"u").replace(/punct/g,Is).getRegex(),js="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",wi=D(js,"gu").replace(/notPunctSpace/g,Ds).replace(/punctSpace/g,Ca).replace(/punct/g,It).getRegex(),Ci=D(js,"gu").replace(/notPunctSpace/g,fi).replace(/punctSpace/g,pi).replace(/punct/g,Is).getRegex(),Mi=D("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ds).replace(/punctSpace/g,Ca).replace(/punct/g,It).getRegex(),bi=D(/\\(punct)/,"gu").replace(/punct/g,It).getRegex(),Ti=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(),Si=D(ya).replace("(?:-->|$)","-->").getRegex(),xi=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",Si).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),kt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ki=D(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",kt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ns=D(/^!?\[(label)\]\[(ref)\]/).replace("label",kt).replace("ref",La).getRegex(),Ps=D(/^!?\[(ref)\](?:\[\])?/).replace("ref",La).getRegex(),Ai=D("reflink|nolink(?!\\()","g").replace("reflink",Ns).replace("nolink",Ps).getRegex(),Ma={_backpedal:rt,anyPunctuation:bi,autolink:Ti,blockSkip:mi,br:vs,code:ui,del:rt,emStrongLDelim:Li,emStrongRDelimAst:wi,emStrongRDelimUnd:Mi,escape:hi,link:ki,nolink:Ps,punctuation:gi,reflink:Ns,reflinkSearch:Ai,tag:xi,text:di,url:rt},Ei={...Ma,link:D(/^!?\[(label)\]\((.*?)\)/).replace("label",kt).getRegex(),reflink:D(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",kt).getRegex()},ta={...Ma,emStrongRDelimAst:Ci,emStrongLDelim:yi,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.!#$%&'*+\/=?_`{\|}~-]+@)))/},vi={...ta,br:D(vs).replace("{2,}","*").getRegex(),text:D(ta.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ct={normal:wa,gfm:li,pedantic:ci},Ge={normal:Ma,gfm:ta,breaks:vi,pedantic:Ei},Di={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Za=n=>Di[n];function fe(n,e){if(e){if(X.escapeTest.test(n))return n.replace(X.escapeReplace,Za)}else if(X.escapeTestNoEncode.test(n))return n.replace(X.escapeReplaceNoEncode,Za);return n}function Ka(n){try{n=encodeURI(n).replace(X.percentDecode,"%")}catch{return null}return n}function Xa(n,e){const t=n.replace(X.findPipe,(i,r,o)=>{let c=!1,h=r;for(;--h>=0&&o[h]==="\\";)c=!c;return c?"|":" |"}),s=t.split(X.splitPipe);let a=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;a<s.length;a++)s[a]=s[a].trim().replace(X.slashPipe,"|");return s}function Ze(n,e,t){const s=n.length;if(s===0)return"";let a=0;for(;a<s&&n.charAt(s-a-1)===e;)a++;return n.slice(0,s-a)}function Ii(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let s=0;s<n.length;s++)if(n[s]==="\\")s++;else if(n[s]===e[0])t++;else if(n[s]===e[1]&&(t--,t<0))return s;return t>0?-2:-1}function es(n,e,t,s,a){const i=e.href,r=e.title||null,o=n[1].replace(a.other.outputLinkReplace,"$1");s.state.inLink=!0;const c={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:r,text:o,tokens:s.inlineTokens(o)};return s.state.inLink=!1,c}function Ri(n,e,t){const s=n.match(t.other.indentCodeCompensation);if(s===null)return e;const a=s[1];return e.split(`
3
3
  `).map(i=>{const r=i.match(t.other.beginningSpace);if(r===null)return i;const[o]=r;return o.length>=a.length?i.slice(a.length):i}).join(`
4
- `)}var xt=class{options;rules;lexer;constructor(n){this.options=n||Ee}space(n){const e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){const e=this.rules.block.code.exec(n);if(e){const t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:qe(t,`
5
- `)}}}fences(n){const e=this.rules.block.fences.exec(n);if(e){const t=e[0],s=bi(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(n){const e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){const s=qe(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(n){const e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:qe(e[0],`
6
- `)}}blockquote(n){const e=this.rules.block.blockquote.exec(n);if(e){let t=qe(e[0],`
4
+ `)}var At=class{options;rules;lexer;constructor(n){this.options=n||De}space(n){const e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){const e=this.rules.block.code.exec(n);if(e){const t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Ze(t,`
5
+ `)}}}fences(n){const e=this.rules.block.fences.exec(n);if(e){const t=e[0],s=Ri(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(n){const e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){const s=Ze(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(n){const e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Ze(e[0],`
6
+ `)}}blockquote(n){const e=this.rules.block.blockquote.exec(n);if(e){let t=Ze(e[0],`
7
7
  `).split(`
8
8
  `),s="",a="";const i=[];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
10
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
11
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,i,!0),this.lexer.state.top=y,t.length===0)break;const L=i.at(-1);if(L?.type==="code")break;if(L?.type==="blockquote"){const E=L,M=E.raw+`
12
+ ${d}`:d;const C=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,i,!0),this.lexer.state.top=C,t.length===0)break;const y=i.at(-1);if(y?.type==="code")break;if(y?.type==="blockquote"){const I=y,S=I.raw+`
13
13
  `+t.join(`
14
- `),p=this.blockquote(M);i[i.length-1]=p,s=s.substring(0,s.length-E.raw.length)+p.raw,a=a.substring(0,a.length-E.text.length)+p.text;break}else if(L?.type==="list"){const E=L,M=E.raw+`
14
+ `),x=this.blockquote(S);i[i.length-1]=x,s=s.substring(0,s.length-I.raw.length)+x.raw,a=a.substring(0,a.length-I.text.length)+x.text;break}else if(y?.type==="list"){const I=y,S=I.raw+`
15
15
  `+t.join(`
16
- `),p=this.list(M);i[i.length-1]=p,s=s.substring(0,s.length-L.raw.length)+p.raw,a=a.substring(0,a.length-E.raw.length)+p.raw,t=M.substring(i.at(-1).raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:s,tokens:i,text:a}}}list(n){let e=this.rules.block.list.exec(n);if(e){let t=e[1].trim();const s=t.length>1,a={type:"list",raw:"",ordered:s,start:s?+t.slice(0,-1):"",loose:!1,items:[]};t=s?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=s?t:"[*+-]");const i=this.rules.other.listItemRegex(t);let r=!1;for(;n;){let c=!1,h="",d="";if(!(e=i.exec(n))||this.rules.block.hr.test(n))break;h=e[0],n=n.substring(h.length);let y=e[2].split(`
18
- `,1)[0].replace(this.rules.other.listReplaceTabs,A=>" ".repeat(3*A.length)),L=n.split(`
19
- `,1)[0],E=!y.trim(),M=0;if(this.options.pedantic?(M=2,d=y.trimStart()):E?M=e[1].length+1:(M=e[2].search(this.rules.other.nonSpaceChar),M=M>4?1:M,d=y.slice(M),M+=e[1].length),E&&this.rules.other.blankLine.test(L)&&(h+=L+`
20
- `,n=n.substring(L.length+1),c=!0),!c){const A=this.rules.other.nextBulletRegex(M),R=this.rules.other.hrRegex(M),B=this.rules.other.fencesBeginRegex(M),I=this.rules.other.headingBeginRegex(M),q=this.rules.other.htmlBeginRegex(M);for(;n;){const ie=n.split(`
21
- `,1)[0];let ge;if(L=ie,this.options.pedantic?(L=L.replace(this.rules.other.listReplaceNesting," "),ge=L):ge=L.replace(this.rules.other.tabCharGlobal," "),B.test(L)||I.test(L)||q.test(L)||A.test(L)||R.test(L))break;if(ge.search(this.rules.other.nonSpaceChar)>=M||!L.trim())d+=`
22
- `+ge.slice(M);else{if(E||y.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||B.test(y)||I.test(y)||R.test(y))break;d+=`
23
- `+L}!E&&!L.trim()&&(E=!0),h+=ie+`
24
- `,n=n.substring(ie.length+1),y=ge.slice(M)}}a.loose||(r?a.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(r=!0));let p=null,T;this.options.gfm&&(p=this.rules.other.listIsTask.exec(d),p&&(T=p[0]!=="[ ] ",d=d.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:h,task:!!p,checked:T,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(n){const e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){const e=this.rules.block.def.exec(n);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(n){const e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const t=Ya(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
- `):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===s.length){for(const r of s)this.rules.other.tableAlignRight.test(r)?i.align.push("right"):this.rules.other.tableAlignCenter.test(r)?i.align.push("center"):this.rules.other.tableAlignLeft.test(r)?i.align.push("left"):i.align.push(null);for(let r=0;r<t.length;r++)i.header.push({text:t[r],tokens:this.lexer.inline(t[r]),header:!0,align:i.align[r]});for(const r of a)i.rows.push(Ya(r,i.header.length).map((o,c)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:i.align[c]})));return i}}lheading(n){const e=this.rules.block.lheading.exec(n);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(n){const e=this.rules.block.paragraph.exec(n);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(n){const e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){const e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){const e=this.rules.inline.tag.exec(n);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(n){const e=this.rules.inline.link.exec(n);if(e){const t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;const i=qe(t.slice(0,-1),"\\");if((t.length-i.length)%2===0)return}else{const i=Ci(e[2],"()");if(i===-2)return;if(i>-1){const o=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let s=e[2],a="";if(this.options.pedantic){const i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],a=i[3])}else a=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?s=s.slice(1):s=s.slice(1,-1)),Ja(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(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){const s=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),a=e[s.toLowerCase()];if(!a){const i=t[0].charAt(0);return{type:"text",raw:i,text:i}}return Ja(t,a,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let s=this.rules.inline.emStrongLDelim.exec(n);if(!s||s[3]&&t.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[2]||"")||!t||this.rules.inline.punctuation.exec(t)){const i=[...s[0]].length-1;let r,o,c=i,h=0;const d=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,e=e.slice(-1*n.length+i);(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])&&i%3&&!((i+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=n.slice(0,i+s.index+y+o);if(Math.min(i,o)%2){const M=L.slice(1,-1);return{type:"em",raw:L,text:M,tokens:this.lexer.inlineTokens(M)}}const E=L.slice(2,-2);return{type:"strong",raw:L,text:E,tokens:this.lexer.inlineTokens(E)}}}}codespan(n){const e=this.rules.inline.code.exec(n);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(n){const e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n){const e=this.rules.inline.del.exec(n);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(n){const e=this.rules.inline.autolink.exec(n);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(n){let e;if(e=this.rules.inline.url.exec(n)){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(n){const e=this.rules.inline.text.exec(n);if(e){const t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},Le=class Kt{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 xt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={other:J,block:yt.normal,inline:Qe.normal};this.options.pedantic?(t.block=yt.pedantic,t.inline=Qe.pedantic):this.options.gfm&&(t.block=yt.gfm,this.options.breaks?t.inline=Qe.breaks:t.inline=Qe.gfm),this.tokenizer.rules=t}static get rules(){return{block:yt,inline:Qe}}static lex(e,t){return new Kt(t).lex(e)}static lexInline(e,t){return new Kt(t).inlineTokens(e)}lex(e){e=e.replace(J.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(J.tabCharGlobal," ").replace(J.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+=`
16
+ `),x=this.list(S);i[i.length-1]=x,s=s.substring(0,s.length-y.raw.length)+x.raw,a=a.substring(0,a.length-I.raw.length)+x.raw,t=S.substring(i.at(-1).raw.length).split(`
17
+ `);continue}}return{type:"blockquote",raw:s,tokens:i,text:a}}}list(n){let e=this.rules.block.list.exec(n);if(e){let t=e[1].trim();const s=t.length>1,a={type:"list",raw:"",ordered:s,start:s?+t.slice(0,-1):"",loose:!1,items:[]};t=s?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=s?t:"[*+-]");const i=this.rules.other.listItemRegex(t);let r=!1;for(;n;){let c=!1,h="",d="";if(!(e=i.exec(n))||this.rules.block.hr.test(n))break;h=e[0],n=n.substring(h.length);let C=e[2].split(`
18
+ `,1)[0].replace(this.rules.other.listReplaceTabs,p=>" ".repeat(3*p.length)),y=n.split(`
19
+ `,1)[0],I=!C.trim(),S=0;if(this.options.pedantic?(S=2,d=C.trimStart()):I?S=e[1].length+1:(S=e[2].search(this.rules.other.nonSpaceChar),S=S>4?1:S,d=C.slice(S),S+=e[1].length),I&&this.rules.other.blankLine.test(y)&&(h+=y+`
20
+ `,n=n.substring(y.length+1),c=!0),!c){const p=this.rules.other.nextBulletRegex(S),g=this.rules.other.hrRegex(S),w=this.rules.other.fencesBeginRegex(S),T=this.rules.other.headingBeginRegex(S),E=this.rules.other.htmlBeginRegex(S);for(;n;){const _=n.split(`
21
+ `,1)[0];let ce;if(y=_,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),ce=y):ce=y.replace(this.rules.other.tabCharGlobal," "),w.test(y)||T.test(y)||E.test(y)||p.test(y)||g.test(y))break;if(ce.search(this.rules.other.nonSpaceChar)>=S||!y.trim())d+=`
22
+ `+ce.slice(S);else{if(I||C.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||w.test(C)||T.test(C)||g.test(C))break;d+=`
23
+ `+y}!I&&!y.trim()&&(I=!0),h+=_+`
24
+ `,n=n.substring(_.length+1),C=ce.slice(S)}}a.loose||(r?a.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(r=!0));let x=null,H;this.options.gfm&&(x=this.rules.other.listIsTask.exec(d),x&&(H=x[0]!=="[ ] ",d=d.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:h,task:!!x,checked:H,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(C=>C.type==="space"),d=h.length>0&&h.some(C=>this.rules.other.anyLine.test(C.raw));a.loose=d}if(a.loose)for(let c=0;c<a.items.length;c++)a.items[c].loose=!0;return a}}html(n){const e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){const e=this.rules.block.def.exec(n);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(n){const e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const t=Xa(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
+ `):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===s.length){for(const r of s)this.rules.other.tableAlignRight.test(r)?i.align.push("right"):this.rules.other.tableAlignCenter.test(r)?i.align.push("center"):this.rules.other.tableAlignLeft.test(r)?i.align.push("left"):i.align.push(null);for(let r=0;r<t.length;r++)i.header.push({text:t[r],tokens:this.lexer.inline(t[r]),header:!0,align:i.align[r]});for(const r of a)i.rows.push(Xa(r,i.header.length).map((o,c)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:i.align[c]})));return i}}lheading(n){const e=this.rules.block.lheading.exec(n);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(n){const e=this.rules.block.paragraph.exec(n);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(n){const e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){const e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){const e=this.rules.inline.tag.exec(n);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(n){const e=this.rules.inline.link.exec(n);if(e){const t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;const i=Ze(t.slice(0,-1),"\\");if((t.length-i.length)%2===0)return}else{const i=Ii(e[2],"()");if(i===-2)return;if(i>-1){const o=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let s=e[2],a="";if(this.options.pedantic){const i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],a=i[3])}else a=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?s=s.slice(1):s=s.slice(1,-1)),es(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(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){const s=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),a=e[s.toLowerCase()];if(!a){const i=t[0].charAt(0);return{type:"text",raw:i,text:i}}return es(t,a,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let s=this.rules.inline.emStrongLDelim.exec(n);if(!s||s[3]&&t.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[2]||"")||!t||this.rules.inline.punctuation.exec(t)){const i=[...s[0]].length-1;let r,o,c=i,h=0;const d=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,e=e.slice(-1*n.length+i);(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])&&i%3&&!((i+o)%3)){h+=o;continue}if(c-=o,c>0)continue;o=Math.min(o,o+c+h);const C=[...s[0]][0].length,y=n.slice(0,i+s.index+C+o);if(Math.min(i,o)%2){const S=y.slice(1,-1);return{type:"em",raw:y,text:S,tokens:this.lexer.inlineTokens(S)}}const I=y.slice(2,-2);return{type:"strong",raw:y,text:I,tokens:this.lexer.inlineTokens(I)}}}}codespan(n){const e=this.rules.inline.code.exec(n);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(n){const e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n){const e=this.rules.inline.del.exec(n);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(n){const e=this.rules.inline.autolink.exec(n);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(n){let e;if(e=this.rules.inline.url.exec(n)){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(n){const e=this.rules.inline.text.exec(n);if(e){const t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},we=class aa{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||De,this.options.tokenizer=this.options.tokenizer||new At,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={other:X,block:Ct.normal,inline:Ge.normal};this.options.pedantic?(t.block=Ct.pedantic,t.inline=Ge.pedantic):this.options.gfm&&(t.block=Ct.gfm,this.options.breaks?t.inline=Ge.breaks:t.inline=Ge.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ct,inline:Ge}}static lex(e,t){return new aa(t).lex(e)}static lexInline(e,t){return new aa(t).inlineTokens(e)}lex(e){e=e.replace(X.carriageReturn,`
27
+ `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const s=this.inlineQueue[t];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){for(this.options.pedantic&&(e=e.replace(X.tabCharGlobal," ").replace(X.spaceLine,""));e;){let a;if(this.options.extensions?.block?.some(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
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
29
  `+a.raw,r.text+=`
30
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+=`
@@ -33,16 +33,16 @@ ${d}`:d;const y=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
33
33
  `+a.raw,r.text+=`
34
34
  `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(a),s=i.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);const r=t.at(-1);r?.type==="text"?(r.raw+=`
35
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 i=!1,r="";for(;e;){i||(r=""),i=!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)),i=!0;const h=t.at(-1);h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):t.push(o);continue}if(e){const h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return t}},kt=class{options;parser;constructor(n){this.options=n||Ee}space(n){return""}code({text:n,lang:e,escaped:t}){const s=(e||"").match(J.notSpaceStart)?.[0],a=n.replace(J.endingNewline,"")+`
37
- `;return s?'<pre><code class="language-'+ue(s)+'">'+(t?a:ue(a,!0))+`</code></pre>
38
- `:"<pre><code>"+(t?a:ue(a,!0))+`</code></pre>
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 i=!1,r="";for(;e;){i||(r=""),i=!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 C;this.options.extensions.startInline.forEach(y=>{C=y.call({lexer:this},d),typeof C=="number"&&C>=0&&(h=Math.min(h,C))}),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)),i=!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}},Et=class{options;parser;constructor(n){this.options=n||De}space(n){return""}code({text:n,lang:e,escaped:t}){const s=(e||"").match(X.notSpaceStart)?.[0],a=n.replace(X.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:n}){return`<blockquote>
40
40
  ${this.parser.parse(n)}</blockquote>
41
41
  `}html({text:n}){return n}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
42
42
  `}hr(n){return`<hr>
43
43
  `}list(n){const e=n.ordered,t=n.start;let s="";for(let r=0;r<n.items.length;r++){const o=n.items[r];s+=this.listitem(o)}const a=e?"ol":"ul",i=e&&t!==1?' start="'+t+'"':"";return"<"+a+i+`>
44
44
  `+s+"</"+a+`>
45
- `}listitem(n){let e="";if(n.task){const t=this.checkbox({checked:!!n.checked});n.loose?n.tokens[0]?.type==="paragraph"?(n.tokens[0].text=t+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=t+" "+ue(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:!0}):e+=t+" "}return e+=this.parser.parse(n.tokens,!!n.loose),`<li>${e}</li>
45
+ `}listitem(n){let e="";if(n.task){const t=this.checkbox({checked:!!n.checked});n.loose?n.tokens[0]?.type==="paragraph"?(n.tokens[0].text=t+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=t+" "+fe(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:!0}):e+=t+" "}return e+=this.parser.parse(n.tokens,!!n.loose),`<li>${e}</li>
46
46
  `}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
47
47
  `}table(n){let e="",t="";for(let a=0;a<n.header.length;a++)t+=this.tablecell(n.header[a]);e+=this.tablerow({text:t});let s="";for(let a=0;a<n.rows.length;a++){const i=n.rows[a];t="";for(let r=0;r<i.length;r++)t+=this.tablecell(i[r]);s+=this.tablerow({text:t})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
48
48
  <thead>
@@ -51,17 +51,22 @@ ${this.parser.parse(n)}</blockquote>
51
51
  `}tablerow({text:n}){return`<tr>
52
52
  ${n}</tr>
53
53
  `}tablecell(n){const e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
54
- `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${ue(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){const s=this.parser.parseInline(t),a=Wa(n);if(a===null)return s;n=a;let i='<a href="'+n+'"';return e&&(i+=' title="'+ue(e)+'"'),i+=">"+s+"</a>",i}image({href:n,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));const a=Wa(n);if(a===null)return ue(t);n=a;let i=`<img src="${n}" alt="${t}"`;return e&&(i+=` title="${ue(e)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:ue(n.text)}},ya=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}},ye=class Xt{options;renderer;textRenderer;constructor(e){this.options=e||Ee,this.options.renderer=this.options.renderer||new kt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ya}static parse(e,t){return new Xt(t).parse(e)}static parseInline(e,t){return new Xt(t).parseInline(e)}parse(e,t=!0){let s="";for(let a=0;a<e.length;a++){const i=e[a];if(this.options.extensions?.renderers?.[i.type]){const o=i,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=i;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 i=e[a];if(this.options.extensions?.renderers?.[i.type]){const o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){s+=o||"";continue}}const r=i;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}},Mt=class{options;block;constructor(n){this.options=n||Ee}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Le.lex:Le.lexInline}provideParser(){return this.block?ye.parse:ye.parseInline}},Si=class{defaults=ha();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ye;Renderer=kt;TextRenderer=ya;Lexer=Le;Tokenizer=xt;Hooks=Mt;constructor(...n){this.use(...n)}walkTokens(n,e){let t=[];for(const s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{const a=s;for(const i of a.header)t=t.concat(this.walkTokens(i.tokens,e));for(const i of a.rows)for(const r of i)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(i=>{const r=a[i].flat(1/0);t=t.concat(this.walkTokens(r,e))}):a.tokens&&(t=t.concat(this.walkTokens(a.tokens,e)))}}return t}use(...n){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{const s={...t};if(s.async=this.defaults.async||s.async||!1,t.extensions&&(t.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const i=e.renderers[a.name];i?e.renderers[a.name]=function(...r){let o=a.renderer.apply(this,r);return o===!1&&(o=i.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 i=e[a.level];i?i.unshift(a.tokenizer):e[a.level]=[a.tokenizer],a.start&&(a.level==="block"?e.startBlock?e.startBlock.push(a.start):e.startBlock=[a.start]:a.level==="inline"&&(e.startInline?e.startInline.push(a.start):e.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(e.childTokens[a.name]=a.childTokens)}),s.extensions=e),t.renderer){const a=this.defaults.renderer||new kt(this.defaults);for(const i in t.renderer){if(!(i in a))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const r=i,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 xt(this.defaults);for(const i in t.tokenizer){if(!(i in a))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const r=i,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 Mt;for(const i in t.hooks){if(!(i in a))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const r=i,o=t.hooks[r],c=a[r];Mt.passThroughHooks.has(i)?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,i=t.walkTokens;s.walkTokens=function(r){let o=[];return o.push(i.call(this,r)),a&&(o=o.concat(a.call(this,r))),o}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return Le.lex(n,e??this.defaults)}parser(n,e){return ye.parse(n,e??this.defaults)}parseMarkdown(n){return(t,s)=>{const a={...s},i={...this.defaults,...a},r=this.onError(!!i.silent,!!i.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"));i.hooks&&(i.hooks.options=i,i.hooks.block=n);const o=i.hooks?i.hooks.provideLexer():n?Le.lex:Le.lexInline,c=i.hooks?i.hooks.provideParser():n?ye.parse:ye.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(h=>o(h,i)).then(h=>i.hooks?i.hooks.processAllTokens(h):h).then(h=>i.walkTokens?Promise.all(this.walkTokens(h,i.walkTokens)).then(()=>h):h).then(h=>c(h,i)).then(h=>i.hooks?i.hooks.postprocess(h):h).catch(r);try{i.hooks&&(t=i.hooks.preprocess(t));let h=o(t,i);i.hooks&&(h=i.hooks.processAllTokens(h)),i.walkTokens&&this.walkTokens(h,i.walkTokens);let d=c(h,i);return i.hooks&&(d=i.hooks.postprocess(d)),d}catch(h){return r(h)}}}onError(n,e){return t=>{if(t.message+=`
56
- Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An error occurred:</p><pre>"+ue(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},ke=new Si;function x(n,e){return ke.parse(n,e)}x.options=x.setOptions=function(n){return ke.setOptions(n),x.defaults=ke.defaults,gs(x.defaults),x};x.getDefaults=ha;x.defaults=Ee;x.use=function(...n){return ke.use(...n),x.defaults=ke.defaults,gs(x.defaults),x};x.walkTokens=function(n,e){return ke.walkTokens(n,e)};x.parseInline=ke.parseInline;x.Parser=ye;x.parser=ye.parse;x.Renderer=kt;x.TextRenderer=ya;x.Lexer=Le;x.lexer=Le.lex;x.Tokenizer=xt;x.Hooks=Mt;x.parse=x;x.options;x.setOptions;x.use;x.walkTokens;x.parseInline;ye.parse;Le.lex;const{entries:Ts,setPrototypeOf:Ga,isFrozen:Ti,getPrototypeOf:xi,getOwnPropertyDescriptor:ki}=Object;let{freeze:G,seal:se,create:Ke}=Object,{apply:ea,construct:ta}=typeof Reflect<"u"&&Reflect;G||(G=function(e){return e});se||(se=function(e){return e});ea||(ea=function(e,t){for(var s=arguments.length,a=new Array(s>2?s-2:0),i=2;i<s;i++)a[i-2]=arguments[i];return e.apply(t,a)});ta||(ta=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 We=Z(Array.prototype.forEach),Ei=Z(Array.prototype.lastIndexOf),Za=Z(Array.prototype.pop),Ye=Z(Array.prototype.push),Ai=Z(Array.prototype.splice),Ct=Z(String.prototype.toLowerCase),Bt=Z(String.prototype.toString),Ht=Z(String.prototype.match),je=Z(String.prototype.replace),vi=Z(String.prototype.indexOf),Di=Z(String.prototype.trim),oe=Z(Object.prototype.hasOwnProperty),Y=Z(RegExp.prototype.test),Je=Ii(TypeError);function Z(n){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 ea(n,e,s)}}function Ii(n){return function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return ta(n,t)}}function C(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ct;Ga&&Ga(n,null);let s=e.length;for(;s--;){let a=e[s];if(typeof a=="string"){const i=t(a);i!==a&&(Ti(e)||(e[s]=i),a=i)}n[a]=!0}return n}function ji(n){for(let e=0;e<n.length;e++)oe(n,e)||(n[e]=null);return n}function de(n){const e=Ke(null);for(const[t,s]of Ts(n))oe(n,t)&&(Array.isArray(s)?e[t]=ji(s):s&&typeof s=="object"&&s.constructor===Object?e[t]=de(s):e[t]=s);return e}function Ge(n,e){for(;n!==null;){const s=ki(n,e);if(s){if(s.get)return Z(s.get);if(typeof s.value=="function")return Z(s.value)}n=xi(n)}function t(){return null}return t}const Ka=G(["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"]),Ut=G(["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"]),Qt=G(["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"]),Ri=G(["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"]),qt=G(["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"]),Ni=G(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Xa=G(["#text"]),es=G(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Wt=G(["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"]),ts=G(["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"]),wt=G(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Pi=se(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Oi=se(/<%[\w\W]*|[\w\W]*%>/gm),_i=se(/\$\{[\w\W]*/gm),Fi=se(/^data-[\-\w.\u00B7-\uFFFF]+$/),zi=se(/^aria-[\-\w]+$/),xs=se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),$i=se(/^(?:\w+script|data):/i),Vi=se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ks=se(/^html$/i),Bi=se(/^[a-z][.\w]*(-[.\w]+)+$/i);var as=Object.freeze({__proto__:null,ARIA_ATTR:zi,ATTR_WHITESPACE:Vi,CUSTOM_ELEMENT:Bi,DATA_ATTR:Fi,DOCTYPE_NAME:ks,ERB_EXPR:Oi,IS_ALLOWED_URI:xs,IS_SCRIPT_OR_DATA:$i,MUSTACHE_EXPR:Pi,TMPLIT_EXPR:_i});const Ze={element:1,text:3,progressingInstruction:7,comment:8,document:9},Hi=function(){return typeof window>"u"?null:window},Ui=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 i="dompurify"+(s?"#"+s:"");try{return e.createPolicy(i,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},ss=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Es(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Hi();const e=f=>Es(f);if(e.version="3.4.0",e.removed=[],!n||!n.document||n.document.nodeType!==Ze.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const s=t,a=s.currentScript,{DocumentFragment:i,HTMLTemplateElement:r,Node:o,Element:c,NodeFilter:h,NamedNodeMap:d=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:y,DOMParser:L,trustedTypes:E}=n,M=c.prototype,p=Ge(M,"cloneNode"),T=Ge(M,"remove"),A=Ge(M,"nextSibling"),R=Ge(M,"childNodes"),B=Ge(M,"parentNode");if(typeof r=="function"){const f=t.createElement("template");f.content&&f.content.ownerDocument&&(t=f.content.ownerDocument)}let I,q="";const{implementation:ie,createNodeIterator:ge,createDocumentFragment:ne,getElementsByTagName:vs}=t,{importNode:Ds}=s;let W=ss();e.isSupported=typeof Ts=="function"&&typeof B=="function"&&ie&&ie.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:lt,ERB_EXPR:ct,TMPLIT_EXPR:ht,DATA_ATTR:Is,ARIA_ATTR:js,IS_SCRIPT_OR_DATA:Rs,ATTR_WHITESPACE:Ca,CUSTOM_ELEMENT:Ns}=as;let{IS_ALLOWED_URI:ba}=as,z=null;const Sa=C({},[...Ka,...Ut,...Qt,...qt,...Xa]);let H=null;const Ta=C({},[...es,...Wt,...ts,...wt]);let N=Object.seal(Ke(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ve=null,ut=null;const we=Object.seal(Ke(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let xa=!0,Dt=!0,ka=!1,Ea=!0,be=!1,Be=!0,Se=!1,It=!1,jt=!1,Ae=!1,dt=!1,gt=!1,Aa=!0,va=!1;const Ps="user-content-";let Rt=!0,He=!1,ve={},ce=null;const Nt=C({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Da=null;const Ia=C({},["audio","video","img","source","image","track"]);let Pt=null;const ja=C({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),pt="http://www.w3.org/1998/Math/MathML",ft="http://www.w3.org/2000/svg",he="http://www.w3.org/1999/xhtml";let De=he,Ot=!1,_t=null;const Os=C({},[pt,ft,he],Bt);let mt=C({},["mi","mo","mn","ms","mtext"]),Lt=C({},["annotation-xml"]);const _s=C({},["title","style","font","a","script"]);let Ue=null;const Fs=["application/xhtml+xml","text/html"],zs="text/html";let O=null,Ie=null;const $s=t.createElement("form"),Ra=function(l){return l instanceof RegExp||l instanceof Function},Ft=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ie&&Ie===l)){if((!l||typeof l!="object")&&(l={}),l=de(l),Ue=Fs.indexOf(l.PARSER_MEDIA_TYPE)===-1?zs:l.PARSER_MEDIA_TYPE,O=Ue==="application/xhtml+xml"?Bt:Ct,z=oe(l,"ALLOWED_TAGS")?C({},l.ALLOWED_TAGS,O):Sa,H=oe(l,"ALLOWED_ATTR")?C({},l.ALLOWED_ATTR,O):Ta,_t=oe(l,"ALLOWED_NAMESPACES")?C({},l.ALLOWED_NAMESPACES,Bt):Os,Pt=oe(l,"ADD_URI_SAFE_ATTR")?C(de(ja),l.ADD_URI_SAFE_ATTR,O):ja,Da=oe(l,"ADD_DATA_URI_TAGS")?C(de(Ia),l.ADD_DATA_URI_TAGS,O):Ia,ce=oe(l,"FORBID_CONTENTS")?C({},l.FORBID_CONTENTS,O):Nt,Ve=oe(l,"FORBID_TAGS")?C({},l.FORBID_TAGS,O):de({}),ut=oe(l,"FORBID_ATTR")?C({},l.FORBID_ATTR,O):de({}),ve=oe(l,"USE_PROFILES")?l.USE_PROFILES:!1,xa=l.ALLOW_ARIA_ATTR!==!1,Dt=l.ALLOW_DATA_ATTR!==!1,ka=l.ALLOW_UNKNOWN_PROTOCOLS||!1,Ea=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,be=l.SAFE_FOR_TEMPLATES||!1,Be=l.SAFE_FOR_XML!==!1,Se=l.WHOLE_DOCUMENT||!1,Ae=l.RETURN_DOM||!1,dt=l.RETURN_DOM_FRAGMENT||!1,gt=l.RETURN_TRUSTED_TYPE||!1,jt=l.FORCE_BODY||!1,Aa=l.SANITIZE_DOM!==!1,va=l.SANITIZE_NAMED_PROPS||!1,Rt=l.KEEP_CONTENT!==!1,He=l.IN_PLACE||!1,ba=l.ALLOWED_URI_REGEXP||xs,De=l.NAMESPACE||he,mt=l.MATHML_TEXT_INTEGRATION_POINTS||mt,Lt=l.HTML_INTEGRATION_POINTS||Lt,N=l.CUSTOM_ELEMENT_HANDLING||Ke(null),l.CUSTOM_ELEMENT_HANDLING&&Ra(l.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(N.tagNameCheck=l.CUSTOM_ELEMENT_HANDLING.tagNameCheck),l.CUSTOM_ELEMENT_HANDLING&&Ra(l.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(N.attributeNameCheck=l.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(N.allowCustomizedBuiltInElements=l.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),be&&(Dt=!1),dt&&(Ae=!0),ve&&(z=C({},Xa),H=Ke(null),ve.html===!0&&(C(z,Ka),C(H,es)),ve.svg===!0&&(C(z,Ut),C(H,Wt),C(H,wt)),ve.svgFilters===!0&&(C(z,Qt),C(H,Wt),C(H,wt)),ve.mathMl===!0&&(C(z,qt),C(H,ts),C(H,wt))),we.tagCheck=null,we.attributeCheck=null,l.ADD_TAGS&&(typeof l.ADD_TAGS=="function"?we.tagCheck=l.ADD_TAGS:(z===Sa&&(z=de(z)),C(z,l.ADD_TAGS,O))),l.ADD_ATTR&&(typeof l.ADD_ATTR=="function"?we.attributeCheck=l.ADD_ATTR:(H===Ta&&(H=de(H)),C(H,l.ADD_ATTR,O))),l.ADD_URI_SAFE_ATTR&&C(Pt,l.ADD_URI_SAFE_ATTR,O),l.FORBID_CONTENTS&&(ce===Nt&&(ce=de(ce)),C(ce,l.FORBID_CONTENTS,O)),l.ADD_FORBID_CONTENTS&&(ce===Nt&&(ce=de(ce)),C(ce,l.ADD_FORBID_CONTENTS,O)),Rt&&(z["#text"]=!0),Se&&C(z,["html","head","body"]),z.table&&(C(z,["tbody"]),delete Ve.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw Je('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Je('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');I=l.TRUSTED_TYPES_POLICY,q=I.createHTML("")}else I===void 0&&(I=Ui(E,a)),I!==null&&typeof q=="string"&&(q=I.createHTML(""));G&&G(l),Ie=l}},Na=C({},[...Ut,...Qt,...Ri]),Pa=C({},[...qt,...Ni]),Vs=function(l){let u=B(l);(!u||!u.tagName)&&(u={namespaceURI:De,tagName:"template"});const g=Ct(l.tagName),v=Ct(u.tagName);return _t[l.namespaceURI]?l.namespaceURI===ft?u.namespaceURI===he?g==="svg":u.namespaceURI===pt?g==="svg"&&(v==="annotation-xml"||mt[v]):!!Na[g]:l.namespaceURI===pt?u.namespaceURI===he?g==="math":u.namespaceURI===ft?g==="math"&&Lt[v]:!!Pa[g]:l.namespaceURI===he?u.namespaceURI===ft&&!Lt[v]||u.namespaceURI===pt&&!mt[v]?!1:!Pa[g]&&(_s[g]||!Na[g]):!!(Ue==="application/xhtml+xml"&&_t[l.namespaceURI]):!1},re=function(l){Ye(e.removed,{element:l});try{B(l).removeChild(l)}catch{T(l)}},Te=function(l,u){try{Ye(e.removed,{attribute:u.getAttributeNode(l),from:u})}catch{Ye(e.removed,{attribute:null,from:u})}if(u.removeAttribute(l),l==="is")if(Ae||dt)try{re(u)}catch{}else try{u.setAttribute(l,"")}catch{}},Oa=function(l){let u=null,g=null;if(jt)l="<remove></remove>"+l;else{const P=Ht(l,/^[\r\n\t ]+/);g=P&&P[0]}Ue==="application/xhtml+xml"&&De===he&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");const v=I?I.createHTML(l):l;if(De===he)try{u=new L().parseFromString(v,Ue)}catch{}if(!u||!u.documentElement){u=ie.createDocument(De,"template",null);try{u.documentElement.innerHTML=Ot?q:v}catch{}}const Q=u.body||u.documentElement;return l&&g&&Q.insertBefore(t.createTextNode(g),Q.childNodes[0]||null),De===he?vs.call(u,Se?"html":"body")[0]:Se?u.documentElement:Q},_a=function(l){return ge.call(l.ownerDocument||l,l,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},zt=function(l){return l instanceof y&&(typeof l.nodeName!="string"||typeof l.textContent!="string"||typeof l.removeChild!="function"||!(l.attributes instanceof d)||typeof l.removeAttribute!="function"||typeof l.setAttribute!="function"||typeof l.namespaceURI!="string"||typeof l.insertBefore!="function"||typeof l.hasChildNodes!="function")},$t=function(l){return typeof o=="function"&&l instanceof o};function pe(f,l,u){We(f,g=>{g.call(e,l,u,Ie)})}const Fa=function(l){let u=null;if(pe(W.beforeSanitizeElements,l,null),zt(l))return re(l),!0;const g=O(l.nodeName);if(pe(W.uponSanitizeElement,l,{tagName:g,allowedTags:z}),Be&&l.hasChildNodes()&&!$t(l.firstElementChild)&&Y(/<[/\w!]/g,l.innerHTML)&&Y(/<[/\w!]/g,l.textContent)||Be&&l.namespaceURI===he&&g==="style"&&$t(l.firstElementChild)||l.nodeType===Ze.progressingInstruction||Be&&l.nodeType===Ze.comment&&Y(/<[/\w]/g,l.data))return re(l),!0;if(Ve[g]||!(we.tagCheck instanceof Function&&we.tagCheck(g))&&!z[g]){if(!Ve[g]&&$a(g)&&(N.tagNameCheck instanceof RegExp&&Y(N.tagNameCheck,g)||N.tagNameCheck instanceof Function&&N.tagNameCheck(g)))return!1;if(Rt&&!ce[g]){const v=B(l)||l.parentNode,Q=R(l)||l.childNodes;if(Q&&v){const P=Q.length;for(let X=P-1;X>=0;--X){const te=p(Q[X],!0);te.__removalCount=(l.__removalCount||0)+1,v.insertBefore(te,A(l))}}}return re(l),!0}return l instanceof c&&!Vs(l)||(g==="noscript"||g==="noembed"||g==="noframes")&&Y(/<\/no(script|embed|frames)/i,l.innerHTML)?(re(l),!0):(be&&l.nodeType===Ze.text&&(u=l.textContent,We([lt,ct,ht],v=>{u=je(u,v," ")}),l.textContent!==u&&(Ye(e.removed,{element:l.cloneNode()}),l.textContent=u)),pe(W.afterSanitizeElements,l,null),!1)},za=function(l,u,g){if(ut[u]||Aa&&(u==="id"||u==="name")&&(g in t||g in $s))return!1;if(!(Dt&&!ut[u]&&Y(Is,u))){if(!(xa&&Y(js,u))){if(!(we.attributeCheck instanceof Function&&we.attributeCheck(u,l))){if(!H[u]||ut[u]){if(!($a(l)&&(N.tagNameCheck instanceof RegExp&&Y(N.tagNameCheck,l)||N.tagNameCheck instanceof Function&&N.tagNameCheck(l))&&(N.attributeNameCheck instanceof RegExp&&Y(N.attributeNameCheck,u)||N.attributeNameCheck instanceof Function&&N.attributeNameCheck(u,l))||u==="is"&&N.allowCustomizedBuiltInElements&&(N.tagNameCheck instanceof RegExp&&Y(N.tagNameCheck,g)||N.tagNameCheck instanceof Function&&N.tagNameCheck(g))))return!1}else if(!Pt[u]){if(!Y(ba,je(g,Ca,""))){if(!((u==="src"||u==="xlink:href"||u==="href")&&l!=="script"&&vi(g,"data:")===0&&Da[l])){if(!(ka&&!Y(Rs,je(g,Ca,"")))){if(g)return!1}}}}}}}return!0},$a=function(l){return l!=="annotation-xml"&&Ht(l,Ns)},Va=function(l){pe(W.beforeSanitizeAttributes,l,null);const{attributes:u}=l;if(!u||zt(l))return;const g={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:H,forceKeepAttr:void 0};let v=u.length;for(;v--;){const Q=u[v],{name:P,namespaceURI:X,value:te}=Q,Me=O(P),Vt=te;let U=P==="value"?Vt:Di(Vt);if(g.attrName=Me,g.attrValue=U,g.keepAttr=!0,g.forceKeepAttr=void 0,pe(W.uponSanitizeAttribute,l,g),U=g.attrValue,va&&(Me==="id"||Me==="name")&&(Te(P,l),U=Ps+U),Be&&Y(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,U)){Te(P,l);continue}if(Me==="attributename"&&Ht(U,"href")){Te(P,l);continue}if(g.forceKeepAttr)continue;if(!g.keepAttr){Te(P,l);continue}if(!Ea&&Y(/\/>/i,U)){Te(P,l);continue}be&&We([lt,ct,ht],Ua=>{U=je(U,Ua," ")});const Ha=O(l.nodeName);if(!za(Ha,Me,U)){Te(P,l);continue}if(I&&typeof E=="object"&&typeof E.getAttributeType=="function"&&!X)switch(E.getAttributeType(Ha,Me)){case"TrustedHTML":{U=I.createHTML(U);break}case"TrustedScriptURL":{U=I.createScriptURL(U);break}}if(U!==Vt)try{X?l.setAttributeNS(X,P,U):l.setAttribute(P,U),zt(l)?re(l):Za(e.removed)}catch{Te(P,l)}}pe(W.afterSanitizeAttributes,l,null)},Ba=function(l){let u=null;const g=_a(l);for(pe(W.beforeSanitizeShadowDOM,l,null);u=g.nextNode();)pe(W.uponSanitizeShadowNode,u,null),Fa(u),Va(u),u.content instanceof i&&Ba(u.content);pe(W.afterSanitizeShadowDOM,l,null)};return e.sanitize=function(f){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,g=null,v=null,Q=null;if(Ot=!f,Ot&&(f="<!-->"),typeof f!="string"&&!$t(f))if(typeof f.toString=="function"){if(f=f.toString(),typeof f!="string")throw Je("dirty is not a string, aborting")}else throw Je("toString is not a function");if(!e.isSupported)return f;if(It||Ft(l),e.removed=[],typeof f=="string"&&(He=!1),He){if(f.nodeName){const te=O(f.nodeName);if(!z[te]||Ve[te])throw Je("root node is forbidden and cannot be sanitized in-place")}}else if(f instanceof o)u=Oa("<!---->"),g=u.ownerDocument.importNode(f,!0),g.nodeType===Ze.element&&g.nodeName==="BODY"||g.nodeName==="HTML"?u=g:u.appendChild(g);else{if(!Ae&&!be&&!Se&&f.indexOf("<")===-1)return I&&gt?I.createHTML(f):f;if(u=Oa(f),!u)return Ae?null:gt?q:""}u&&jt&&re(u.firstChild);const P=_a(He?f:u);for(;v=P.nextNode();)Fa(v),Va(v),v.content instanceof i&&Ba(v.content);if(He)return f;if(Ae){if(be){u.normalize();let te=u.innerHTML;We([lt,ct,ht],Me=>{te=je(te,Me," ")}),u.innerHTML=te}if(dt)for(Q=ne.call(u.ownerDocument);u.firstChild;)Q.appendChild(u.firstChild);else Q=u;return(H.shadowroot||H.shadowrootmode)&&(Q=Ds.call(s,Q,!0)),Q}let X=Se?u.outerHTML:u.innerHTML;return Se&&z["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&Y(ks,u.ownerDocument.doctype.name)&&(X="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
57
- `+X),be&&We([lt,ct,ht],te=>{X=je(X,te," ")}),I&&gt?I.createHTML(X):X},e.setConfig=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ft(f),It=!0},e.clearConfig=function(){Ie=null,It=!1},e.isValidAttribute=function(f,l,u){Ie||Ft({});const g=O(f),v=O(l);return za(g,v,u)},e.addHook=function(f,l){typeof l=="function"&&Ye(W[f],l)},e.removeHook=function(f,l){if(l!==void 0){const u=Ei(W[f],l);return u===-1?void 0:Ai(W[f],u,1)[0]}return Za(W[f])},e.removeHooks=function(f){W[f]=[]},e.removeAllHooks=function(){W=ss()},e}var is=Es();class Qi{dataLayer;constructor(e){this.dataLayer=e}get answerWidgetShowMoreLimit(){return this.dataLayer.answerWidgetShowMoreLimit??100}get currentPage(){return this.dataLayer.searchObject?.page}get totalPages(){return this.resultsPerPage===0?0:Math.ceil(this.totalResults/this.resultsPerPage)}get totalResults(){return this.dataLayer.searchResultsMetadata?.totalResultsValue||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){return this.dataLayer.searchResultsMetadata?.sorting.options||[]}get selectedSortOption(){return this.dataLayer.searchResultsMetadata?.sorting.selectedSortOption||""}get startResultIndex(){return(this.dataLayer.searchObject?.page-1)*this.resultsPerPage+1}get endResultIndex(){const e=(this.dataLayer.searchObject?.page-1)*this.resultsPerPage+(this.resultsPerPage??0);return e>this.totalResults?this.totalResults:e}get isFirstPage(){return this.dataLayer.searchObject?.page===1}get isLastPage(){return this.dataLayer.searchObject?.page>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){return this.dataLayer.searchResultsMetadata?.autoCorrectedQuery||""}get originalQuery(){return this.dataLayer.searchObject?.query||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswerLoadMore(){return this.dataLayer.getAnswerData.split(" ").length>this.answerWidgetShowMoreLimit}get answerTruncated(){return this.dataLayer.getAnswerData.split(" ").slice(0,this.answerWidgetShowMoreLimit).join(" ")+"..."}get fullAnswerFormatted(){return is.sanitize(x.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,i)=>{const r=a.value==="any"?0:parseFloat(a.value),o=i.value==="any"?0:parseFloat(i.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 is.sanitize(x.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(a=>{const i=a.name,r=a.value,o=e.find(c=>c.name===i);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(a=>a!==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 ae{static deepEqual(e,t){const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(const i of s){const r=e[i],o=t[i],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 w{value;observers={};constructor(e){this.value=e,this.observers={}}subscribe(e,t){const s=Math.random().toString(36).substring(2,15),a=t||s;return this.observers[a]=e,e(this.value),a}unsubscribe(e){this.observers[e]&&delete this.observers[e]}subscribeOnce(e){const t=Math.random().toString(36).substring(2,15),s=a=>{e(a),this.unsubscribe(t)};this.subscribe(s,t)}subscribeTwice(e){const t=Math.random().toString(36).substring(2,15);let s=0;const a=i=>{s++,e(i),s>=2&&this.unsubscribe(t)};this.subscribe(a,t)}subscribeUntil(e,t,s=6e3,a=!0){const i=Math.random().toString(36).substring(2,15),r=o=>{o===t&&(e(o),this.unsubscribe(i))};return this.value===t?(e(this.value),null):(this.subscribe(r,i),setTimeout(()=>{a&&this.observers[i]&&e(this.value),this.unsubscribe(i)},s),i)}subscribeUntilHasValue(e,t=6e3,s=!0){const a=Math.random().toString(36).substring(2,15),i=r=>{r!=null&&(e(r),this.unsubscribe(a))};return this.value!==null&&this.value!==void 0?(e(this.value),null):(this.subscribe(i,a),t>0&&setTimeout(()=>{s&&this.observers[a]&&e(this.value),this.unsubscribe(a)},t),i)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){for(const e in this.observers)if(Object.prototype.hasOwnProperty.call(this.observers,e)){const t=this.observers[e];typeof t=="function"&&t(this.value)}}}class Yt{static getOrSetCookie(e,t){let s=this.getCookie(e);return s==null&&(s=t??this.makeid(25),this.setCookie(e,s,{secure:!0,"max-age":3600})),s}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=s.length;for(let i=0;i<e;i++)t+=s.charAt(Math.floor(Math.random()*a));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,s){const a={path:"/",...s};s.expires instanceof Date&&(a.expires=s.expires.toUTCString());let i=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const r in a){i+="; "+r;const o=a[r];o!==!0&&(i+="="+o)}typeof document<"u"&&(document.cookie=i)}}class V{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",s=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(s,""):""}}class qi{$searchTermChange=new w("");$searchLocationChange=new w("");$searchLocationCoordinatesDecoded=new w("");$searchLatChange=new w("");$searchLongChange=new w("");$searchRadiusChange=new w(void 0);$loadingChange=new w(!1);$locationError=new w(!1);$searchResults=new w(null);$searchResultsMetadata=new w(null);$searchAutosuggest=new w(null);$searchFacets=new w(null);$searchFacetsCached=new w(null);$searchFacetsCachedTabs=new w(null);$searchstaxConfig=new w(null);$autosuggestResults=new w(null);$itemsPerPage=new w(void 0);$searchObject=new w({query:"",itemsPerPage:void 0,page:99999999,order:"",facets:[],additionalProps:[],location:{term:void 0,radius:void 0,lat:void 0,lon:void 0},model:""});$searchRelatedSearches=new w(null);$searchInputConfig=new w(null);$searchLocationConfig=new w(null);$searchExternalPromotions=new w(null);$facetsTemplateData=new w(null);$selectedFacetsTemplateData=new w(null);$paginationData=new w(null);$answerData=new w(null);$searchFeedbackData=new w(null);$inputWidgetTemplateData=new w(null);$locationWidgetTemplateData=new w(null);$searchSortingData=new w(null);$searchRelatedSearchesData=new w(null);$searchExternalPromotionsData=new w(null);$cookiesDisabled=new w(null);$locationDecodingLoading=new w(!1);$answer=new w("");$language=new w("en");$model=new w("");$answerLoading=new w(!1);$locationEnabled=new w(null);$answerError=new w(!1);$answerErrorMessage=new w("");$isQuestion=new w(!1);$inputTemplateRendered=new w(!1);currentPageValue=1;isAnswerWidgetCreatedValue=!1;renderingEngineValue=j.mustache;parsedData=new Qi(this);sessionId;sessionIdValue=null;autoCorrect=!0;forceNotCorrect=!1;lastSearchValue="";turnAIAnswerGenerationOn=!1;questionURL="";isInfiniteScroll=!1;firstSearchHappened=!1;facetsWereSet=!1;answerWidgetShowMoreLimit=100;searchHelper;searchResultUnparsed;constructor(e,t){this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,Yt.deleteCookie(this.sessionId),Yt.deleteCookie("ms_visitorid")):this.sessionIdValue=Yt.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(V.removeXSSRiskyTags(e))}setSearchLocation(e){this.$searchLocationChange.setValue(V.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,(!ae.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){ae.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&&(!ae.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){this.facetsWereSet=!0,ae.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){ae.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchFacetsCachedTabs(e){ae.deepEqual(e,this.searchFacetsCachedTabs??[])||this.$searchFacetsCachedTabs.setValue(e)}setSearchRelatedSearches(e){ae.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){ae.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(V.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 Xe{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,i)=>{const r=a[e.responseHeader.params.uniqueId]??"",o={custom:null,uniqueId:r,position:s+1+i,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 i=e.facet_counts.facet_fields[s.name];for(let r=0;r<i.length;r+=2){const o={};o.value=i[r],o.parentName=a.name,o.count=i[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(i=>i.result_card==="date")?.name,s.options=[],e.metadata.sorts?.length){const i=e.metadata.sorts.map(r=>({value:r.label,key:r.name+" "+r.order}));s.options=[{key:"",value:"Relevance"},...i]}return t=e?.spellcheck?.suggestions?.[1]?.suggestion?.[0]??"",typeof t!="string"&&(t=t?.word??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:t,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:s,location:a,isLocationMapped:this.doesMapExist("distance",e)}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const i=s[a],r={};r.cDocId=this.getDataForAnalytics(i.uniqueId),i.title&&(r.cDocTitle=this.getDataForAnalytics(i.titleTracking)),r.position=i.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),i=[];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);i.push({key:r,value:o,isImage:this.checkIfImage(e[r])})}return i}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const s=t.metadata.results.map(i=>i.name),a=[];for(const i of Object.keys(e))s.indexOf(i)!==-1&&a.push({key:i,value:e[i],isImage:this.checkIfImage(e[i])});return a}static doesMapExist(e,t){return t.metadata.results.find(s=>s.result_card===e)!==void 0}static getValueByKey(e,t,s,a,i=!1){const 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"?i?o:this.getHighlightedResults(r.name,o,a,s):typeof o=="number"?o:Array.isArray(o)?i?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 i=a.highlighting[s];if(i&&e in i){let r=i[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 ns{routeName="searchstax";ignoredKeys=[];queryStringHelper;titleParser;constructor(e){e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new Wi(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=typeof document<"u"?document?.title:"";this.titleParser&&(s=this.titleParser(e)),typeof document<"u"&&(document.title=s),window?.location.href!==t&&window?.history.replaceState(window.history.state,s,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window?.location.href??"")?window?.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):window?.location.href+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},s=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=s+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.itemsPerPage&&e.itemsPerPage!==10&&(t[this.routeName+"[itemsPerPage]"]=e.itemsPerPage+""),e.location)for(const a in e.location){const i=e.location[a];i&&(t[this.routeName+`[location][${a}]`]=i)}if(e.facets)for(const a in e.facets){const i=e.facets[a].type+":"+encodeURIComponent(e.facets[a].name)+":"+encodeURIComponent(e.facets[a].value);t[this.routeName+`[facets][${a}]`]=i}if(e.model&&(t[this.routeName+"[model]"]=e.model),this.queryStringHelper.urlHasQueryParams(window?.location.href??"")){const a=this.queryStringHelper.urlToParams(window?.location.href??"");for(const i in a)i.startsWith(this.routeName)&&delete a[i];return{...a,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const s in e)s.startsWith(this.routeName)||(t[s]=e[s]);return t}extractArrayOfFacetsFromQueryParameters(e){const t=[];for(const s in e)if(s.startsWith(this.routeName+"[facets]")){const a=V.removeXSSRiskyTags(e[s].split(":")?.[0]),i=V.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[1])),r=V.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[2]));t.push({type:a,name:i,value:r})}return t}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=V.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),i=parseInt(a),r=isNaN(i)?1:i;let o=parseInt(V.removeXSSRiskyTags(s[this.routeName+"[itemsPerPage]"]));return isNaN(o)&&(o=10),{query:V.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:r,itemsPerPage:t??o,order:V.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[],model:V.removeXSSRiskyTags(s[this.routeName+"[model]"])||"",location:{address:V.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][address]"]||"")),radius:V.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][radius]"]||"")),lat:V.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lat]"]||"")),lon:V.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lon]"]||""))}}}}class Wi{routeName="";constructor(e){this.routeName=e}stringify=(e,t)=>{const s=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(s).map(a=>{const i=s[a];return Array.isArray(i)?i.map(r=>`${a}=${r}`).join("&"):`${a}=${i}`}).join("&")};filterOutIgnoredKeys(e,t){const s=t||[],a={};return Object.keys(e).forEach(i=>{s.includes(i)||e[i]!==""&&(a[i]=e[i])}),a}urlToParams(e){const t={},s=e.split("?")[1];return s&&s.split("&").forEach(a=>{const[i,r]=a.split("=");t[i]=r}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const Oe={question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class rs extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function Jt(n){}function Yi(n){if(typeof n=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=Jt,onError:t=Jt,onRetry:s=Jt,onComment:a}=n;let i="",r=!0,o,c="",h="";function d(p){const T=r?p.replace(/^\xEF\xBB\xBF/,""):p,[A,R]=Ji(`${i}${T}`);for(const B of A)y(B);i=R,r=!1}function y(p){if(p===""){E();return}if(p.startsWith(":")){a&&a(p.slice(p.startsWith(": ")?2:1));return}const T=p.indexOf(":");if(T!==-1){const A=p.slice(0,T),R=p[T+1]===" "?2:1,B=p.slice(T+R);L(A,B,p);return}L(p,"",p)}function L(p,T,A){switch(p){case"event":h=T;break;case"data":c=`${c}${T}
58
- `;break;case"id":o=T.includes("\0")?void 0:T;break;case"retry":/^\d+$/.test(T)?s(parseInt(T,10)):t(new rs(`Invalid \`retry\` value: "${T}"`,{type:"invalid-retry",value:T,line:A}));break;default:t(new rs(`Unknown field "${p.length>20?`${p.slice(0,20)}…`:p}"`,{type:"unknown-field",field:p,value:T,line:A}));break}}function E(){c.length>0&&e({id:o,event:h||void 0,data:c.endsWith(`
59
- `)?c.slice(0,-1):c}),o=void 0,c="",h=""}function M(p={}){i&&p.consume&&y(i),r=!0,o=void 0,c="",h="",i=""}return{feed:d,reset:M}}function Ji(n){const e=[];let t="",s=0;for(;s<n.length;){const a=n.indexOf("\r",s),i=n.indexOf(`
60
- `,s);let r=-1;if(a!==-1&&i!==-1?r=Math.min(a,i):a!==-1?a===n.length-1?r=-1:r=a:i!==-1&&(r=i),r===-1){t=n.slice(s);break}else{const o=n.slice(s,r);e.push(o),s=r+1,n[s-1]==="\r"&&n[s]===`
61
- `&&s++}}return[e,t]}class os 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(ls(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(ls(this),t)}}function Gi(n){const e=globalThis.DOMException;return typeof e=="function"?new e(n,"SyntaxError"):new SyntaxError(n)}function aa(n){return n instanceof Error?"errors"in n&&Array.isArray(n.errors)?n.errors.map(aa).join(", "):"cause"in n&&n.cause instanceof Error?`${n}: ${aa(n.cause)}`:n.message:`${n}`}function ls(n){return{type:n.type,message:n.message,code:n.code,defaultPrevented:n.defaultPrevented,cancelable:n.cancelable,timeStamp:n.timeStamp}}var As=n=>{throw TypeError(n)},wa=(n,e,t)=>e.has(n)||As("Cannot "+t),b=(n,e,t)=>(wa(n,e,"read from private field"),t?t.call(n):e.get(n)),_=(n,e,t)=>e.has(n)?As("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),D=(n,e,t,s)=>(wa(n,e,"write to private field"),e.set(n,t),t),fe=(n,e,t)=>(wa(n,e,"access private method"),t),ee,xe,Re,bt,Et,st,_e,it,Ce,Ne,Fe,Pe,et,le,sa,ia,na,cs,ra,oa,tt,la,ca;class St extends EventTarget{constructor(e,t){var s,a;super(),_(this,le),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,_(this,ee),_(this,xe),_(this,Re),_(this,bt),_(this,Et),_(this,st),_(this,_e),_(this,it,null),_(this,Ce),_(this,Ne),_(this,Fe,null),_(this,Pe,null),_(this,et,null),_(this,ia,async i=>{var r;b(this,Ne).reset();const{body:o,redirected:c,status:h,headers:d}=i;if(h===204){fe(this,le,tt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?D(this,Re,new URL(i.url)):D(this,Re,void 0),h!==200){fe(this,le,tt).call(this,`Non-200 status code (${h})`,h);return}if(!(d.get("content-type")||"").startsWith("text/event-stream")){fe(this,le,tt).call(this,'Invalid content type, expected "text/event-stream"',h);return}if(b(this,ee)===this.CLOSED)return;D(this,ee,this.OPEN);const y=new Event("open");if((r=b(this,et))==null||r.call(this,y),this.dispatchEvent(y),typeof o!="object"||!o||!("getReader"in o)){fe(this,le,tt).call(this,"Invalid response body, expected a web ReadableStream",h),this.close();return}const L=new TextDecoder,E=o.getReader();let M=!0;do{const{done:p,value:T}=await E.read();T&&b(this,Ne).feed(L.decode(T,{stream:!p})),p&&(M=!1,b(this,Ne).reset(),fe(this,le,la).call(this))}while(M)}),_(this,na,i=>{D(this,Ce,void 0),!(i.name==="AbortError"||i.type==="aborted")&&fe(this,le,la).call(this,aa(i))}),_(this,ra,i=>{typeof i.id=="string"&&D(this,it,i.id);const r=new MessageEvent(i.event||"message",{data:i.data,origin:b(this,Re)?b(this,Re).origin:b(this,xe).origin,lastEventId:i.id||""});b(this,Pe)&&(!i.event||i.event==="message")&&b(this,Pe).call(this,r),this.dispatchEvent(r)}),_(this,oa,i=>{D(this,st,i)}),_(this,ca,()=>{D(this,_e,void 0),b(this,ee)===this.CONNECTING&&fe(this,le,sa).call(this)});try{if(e instanceof URL)D(this,xe,e);else if(typeof e=="string")D(this,xe,new URL(e,Zi()));else throw new Error("Invalid URL")}catch{throw Gi("An invalid or illegal string was specified")}D(this,Ne,Yi({onEvent:b(this,ra),onRetry:b(this,oa)})),D(this,ee,this.CONNECTING),D(this,st,3e3),D(this,Et,(s=t?.fetch)!=null?s:globalThis.fetch),D(this,bt,(a=t?.withCredentials)!=null?a:!1),fe(this,le,sa).call(this)}get readyState(){return b(this,ee)}get url(){return b(this,xe).href}get withCredentials(){return b(this,bt)}get onerror(){return b(this,Fe)}set onerror(e){D(this,Fe,e)}get onmessage(){return b(this,Pe)}set onmessage(e){D(this,Pe,e)}get onopen(){return b(this,et)}set onopen(e){D(this,et,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(){b(this,_e)&&clearTimeout(b(this,_e)),b(this,ee)!==this.CLOSED&&(b(this,Ce)&&b(this,Ce).abort(),D(this,ee,this.CLOSED),D(this,Ce,void 0))}}ee=new WeakMap,xe=new WeakMap,Re=new WeakMap,bt=new WeakMap,Et=new WeakMap,st=new WeakMap,_e=new WeakMap,it=new WeakMap,Ce=new WeakMap,Ne=new WeakMap,Fe=new WeakMap,Pe=new WeakMap,et=new WeakMap,le=new WeakSet,sa=function(){D(this,ee,this.CONNECTING),D(this,Ce,new AbortController),b(this,Et)(b(this,xe),fe(this,le,cs).call(this)).then(b(this,ia)).catch(b(this,na))},ia=new WeakMap,na=new WeakMap,cs=function(){var n;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...b(this,it)?{"Last-Event-ID":b(this,it)}:void 0},cache:"no-store",signal:(n=b(this,Ce))==null?void 0:n.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},ra=new WeakMap,oa=new WeakMap,tt=function(n,e){var t;b(this,ee)!==this.CLOSED&&D(this,ee,this.CLOSED);const s=new os("error",{code:e,message:n});(t=b(this,Fe))==null||t.call(this,s),this.dispatchEvent(s)},la=function(n,e){var t;if(b(this,ee)===this.CLOSED)return;D(this,ee,this.CONNECTING);const s=new os("error",{code:e,message:n});(t=b(this,Fe))==null||t.call(this,s),this.dispatchEvent(s),D(this,_e,setTimeout(b(this,ca),b(this,st)))},ca=new WeakMap,St.CONNECTING=0,St.OPEN=1,St.CLOSED=2;function Zi(){const n="document"in globalThis?globalThis.document:void 0;return n&&typeof n=="object"&&"baseURI"in n&&typeof n.baseURI=="string"?n.baseURI:void 0}class me{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 i=document.createElement("script");i.type="text/javascript",i.src=s;var r=document.getElementsByTagName("script")[0];r.parentNode&&r.parentNode.insertBefore(i,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 i=["trackClick",t];t.key?this.msq().push(i,(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 i=["answerSourceClick",t];t.key?this.msq().push(i,(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+""};setTimeout(()=>{t.key&&this.msq().push(["trackquestionanswer",t])},0)}static trackFeedback(e){setTimeout(()=>{this.msq().push(["trackSearchSatisfaction",{key:e.trackApiKey,email:e.email,score:e.rating,comments:e.feedback,language:e.language,model:e.model}])},0)}}class Ki{cachedQuery="";cachedANDFacets="";url="";relatedSearches="";suggester="";authHeader;authHeaderRelated;trackApiKey="";session="";searchAuthType;searchAuth="";controllerSearch;signalSearch;controllerSuggest;signalSuggest;_authToken="";resolveFn;dataLayer;constructor(e,t){this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json"),this._authToken=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`,this.authHeader.append("Authorization",this._authToken),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let s=[];if(!t)e.forEach(function(a){const i=a.name+':"'+a.value+'"';s=s.concat("fq="+decodeURIComponent(i).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 i="";for(const r in a)if(Object.prototype.hasOwnProperty.call(a,r)){const o=a[r],c=r;for(const h of o)i+=i===""?` ${c}:"${h}"`:` OR ${c}:"${h}"`}s=s.concat("fq="+i.trim())}return s=s.map(a=>a.replace(/&/g,"%26").replace(/\+/g,"%2B")),s.length?"&"+s.join("&"):""}generateLocationQuery(e){let t="";if(e.lat&&e.lon){const s=Math.floor(parseFloat(e.lat)*100)/100,a=Math.floor(parseFloat(e.lon)*100)/100;t+=`&pt=${s},${a}`}return e.radius&&t!==""&&e.radius!=="any"&&(t+=`&distanceFilter=${e.radius}`),t}getRelatedSearches(e,t,s,a){const i=new Headers;i.append("Accept","application/json"),i.append("Authorization",s),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:i,credentials:"same-origin"}).then(r=>r.json()).then(r=>{a(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 s=[this.dataLayer.searchObject.facets.filter(a=>e?!1:a.type==="and"||a.type==="tabs")].flat();this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:s,additionalProps:this.dataLayer.searchObject.additionalProps,location:this.dataLayer.searchObject.location,model:this.dataLayer.model},this.cacheFacetsCallback.bind(this),!0,!1,e)}else this.resolveFn()})}cacheFacetsCallback(e,t){let s=Xe.extractFacets(e);t?this.dataLayer.setSearchFacetsCachedTabs(s):this.dataLayer.setSearchFacetsCached(s),this.resolveFn&&this.resolveFn()}search(e,t,s=!1,a=!1,i=!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,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,i)}).catch(()=>{this.dataLayer.setLoading(!1)})}}generateQueryParams(e,t){let s=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),a=e.order?`&sort=${e.order}`:"";const i=new Proxy(new URLSearchParams(window?.location.search??""),{get:(c,h)=>c.get(h)??""}),r=i.languageVariant?"&fq=_language:"+i.languageVariant:"",o=e.model??this.dataLayer.model;return"?q="+encodeURIComponent(e.query.trim())+"&start="+s+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(c=>c.type==="or"||c.type==="showUnavailable"),!0)+this.generateLocationQuery(e.location)+this.generateFacetQuery(e.facets.filter(c=>c.type==="and"||c.type==="tabs"),!1)+a+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!t}`+(o?`&model=${o}`:"")+"&language="+this.dataLayer.language+r}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.searchObject.page!==1)return;const s=new St(this.dataLayer.questionURL+this.generateQueryParams(this.dataLayer.searchObject),{fetch:(i,r)=>fetch(i,{...r,headers:{...r?.headers,Authorization:this._authToken}})}),a=this.dataLayer;return s.onmessage=i=>{if(i.data===Oe.question||i.data===Oe.notQuestion){i.data===Oe.question?(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setIsQuestion(!0)):(a.setAnswerLoading(!1),this.dataLayer.setIsQuestion(!1)),a.setAnswerData("");return}if(i.data===Oe.close){me.trackAnswerData({...a.parsedData.trackingData,answer:a.$answer.getValue(),isQuestion:this.dataLayer.isQuestion}),a.setAnswerLoading(!1),s.close();return}if(i.data.indexOf("[!CAUTION]")!==-1){a.setAnswerError(!0),a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),s.close();return}if(i.data.indexOf("[comment]: <> ({")!==-1){const r=i.data.split("[comment]: <> ({")[1].split("})")[0],o=JSON.parse("{"+r+"}");this.dataLayer.answerWidgetShowMoreLimit=o.displayShowMoreAfter,o.showMoreEnabled||(this.dataLayer.answerWidgetShowMoreLimit=1e17),t("")}else t(i.data)},s.addEventListener("error",i=>{(i.code===401||i.code===500)&&(a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),a.setAnswerError(!0))}),s.onerror=()=>{a.setAnswerLoading(!1),s.close()},s}suggest(e,t,s){if(this.controllerSuggest&&this.controllerSuggest.abort(),this.suggester.trim()==="")return;this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const a=this.suggester+"?q="+e.trim()+this.toQueryString(s)+"&language="+this.dataLayer.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(i=>i.json()).then(i=>{t(i)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const s of e)t.push(encodeURIComponent(s.key)+"="+encodeURIComponent(s.value));return"&"+t.join("&")}}var Xi=Object.prototype.toString,$e=Array.isArray||function(e){return Xi.call(e)==="[object Array]"};function Ma(n){return typeof n=="function"}function en(n){return $e(n)?"array":typeof n}function Gt(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function hs(n,e){return n!=null&&typeof n=="object"&&e in n}function tn(n,e){return n!=null&&typeof n!="object"&&n.hasOwnProperty&&n.hasOwnProperty(e)}var an=RegExp.prototype.test;function sn(n,e){return an.call(n,e)}var nn=/\S/;function rn(n){return!sn(nn,n)}var on={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function ln(n){return String(n).replace(/[&<>"'`=\/]/g,function(t){return on[t]})}var cn=/\s*/,hn=/\s+/,us=/\s*=/,un=/\s*\}/,dn=/#|\^|\/|>|\{|&|=|!/;function gn(n,e){if(!n)return[];var t=!1,s=[],a=[],i=[],r=!1,o=!1,c="",h=0;function d(){if(r&&!o)for(;i.length;)delete a[i.pop()];else i=[];r=!1,o=!1}var y,L,E;function M(ne){if(typeof ne=="string"&&(ne=ne.split(hn,2)),!$e(ne)||ne.length!==2)throw new Error("Invalid tags: "+ne);y=new RegExp(Gt(ne[0])+"\\s*"),L=new RegExp("\\s*"+Gt(ne[1])),E=new RegExp("\\s*"+Gt("}"+ne[1]))}M(e||S.tags);for(var p=new ot(n),T,A,R,B,I,q;!p.eos();){if(T=p.pos,R=p.scanUntil(y),R)for(var ie=0,ge=R.length;ie<ge;++ie)B=R.charAt(ie),rn(B)?(i.push(a.length),c+=B):(o=!0,t=!0,c+=" "),a.push(["text",B,T,T+1]),T+=1,B===`
62
- `&&(d(),c="",h=0,t=!1);if(!p.scan(y))break;if(r=!0,A=p.scan(dn)||"name",p.scan(cn),A==="="?(R=p.scanUntil(us),p.scan(us),p.scanUntil(L)):A==="{"?(R=p.scanUntil(E),p.scan(un),p.scanUntil(L),A="&"):R=p.scanUntil(L),!p.scan(L))throw new Error("Unclosed tag at "+p.pos);if(A==">"?I=[A,R,T,p.pos,c,h,t]:I=[A,R,T,p.pos],h++,a.push(I),A==="#"||A==="^")s.push(I);else if(A==="/"){if(q=s.pop(),!q)throw new Error('Unopened section "'+R+'" at '+T);if(q[1]!==R)throw new Error('Unclosed section "'+q[1]+'" at '+T)}else A==="name"||A==="{"||A==="&"?o=!0:A==="="&&M(R)}if(d(),q=s.pop(),q)throw new Error('Unclosed section "'+q[1]+'" at '+p.pos);return fn(pn(a))}function pn(n){for(var e=[],t,s,a=0,i=n.length;a<i;++a)t=n[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 fn(n){for(var e=[],t=e,s=[],a,i,r=0,o=n.length;r<o;++r)switch(a=n[r],a[0]){case"#":case"^":t.push(a),s.push(a),t=a[4]=[];break;case"/":i=s.pop(),i[5]=a[2],t=s.length>0?s[s.length-1][4]:e;break;default:t.push(a)}return e}function ot(n){this.string=n,this.tail=n,this.pos=0}ot.prototype.eos=function(){return this.tail===""};ot.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};ot.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 ze(n,e){this.view=n,this.cache={".":this.view},this.parent=e}ze.prototype.push=function(e){return new ze(e,this)};ze.prototype.lookup=function(e){var t=this.cache,s;if(t.hasOwnProperty(e))s=t[e];else{for(var a=this,i,r,o,c=!1;a;){if(e.indexOf(".")>0)for(i=a.view,r=e.split("."),o=0;i!=null&&o<r.length;)o===r.length-1&&(c=hs(i,r[o])||tn(i,r[o])),i=i[r[o++]];else i=a.view[e],c=hs(a.view,e);if(c){s=i;break}a=a.parent}t[e]=s}return Ma(s)&&(s=s.call(this.view)),s};function K(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}K.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};K.prototype.parse=function(e,t){var s=this.templateCache,a=e+":"+(t||S.tags).join(":"),i=typeof s<"u",r=i?s.get(a):void 0;return r==null&&(r=gn(e,t),i&&s.set(a,r)),r};K.prototype.render=function(e,t,s,a){var i=this.getConfigTags(a),r=this.parse(e,i),o=t instanceof ze?t:new ze(t,void 0);return this.renderTokens(r,o,s,e,a)};K.prototype.renderTokens=function(e,t,s,a,i){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,i):c==="^"?h=this.renderInverted(o,t,s,a,i):c===">"?h=this.renderPartial(o,t,s,i):c==="&"?h=this.unescapedValue(o,t):c==="name"?h=this.escapedValue(o,t,i):c==="text"&&(h=this.rawValue(o)),h!==void 0&&(r+=h);return r};K.prototype.renderSection=function(e,t,s,a,i){var r=this,o="",c=t.lookup(e[1]);function h(L){return r.render(L,t,s,i)}if(c){if($e(c))for(var d=0,y=c.length;d<y;++d)o+=this.renderTokens(e[4],t.push(c[d]),s,a,i);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")o+=this.renderTokens(e[4],t.push(c),s,a,i);else if(Ma(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,i);return o}};K.prototype.renderInverted=function(e,t,s,a,i){var r=t.lookup(e[1]);if(!r||$e(r)&&r.length===0)return this.renderTokens(e[4],t,s,a,i)};K.prototype.indentPartial=function(e,t,s){for(var a=t.replace(/[^ \t]/g,""),i=e.split(`
54
+ `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${fe(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){const s=this.parser.parseInline(t),a=Ka(n);if(a===null)return s;n=a;let i='<a href="'+n+'"';return e&&(i+=' title="'+fe(e)+'"'),i+=">"+s+"</a>",i}image({href:n,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));const a=Ka(n);if(a===null)return fe(t);n=a;let i=`<img src="${n}" alt="${t}"`;return e&&(i+=` title="${fe(e)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:fe(n.text)}},ba=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}},Ce=class sa{options;renderer;textRenderer;constructor(e){this.options=e||De,this.options.renderer=this.options.renderer||new Et,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ba}static parse(e,t){return new sa(t).parse(e)}static parseInline(e,t){return new sa(t).parseInline(e)}parse(e,t=!0){let s="";for(let a=0;a<e.length;a++){const i=e[a];if(this.options.extensions?.renderers?.[i.type]){const o=i,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=i;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 i=e[a];if(this.options.extensions?.renderers?.[i.type]){const o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){s+=o||"";continue}}const r=i;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}},Tt=class{options;block;constructor(n){this.options=n||De}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?we.lex:we.lexInline}provideParser(){return this.block?Ce.parse:Ce.parseInline}},ji=class{defaults=pa();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ce;Renderer=Et;TextRenderer=ba;Lexer=we;Tokenizer=At;Hooks=Tt;constructor(...n){this.use(...n)}walkTokens(n,e){let t=[];for(const s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{const a=s;for(const i of a.header)t=t.concat(this.walkTokens(i.tokens,e));for(const i of a.rows)for(const r of i)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(i=>{const r=a[i].flat(1/0);t=t.concat(this.walkTokens(r,e))}):a.tokens&&(t=t.concat(this.walkTokens(a.tokens,e)))}}return t}use(...n){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{const s={...t};if(s.async=this.defaults.async||s.async||!1,t.extensions&&(t.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const i=e.renderers[a.name];i?e.renderers[a.name]=function(...r){let o=a.renderer.apply(this,r);return o===!1&&(o=i.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 i=e[a.level];i?i.unshift(a.tokenizer):e[a.level]=[a.tokenizer],a.start&&(a.level==="block"?e.startBlock?e.startBlock.push(a.start):e.startBlock=[a.start]:a.level==="inline"&&(e.startInline?e.startInline.push(a.start):e.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(e.childTokens[a.name]=a.childTokens)}),s.extensions=e),t.renderer){const a=this.defaults.renderer||new Et(this.defaults);for(const i in t.renderer){if(!(i in a))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const r=i,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 At(this.defaults);for(const i in t.tokenizer){if(!(i in a))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const r=i,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 Tt;for(const i in t.hooks){if(!(i in a))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const r=i,o=t.hooks[r],c=a[r];Tt.passThroughHooks.has(i)?a[r]=h=>{if(this.defaults.async)return Promise.resolve(o.call(a,h)).then(C=>c.call(a,C));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,i=t.walkTokens;s.walkTokens=function(r){let o=[];return o.push(i.call(this,r)),a&&(o=o.concat(a.call(this,r))),o}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return we.lex(n,e??this.defaults)}parser(n,e){return Ce.parse(n,e??this.defaults)}parseMarkdown(n){return(t,s)=>{const a={...s},i={...this.defaults,...a},r=this.onError(!!i.silent,!!i.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"));i.hooks&&(i.hooks.options=i,i.hooks.block=n);const o=i.hooks?i.hooks.provideLexer():n?we.lex:we.lexInline,c=i.hooks?i.hooks.provideParser():n?Ce.parse:Ce.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(h=>o(h,i)).then(h=>i.hooks?i.hooks.processAllTokens(h):h).then(h=>i.walkTokens?Promise.all(this.walkTokens(h,i.walkTokens)).then(()=>h):h).then(h=>c(h,i)).then(h=>i.hooks?i.hooks.postprocess(h):h).catch(r);try{i.hooks&&(t=i.hooks.preprocess(t));let h=o(t,i);i.hooks&&(h=i.hooks.processAllTokens(h)),i.walkTokens&&this.walkTokens(h,i.walkTokens);let d=c(h,i);return i.hooks&&(d=i.hooks.postprocess(d)),d}catch(h){return r(h)}}}onError(n,e){return t=>{if(t.message+=`
56
+ Please report this to https://github.com/markedjs/marked.`,n){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}}},ve=new ji;function v(n,e){return ve.parse(n,e)}v.options=v.setOptions=function(n){return ve.setOptions(n),v.defaults=ve.defaults,xs(v.defaults),v};v.getDefaults=pa;v.defaults=De;v.use=function(...n){return ve.use(...n),v.defaults=ve.defaults,xs(v.defaults),v};v.walkTokens=function(n,e){return ve.walkTokens(n,e)};v.parseInline=ve.parseInline;v.Parser=Ce;v.parser=Ce.parse;v.Renderer=Et;v.TextRenderer=ba;v.Lexer=we;v.lexer=we.lex;v.Tokenizer=At;v.Hooks=Tt;v.parse=v;v.options;v.setOptions;v.use;v.walkTokens;v.parseInline;Ce.parse;we.lex;const{entries:Os,setPrototypeOf:ts,isFrozen:Ni,getPrototypeOf:Pi,getOwnPropertyDescriptor:Oi}=Object;let{freeze:ee,seal:le,create:Oe}=Object,{apply:ia,construct:na}=typeof Reflect<"u"&&Reflect;ee||(ee=function(e){return e});le||(le=function(e){return e});ia||(ia=function(e,t){for(var s=arguments.length,a=new Array(s>2?s-2:0),i=2;i<s;i++)a[i-2]=arguments[i];return e.apply(t,a)});na||(na=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 Ke=z(Array.prototype.forEach),_i=z(Array.prototype.lastIndexOf),as=z(Array.prototype.pop),Xe=z(Array.prototype.push),Fi=z(Array.prototype.splice),K=Array.isArray,at=z(String.prototype.toLowerCase),Wt=z(String.prototype.toString),ss=z(String.prototype.match),Pe=z(String.prototype.replace),is=z(String.prototype.indexOf),zi=z(String.prototype.trim),$i=z(Number.prototype.toString),Vi=z(Boolean.prototype.toString),ns=typeof BigInt>"u"?null:z(BigInt.prototype.toString),rs=typeof Symbol>"u"?null:z(Symbol.prototype.toString),N=z(Object.prototype.hasOwnProperty),et=z(Object.prototype.toString),G=z(RegExp.prototype.test),Mt=Bi(TypeError);function z(n){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 ia(n,e,s)}}function Bi(n){return function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return na(n,t)}}function b(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:at;if(ts&&ts(n,null),!K(e))return n;let s=e.length;for(;s--;){let a=e[s];if(typeof a=="string"){const i=t(a);i!==a&&(Ni(e)||(e[s]=i),a=i)}n[a]=!0}return n}function Hi(n){for(let e=0;e<n.length;e++)N(n,e)||(n[e]=null);return n}function se(n){const e=Oe(null);for(const[t,s]of Os(n))N(n,t)&&(K(s)?e[t]=Hi(s):s&&typeof s=="object"&&s.constructor===Object?e[t]=se(s):e[t]=s);return e}function Ui(n){switch(typeof n){case"string":return n;case"number":return $i(n);case"boolean":return Vi(n);case"bigint":return ns?ns(n):"0";case"symbol":return rs?rs(n):"Symbol()";case"undefined":return et(n);case"function":case"object":{if(n===null)return et(n);const e=n,t=_e(e,"toString");if(typeof t=="function"){const s=t(e);return typeof s=="string"?s:et(s)}return et(n)}default:return et(n)}}function _e(n,e){for(;n!==null;){const s=Oi(n,e);if(s){if(s.get)return z(s.get);if(typeof s.value=="function")return z(s.value)}n=Pi(n)}function t(){return null}return t}function Qi(n){try{return G(n,""),!0}catch{return!1}}const os=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"]),Yt=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"]),Jt=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"]),qi=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"]),Gt=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"]),Wi=ee(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ls=ee(["#text"]),cs=ee(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Zt=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"]),hs=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"]),bt=ee(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Yi=le(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ji=le(/<%[\w\W]*|[\w\W]*%>/gm),Gi=le(/\$\{[\w\W]*/gm),Zi=le(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ki=le(/^aria-[\-\w]+$/),_s=le(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Xi=le(/^(?:\w+script|data):/i),en=le(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Fs=le(/^html$/i),tn=le(/^[a-z][.\w]*(-[.\w]+)+$/i);var us=Object.freeze({__proto__:null,ARIA_ATTR:Ki,ATTR_WHITESPACE:en,CUSTOM_ELEMENT:tn,DATA_ATTR:Zi,DOCTYPE_NAME:Fs,ERB_EXPR:Ji,IS_ALLOWED_URI:_s,IS_SCRIPT_OR_DATA:Xi,MUSTACHE_EXPR:Yi,TMPLIT_EXPR:Gi});const tt={element:1,text:3,progressingInstruction:7,comment:8,document:9},an=function(){return typeof window>"u"?null:window},sn=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 i="dompurify"+(s?"#"+s:"");try{return e.createPolicy(i,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},ds=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function zs(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:an();const e=m=>zs(m);if(e.version="3.4.2",e.removed=[],!n||!n.document||n.document.nodeType!==tt.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const s=t,a=s.currentScript,{DocumentFragment:i,HTMLTemplateElement:r,Node:o,Element:c,NodeFilter:h,NamedNodeMap:d=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:C,DOMParser:y,trustedTypes:I}=n,S=c.prototype,x=_e(S,"cloneNode"),H=_e(S,"remove"),p=_e(S,"nextSibling"),g=_e(S,"childNodes"),w=_e(S,"parentNode");if(typeof r=="function"){const m=t.createElement("template");m.content&&m.content.ownerDocument&&(t=m.content.ownerDocument)}let T,E="";const{implementation:_,createNodeIterator:ce,createDocumentFragment:ne,getElementsByTagName:Rt}=t,{importNode:Me}=s;let U=ds();e.isSupported=typeof Os=="function"&&typeof w=="function"&&_&&_.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:dt,ERB_EXPR:gt,TMPLIT_EXPR:pt,DATA_ATTR:Vs,ARIA_ATTR:Bs,IS_SCRIPT_OR_DATA:Hs,ATTR_WHITESPACE:xa,CUSTOM_ELEMENT:Us}=us;let{IS_ALLOWED_URI:ka}=us,Q=null;const Aa=b({},[...os,...Yt,...Jt,...Gt,...ls]);let J=null;const Ea=b({},[...cs,...Zt,...hs,...bt]);let O=Object.seal(Oe(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),qe=null,ft=null;const be=Object.seal(Oe(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let va=!0,jt=!0,Da=!1,Ia=!0,Se=!1,We=!0,xe=!1,Nt=!1,Pt=!1,Ie=!1,mt=!1,Lt=!1,Ra=!0,ja=!1;const Na="user-content-";let Ot=!0,Ye=!1,Re={},ge=null;const _t=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 Pa=null;const Oa=b({},["audio","video","img","source","image","track"]);let Ft=null;const _a=b({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),yt="http://www.w3.org/1998/Math/MathML",wt="http://www.w3.org/2000/svg",pe="http://www.w3.org/1999/xhtml";let je=pe,zt=!1,$t=null;const Qs=b({},[yt,wt,pe],Wt);let Vt=b({},["mi","mo","mn","ms","mtext"]),Bt=b({},["annotation-xml"]);const qs=b({},["title","style","font","a","script"]);let Je=null;const Ws=["application/xhtml+xml","text/html"],Ys="text/html";let $=null,Ne=null;const Js=t.createElement("form"),Fa=function(l){return l instanceof RegExp||l instanceof Function},Ht=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ne&&Ne===l)return;(!l||typeof l!="object")&&(l={}),l=se(l),Je=Ws.indexOf(l.PARSER_MEDIA_TYPE)===-1?Ys:l.PARSER_MEDIA_TYPE,$=Je==="application/xhtml+xml"?Wt:at,Q=N(l,"ALLOWED_TAGS")&&K(l.ALLOWED_TAGS)?b({},l.ALLOWED_TAGS,$):Aa,J=N(l,"ALLOWED_ATTR")&&K(l.ALLOWED_ATTR)?b({},l.ALLOWED_ATTR,$):Ea,$t=N(l,"ALLOWED_NAMESPACES")&&K(l.ALLOWED_NAMESPACES)?b({},l.ALLOWED_NAMESPACES,Wt):Qs,Ft=N(l,"ADD_URI_SAFE_ATTR")&&K(l.ADD_URI_SAFE_ATTR)?b(se(_a),l.ADD_URI_SAFE_ATTR,$):_a,Pa=N(l,"ADD_DATA_URI_TAGS")&&K(l.ADD_DATA_URI_TAGS)?b(se(Oa),l.ADD_DATA_URI_TAGS,$):Oa,ge=N(l,"FORBID_CONTENTS")&&K(l.FORBID_CONTENTS)?b({},l.FORBID_CONTENTS,$):_t,qe=N(l,"FORBID_TAGS")&&K(l.FORBID_TAGS)?b({},l.FORBID_TAGS,$):se({}),ft=N(l,"FORBID_ATTR")&&K(l.FORBID_ATTR)?b({},l.FORBID_ATTR,$):se({}),Re=N(l,"USE_PROFILES")?l.USE_PROFILES&&typeof l.USE_PROFILES=="object"?se(l.USE_PROFILES):l.USE_PROFILES:!1,va=l.ALLOW_ARIA_ATTR!==!1,jt=l.ALLOW_DATA_ATTR!==!1,Da=l.ALLOW_UNKNOWN_PROTOCOLS||!1,Ia=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Se=l.SAFE_FOR_TEMPLATES||!1,We=l.SAFE_FOR_XML!==!1,xe=l.WHOLE_DOCUMENT||!1,Ie=l.RETURN_DOM||!1,mt=l.RETURN_DOM_FRAGMENT||!1,Lt=l.RETURN_TRUSTED_TYPE||!1,Pt=l.FORCE_BODY||!1,Ra=l.SANITIZE_DOM!==!1,ja=l.SANITIZE_NAMED_PROPS||!1,Ot=l.KEEP_CONTENT!==!1,Ye=l.IN_PLACE||!1,ka=Qi(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:_s,je=typeof l.NAMESPACE=="string"?l.NAMESPACE:pe,Vt=N(l,"MATHML_TEXT_INTEGRATION_POINTS")&&l.MATHML_TEXT_INTEGRATION_POINTS&&typeof l.MATHML_TEXT_INTEGRATION_POINTS=="object"?se(l.MATHML_TEXT_INTEGRATION_POINTS):b({},["mi","mo","mn","ms","mtext"]),Bt=N(l,"HTML_INTEGRATION_POINTS")&&l.HTML_INTEGRATION_POINTS&&typeof l.HTML_INTEGRATION_POINTS=="object"?se(l.HTML_INTEGRATION_POINTS):b({},["annotation-xml"]);const u=N(l,"CUSTOM_ELEMENT_HANDLING")&&l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING=="object"?se(l.CUSTOM_ELEMENT_HANDLING):Oe(null);if(O=Oe(null),N(u,"tagNameCheck")&&Fa(u.tagNameCheck)&&(O.tagNameCheck=u.tagNameCheck),N(u,"attributeNameCheck")&&Fa(u.attributeNameCheck)&&(O.attributeNameCheck=u.attributeNameCheck),N(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(O.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),Se&&(jt=!1),mt&&(Ie=!0),Re&&(Q=b({},ls),J=Oe(null),Re.html===!0&&(b(Q,os),b(J,cs)),Re.svg===!0&&(b(Q,Yt),b(J,Zt),b(J,bt)),Re.svgFilters===!0&&(b(Q,Jt),b(J,Zt),b(J,bt)),Re.mathMl===!0&&(b(Q,Gt),b(J,hs),b(J,bt))),be.tagCheck=null,be.attributeCheck=null,N(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?be.tagCheck=l.ADD_TAGS:K(l.ADD_TAGS)&&(Q===Aa&&(Q=se(Q)),b(Q,l.ADD_TAGS,$))),N(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?be.attributeCheck=l.ADD_ATTR:K(l.ADD_ATTR)&&(J===Ea&&(J=se(J)),b(J,l.ADD_ATTR,$))),N(l,"ADD_URI_SAFE_ATTR")&&K(l.ADD_URI_SAFE_ATTR)&&b(Ft,l.ADD_URI_SAFE_ATTR,$),N(l,"FORBID_CONTENTS")&&K(l.FORBID_CONTENTS)&&(ge===_t&&(ge=se(ge)),b(ge,l.FORBID_CONTENTS,$)),N(l,"ADD_FORBID_CONTENTS")&&K(l.ADD_FORBID_CONTENTS)&&(ge===_t&&(ge=se(ge)),b(ge,l.ADD_FORBID_CONTENTS,$)),Ot&&(Q["#text"]=!0),xe&&b(Q,["html","head","body"]),Q.table&&(b(Q,["tbody"]),delete qe.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw Mt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Mt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');T=l.TRUSTED_TYPES_POLICY,E=T.createHTML("")}else T===void 0&&(T=sn(I,a)),T!==null&&typeof E=="string"&&(E=T.createHTML(""));ee&&ee(l),Ne=l},za=b({},[...Yt,...Jt,...qi]),$a=b({},[...Gt,...Wi]),Gs=function(l){let u=w(l);(!u||!u.tagName)&&(u={namespaceURI:je,tagName:"template"});const f=at(l.tagName),R=at(u.tagName);return $t[l.namespaceURI]?l.namespaceURI===wt?u.namespaceURI===pe?f==="svg":u.namespaceURI===yt?f==="svg"&&(R==="annotation-xml"||Vt[R]):!!za[f]:l.namespaceURI===yt?u.namespaceURI===pe?f==="math":u.namespaceURI===wt?f==="math"&&Bt[R]:!!$a[f]:l.namespaceURI===pe?u.namespaceURI===wt&&!Bt[R]||u.namespaceURI===yt&&!Vt[R]?!1:!$a[f]&&(qs[f]||!za[f]):!!(Je==="application/xhtml+xml"&&$t[l.namespaceURI]):!1},he=function(l){Xe(e.removed,{element:l});try{w(l).removeChild(l)}catch{H(l)}},ke=function(l,u){try{Xe(e.removed,{attribute:u.getAttributeNode(l),from:u})}catch{Xe(e.removed,{attribute:null,from:u})}if(u.removeAttribute(l),l==="is")if(Ie||mt)try{he(u)}catch{}else try{u.setAttribute(l,"")}catch{}},Va=function(l){let u=null,f=null;if(Pt)l="<remove></remove>"+l;else{const F=ss(l,/^[\r\n\t ]+/);f=F&&F[0]}Je==="application/xhtml+xml"&&je===pe&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");const R=T?T.createHTML(l):l;if(je===pe)try{u=new y().parseFromString(R,Je)}catch{}if(!u||!u.documentElement){u=_.createDocument(je,"template",null);try{u.documentElement.innerHTML=zt?E:R}catch{}}const Z=u.body||u.documentElement;return l&&f&&Z.insertBefore(t.createTextNode(f),Z.childNodes[0]||null),je===pe?Rt.call(u,xe?"html":"body")[0]:xe?u.documentElement:Z},Ba=function(l){return ce.call(l.ownerDocument||l,l,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},Ut=function(l){return l instanceof C&&(typeof l.nodeName!="string"||typeof l.textContent!="string"||typeof l.removeChild!="function"||!(l.attributes instanceof d)||typeof l.removeAttribute!="function"||typeof l.setAttribute!="function"||typeof l.namespaceURI!="string"||typeof l.insertBefore!="function"||typeof l.hasChildNodes!="function")},Qt=function(l){return typeof o=="function"&&l instanceof o};function me(m,l,u){Ke(m,f=>{f.call(e,l,u,Ne)})}const Ha=function(l){let u=null;if(me(U.beforeSanitizeElements,l,null),Ut(l))return he(l),!0;const f=$(l.nodeName);if(me(U.uponSanitizeElement,l,{tagName:f,allowedTags:Q}),We&&l.hasChildNodes()&&!Qt(l.firstElementChild)&&G(/<[/\w!]/g,l.innerHTML)&&G(/<[/\w!]/g,l.textContent)||We&&l.namespaceURI===pe&&f==="style"&&Qt(l.firstElementChild)||l.nodeType===tt.progressingInstruction||We&&l.nodeType===tt.comment&&G(/<[/\w]/g,l.data))return he(l),!0;if(qe[f]||!(be.tagCheck instanceof Function&&be.tagCheck(f))&&!Q[f]){if(!qe[f]&&Qa(f)&&(O.tagNameCheck instanceof RegExp&&G(O.tagNameCheck,f)||O.tagNameCheck instanceof Function&&O.tagNameCheck(f)))return!1;if(Ot&&!ge[f]){const R=w(l)||l.parentNode,Z=g(l)||l.childNodes;if(Z&&R){const F=Z.length;for(let ae=F-1;ae>=0;--ae){const re=x(Z[ae],!0);R.insertBefore(re,p(l))}}}return he(l),!0}return l instanceof c&&!Gs(l)||(f==="noscript"||f==="noembed"||f==="noframes")&&G(/<\/no(script|embed|frames)/i,l.innerHTML)?(he(l),!0):(Se&&l.nodeType===tt.text&&(u=l.textContent,Ke([dt,gt,pt],R=>{u=Pe(u,R," ")}),l.textContent!==u&&(Xe(e.removed,{element:l.cloneNode()}),l.textContent=u)),me(U.afterSanitizeElements,l,null),!1)},Ua=function(l,u,f){if(ft[u]||Ra&&(u==="id"||u==="name")&&(f in t||f in Js))return!1;const R=J[u]||be.attributeCheck instanceof Function&&be.attributeCheck(u,l);if(!(jt&&!ft[u]&&G(Vs,u))){if(!(va&&G(Bs,u))){if(!R||ft[u]){if(!(Qa(l)&&(O.tagNameCheck instanceof RegExp&&G(O.tagNameCheck,l)||O.tagNameCheck instanceof Function&&O.tagNameCheck(l))&&(O.attributeNameCheck instanceof RegExp&&G(O.attributeNameCheck,u)||O.attributeNameCheck instanceof Function&&O.attributeNameCheck(u,l))||u==="is"&&O.allowCustomizedBuiltInElements&&(O.tagNameCheck instanceof RegExp&&G(O.tagNameCheck,f)||O.tagNameCheck instanceof Function&&O.tagNameCheck(f))))return!1}else if(!Ft[u]){if(!G(ka,Pe(f,xa,""))){if(!((u==="src"||u==="xlink:href"||u==="href")&&l!=="script"&&is(f,"data:")===0&&Pa[l])){if(!(Da&&!G(Hs,Pe(f,xa,"")))){if(f)return!1}}}}}}return!0},Zs=b({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Qa=function(l){return!Zs[at(l)]&&G(Us,l)},qa=function(l){me(U.beforeSanitizeAttributes,l,null);const{attributes:u}=l;if(!u||Ut(l))return;const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J,forceKeepAttr:void 0};let R=u.length;for(;R--;){const Z=u[R],{name:F,namespaceURI:ae,value:re}=Z,ue=$(F),qt=re;let q=F==="value"?qt:zi(qt);if(f.attrName=ue,f.attrValue=q,f.keepAttr=!0,f.forceKeepAttr=void 0,me(U.uponSanitizeAttribute,l,f),q=f.attrValue,ja&&(ue==="id"||ue==="name")&&is(q,Na)!==0&&(ke(F,l),q=Na+q),We&&G(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,q)){ke(F,l);continue}if(ue==="attributename"&&ss(q,"href")){ke(F,l);continue}if(f.forceKeepAttr)continue;if(!f.keepAttr){ke(F,l);continue}if(!Ia&&G(/\/>/i,q)){ke(F,l);continue}Se&&Ke([dt,gt,pt],Ja=>{q=Pe(q,Ja," ")});const Ya=$(l.nodeName);if(!Ua(Ya,ue,q)){ke(F,l);continue}if(T&&typeof I=="object"&&typeof I.getAttributeType=="function"&&!ae)switch(I.getAttributeType(Ya,ue)){case"TrustedHTML":{q=T.createHTML(q);break}case"TrustedScriptURL":{q=T.createScriptURL(q);break}}if(q!==qt)try{ae?l.setAttributeNS(ae,F,q):l.setAttribute(F,q),Ut(l)?he(l):as(e.removed)}catch{ke(F,l)}}me(U.afterSanitizeAttributes,l,null)},Wa=function(l){let u=null;const f=Ba(l);for(me(U.beforeSanitizeShadowDOM,l,null);u=f.nextNode();)me(U.uponSanitizeShadowNode,u,null),Ha(u),qa(u),u.content instanceof i&&Wa(u.content);me(U.afterSanitizeShadowDOM,l,null)};return e.sanitize=function(m){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,f=null,R=null,Z=null;if(zt=!m,zt&&(m="<!-->"),typeof m!="string"&&!Qt(m)&&(m=Ui(m),typeof m!="string"))throw Mt("dirty is not a string, aborting");if(!e.isSupported)return m;if(Nt||Ht(l),e.removed=[],typeof m=="string"&&(Ye=!1),Ye){const re=m.nodeName;if(typeof re=="string"){const ue=$(re);if(!Q[ue]||qe[ue])throw Mt("root node is forbidden and cannot be sanitized in-place")}}else if(m instanceof o)u=Va("<!---->"),f=u.ownerDocument.importNode(m,!0),f.nodeType===tt.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?u=f:u.appendChild(f);else{if(!Ie&&!Se&&!xe&&m.indexOf("<")===-1)return T&&Lt?T.createHTML(m):m;if(u=Va(m),!u)return Ie?null:Lt?E:""}u&&Pt&&he(u.firstChild);const F=Ba(Ye?m:u);for(;R=F.nextNode();)Ha(R),qa(R),R.content instanceof i&&Wa(R.content);if(Ye)return m;if(Ie){if(Se){u.normalize();let re=u.innerHTML;Ke([dt,gt,pt],ue=>{re=Pe(re,ue," ")}),u.innerHTML=re}if(mt)for(Z=ne.call(u.ownerDocument);u.firstChild;)Z.appendChild(u.firstChild);else Z=u;return(J.shadowroot||J.shadowrootmode)&&(Z=Me.call(s,Z,!0)),Z}let ae=xe?u.outerHTML:u.innerHTML;return xe&&Q["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&G(Fs,u.ownerDocument.doctype.name)&&(ae="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
57
+ `+ae),Se&&Ke([dt,gt,pt],re=>{ae=Pe(ae,re," ")}),T&&Lt?T.createHTML(ae):ae},e.setConfig=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ht(m),Nt=!0},e.clearConfig=function(){Ne=null,Nt=!1},e.isValidAttribute=function(m,l,u){Ne||Ht({});const f=$(m),R=$(l);return Ua(f,R,u)},e.addHook=function(m,l){typeof l=="function"&&Xe(U[m],l)},e.removeHook=function(m,l){if(l!==void 0){const u=_i(U[m],l);return u===-1?void 0:Fi(U[m],u,1)[0]}return as(U[m])},e.removeHooks=function(m){U[m]=[]},e.removeAllHooks=function(){U=ds()},e}var gs=zs();class nn{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(v.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,i)=>{const r=a.value==="any"?0:parseFloat(a.value),o=i.value==="any"?0:parseFloat(i.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(v.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(a=>{const i=a.name,r=a.value,o=e.find(c=>c.name===i);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(a=>a!==null):[]}get cachedANDFacets(){let e="";for(const t of this.dataLayer.searchObject.facets)(t.type==="and"||t.type==="tabs")&&(e+=JSON.stringify(t));return e}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalPages:this.totalPages,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,selectedFacets:this.selectedFacets,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,answerTruncated:this.answerTruncated,fullAnswerFormatted:this.fullAnswerFormatted,shouldShowAnswerLoadMore:this.shouldShowAnswerLoadMore,answerLoading:this.answerLoading,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption,shouldShowAnswerError:this.shouldShowAnswerError,answerErrorMessage:this.answerErrorMessage,locationSearchEnabled:this.locationSearchEnabled,locationSearchDistanceEnabled:this.locationSearchDistanceEnabled,locationSearchDistanceValues:this.locationSearchDistanceValues,shouldShowLocationDistanceDropdown:this.shouldShowLocationDistanceDropdown,locationError:this.locationError}}get trackingData(){return{searchTerm:this.searchTerm,trackApiKey:this.dataLayer.searchstaxConfig?.trackApiKey??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:this.dataLayer.searchResultsMetadata?.recordsPerPageValue??0,totalResults:this.dataLayer.searchResultsMetadata?.totalResultsValue??0,currentPage:this.dataLayer.currentPage,latencyVal:this.dataLayer.searchResultsMetadata?.latency??0,...this.dataLayer.model?{model:this.dataLayer.model}:{}}}}class oe{static deepEqual(e,t){const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(const i of s){const r=e[i],o=t[i],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 s=Math.random().toString(36).substring(2,15),a=t||s;return this.observers[a]=e,e(this.value),a}unsubscribe(e){this.observers[e]&&delete this.observers[e]}subscribeOnce(e){const t=Math.random().toString(36).substring(2,15),s=a=>{e(a),this.unsubscribe(t)};this.subscribe(s,t)}subscribeTwice(e){const t=Math.random().toString(36).substring(2,15);let s=0;const a=i=>{s++,e(i),s>=2&&this.unsubscribe(t)};this.subscribe(a,t)}subscribeUntil(e,t,s=6e3,a=!0){const i=Math.random().toString(36).substring(2,15),r=o=>{o===t&&(e(o),this.unsubscribe(i))};return this.value===t?(e(this.value),null):(this.subscribe(r,i),setTimeout(()=>{a&&this.observers[i]&&e(this.value),this.unsubscribe(i)},s),i)}subscribeUntilHasValue(e,t=6e3,s=!0){const a=Math.random().toString(36).substring(2,15),i=r=>{r!=null&&(e(r),this.unsubscribe(a))};return this.value!==null&&this.value!==void 0?(e(this.value),null):(this.subscribe(i,a),t>0&&setTimeout(()=>{s&&this.observers[a]&&e(this.value),this.unsubscribe(a)},t),i)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){for(const e in this.observers)if(Object.prototype.hasOwnProperty.call(this.observers,e)){const t=this.observers[e];typeof t=="function"&&t(this.value)}}}class Kt{static getOrSetCookie(e,t){let s=this.getCookie(e);return s==null&&(s=t??this.makeid(25),this.setCookie(e,s,{secure:!0,"max-age":3600})),s}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=s.length;for(let i=0;i<e;i++)t+=s.charAt(Math.floor(Math.random()*a));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,s){const a={path:"/",...s};s.expires instanceof Date&&(a.expires=s.expires.toUTCString());let i=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const r in a){i+="; "+r;const o=a[r];o!==!0&&(i+="="+o)}typeof document<"u"&&(document.cookie=i)}}class Y{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 rn{$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=P.mustache;parsedData=new nn(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,Kt.deleteCookie(this.sessionId),Kt.deleteCookie("ms_visitorid")):this.sessionIdValue=Kt.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(Y.removeXSSRiskyTags(e))}setSearchLocation(e){this.$searchLocationChange.setValue(Y.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(Y.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 st{static combineResultsWithMetadata(e){const t=[],s=parseInt(e.response.start+"");return e.response.docs.forEach((a,i)=>{const r=a[e.responseHeader.params.uniqueId]??"",o={custom:null,uniqueId:r,position:s+1+i,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 i=e.facet_counts.facet_fields[s.name];for(let r=0;r<i.length;r+=2){const o={};o.value=i[r],o.parentName=a.name,o.count=i[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(i=>i.result_card==="date")?.name,s.options=[],e.metadata.sorts?.length){const i=e.metadata.sorts.map(r=>({value:r.label,key:r.name+" "+r.order}));s.options=[{key:"",value:"Relevance"},...i]}return t=e?.spellcheck?.suggestions?.[1]?.suggestion?.[0]??"",typeof t!="string"&&(t=t?.word??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:t,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:s,location:a,isLocationMapped:this.doesMapExist("distance",e)}}static getImpressions(e){const t=[],s=this.combineResultsWithMetadata(e);for(const a in s){const i=s[a],r={};r.cDocId=this.getDataForAnalytics(i.uniqueId),i.title&&(r.cDocTitle=this.getDataForAnalytics(i.titleTracking)),r.position=i.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),i=[];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);i.push({key:r,value:o,isImage:this.checkIfImage(e[r])})}return i}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const s=t.metadata.results.map(i=>i.name),a=[];for(const i of Object.keys(e))s.indexOf(i)!==-1&&a.push({key:i,value:e[i],isImage:this.checkIfImage(e[i])});return a}static doesMapExist(e,t){return t.metadata.results.find(s=>s.result_card===e)!==void 0}static getValueByKey(e,t,s,a,i=!1){const 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"?i?o:this.getHighlightedResults(r.name,o,a,s):typeof o=="number"?o:Array.isArray(o)?i?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 i=a.highlighting[s];if(i&&e in i){let r=i[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 on(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let s=typeof document<"u"?document?.title:"";this.titleParser&&(s=this.titleParser(e)),typeof document<"u"&&(document.title=s),window?.location.href!==t&&window?.history.replaceState(window.history.state,s,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window?.location.href??"")?window?.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):window?.location.href+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},s=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=s+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.itemsPerPage&&e.itemsPerPage!==10&&(t[this.routeName+"[itemsPerPage]"]=e.itemsPerPage+""),e.location)for(const a in e.location){const i=e.location[a];i&&(t[this.routeName+`[location][${a}]`]=i)}if(e.facets)for(const a in e.facets){const i=e.facets[a].type+":"+encodeURIComponent(e.facets[a].name)+":"+encodeURIComponent(e.facets[a].value);t[this.routeName+`[facets][${a}]`]=i}if(e.model&&(t[this.routeName+"[model]"]=e.model),this.queryStringHelper.urlHasQueryParams(window?.location.href??"")){const a=this.queryStringHelper.urlToParams(window?.location.href??"");for(const i in a)i.startsWith(this.routeName)&&delete a[i];return{...a,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const s in e)s.startsWith(this.routeName)||(t[s]=e[s]);return t}extractArrayOfFacetsFromQueryParameters(e){const t=[];for(const s in e)if(s.startsWith(this.routeName+"[facets]")){const a=Y.removeXSSRiskyTags(e[s].split(":")?.[0]),i=Y.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[1])),r=Y.removeXSSRiskyTags(decodeURIComponent(e[s].split(":")?.[2]));t.push({type:a,name:i,value:r})}return t}urlToSearchObject(e,t){const s=this.queryStringHelper.urlToParams(e),a=Y.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[page]"])),i=parseInt(a),r=isNaN(i)?1:i;let o=parseInt(Y.removeXSSRiskyTags(s[this.routeName+"[itemsPerPage]"]));return isNaN(o)&&(o=10),{query:Y.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[query]"]))||"",page:r,itemsPerPage:t??o,order:Y.removeXSSRiskyTags(s[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(s)||[],model:Y.removeXSSRiskyTags(s[this.routeName+"[model]"])||"",location:{address:Y.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][address]"]||"")),radius:Y.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][radius]"]||"")),lat:Y.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lat]"]||"")),lon:Y.removeXSSRiskyTags(decodeURIComponent(s[this.routeName+"[location][lon]"]||""))}}}}class on{routeName="";constructor(e){this.routeName=e}stringify=(e,t)=>{const s=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(s).map(a=>{const i=s[a];return Array.isArray(i)?i.map(r=>`${a}=${r}`).join("&"):`${a}=${i}`}).join("&")};filterOutIgnoredKeys(e,t){const s=t||[],a={};return Object.keys(e).forEach(i=>{s.includes(i)||e[i]!==""&&(a[i]=e[i])}),a}urlToParams(e){const t={},s=e.split("?")[1];return s&&s.split("&").forEach(a=>{const[i,r]=a.split("=");t[i]=r}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const Ve={question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class fs 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 ms=10,ln=13,Ae=32;function Xt(n){}function cn(n){if(typeof n=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=Xt,onError:t=Xt,onRetry:s=Xt,onComment:a}=n,i=[];let r=!0,o,c="",h=0,d;function C(p){if(r&&(r=!1,p.charCodeAt(0)===239&&p.charCodeAt(1)===187&&p.charCodeAt(2)===191&&(p=p.slice(3))),i.length===0){const T=y(p);T!==""&&i.push(T);return}if(p.indexOf(`
58
+ `)===-1&&p.indexOf("\r")===-1){i.push(p);return}i.push(p);const g=i.join("");i.length=0;const w=y(g);w!==""&&i.push(w)}function y(p){let g=0;if(p.indexOf("\r")===-1){let w=p.indexOf(`
59
+ `,g);for(;w!==-1;){if(g===w){h>0&&e({id:o,event:d,data:c}),o=void 0,c="",h=0,d=void 0,g=w+1,w=p.indexOf(`
60
+ `,g);continue}const T=p.charCodeAt(g);if(Ls(p,g,T)){const E=p.charCodeAt(g+5)===Ae?g+6:g+5,_=p.slice(E,w);if(h===0&&p.charCodeAt(w+1)===ms){e({id:o,event:d,data:_}),o=void 0,c="",d=void 0,g=w+2,w=p.indexOf(`
61
+ `,g);continue}c=h===0?_:`${c}
62
+ ${_}`,h++}else ys(p,g,T)?d=p.slice(p.charCodeAt(g+6)===Ae?g+7:g+6,w)||void 0:I(p,g,w);g=w+1,w=p.indexOf(`
63
+ `,g)}return p.slice(g)}for(;g<p.length;){const w=p.indexOf("\r",g),T=p.indexOf(`
64
+ `,g);let E=-1;if(w!==-1&&T!==-1?E=w<T?w:T:w!==-1?w===p.length-1?E=-1:E=w:T!==-1&&(E=T),E===-1)break;I(p,g,E),g=E+1,p.charCodeAt(g-1)===ln&&p.charCodeAt(g)===ms&&g++}return p.slice(g)}function I(p,g,w){if(g===w){x();return}const T=p.charCodeAt(g);if(Ls(p,g,T)){const Me=p.charCodeAt(g+5)===Ae?g+6:g+5,U=p.slice(Me,w);c=h===0?U:`${c}
65
+ ${U}`,h++;return}if(ys(p,g,T)){d=p.slice(p.charCodeAt(g+6)===Ae?g+7:g+6,w)||void 0;return}if(T===105&&p.charCodeAt(g+1)===100&&p.charCodeAt(g+2)===58){const Me=p.slice(p.charCodeAt(g+3)===Ae?g+4:g+3,w);o=Me.includes("\0")?void 0:Me;return}if(T===58){if(a){const Me=p.slice(g,w);a(Me.slice(p.charCodeAt(g+1)===Ae?2:1))}return}const E=p.slice(g,w),_=E.indexOf(":");if(_===-1){S(E,"",E);return}const ce=E.slice(0,_),ne=E.charCodeAt(_+1)===Ae?2:1,Rt=E.slice(_+ne);S(ce,Rt,E)}function S(p,g,w){switch(p){case"event":d=g||void 0;break;case"data":c=h===0?g:`${c}
66
+ ${g}`,h++;break;case"id":o=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.test(g)?s(parseInt(g,10)):t(new fs(`Invalid \`retry\` value: "${g}"`,{type:"invalid-retry",value:g,line:w}));break;default:t(new fs(`Unknown field "${p.length>20?`${p.slice(0,20)}…`:p}"`,{type:"unknown-field",field:p,value:g,line:w}));break}}function x(){h>0&&e({id:o,event:d,data:c}),o=void 0,c="",h=0,d=void 0}function H(p={}){if(p.consume&&i.length>0){const g=i.join("");I(g,0,g.length)}r=!0,o=void 0,c="",h=0,d=void 0,i.length=0}return{feed:C,reset:H}}function Ls(n,e,t){return t===100&&n.charCodeAt(e+1)===97&&n.charCodeAt(e+2)===116&&n.charCodeAt(e+3)===97&&n.charCodeAt(e+4)===58}function ys(n,e,t){return t===101&&n.charCodeAt(e+1)===118&&n.charCodeAt(e+2)===101&&n.charCodeAt(e+3)===110&&n.charCodeAt(e+4)===116&&n.charCodeAt(e+5)===58}class ws extends Event{constructor(e,t){var s,a;super(e),this.code=(s=t?.code)!=null?s:void 0,this.message=(a=t?.message)!=null?a:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,t,s){return s(Cs(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(Cs(this),t)}}function hn(n){const e=globalThis.DOMException;return typeof e=="function"?new e(n,"SyntaxError"):new SyntaxError(n)}function ra(n){return n instanceof Error?"errors"in n&&Array.isArray(n.errors)?n.errors.map(ra).join(", "):"cause"in n&&n.cause instanceof Error?`${n}: ${ra(n.cause)}`:n.message:`${n}`}function Cs(n){return{type:n.type,message:n.message,code:n.code,defaultPrevented:n.defaultPrevented,cancelable:n.cancelable,timeStamp:n.timeStamp}}var $s=n=>{throw TypeError(n)},Ta=(n,e,t)=>e.has(n)||$s("Cannot "+t),k=(n,e,t)=>(Ta(n,e,"read from private field"),t?t.call(n):e.get(n)),V=(n,e,t)=>e.has(n)?$s("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),j=(n,e,t,s)=>(Ta(n,e,"write to private field"),e.set(n,t),t),Le=(n,e,t)=>(Ta(n,e,"access private method"),t),ie,Ee,Fe,St,vt,ot,Be,lt,Te,ze,He,$e,it,de,oa,la,ca,Ms,ha,ua,nt,da,ga;class xt extends EventTarget{constructor(e,t){var s,a;super(),V(this,de),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,V(this,ie),V(this,Ee),V(this,Fe),V(this,St),V(this,vt),V(this,ot),V(this,Be),V(this,lt,null),V(this,Te),V(this,ze),V(this,He,null),V(this,$e,null),V(this,it,null),V(this,la,async i=>{var r;k(this,ze).reset();const{body:o,redirected:c,status:h,headers:d}=i;if(h===204){Le(this,de,nt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?j(this,Fe,new URL(i.url)):j(this,Fe,void 0),h!==200){Le(this,de,nt).call(this,`Non-200 status code (${h})`,h);return}if(!(d.get("content-type")||"").startsWith("text/event-stream")){Le(this,de,nt).call(this,'Invalid content type, expected "text/event-stream"',h);return}if(k(this,ie)===this.CLOSED)return;j(this,ie,this.OPEN);const C=new Event("open");if((r=k(this,it))==null||r.call(this,C),this.dispatchEvent(C),typeof o!="object"||!o||!("getReader"in o)){Le(this,de,nt).call(this,"Invalid response body, expected a web ReadableStream",h),this.close();return}const y=new TextDecoder,I=o.getReader();let S=!0;do{const{done:x,value:H}=await I.read();H&&k(this,ze).feed(y.decode(H,{stream:!x})),x&&(S=!1,k(this,ze).reset(),Le(this,de,da).call(this))}while(S)}),V(this,ca,i=>{j(this,Te,void 0),!(i.name==="AbortError"||i.type==="aborted")&&Le(this,de,da).call(this,ra(i))}),V(this,ha,i=>{typeof i.id=="string"&&j(this,lt,i.id);const r=new MessageEvent(i.event||"message",{data:i.data,origin:k(this,Fe)?k(this,Fe).origin:k(this,Ee).origin,lastEventId:i.id||""});k(this,$e)&&(!i.event||i.event==="message")&&k(this,$e).call(this,r),this.dispatchEvent(r)}),V(this,ua,i=>{j(this,ot,i)}),V(this,ga,()=>{j(this,Be,void 0),k(this,ie)===this.CONNECTING&&Le(this,de,oa).call(this)});try{if(e instanceof URL)j(this,Ee,e);else if(typeof e=="string")j(this,Ee,new URL(e,un()));else throw new Error("Invalid URL")}catch{throw hn("An invalid or illegal string was specified")}j(this,ze,cn({onEvent:k(this,ha),onRetry:k(this,ua)})),j(this,ie,this.CONNECTING),j(this,ot,3e3),j(this,vt,(s=t?.fetch)!=null?s:globalThis.fetch),j(this,St,(a=t?.withCredentials)!=null?a:!1),Le(this,de,oa).call(this)}get readyState(){return k(this,ie)}get url(){return k(this,Ee).href}get withCredentials(){return k(this,St)}get onerror(){return k(this,He)}set onerror(e){j(this,He,e)}get onmessage(){return k(this,$e)}set onmessage(e){j(this,$e,e)}get onopen(){return k(this,it)}set onopen(e){j(this,it,e)}addEventListener(e,t,s){const a=t;super.addEventListener(e,a,s)}removeEventListener(e,t,s){const a=t;super.removeEventListener(e,a,s)}close(){k(this,Be)&&clearTimeout(k(this,Be)),k(this,ie)!==this.CLOSED&&(k(this,Te)&&k(this,Te).abort(),j(this,ie,this.CLOSED),j(this,Te,void 0))}}ie=new WeakMap,Ee=new WeakMap,Fe=new WeakMap,St=new WeakMap,vt=new WeakMap,ot=new WeakMap,Be=new WeakMap,lt=new WeakMap,Te=new WeakMap,ze=new WeakMap,He=new WeakMap,$e=new WeakMap,it=new WeakMap,de=new WeakSet,oa=function(){j(this,ie,this.CONNECTING),j(this,Te,new AbortController),k(this,vt)(k(this,Ee),Le(this,de,Ms).call(this)).then(k(this,la)).catch(k(this,ca))},la=new WeakMap,ca=new WeakMap,Ms=function(){var n;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...k(this,lt)?{"Last-Event-ID":k(this,lt)}:void 0},cache:"no-store",signal:(n=k(this,Te))==null?void 0:n.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},ha=new WeakMap,ua=new WeakMap,nt=function(n,e){var t;k(this,ie)!==this.CLOSED&&j(this,ie,this.CLOSED);const s=new ws("error",{code:e,message:n});(t=k(this,He))==null||t.call(this,s),this.dispatchEvent(s)},da=function(n,e){var t;if(k(this,ie)===this.CLOSED)return;j(this,ie,this.CONNECTING);const s=new ws("error",{code:e,message:n});(t=k(this,He))==null||t.call(this,s),this.dispatchEvent(s),j(this,Be,setTimeout(k(this,ga),k(this,ot)))},ga=new WeakMap,xt.CONNECTING=0,xt.OPEN=1,xt.CLOSED=2;function un(){const n="document"in globalThis?globalThis.document:void 0;return n&&typeof n=="object"&&"baseURI"in n&&typeof n.baseURI=="string"?n.baseURI:void 0}class ye{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 i=document.createElement("script");i.type="text/javascript",i.src=s;var r=document.getElementsByTagName("script")[0];r.parentNode&&r.parentNode.insertBefore(i,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 i=["trackClick",t];t.key?this.msq().push(i,(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 i=["answerSourceClick",t];t.key?this.msq().push(i,(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+""};setTimeout(()=>{t.key&&this.msq().push(["trackquestionanswer",t])},0)}static trackFeedback(e){setTimeout(()=>{this.msq().push(["trackSearchSatisfaction",{key:e.trackApiKey,email:e.email,score:e.rating,comments:e.feedback,language:e.language,model:e.model}])},0)}}class dn{cachedQuery="";cachedANDFacets="";url="";relatedSearches="";suggester="";authHeader;authHeaderRelated;trackApiKey="";session="";searchAuthType;searchAuth="";controllerSearch;signalSearch;controllerSuggest;signalSuggest;_authToken="";resolveFn;dataLayer;constructor(e,t){this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json"),this._authToken=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`,this.authHeader.append("Authorization",this._authToken),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let s=[];if(!t)e.forEach(function(a){const i=a.name+':"'+a.value+'"';s=s.concat("fq="+decodeURIComponent(i).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 i="";for(const r in a)if(Object.prototype.hasOwnProperty.call(a,r)){const o=a[r],c=r;for(const h of o)i+=i===""?` ${c}:"${h}"`:` OR ${c}:"${h}"`}s=s.concat("fq="+i.trim())}return s=s.map(a=>a.replace(/&/g,"%26").replace(/\+/g,"%2B")),s.length?"&"+s.join("&"):""}generateLocationQuery(e){let t="";if(e.lat&&e.lon){const s=Math.floor(parseFloat(e.lat)*100)/100,a=Math.floor(parseFloat(e.lon)*100)/100;t+=`&pt=${s},${a}`}return e.radius&&t!==""&&e.radius!=="any"&&(t+=`&distanceFilter=${e.radius}`),t}getRelatedSearches(e,t,s,a){const i=new Headers;i.append("Accept","application/json"),i.append("Authorization",s),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:i,credentials:"same-origin"}).then(r=>r.json()).then(r=>{a(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 s=[this.dataLayer.searchObject.facets.filter(a=>e?!1:a.type==="and"||a.type==="tabs")].flat();this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:s,additionalProps:this.dataLayer.searchObject.additionalProps,location:this.dataLayer.searchObject.location,model:this.dataLayer.model},this.cacheFacetsCallback.bind(this),!0,!1,e)}else this.resolveFn()})}cacheFacetsCallback(e,t){let s=st.extractFacets(e);t?this.dataLayer.setSearchFacetsCachedTabs(s):this.dataLayer.setSearchFacetsCached(s),this.resolveFn&&this.resolveFn()}search(e,t,s=!1,a=!1,i=!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,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,i)}).catch(()=>{this.dataLayer.setLoading(!1)})}}generateQueryParams(e,t){let s=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),a=e.order?`&sort=${e.order}`:"";const i=e.itemsPerPage!==void 0?`&rows=${e.itemsPerPage}`:"",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+i+`&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=new xt(this.dataLayer.questionURL+this.generateQueryParams(this.dataLayer.searchObject),{fetch:(i,r)=>fetch(i,{...r,headers:{...r?.headers,Authorization:this._authToken}})}),a=this.dataLayer;return s.onmessage=i=>{if(i.data===Ve.question||i.data===Ve.notQuestion){i.data===Ve.question?(this.dataLayer.setAnswerLoading(!0),this.dataLayer.setIsQuestion(!0)):(a.setAnswerLoading(!1),this.dataLayer.setIsQuestion(!1)),a.setAnswerData("");return}if(i.data===Ve.close){ye.trackAnswerData({...a.parsedData.trackingData,answer:a.$answer.getValue(),isQuestion:this.dataLayer.isQuestion}),a.setAnswerLoading(!1),s.close();return}if(i.data.indexOf("[!CAUTION]")!==-1){a.setAnswerError(!0),a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),s.close();return}if(i.data.indexOf("[comment]: <> ({")!==-1)try{const r=i.data.split("[comment]: <> ({");if(r.length<2){t(i.data);return}const o=r[1].split("})");if(o.length<2){t(i.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(i.data)}else t(i.data)},s.addEventListener("error",i=>{(i.code===401||i.code===500)&&(a.setAnswerErrorMessage("We're having trouble generating an answer. Please try again."),a.setAnswerError(!0))}),s.onerror=()=>{a.setAnswerLoading(!1),s.close()},s}suggest(e,t,s){if(this.controllerSuggest&&this.controllerSuggest.abort(),this.suggester.trim()==="")return;this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const a=this.suggester+"?q="+e.trim()+this.toQueryString(s)+"&language="+this.dataLayer.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(i=>i.json()).then(i=>{t(i)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const s of e)t.push(encodeURIComponent(s.key)+"="+encodeURIComponent(s.value));return"&"+t.join("&")}}var gn=Object.prototype.toString,Qe=Array.isArray||function(e){return gn.call(e)==="[object Array]"};function Sa(n){return typeof n=="function"}function pn(n){return Qe(n)?"array":typeof n}function ea(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function bs(n,e){return n!=null&&typeof n=="object"&&e in n}function fn(n,e){return n!=null&&typeof n!="object"&&n.hasOwnProperty&&n.hasOwnProperty(e)}var mn=RegExp.prototype.test;function Ln(n,e){return mn.call(n,e)}var yn=/\S/;function wn(n){return!Ln(yn,n)}var Cn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function Mn(n){return String(n).replace(/[&<>"'`=\/]/g,function(t){return Cn[t]})}var bn=/\s*/,Tn=/\s+/,Ts=/\s*=/,Sn=/\s*\}/,xn=/#|\^|\/|>|\{|&|=|!/;function kn(n,e){if(!n)return[];var t=!1,s=[],a=[],i=[],r=!1,o=!1,c="",h=0;function d(){if(r&&!o)for(;i.length;)delete a[i.pop()];else i=[];r=!1,o=!1}var C,y,I;function S(ne){if(typeof ne=="string"&&(ne=ne.split(Tn,2)),!Qe(ne)||ne.length!==2)throw new Error("Invalid tags: "+ne);C=new RegExp(ea(ne[0])+"\\s*"),y=new RegExp("\\s*"+ea(ne[1])),I=new RegExp("\\s*"+ea("}"+ne[1]))}S(e||A.tags);for(var x=new ut(n),H,p,g,w,T,E;!x.eos();){if(H=x.pos,g=x.scanUntil(C),g)for(var _=0,ce=g.length;_<ce;++_)w=g.charAt(_),wn(w)?(i.push(a.length),c+=w):(o=!0,t=!0,c+=" "),a.push(["text",w,H,H+1]),H+=1,w===`
67
+ `&&(d(),c="",h=0,t=!1);if(!x.scan(C))break;if(r=!0,p=x.scan(xn)||"name",x.scan(bn),p==="="?(g=x.scanUntil(Ts),x.scan(Ts),x.scanUntil(y)):p==="{"?(g=x.scanUntil(I),x.scan(Sn),x.scanUntil(y),p="&"):g=x.scanUntil(y),!x.scan(y))throw new Error("Unclosed tag at "+x.pos);if(p==">"?T=[p,g,H,x.pos,c,h,t]:T=[p,g,H,x.pos],h++,a.push(T),p==="#"||p==="^")s.push(T);else if(p==="/"){if(E=s.pop(),!E)throw new Error('Unopened section "'+g+'" at '+H);if(E[1]!==g)throw new Error('Unclosed section "'+E[1]+'" at '+H)}else p==="name"||p==="{"||p==="&"?o=!0:p==="="&&S(g)}if(d(),E=s.pop(),E)throw new Error('Unclosed section "'+E[1]+'" at '+x.pos);return En(An(a))}function An(n){for(var e=[],t,s,a=0,i=n.length;a<i;++a)t=n[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 En(n){for(var e=[],t=e,s=[],a,i,r=0,o=n.length;r<o;++r)switch(a=n[r],a[0]){case"#":case"^":t.push(a),s.push(a),t=a[4]=[];break;case"/":i=s.pop(),i[5]=a[2],t=s.length>0?s[s.length-1][4]:e;break;default:t.push(a)}return e}function ut(n){this.string=n,this.tail=n,this.pos=0}ut.prototype.eos=function(){return this.tail===""};ut.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};ut.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 Ue(n,e){this.view=n,this.cache={".":this.view},this.parent=e}Ue.prototype.push=function(e){return new Ue(e,this)};Ue.prototype.lookup=function(e){var t=this.cache,s;if(t.hasOwnProperty(e))s=t[e];else{for(var a=this,i,r,o,c=!1;a;){if(e.indexOf(".")>0)for(i=a.view,r=e.split("."),o=0;i!=null&&o<r.length;)o===r.length-1&&(c=bs(i,r[o])||fn(i,r[o])),i=i[r[o++]];else i=a.view[e],c=bs(a.view,e);if(c){s=i;break}a=a.parent}t[e]=s}return Sa(s)&&(s=s.call(this.view)),s};function te(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}te.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};te.prototype.parse=function(e,t){var s=this.templateCache,a=e+":"+(t||A.tags).join(":"),i=typeof s<"u",r=i?s.get(a):void 0;return r==null&&(r=kn(e,t),i&&s.set(a,r)),r};te.prototype.render=function(e,t,s,a){var i=this.getConfigTags(a),r=this.parse(e,i),o=t instanceof Ue?t:new Ue(t,void 0);return this.renderTokens(r,o,s,e,a)};te.prototype.renderTokens=function(e,t,s,a,i){for(var r="",o,c,h,d=0,C=e.length;d<C;++d)h=void 0,o=e[d],c=o[0],c==="#"?h=this.renderSection(o,t,s,a,i):c==="^"?h=this.renderInverted(o,t,s,a,i):c===">"?h=this.renderPartial(o,t,s,i):c==="&"?h=this.unescapedValue(o,t):c==="name"?h=this.escapedValue(o,t,i):c==="text"&&(h=this.rawValue(o)),h!==void 0&&(r+=h);return r};te.prototype.renderSection=function(e,t,s,a,i){var r=this,o="",c=t.lookup(e[1]);function h(y){return r.render(y,t,s,i)}if(c){if(Qe(c))for(var d=0,C=c.length;d<C;++d)o+=this.renderTokens(e[4],t.push(c[d]),s,a,i);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")o+=this.renderTokens(e[4],t.push(c),s,a,i);else if(Sa(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,i);return o}};te.prototype.renderInverted=function(e,t,s,a,i){var r=t.lookup(e[1]);if(!r||Qe(r)&&r.length===0)return this.renderTokens(e[4],t,s,a,i)};te.prototype.indentPartial=function(e,t,s){for(var a=t.replace(/[^ \t]/g,""),i=e.split(`
63
68
  `),r=0;r<i.length;r++)i[r].length&&(r>0||!s)&&(i[r]=a+i[r]);return i.join(`
64
- `)};K.prototype.renderPartial=function(e,t,s,a){if(s){var i=this.getConfigTags(a),r=Ma(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,i);return this.renderTokens(y,t,s,d,a)}}};K.prototype.unescapedValue=function(e,t){var s=t.lookup(e[1]);if(s!=null)return s};K.prototype.escapedValue=function(e,t,s){var a=this.getConfigEscape(s)||S.escape,i=t.lookup(e[1]);if(i!=null)return typeof i=="number"&&a===S.escape?String(i):a(i)};K.prototype.rawValue=function(e){return e[1]};K.prototype.getConfigTags=function(e){return $e(e)?e:e&&typeof e=="object"?e.tags:void 0};K.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!$e(e))return e.escape};var S={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(n){nt.templateCache=n},get templateCache(){return nt.templateCache}},nt=new K;S.clearCache=function(){return nt.clearCache()};S.parse=function(e,t){return nt.parse(e,t)};S.render=function(e,t,s,a){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+en(e)+'" was given as the first argument for mustache#render(template, view, partials)');return nt.render(e,t,s,a)};S.escape=ln;S.Scanner=ot;S.Context=ze;S.Writer=K;const mn={main:{template:`
69
+ `)};te.prototype.renderPartial=function(e,t,s,a){if(s){var i=this.getConfigTags(a),r=Sa(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 C=this.parse(d,i);return this.renderTokens(C,t,s,d,a)}}};te.prototype.unescapedValue=function(e,t){var s=t.lookup(e[1]);if(s!=null)return s};te.prototype.escapedValue=function(e,t,s){var a=this.getConfigEscape(s)||A.escape,i=t.lookup(e[1]);if(i!=null)return typeof i=="number"&&a===A.escape?String(i):a(i)};te.prototype.rawValue=function(e){return e[1]};te.prototype.getConfigTags=function(e){return Qe(e)?e:e&&typeof e=="object"?e.tags:void 0};te.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!Qe(e))return e.escape};var A={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(n){ct.templateCache=n},get templateCache(){return ct.templateCache}},ct=new te;A.clearCache=function(){return ct.clearCache()};A.parse=function(e,t){return ct.parse(e,t)};A.render=function(e,t,s,a){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+pn(e)+'" was given as the first argument for mustache#render(template, view, partials)');return ct.render(e,t,s,a)};A.escape=Mn;A.Scanner=ut;A.Context=Ue;A.Writer=te;const vn={main:{template:`
65
70
  {{#shouldShowAnswer}}
66
71
  <div class="searchstax-answer-wrap">
67
72
  <div class="searchstax-answer-icon"></div>
@@ -98,7 +103,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
98
103
  </div>
99
104
  </div>
100
105
  {{/shouldShowAnswer}}
101
- `}},Ln={mainTemplate:{template:`
106
+ `}},Dn={mainTemplate:{template:`
102
107
  {{#hasExternalPromotions}}
103
108
  <div class="searchstax-external-promotions-container" id="searchstax-external-promotions-container" data-test-id="searchstax-external-promotions-container">
104
109
  External promotions go here
@@ -124,7 +129,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
124
129
  </p>
125
130
  {{/url}}
126
131
  </div>
127
- `}},yn={mainTemplateDesktop:{template:`
132
+ `}},In={mainTemplateDesktop:{template:`
128
133
  {{#hasResultsOrExternalPromotions}}
129
134
  <div class="searchstax-facets-container-desktop"></div>
130
135
  {{/hasResultsOrExternalPromotions}}
@@ -182,7 +187,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
182
187
  <div class="searchstax-facets-pill-label">{{value}} ({{count}})</div>
183
188
  <div class="searchstax-facets-pill-icon-close"></div>
184
189
  </div>
185
- `,containerClass:"searchstax-facets-pill-facets"}},wn={mainTemplate:{template:`
190
+ `,containerClass:"searchstax-facets-pill-facets"}},Rn={mainTemplate:{template:`
186
191
  {{#results.length}}
187
192
  <div class="searchstax-pagination-container" data-test-id="searchstax-pagination-container">
188
193
  <div class="searchstax-pagination-content">
@@ -200,7 +205,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
200
205
  <a class="searchstax-pagination-load-more" data-test-id="searchstax-pagination-load-more" tabindex="0">Show More</a>
201
206
  {{/isLastPage}}
202
207
  {{/results.length}}
203
- `,loadMoreButtonClass:"searchstax-pagination-load-more"}},Mn={main:{template:`
208
+ `,loadMoreButtonClass:"searchstax-pagination-load-more"}},jn={main:{template:`
204
209
  {{#hasRelatedSearches}}
205
210
  <div class="searchstax-related-searches-container" data-test-id="searchstax-related-searches-container" id="searchstax-related-searches-container">
206
211
  Related searches: <span id="searchstax-related-searches"></span>
@@ -215,7 +220,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
215
220
  <span role="link" class="searchstax-related-search searchstax-related-search-item" data-test-id="searchstax-related-search-item" aria-label="Related search: {{related_search}}" tabindex="0">
216
221
  {{ related_search }}{{^last}}<span>,</span>{{/last}}
217
222
  </span>
218
- `,relatedSearchContainerClass:"searchstax-related-search-item"}},Cn={main:{template:`
223
+ `,relatedSearchContainerClass:"searchstax-related-search-item"}},Nn={main:{template:`
219
224
  {{#searchExecuted}}
220
225
  <a href="#searchstax-search-results" data-test-id="searchstax-skip" class="searchstax-skip">Skip to results section</a>
221
226
  <h4 class="searchstax-feedback-container" data-test-id="searchstax-feedback-container">
@@ -229,7 +234,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
229
234
  {{/hasResults}}
230
235
  </h4>
231
236
  {{/searchExecuted}}
232
- `,originalQueryClass:"searchstax-feedback-original-query"}},bn={mainTemplate:{template:`
237
+ `,originalQueryClass:"searchstax-feedback-original-query"}},Pn={mainTemplate:{template:`
233
238
  <div class="searchstax-search-input-container searchstax-search-input-container-new {{#locationEnabled}}searchstax-alternative-render{{/locationEnabled}}">
234
239
  <div class="searchstax-search-input-wrapper">
235
240
  <input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." aria-label="Search" />
@@ -239,7 +244,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
239
244
  </div>
240
245
  `,searchInputId:"searchstax-search-input"},autosuggestItemTemplate:{template:`
241
246
  <div class="searchstax-autosuggest-item-term-container">{{{term}}}</div>
242
- `}},Sn={mainTemplate:{template:`
247
+ `}},On={mainTemplate:{template:`
243
248
  <div class="searchstax-location-input-container" data-test-id="searchstax-location-input-container">
244
249
  <div class="searchstax-location-input-wrapper">
245
250
  <span class="searchstax-location-input-label">NEAR</span>
@@ -257,7 +262,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
257
262
  {{/shouldShowLocationDistanceDropdown}}
258
263
  </div>
259
264
  </div>
260
- `,locationInputId:"searchstax-location-input",radiusInputId:"searchstax-location-radius-select",currentLocationActionButtonId:"searchstax-location-get-current-location"}},Tn={mainTemplate:{template:`
265
+ `,locationInputId:"searchstax-location-input",radiusInputId:"searchstax-location-radius-select",currentLocationActionButtonId:"searchstax-location-get-current-location"}},_n={mainTemplate:{template:`
261
266
  <section aria-label="search results container" tabindex="0">
262
267
  <div class="searchstax-search-results-container" id="searchstax-search-results-container" data-test-id="searchstax-search-results-container">
263
268
  <div class="searchstax-search-results" id="searchstax-search-results"></div>
@@ -329,7 +334,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
329
334
  </ul>
330
335
  </div>
331
336
  {{/searchExecuted}}
332
- `}},xn={main:{template:`
337
+ `}},Fn={main:{template:`
333
338
  {{#searchExecuted}}
334
339
  {{#hasResultsOrExternalPromotions}}
335
340
  {{#sortOptions.length}}
@@ -346,7 +351,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
346
351
  {{/sortOptions.length}}
347
352
  {{/hasResultsOrExternalPromotions}}
348
353
  {{/searchExecuted}}
349
- `,selectId:"searchstax-search-order-select"}},$={mainTemplate:{template:`
354
+ `,selectId:"searchstax-search-order-select"}},W={mainTemplate:{template:`
350
355
  <div class="sf-widget-container">
351
356
  <div id="sf-widget" class="sf-main">
352
357
  <a role="button" href="#" id="searchstax-open-feedback" class="sf-open-feedback" tabindex="0" aria-label="Open Search Feedback">[ - ] Search Feedback</a>
@@ -429,4 +434,4 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
429
434
 
430
435
  </div>
431
436
  </div>
432
- `,thumbsUpButtonClass:"searchstax-lightweight-widget-thumbs-up",thumbsDownButtonClass:"searchstax-lightweight-widget-thumbs-down"}};class m{static answer=mn;static externalPromotions=Ln;static facets=yn;static pagination=wn;static relatedSearches=Mn;static searchFeedback=Cn;static searchInput=bn;static location=Sn;static searchResults=Tn;static sorting=xn;static feedback=$}class kn{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",i=>{this.trackClick(e,i)}),a.innerHTML=S.render(s,e),t.appendChild(a)}}}trackClick(e,t){t.stopPropagation(),t.preventDefault(),window?.open(e.url,"_blank")}renderMainTemplate(e){const t=this.config?.templates?.mainTemplate?.template||m.externalPromotions.mainTemplate?.template;if(this.dataLayer.renderingEngine===j.mustache){this.searchExternalPromotionsMainContainer.innerHTML=S.render(t,e);const s=typeof document<"u"?document?.getElementById(this.externalPromotionsContainerId):null;s&&(s.innerHTML="");for(const a of e.externalPromotions)this.addExternalSearch(a)}}}class F{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",i=document.getElementById(a);i&&i.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 En{dataLayer;config;containerId;routerHelper;cachedPhrase="";cachedANDFacets="";isCached=!1;overlayOpened=!1;facetPaginationStep;facetPaginationStepMobile;searchFacetsMainContainer=null;searchFacetsMobileContainer=null;searchFacetsDesktopContainer=null;facetLimits={};facetLimitsMobile={};deactivatedFacets={};focusedElement=null;cachedData=null;cacheFacets;constructor(e,t){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.routerHelper=e.routerHelper,this.cacheFacets=t,this.facetPaginationStep=this.config.itemsPerPageDesktop,this.facetPaginationStepMobile=this.config.itemsPerPageMobile,typeof document<"u"&&(this.searchFacetsMainContainer=document?.getElementById(this.containerId)),this.needCache&&t(this.config.facetingType==="tabs"),this.initializeSubscriptions()}get needCache(){return this.config.facetingType==="showUnavailable"||this.config.facetingType==="or"||this.config.facetingType==="tabs"}get needDisabling(){return this.config.facetingType==="showUnavailable"}initializeSubscriptions(){this.needCache&&(this.dataLayer.$searchFacetsCached.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$searchFacetsCachedTabs.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())})),this.dataLayer.$searchResults.subscribe(e=>{e&&(this.needCache&&!this.isCached&&(this.dataLayer.searchFacets&&!this.dataLayer.searchFacetsCached&&this.dataLayer.setSearchFacetsCached(this.dataLayer.searchFacets),this.cacheFacets(this.config.facetingType==="tabs")),this.renderMainTemplate(this.generateTemplateData()))}),this.dataLayer.$searchObject.subscribe(e=>{this.cachedPhrase!==e.query||this.cachedANDFacets!==this.dataLayer.parsedData.cachedANDFacets?(this.cachedANDFacets=this.dataLayer.parsedData.cachedANDFacets,this.cachedPhrase=e.query,this.isCached=!1):this.isCached=!0})}extractFacetValue(e){return{type:this.config.facetingType,name:e.parentName,value:e.value}}applyFacetLimits(e,t){const s=t?this.facetPaginationStepMobile:this.facetPaginationStep,a=t?this.facetLimits:this.facetLimitsMobile;return e.forEach(i=>{a[i.name]||(a[i.name]=s)}),e.map(i=>({...i,values:i.values.slice(0,a[i.name]),showingAllFacets:i.values.length<=a[i.name],hasMoreFacets:i.values.length>s}))}generateTemplateData(e){if(this.generateSelectedFacetsData(),this.dataLayer.searchFacets){let t=this.dataLayer.searchFacets;this.config.hooks?.beforeFacetsRender&&(t=this.config.hooks.beforeFacetsRender(t)),this.needCache&&this.dataLayer.searchFacetsCached&&(t=this.dataLayer.searchFacetsCached,this.config.facetingType==="tabs"&&this.dataLayer.searchFacetsCachedTabs&&(t=this.dataLayer.searchFacetsCachedTabs),this.needDisabling&&(t=t.map(a=>{const i=this.dataLayer.searchFacets?.find(r=>r.name===a.name);return i?{...a,values:a.values.map(o=>{const c=i.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 i=this.config?.templates?.facetItemContainerTemplate?.template||m.facets.facetItemContainerTemplate?.template;a.innerHTML=S.render(i,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=>ae.deepEqual(t,this.extractFacetValue(e)))}createFacetListItem(e,t,s){if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-facet-value-container"),e.disabled&&a.classList.add("searchstax-facet-value-disabled");const i=this.isChecked(e),r=this.config?.templates?.facetItemTemplate?.template||m.facets.facetItemTemplate?.template;a.innerHTML=S.render(r,{...e,isChecked:i});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,i)=>{if(e.stopPropagation(),!t.disabled){const r=s.querySelector("input");let o=a?r.checked:!r.checked;i!==void 0&&(o=!i),r.checked=o;const c=this.dataLayer.searchObject;let h=[...c.facets];const d=this.extractFacetValue(t);o?h.find(L=>ae.deepEqual(L,d)?L:!1)||(this.config.facetingType==="tabs"&&(h=h.filter(L=>L.name!==d.name)),h.push(d)):h=h.filter(y=>!ae.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 i=this.config?.templates?.showMoreButtonContainerTemplate?.template||m.facets.showMoreButtonContainerTemplate?.template;a.innerHTML=S.render(i,{...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,i=s?this.facetLimits:this.facetLimitsMobile;i[t.name]===void 0?i[t.name]=a*2:i[t.name]<=t.values.length?(F.setAccessibilityText(`More Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),i[t.name]=i[t.name]+a):(F.setAccessibilityText(`Less Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),i[t.name]=a),this.generateTemplateData(s),this.renderMainTemplate(this.generateTemplateData())}renderMainTemplate(e,t){if(e&&(!ae.deepEqual(this.cachedData??{},e)||t)){this.cachedData=e;const s=this.config?.templates?.mainTemplateDesktop?.template||m.facets.mainTemplateDesktop?.template;if(this.dataLayer.renderingEngine===j.mustache&&this.searchFacetsMainContainer){const a=document.activeElement;a instanceof HTMLInputElement&&a.type==="checkbox"||a?.classList.contains("searchstax-facet-show-more-button")||a?.classList.contains("searchstax-facet-show-less-button")?this.focusedElement=a:this.focusedElement=null,this.searchFacetsMainContainer.innerHTML=S.render(s,{...e});const i=this.searchFacetsMainContainer?.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.facetsContainerClass||m.facets.mainTemplateDesktop.facetsContainerClass));if(i){i.innerHTML="";for(const r of e.facets)this.createFacetItem(r,i);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(i=>{i.setAttribute("aria-expanded",String(!0)),i.setAttribute("tabindex","0"),i.setAttribute("role","button")})},100),this.renderMobileTemplate(this.generateTemplateData(!0))}else this.generateSelectedFacetsData()}generateSelectedFacetsData(){const e=[],t=this.dataLayer.searchObject.facets;for(const s of t){const a=decodeURIComponent(s.name),i=decodeURIComponent(s.value);if(this.dataLayer.searchFacets){const o=(this.needCache?this.dataLayer.searchFacetsCached:this.dataLayer.searchFacets)?.find(c=>c.name===a);if(o){const c=o.values.find(h=>h.type==="range"?!1:h.type==="checkbox"?`"${h.value}"`==`"${i}"`:!1);c&&e.push(c)}}}this.dataLayer.setSelectedFacetsTemplateData(e)}createSelectedFacetsComponents(e){this.generateSelectedFacetsData(),this.dataLayer.selectedFacetsTemplateData?.forEach(t=>{this.createSelectedFacetsComponent(e,t)})}createClearFacetsComponents(e){if(typeof document<"u"){const t=this.dataLayer.searchObject,s=this.config?.templates?.clearFacetsTemplate?.template||m.facets.clearFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=S.render(s,{shouldShow:t.facets.length>0});const i=a.querySelector("."+(this.config?.templates?.clearFacetsTemplate?.containerClass||m.facets.clearFacetsTemplate?.containerClass));i&&(i.addEventListener("click",()=>{this.removeSelectedFacets()}),i.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.removeSelectedFacets()}),e.appendChild(i))}}createSelectedFacetsComponent(e,t){if(typeof document<"u"){const s=this.config?.templates?.selectedFacetsTemplate?.template||m.facets.selectedFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=S.render(s,t);const i=a.querySelector("."+(this.config?.templates?.selectedFacetsTemplate?.containerClass||m.facets.selectedFacetsTemplate?.containerClass));i&&(i.addEventListener("click",()=>{this.unselectFacet(t)}),i.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.unselectFacet(t)}),e.appendChild(i))}}unselectFacet(e){const t=this.dataLayer.searchObject;let s=[...t.facets];e.type==="checkbox"&&(s=s.filter(a=>JSON.stringify(a)!==JSON.stringify(this.extractFacetValue(e)))),setTimeout(()=>{this.dataLayer.setSearchObject({...t,facets:s}),this.generateSelectedFacetsData()},0)}removeSelectedFacets(){const e=this.dataLayer.searchObject;this.dataLayer.setSearchObject({...e,facets:[]})}createFilterByComponent(e){if(typeof document<"u"){const t=this.config?.templates?.filterByTemplate?.template||m.facets.filterByTemplate?.template,s=document?.createElement("div");s.innerHTML=S.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",i=>{(i.code==="Space"||i.code==="Enter")&&this.openOverlay()}))}}openOverlay(){F.setAccessibilityText("Facet overlay opened. Tab to select facets."),this.overlayOpened=!0,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.add("searchstax-show"))}closeOverlay(){F.setAccessibilityText("Facet overlay closed"),this.overlayOpened=!1,this.searchFacetsMainContainer&&(typeof document<"u"&&document.body.classList.toggle("searchstax-no-scroll"),this.searchFacetsMainContainer.querySelector(".searchstax-facets-mobile-overlay")?.classList.remove("searchstax-show"))}renderMobileTemplate(e){if(e&&typeof document<"u"){const t=document?.createElement("div");t.classList.add("searchstax-facets-container-mobile");const s=this.config?.templates?.mainTemplateMobile?.template||m.facets.mainTemplateMobile?.template;if(this.dataLayer.renderingEngine===j.mustache){if(t.innerHTML=S.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 i=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.selectedFacetsContainerClass||m.facets.mainTemplateMobile.selectedFacetsContainerClass));i&&(this.createSelectedFacetsComponents(i),this.createClearFacetsComponents(i));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 An{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 i=a.querySelector('[tabindex="0"]');i instanceof HTMLElement&&i.focus()}else document.body.tabIndex=-1,document.body.focus();t||(a instanceof HTMLElement?a.scrollIntoView({block:"start",behavior:"auto"}):window?.scrollTo(0,0))}nextPage(e){e?.preventDefault(),e?.stopPropagation(),this.isLastPage||this.goToPage(this.dataLayer.searchObject?.page+1,this.dataLayer.isInfiniteScroll)}previousPage(e){e?.preventDefault(),e?.stopPropagation(),this.isFirstPage||this.goToPage(this.dataLayer.searchObject?.page-1)}overridePaginationEvents(){if(this.searchPaginationMainContainer){const e=this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass),t=this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass),s=this.searchPaginationMainContainer.querySelector("."+this.loadMoreButtonClass);e&&(e.addEventListener("click",this.previousPage.bind(this)),e.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.previousPage(a)})),t&&(t.addEventListener("click",this.nextPage.bind(this)),t.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.nextPage(a)})),s&&(s.addEventListener("click",this.nextPage.bind(this)),s.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.nextPage(a)}))}}renderMainTemplate(e){this.searchPaginationMainContainer&&(this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass)?.removeEventListener("click",this.previousPage),this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass)?.removeEventListener("click",this.nextPage));let t=this.config?.templates?.mainTemplate?.template||m.pagination.mainTemplate?.template;this.dataLayer.isInfiniteScroll&&(t=this.config?.templates?.infiniteScrollTemplate?.template||m.pagination.infiniteScrollTemplate?.template),this.dataLayer.renderingEngine===j.mustache&&(this.searchPaginationMainContainer.innerHTML=S.render(t,e),setTimeout(()=>{this.overridePaginationEvents()},0))}}class vn{dataLayer;config;containerId;relatedSearchesContainerClass;searchRelatedSearchesMainContainer=null;track;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.relatedSearchesContainerClass=this.config.templates?.main?.relatedSearchesContainerClass||m.relatedSearches.main.relatedSearchesContainerClass,typeof document<"u"&&(this.searchRelatedSearchesMainContainer=document?.getElementById(this.containerId)),this.track=e.trackRelatedSearchClick,this.initializeSubscriptions()}initializeSubscriptions(){this.dataLayer.$searchRelatedSearches.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setRelatedSearchesData(e),e}addRelatedSearchComponent(e,t){if(typeof document<"u"){const s=document?.createElement("div"),a=this.config?.templates?.relatedSearch?.template||m.relatedSearches.relatedSearch.template;if(this.dataLayer.renderingEngine===j.mustache){s.innerHTML=S.render(a,e);const i=s.querySelector("."+(this.config.templates?.relatedSearch?.relatedSearchContainerClass||m.relatedSearches.relatedSearch.relatedSearchContainerClass));i&&(t.appendChild(i),i.addEventListener("click",()=>{this.executeSearch(e)}),i.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===j.mustache&&this.searchRelatedSearchesMainContainer){this.searchRelatedSearchesMainContainer.innerHTML="",this.searchRelatedSearchesMainContainer.innerHTML=S.render(t,e);const s=this.searchRelatedSearchesMainContainer?.querySelector(`.${this.relatedSearchesContainerClass}`);if(s)for(const a of e.relatedSearches)this.addRelatedSearchComponent(a,s)}}}class Dn{dataLayer;config;containerId;searchFeedbackMainContainer=null;searchTrigger;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.searchTrigger=e.searchTrigger,typeof document<"u"&&(this.searchFeedbackMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions()}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setSearchFeedbackData(e),e}onOriginalQueryClick(e){e.stopPropagation(),e.preventDefault();const t=e.target?.innerHTML;this.searchTrigger(t,!0)}attachClick(){const e=this.searchFeedbackMainContainer?.querySelector("."+(this.config?.templates?.main?.originalQueryClass||m.searchFeedback.main?.originalQueryClass));e&&e.addEventListener("click",this.onOriginalQueryClick.bind(this))}renderMainTemplate(e){const t=this.config?.templates?.main?.template||m.searchFeedback.main.template;this.dataLayer.renderingEngine===j.mustache&&(this.searchFeedbackMainContainer.innerHTML=S.render(t,e),setTimeout(()=>{this.attachClick()},0))}}class In{searchHelper;dataLayer;config;suggestAfterMinChars;containerId;currentInputValue="";autosuggestResults;searchInput;actionButton;autosuggestContainer;buttonState="search";selectedAutosuggestItem=-1;suggestTrigger;searchTrigger;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.searchTrigger=e.searchTrigger,this.suggestTrigger=e.suggestTrigger,this.containerId=e.containerId,this.suggestAfterMinChars=e.config.suggestAfterMinChars,this.suggestAfterMinChars===void 0&&this.getSuggestAfterValue(),this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())},200)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||m.searchInput.mainTemplate.template,s={...this.dataLayer.parsedData.data,locationEnabled:!!this.dataLayer.locationEnabled};if(this.dataLayer.setInputWidgetTemplateData(s),this.dataLayer.renderingEngine===j.mustache){const r=S.render(t,s);e.innerHTML=r,this.dataLayer.setInputTemplateRendered(!0)}const a=this.config.templates?.mainTemplate?.searchInputId||m.searchInput.mainTemplate.searchInputId,i=document?.querySelector(`#${a}`);if(i)this.searchInput=i,i.addEventListener("keyup",this.inputKeyupEvent.bind(this)),i.addEventListener("blur",this.hideAutosuggest.bind(this)),i.addEventListener("paste",this.inputPasteEvent.bind(this));else throw new Error("Input not found")}}createAutosuggestContainer(){this.dataLayer.renderingEngine===j.mustache&&typeof document<"u"&&(this.autosuggestContainer=document?.createElement("div"),this.autosuggestContainer.classList.add("searchstax-autosuggest-container"),this.autosuggestContainer.addEventListener("mouseleave",()=>{this.resetAutosuggestSelection(),this.markActiveAutosuggestItem()}),this.searchInput?.after(this.autosuggestContainer))}getSuggestAfterValue(){this.dataLayer.searchHelper&&this.dataLayer.searchHelper.suggest("*",e=>{this.suggestAfterMinChars=e.metadata.minPrefixChars},[])}actionButtonInit(){typeof document<"u"&&(this.actionButton=document?.getElementById("searchstax-search-input-action-button"),this.actionButton&&this.actionButton.addEventListener("click",()=>{this.executeSearch(this.searchInput?.value??"")}))}attachSubscriptions(){this.dataLayer.$searchTermChange.subscribe(()=>{this.handleSearchTermChange()}),this.dataLayer.$loadingChange.subscribe(()=>{this.handleLoadingChange()}),this.dataLayer.$searchAutosuggest.subscribe(e=>{e&&this.appendSuggestions(e)}),this.dataLayer.$searchObject.subscribe(e=>{e.query!=="undefined"&&e.query!==void 0&&e.query!=="*"&&this.searchInput&&(this.searchInput.value=this.cleanSuggestionTerm(e.query??""))})}handleLoadingChange(){this.dataLayer.loading?this.updateActionButtonState("loading"):this.handleSearchTermChange()}handleSearchTermChange(){this.updateActionButtonState("search")}updateActionButtonState(e){if(this.buttonState=e,this.actionButton)switch(this.actionButton.classList.remove("searchstax-spinner-icon"),this.actionButton.classList.remove("searchstax-search-icon"),e){case"loading":this.actionButton.classList.add("searchstax-spinner-icon");break;case"search":this.actionButton.classList.add("searchstax-search-icon"),this.actionButton.setAttribute("aria-label","search");break}}selectPreviousAutosuggestItem(e){this.selectedAutosuggestItem>0?this.selectedAutosuggestItem--:this.selectedAutosuggestItem===0?(this.selectedAutosuggestItem=-1,e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),F.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=this.autosuggestResults.suggestions.length-1,this.markActiveAutosuggestItem()}selectNextAutosuggestItem(){this.selectedAutosuggestItem<this.autosuggestResults.suggestions.length-1?this.selectedAutosuggestItem++:this.selectedAutosuggestItem===this.autosuggestResults.suggestions.length-1?(this.selectedAutosuggestItem=-1,F.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=0,this.markActiveAutosuggestItem()}resetAutosuggestSelection(){this.selectedAutosuggestItem=-1,this.markActiveAutosuggestItem()}markActiveAutosuggestItem(){if(typeof document<"u"){const e=document?.getElementsByClassName("searchstax-autosuggest-item");for(let t=0;t<e.length;t++){const s=e[t];t===this.selectedAutosuggestItem?(s.classList.add("active"),F.setAccessibilityText(`Selected suggestion: ${s.innerText}`)):s.classList.remove("active")}}}inputKeyupEvent(e){const t=e.key;this.currentInputValue=e.target.value,t==="Enter"?this.suggestionChosen():t==="Escape"?this.hideAutosuggest(e.target):t==="ArrowUp"?this.selectPreviousAutosuggestItem(e.target):t==="ArrowDown"?this.selectNextAutosuggestItem():this.autosuggestHandling(e),this.handleSearchTermChange()}autosuggestHandling(e){this.suggestAfterMinChars&&e.target&&e.target.value.length>=this.suggestAfterMinChars?this.executeSuggest(e.target.value):this.hideAutosuggest()}inputPasteEvent(e){setTimeout(()=>{this.autosuggestHandling(e),this.handleSearchTermChange()},0)}executeSuggest(e){this.suggestTrigger(e)}executeSearch(e){this.hideAutosuggest(),this.searchTrigger(e===""?"*":e)}suggestionChosen(){this.selectedAutosuggestItem>-1?this.autosuggestItemClicked(this.autosuggestResults.suggestions[this.selectedAutosuggestItem]):this.executeSearch(this.currentInputValue)}hideAutosuggest(e){setTimeout(()=>{this.dataLayer.setAutosuggestResults({numFound:0,suggestions:[]}),this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.add("hidden")),this.resetAutosuggestSelection(),e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),F.setAccessibilityText("No Suggestion selected")},200)}cleanSuggestionTerm(e){return V.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=S.render(s,e),t}onSuggestionEnter(e){this.selectedAutosuggestItem=this.autosuggestResults?.suggestions.indexOf(e)||0,this.markActiveAutosuggestItem()}appendSuggestions(e){this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.remove("hidden"));for(const t in e.suggest)if(Object.prototype.hasOwnProperty.call(e.suggest,t)){const s=e.suggest[t];for(const a in s)if(Object.prototype.hasOwnProperty.call(s,a)){const i=s[a];i.numFound?F.setAccessibilityText("Suggestions are available. Use up and down arrows to navigate while focusing input. Use Escape key to escape out of the suggestions",2e3):F.setAccessibilityText("",0),this.autosuggestResults=i,this.dataLayer.setAutosuggestResults(i),i.numFound>0?i.suggestions.forEach(r=>{this.autosuggestContainer&&typeof document<"u"&&this.autosuggestContainer.appendChild(this.createAutosuggestItem(r))}):this.autosuggestContainer&&this.autosuggestContainer.classList.add("hidden")}}}}class jn{dataLayer;config;linkClickCallback;searchCallback;containerId;searchResultsMainContainer;searchResultsContainer;searchResultLinks=[];constructor(e){this.linkClickCallback=e.linkClickCallback,this.searchCallback=e.searchTrigger,this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId;const t=document?.getElementById(this.containerId);if(t)this.searchResultsMainContainer=t;else throw new Error(`Search Results Main Container with id ${this.containerId} not found`);this.dataLayer.setIsInfiniteScroll(e.config.renderMethod==="infiniteScroll"),this.initializeSubscriptions(),this.renderMainTemplate()}initializeSubscriptions(){this.dataLayer.$searchObject.subscribe(()=>{F.setAccessibilityText("Searching...")}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.searchResultsContainer&&this.renderResults(e)})}changeTemplate(){this.dataLayer.searchResults&&this.renderResults(this.dataLayer.searchResults)}renderNoResultsTemplate(){const e=this.config?.templates?.noSearchResultTemplate?.template||m.searchResults.noSearchResultTemplate?.template,t=this.dataLayer.searchResultsMetadata?.spellingSuggestion??"";if(this.dataLayer.renderingEngine===j.mustache&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=S.render(e,{spellingSuggestion:t,...this.dataLayer.parsedData.data,searchCallback:this.searchCallback.bind(this)})),t&&this.searchResultsContainer){const s=this.searchResultsContainer.querySelector("a");s&&s.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.searchCallback(t)})}}renderResults(e){if(this.dataLayer.renderingEngine===j.mustache&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)F.setAccessibilityText("Search has no results"),this.renderNoResultsTemplate();else{F.setAccessibilityText(`Showing ${this.dataLayer.parsedData.startResultIndex} through ${this.dataLayer.parsedData.endResultIndex} results from ${this.dataLayer.parsedData.totalResults}. Press tab to navigate through results`);const t=this.config?.templates?.searchResultTemplate?.template||m.searchResults.searchResultTemplate?.template,s=e.map(a=>S.render(t,a));this.config?.renderMethod==="infiniteScroll"&&this.dataLayer.searchObject.page>1?this.searchResultsContainer.innerHTML+=s.join(""):this.searchResultsContainer.innerHTML=s.join(""),this.searchResultLinks=Array.from(this.searchResultsContainer.querySelectorAll(`[${this.uniqueIdAttribute}]`)),this.attachLinkClickEvents()}}removeLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.removeEventListener("click",()=>{}),e.removeEventListener("keydown",()=>{})})}get uniqueIdAttribute(){return this.config?.templates?.searchResultTemplate?.searchResultUniqueIdAttribute||m.searchResults.searchResultTemplate?.searchResultUniqueIdAttribute}attachLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const s=e.getAttribute(this.uniqueIdAttribute)??"";s&&this.linkClickCallback(s)}),e.addEventListener("keydown",t=>{if(t.code==="Space"||t.code==="Enter"){const s=e.getAttribute(this.uniqueIdAttribute)??"";s&&this.linkClickCallback(s)}})})}renderMainTemplate(){const e=this.config?.templates?.mainTemplate?.template||m.searchResults.mainTemplate?.template;this.dataLayer.renderingEngine===j.mustache&&(this.searchResultsMainContainer.innerHTML=S.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 Rn{dataLayer;config;containerId;selectId;searchSortingMainContainer=null;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.selectId=this.config.templates?.main?.selectId||m.sorting.main.selectId,this.searchSortingMainContainer=document?.getElementById(this.containerId),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data};return this.dataLayer.setSearchSortingData(e),e}setOrderQuery(e){const t=this.dataLayer.searchObject;t&&(t.order=e,this.dataLayer.setSearchObject(t))}markOptionSelected(){const e=document?.getElementById(this.selectId);if(e){const t=e.querySelector(`option[value="${decodeURIComponent(this.dataLayer.searchObject.order)}"]`);t&&(t.selected=!0)}}renderMainTemplate(e){const t=this.config?.templates?.main?.template||m.sorting.main.template;if(this.dataLayer.renderingEngine===j.mustache){this.searchSortingMainContainer.innerHTML=S.render(t,e),this.markOptionSelected();const s=document?.getElementById(this.selectId);s&&s.addEventListener("change",a=>{this.setOrderQuery(a.target.value)})}}}class Nn{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(){me.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=$?.mainTemplate?.template;if(this.mainTemplateOverride&&(s=this.mainTemplateOverride),this.isLightweight&&(s=$.lightweightTemplate?.template,this.lightweightTemplateOverride&&(s=this.lightweightTemplateOverride)),this.mainContainer.innerHTML=S.render(s,e),this.focusedElement&&this.mainContainer){const a=this.focusedElement.type==="radio"?this.focusedElement.getAttribute("id"):this.focusedElement.getAttribute("class"),i=this.focusedElement.type==="radio"?"id":"class",r=this.mainContainer.querySelector(`[${i}="${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],i=s[s.length-1];e.key==="Tab"&&(e.shiftKey?(document.activeElement===a||!t.contains(document.activeElement))&&(e.preventDefault(),i?.focus()):(document.activeElement===i||!t.contains(document.activeElement))&&(e.preventDefault(),a?.focus())),e.key==="Escape"&&(e.preventDefault(),this.closeFeedbackModal())},document.addEventListener("keydown",this.focusTrapListener)}getFocusableElements(e){const t=["button:not([disabled])","input:not([disabled])","textarea:not([disabled])","select:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(e.querySelectorAll(t))}getModalElement(){const e=$.mainTemplate?.modalContainerClass;return this.mainContainer?.querySelector(`.${e}`)||null}attachLightweightEvents(){const e=$.lightweightTemplate?.thumbsUpButtonClass,t=$.lightweightTemplate?.thumbsDownButtonClass,s=this.mainContainer?.querySelector("."+e),a=this.mainContainer?.querySelector("."+t);s&&s.addEventListener("click",()=>{const i=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[this.templateData.ratings.length-1].isSelected&&this.ratedQuestion===i||(this.templateData.thumbsUpActive=!0,this.templateData.thumbsDownActive=!1,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsUpValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=i,this.submit())}),a&&a.addEventListener("click",()=>{const i=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[0].isSelected&&this.ratedQuestion===i||(this.templateData.thumbsUpActive=!1,this.templateData.thumbsDownActive=!0,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsDownValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=i,this.submit())})}attachSubmitButtonEvents(){const e=$.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.checkIfValid()})}checkIfValid(){const e=this.mainContainer?.querySelector("#"+$.mainTemplate?.emailInputId);this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,F.setAccessibilityText("Please enter a valid email address.")),this.templateData.ratings.some(a=>a.isSelected)?this.templateData.errors.rating=!1:(this.templateData.errors.rating=!0,F.setAccessibilityText("Please Rate your experience.")),this.templateData.errors.rating||this.templateData.errors.email?this.renderMainTemplate(this.generateTemplateData()):this.submit()}submit(){this.templateData.submitted=!0;const e=this.templateData.ratings.find(t=>t.isSelected)?.index;e!==void 0&&(me.trackFeedback({trackApiKey:this.analyticsKey,email:this.emailOverride&&this.isLightweight?this.emailOverride():this.templateData.emailInput,rating:e,feedback:this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea,model:this.model?this.model:void 0,language:this.language?this.language:void 0}),this.showCheckmarkAnimation(),F.setAccessibilityText("Feedback has been sent.",1e3),this.mainContainer?.querySelector("."+$.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("#"+$.mainTemplate?.emailInputId);e&&(e.addEventListener("input",()=>{this.templateData.emailInput=e.value}),e.addEventListener("blur",()=>{setTimeout(()=>{this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,F.setAccessibilityText("Please enter a valid email address.")),this.renderMainTemplate(this.generateTemplateData())},300)}))}attachTextAreaEvents(){const e=this.mainContainer?.querySelector("#"+$.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("."+$.mainTemplate?.charactersRemainingContainerclass);t&&(t.innerText=this.templateData.charactersLeft+"")})}attachRatingEvents(){const e=$.mainTemplate?.ratingInputclass,t=this.mainContainer?.querySelectorAll("."+e);t&&t.forEach(s=>{s.addEventListener("click",a=>{const i=a.target.value;this.templateData.ratings.forEach(r=>{r.isSelected=r.index+""===i}),this.templateData.errors.rating=!1,this.renderMainTemplate(this.generateTemplateData())})})}attachOpenModalEvent(){const e=$.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=$.mainTemplate?.closeModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.closeFeedbackModal()})}openFeedbackModal(){this.lastFocusedElementBeforeModal=document.activeElement,this.templateData.feedbackOpen=!0,this.renderMainTemplate(this.generateTemplateData()),setTimeout(()=>{const e=this.getModalElement();if(e){const t=this.getFocusableElements(e);t.length>0&&t[0].focus()}this.attachFocusTrap()},0),F.setAccessibilityText("Feedback form opened",1e3)}closeFeedbackModal(){this.templateData.feedbackOpen=!1,this.focusTrapListener&&(document.removeEventListener("keydown",this.focusTrapListener),this.focusTrapListener=null),this.renderMainTemplate(this.generateTemplateData()),this.lastFocusedElementBeforeModal&&(this.lastFocusedElementBeforeModal.focus(),this.lastFocusedElementBeforeModal=null),F.setAccessibilityText("Feedback form closed",1e3)}showCheckmarkAnimation(){const e=$.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&(t.disabled=!0);const s=$.mainTemplate?.checkmarkClass,a=this.mainContainer?.querySelector("."+s);a&&a.classList.remove("hidden");const i=$.mainTemplate?.submitButtonTextClass,r=this.mainContainer?.querySelector("."+i);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 Pn{dataLayer;config;containerId;answerContainer=null;showMoreVisible=!1;renderFeedbackWidget=!1;clicked=!1;renderedWithShowMore=!1;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.renderFeedbackWidget=this.config.feedbackwidget?.renderFeedbackWidget||!1,this.config.showMoreAfterWordCount&&(this.dataLayer.answerWidgetShowMoreLimit=this.config.showMoreAfterWordCount),typeof document<"u"&&(this.answerContainer=document?.getElementById(this.containerId)),this.config.testString?(this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())):this.initializeSubscriptions(),this.dataLayer.setIsAnswerWidgetCreated(!0)}initializeSubscriptions(){this.dataLayer.$answer.subscribe(()=>{this.clicked?this.showMoreVisible=!1:this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerLoading.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerError.subscribe(e=>{e&&setTimeout(()=>{this.renderMainTemplate(this.generateTemplateData())},100)}),this.dataLayer.$searchObject.subscribe(()=>{this.clicked=!1,this.renderedWithShowMore=!1,this.showMoreVisible=!1}),this.dataLayer.$paginationData.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answer.subscribe(e=>{e&&setTimeout(()=>{this.initializeWidget()},600)}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.$answer.getValue()&&setTimeout(()=>{this.initializeWidget()},600)})}searchstaxFeedbackTextAreaOverride(){return"Question: "+(this.dataLayer.searchObject.query==="undefined"?"":this.dataLayer.searchObject.query)+" Answer: "+this.dataLayer.parsedData.getAnswerData}initializeWidget(){this.renderFeedbackWidget&&document.getElementById("feedbackWidgetContainer")&&!this.dataLayer.answerLoading&&new Nn({analyticsKey:this.dataLayer.parsedData.trackingData.trackApiKey,containerId:"feedbackWidgetContainer",lightweight:!0,model:this.dataLayer.parsedData.trackingData.model,language:this.dataLayer.parsedData.trackingData.language,emailOverride:this.config.feedbackwidget?.emailOverride,feedbackTextAreaOverride:this.config.feedbackwidget?.searchstaxFeedbackTextAreaOverride??this.searchstaxFeedbackTextAreaOverride.bind(this),thumbsUpValue:this.config.feedbackwidget?.thumbsUpValue??10,thumbsDownValue:this.config.feedbackwidget?.thumbsDownValue??0,lightweightTemplateOverride:this.config.feedbackwidget?.lightweightTemplateOverride})}showMore(e){e.preventDefault(),this.clicked=!0,this.showMoreVisible=!1,this.renderMainTemplate(this.generateTemplateData()),this.config.testString||setTimeout(()=>{this.initializeWidget()},600)}attachClickEventToShowMore(){const e=document.querySelector(".searchstax-answer-load-more-button");e&&e.addEventListener("click",this.showMore.bind(this))}trackLinkClick(e){e.preventDefault(),e.stopPropagation();const s=e.target.getAttribute("href");me.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===j.mustache?(!this.renderedWithShowMore||!e.answerLoading||this.clicked)&&(e.showMoreButtonVisible&&(this.renderedWithShowMore=!0),this.answerContainer.innerHTML=S.render(t,e),setTimeout(()=>{this.attachClickEventToShowMore(),this.attachLinkTracking()},100)):setTimeout(()=>{this.attachLinkTracking()},500)}generateTemplateData(){this.config.testString&&this.dataLayer.setAnswerData(this.config.testString??"");const e={...this.dataLayer.parsedData.data,showMoreButtonVisible:this.showMoreVisible};return this.config.testString&&(e.searchExecuted=!0),this.dataLayer.setAnswerFullData(e),e}}class ds{dataLayer;config;containerId;currentSelectValue="";locationInput;radiusInput;locationDecode;locationDecodeCoordinatesToAddress;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.locationDecode=e.config.hooks?.locationDecode,this.locationDecodeCoordinatesToAddress=e.config.hooks?.locationDecodeCoordinatesToAddress,this.dataLayer.locationEnabled&&this.dataLayer.$inputTemplateRendered.subscribeUntil(()=>{this.renderMainTemplate(),this.attachSubscriptions()},!0,500)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||m.location.mainTemplate.template,s={...this.dataLayer.parsedData.data};if(this.dataLayer.setLocationWidgetTemplateData(s),this.dataLayer.renderingEngine===j.mustache){const a=S.render(t,s);e.innerHTML=a;const i=this.config.templates?.mainTemplate?.locationInputId||m.location.mainTemplate.locationInputId,r=document?.querySelector(`#${i}`);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===j.mustache&&this.locationInput&&(this.locationInput.value=this.dataLayer.searchLocationCoordinatesDecoded)}getCurrentLocation(){navigator.geolocation?navigator.geolocation.getCurrentPosition(e=>{const t=e.coords.latitude.toString(),s=e.coords.longitude.toString(),a=Math.floor(parseFloat(t)*100)/100,i=Math.floor(parseFloat(s)*100)/100;this.dataLayer.setSearchLat(a+""),this.dataLayer.setSearchLong(i+"");const r=this.locationDecodeCoordinatesToAddress;r?r(a+"",i+"").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 V.removeXSSRiskyTags(e.replace(/(<([^>]+)>)/gi,"")).trim()}triggerGeocoder(e){const t=this.locationDecode;this.dataLayer.setLocationDecodingLoading(!0),e&&this.dataLayer.searchLocation!==e&&e!==this.dataLayer.searchLocationCoordinatesDecoded?t(e).then(s=>{this.dataLayer.setSearchLocation(s.address||""),this.dataLayer.setSearchLat(s.lat||""),this.dataLayer.setSearchLong(s.lon||""),this.locationInput&&(this.locationInput.value=this.cleanSuggestionTerm(s.address||"")),this.dataLayer.renderingEngine===j.mustache&&s.error&&this.locationInput&&this.locationInput.classList.add("searchstax-input-location-error"),s.error?this.dataLayer.setLocationError(!0):this.dataLayer.setLocationError(!1),this.dataLayer.setLocationDecodingLoading(!1)}).catch(()=>{this.dataLayer.setLocationDecodingLoading(!1)}):e===""&&(this.dataLayer.setSearchLocation(void 0),this.dataLayer.setSearchLat(void 0),this.dataLayer.setSearchLong(void 0),this.dataLayer.setLocationDecodingLoading(!1))}focusEvent(e){e.target.classList.remove("searchstax-input-location-error"),this.dataLayer.setLocationError(!1)}blurEvent(e){const s=e.target.value;this.triggerGeocoder(s)}}class On{routerEnabled=!1;cachedQuery="";routerHelper;searchHelper;searchResultsConfig;searchPaginationConfig;searchFeedbackConfig;searchSortingConfig;searchFacetsConfig;relatedSearchesConfig;externalPromotionsConfig;searchInputWidget;searchLocationWidget;searchResultsWidget;searchFacetsWidget;searchPaginationWidget;searchFeedbackWidget;searchSortingWidget;relatedSearchesWidget;externalPromotionsWidget;answerWidget;locationObserver=null;dataLayer;firstRequest=!0;previousQuery="";eventSource=null;renderEngine=j.mustache;constructor(e=j.mustache){e&&(this.renderEngine=e)}setRenderingEngine(e=j.mustache){this.dataLayer.setRenderingEngine(e)}handleHooks(){this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&this.dataLayer.$searchResults.subscribe(e=>{this.dataLayer.searchstaxConfig.hooks.afterSearch(e,this.dataLayer.searchResultUnparsedData)}),setTimeout(()=>{this.dataLayer.$searchObject.subscribe(e=>{e.query!==this.previousQuery&&this.dataLayer.setAnswerData(""),e.query!==""&&e.query!==void 0&&e.query!=="undefined"?(this.search(e),e.query!==this.previousQuery&&this.startSSE(e.query)):this.dataLayer.searchLocationConfig?.locationSearchEnabled&&!this.dataLayer.searchLocationConfig?.locationValuesOverride?this.getMetadata(e):this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue),this.previousQuery=e.query})},10),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&me.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){me.attachAnalyticsScript(e)}initialize(e){if(this.dataLayer=new qi("searchstax_session_id",e.sessionId),this.renderEngine&&this.dataLayer.setRenderingEngine(this.renderEngine),this.handleHooks(),e.questionURL&&(this.dataLayer.questionURL=e.questionURL),e.analyticsBaseUrl&&typeof window<"u"&&(window.analyticsBaseUrl=e.analyticsBaseUrl,window._msq=e._msq||[],this.attachAnalyticsScript(e.analyticsSrc)),e.autoCorrect===!1&&(this.dataLayer.autoCorrect=!1),e.language&&this.dataLayer.setLanguage(e.language),e.model&&this.dataLayer.setModel(e.model),this.dataLayer.searchstaxConfig||(this.dataLayer.setSearchstaxConfig(e),this.searchHelper=new Ki({...e,sessionId:this.dataLayer.sessionId},this.dataLayer),this.dataLayer.searchHelper=this.searchHelper),e.router?.enabled===void 0||e.router?.enabled===!0){this.routerEnabled=!0,this.routerHelper=new ns(e.router?e.router:{enabled:!0});const t=this.routerHelper.urlToSearchObject(window?.location.href??"");this.dataLayer.searchObject.itemsPerPage?t.itemsPerPage=this.dataLayer.searchObject.itemsPerPage:t.itemsPerPage&&this.dataLayer.setItemsPerPage(t.itemsPerPage),t.model&&this.dataLayer.setModel(t.model),t.location&&(t.location.address&&this.dataLayer.setSearchLocation(t.location.address),t.location.lat&&this.dataLayer.setSearchLat(t.location.lat),t.location.lon&&this.dataLayer.setSearchLong(t.location.lon),t.location.radius&&this.dataLayer.setSearchRadius(t.location.radius)),this.dataLayer.setSearchObject(t),addEventListener("popstate",()=>{this.routerHelper&&this.dataLayer.setSearchObject(this.routerHelper.urlToSearchObject(window?.location.href??"",this.dataLayer.searchObject.itemsPerPage))})}else this.routerHelper=new ns({})}getMetadata(e){this.searchHelper&&(e.query==="undefined"||e.query===void 0)&&this.dataLayer.setSearchObject({...e,query:"*"})}search(e){if(this.searchHelper){const t=this.dataLayer.forceNotCorrect;this.searchHelper.url&&(this.searchHelper.search(e,this.parseSearchResultsResponse.bind(this),this.firstRequest,t),this.firstRequest=!1),this.getRelatedSearches()}}getRelatedSearches(){this.searchHelper&&this.relatedSearchesConfig&&this.relatedSearchesConfig?.relatedSearchesURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&this.searchHelper.getRelatedSearches(this.dataLayer.searchObject,this.relatedSearchesConfig.relatedSearchesURL,this.relatedSearchesConfig.relatedSearchesAPIKey,this.parseRelatedSearchesResponse.bind(this))}parseRelatedSearchesResponse(e){const s=(e.response?.docs??[]).map((i,r)=>({...i,position:r+1})),a=[];for(const i of s)a.push({relatedSearch:i.related_search,position:i.position});this.dataLayer.setSearchRelatedSearches(s),this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&a.length&&me.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=Xe.extractSearchResultsMetadata(e),s=this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue??t.location?.filter?.defaultValue;!this.dataLayer.searchRadius&&s&&this.dataLayer.setSearchRadius(s),this.dataLayer.setSearchResultsMetadata(t)}parseSearchResultsResponse(e){this.handleRouter(),this.dataLayer.setItemsPerPage(parseInt(e.responseHeader.params.rows)),this.dataLayer.setModel(e.responseHeader.params.model);let t=Xe.combineResultsWithMetadata(e),s=Xe.extractFacets(e);this.dataLayer.setSearchFacets(s),this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&(t=this.dataLayer.searchstaxConfig.hooks.afterSearch(t,e)),this.dataLayer.setSearchExternalPromotions(e.externalLinks??[]),this.parseSearchResultsResponseMetadata(e),this.dataLayer.setSearchResultUnparsedData(e),this.dataLayer.setSearchResults(t)}parseAnswerResultsResponse(e){this.handleRouter(),e!==Oe.question&&e!==Oe.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 In({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 ds({containerId:e,config:t,dataLayer:this.dataLayer}),t?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(t?.locationValuesOverride?.locationFilterDefaultValue)):this.dataLayer.$searchResultsMetadata.subscribeUntilHasValue(()=>{this.searchLocationWidget=new ds({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 Pn({containerId:e,config:t,dataLayer:this.dataLayer})}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new jn({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 An({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper})}addSearchFeedbackWidget(e,t){this.searchFeedbackConfig=t,this.searchFeedbackWidget=new Dn({containerId:e,config:t,dataLayer:this.dataLayer,searchTrigger:this.executeSearch.bind(this)})}addSearchSortingWidget(e,t){this.searchSortingConfig=t,this.searchSortingWidget=new Rn({containerId:e,config:t,dataLayer:this.dataLayer})}addRelatedSearchesWidget(e,t){this.relatedSearchesConfig=t,this.relatedSearchesWidget=new vn({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 kn({containerId:e,config:t,dataLayer:this.dataLayer})}addFacetsWidget(e,t){this.searchFacetsConfig=t,this.searchFacetsWidget=new En({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper},this.cacheFacets.bind(this))}executeSearch(e,t){const s={...this.dataLayer.searchObject};s.query=V.removeXSSRiskyTags(e),s.page=1,s.facets=[],s.location={...s.location},this.locationObserver&&this.dataLayer.$locationDecodingLoading.unsubscribe(this.locationObserver),this.locationObserver=this.dataLayer.$locationDecodingLoading.subscribeUntil(()=>{s.location.address=this.dataLayer.searchLocation,s.location.radius=this.dataLayer.searchRadius,s.location.lat=this.dataLayer.searchLat,s.location.lon=this.dataLayer.searchLong,this.dataLayer.forceNotCorrect=!!t;let a=this.routerHelper?.searchObjectToParams(s);a&&(a=this.routerHelper?.extractParamsThatDoNotStartWithRouteName(a)),a&&(s.additionalProps=Object.keys(a).map(i=>a?{key:i,value:a[i]}:{key:"",value:""})),this.dataLayer.setSearchObject(s),this.dataLayer.lastSearchValue=s.query},!1)}executeSuggest(e){let t={term:e,queryParams:[]};this.dataLayer.searchInputConfig?.hooks?.beforeAutosuggest&&(t=this.dataLayer.searchInputConfig.hooks.beforeAutosuggest(t)),t&&t.term!==void 0&&t.queryParams!==void 0&&this.suggest(t.term,t.queryParams)}trackRelatedSearchClick(e){this.dataLayer.searchResultsMetadata&&this.dataLayer.searchRelatedSearches&&!this.dataLayer.cookiesDisabled&&me.trackRelatedSearchClick({...this.dataLayer.parsedData.trackingData,relatedSearch:e,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}executeLinkClick(e){let t=Xe.findResultByUniqueId(e,this.dataLayer.searchResults??[]);t&&(this.searchResultsConfig?.hooks?.afterLinkClick&&(t=this.searchResultsConfig.hooks.afterLinkClick(t)),t&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&me.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())}}exports.Searchstax=On;
437
+ `,thumbsUpButtonClass:"searchstax-lightweight-widget-thumbs-up",thumbsDownButtonClass:"searchstax-lightweight-widget-thumbs-down"}};class L{static answer=vn;static externalPromotions=Dn;static facets=In;static pagination=Rn;static relatedSearches=jn;static searchFeedback=Nn;static searchInput=Pn;static location=On;static searchResults=_n;static sorting=Fn;static feedback=W}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||L.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||L.externalPromotions.externalPromotion?.template;if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-external-promotion"),a.addEventListener("click",i=>{this.trackClick(e,i)}),a.innerHTML=A.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||L.externalPromotions.mainTemplate?.template;if(this.dataLayer.renderingEngine===P.mustache){this.searchExternalPromotionsMainContainer.innerHTML=A.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 B{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",i=document.getElementById(a);i&&i.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 $n{dataLayer;config;containerId;routerHelper;cachedPhrase="";cachedANDFacets="";isCached=!1;overlayOpened=!1;facetPaginationStep;facetPaginationStepMobile;searchFacetsMainContainer=null;searchFacetsMobileContainer=null;searchFacetsDesktopContainer=null;facetLimits={};facetLimitsMobile={};deactivatedFacets={};focusedElement=null;cachedData=null;cacheFacets;constructor(e,t){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.routerHelper=e.routerHelper,this.cacheFacets=t,this.facetPaginationStep=this.config.itemsPerPageDesktop,this.facetPaginationStepMobile=this.config.itemsPerPageMobile,typeof document<"u"&&(this.searchFacetsMainContainer=document?.getElementById(this.containerId)),this.needCache&&t(this.config.facetingType==="tabs"),this.initializeSubscriptions()}get needCache(){return this.config.facetingType==="showUnavailable"||this.config.facetingType==="or"||this.config.facetingType==="tabs"}get needDisabling(){return this.config.facetingType==="showUnavailable"}initializeSubscriptions(){this.needCache&&(this.dataLayer.$searchFacetsCached.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$searchFacetsCachedTabs.subscribe(e=>{e&&this.dataLayer.searchFacets&&this.renderMainTemplate(this.generateTemplateData())})),this.dataLayer.$searchResults.subscribe(e=>{e&&(this.needCache&&!this.isCached&&(this.dataLayer.searchFacets&&!this.dataLayer.searchFacetsCached&&this.dataLayer.setSearchFacetsCached(this.dataLayer.searchFacets),this.cacheFacets(this.config.facetingType==="tabs")),this.renderMainTemplate(this.generateTemplateData()))}),this.dataLayer.$searchObject.subscribe(e=>{this.cachedPhrase!==e.query||this.cachedANDFacets!==this.dataLayer.parsedData.cachedANDFacets?(this.cachedANDFacets=this.dataLayer.parsedData.cachedANDFacets,this.cachedPhrase=e.query,this.isCached=!1):this.isCached=!0})}extractFacetValue(e){return{type:this.config.facetingType,name:e.parentName,value:e.value}}applyFacetLimits(e,t){const s=t?this.facetPaginationStepMobile:this.facetPaginationStep,a=t?this.facetLimits:this.facetLimitsMobile;return e.forEach(i=>{a[i.name]||(a[i.name]=s)}),e.map(i=>({...i,values:i.values.slice(0,a[i.name]),showingAllFacets:i.values.length<=a[i.name],hasMoreFacets:i.values.length>s}))}generateTemplateData(e){if(this.generateSelectedFacetsData(),this.dataLayer.searchFacets){let t=this.dataLayer.searchFacets;this.config.hooks?.beforeFacetsRender&&(t=this.config.hooks.beforeFacetsRender(t)),this.needCache&&this.dataLayer.searchFacetsCached&&(t=this.dataLayer.searchFacetsCached,this.config.facetingType==="tabs"&&this.dataLayer.searchFacetsCachedTabs&&(t=this.dataLayer.searchFacetsCachedTabs),this.needDisabling&&(t=t.map(a=>{const i=this.dataLayer.searchFacets?.find(r=>r.name===a.name);return i?{...a,values:a.values.map(o=>{const c=i.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 i=this.config?.templates?.facetItemContainerTemplate?.template||L.facets.facetItemContainerTemplate?.template;a.innerHTML=A.render(i,e),t.appendChild(a);const r=a.querySelector("."+(this.config?.templates?.facetItemContainerTemplate?.facetListTitleContainerClass||L.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||L.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=>oe.deepEqual(t,this.extractFacetValue(e)))}createFacetListItem(e,t,s){if(typeof document<"u"){const a=document?.createElement("div");a.classList.add("searchstax-facet-value-container"),e.disabled&&a.classList.add("searchstax-facet-value-disabled");const i=this.isChecked(e),r=this.config?.templates?.facetItemTemplate?.template||L.facets.facetItemTemplate?.template;a.innerHTML=A.render(r,{...e,isChecked:i});let o=L.facets.facetItemTemplate?.checkTriggerClasses;o=this.config?.templates?.facetItemTemplate?.checkTriggerClasses||o,o.forEach(h=>{a.querySelector("."+h)?.addEventListener("click",C=>{this.onFacetSelect(C,e,a)})});const c=a.querySelector("."+(this.config?.templates?.facetItemTemplate?.inputCheckboxClass||L.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,i)=>{if(e.stopPropagation(),!t.disabled){const r=s.querySelector("input");let o=a?r.checked:!r.checked;i!==void 0&&(o=!i),r.checked=o;const c=this.dataLayer.searchObject;let h=[...c.facets];const d=this.extractFacetValue(t);o?h.find(y=>oe.deepEqual(y,d)?y:!1)||(this.config.facetingType==="tabs"&&(h=h.filter(y=>y.name!==d.name)),h.push(d)):h=h.filter(C=>!oe.deepEqual(C,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 i=this.config?.templates?.showMoreButtonContainerTemplate?.template||L.facets.showMoreButtonContainerTemplate?.template;a.innerHTML=A.render(i,{...e,focusId:`moreLess${e?.values?.[0]?.value}`});const r=a.querySelector("."+(this.config?.templates?.showMoreButtonContainerTemplate?.showMoreButtonClass||L.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,i=s?this.facetLimits:this.facetLimitsMobile;i[t.name]===void 0?i[t.name]=a*2:i[t.name]<=t.values.length?(B.setAccessibilityText(`More Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),i[t.name]=i[t.name]+a):(B.setAccessibilityText(`Less Facets shown for ${t.label}`,0,`moreLess${new Date().getTime()}`),i[t.name]=a),this.generateTemplateData(s),this.renderMainTemplate(this.generateTemplateData())}renderMainTemplate(e,t){if(e&&(!oe.deepEqual(this.cachedData??{},e)||t)){this.cachedData=e;const s=this.config?.templates?.mainTemplateDesktop?.template||L.facets.mainTemplateDesktop?.template;if(this.dataLayer.renderingEngine===P.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=A.render(s,{...e});const i=this.searchFacetsMainContainer?.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.facetsContainerClass||L.facets.mainTemplateDesktop.facetsContainerClass));if(i){i.innerHTML="";for(const r of e.facets)this.createFacetItem(r,i);if(this.searchFacetsMainContainer){const r=this.searchFacetsMainContainer.querySelector("."+(this.config?.templates?.mainTemplateDesktop?.selectedFacetsContainerClass||L.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(i=>{i.setAttribute("aria-expanded",String(!0)),i.setAttribute("tabindex","0"),i.setAttribute("role","button")})},100),this.renderMobileTemplate(this.generateTemplateData(!0))}else this.generateSelectedFacetsData()}generateSelectedFacetsData(){const e=[],t=this.dataLayer.searchObject.facets;for(const s of t){const a=decodeURIComponent(s.name),i=decodeURIComponent(s.value);if(this.dataLayer.searchFacets){const o=(this.needCache?this.dataLayer.searchFacetsCached:this.dataLayer.searchFacets)?.find(c=>c.name===a);if(o){const c=o.values.find(h=>h.type==="range"?!1:h.type==="checkbox"?`"${h.value}"`==`"${i}"`:!1);c&&e.push(c)}}}this.dataLayer.setSelectedFacetsTemplateData(e)}createSelectedFacetsComponents(e){this.generateSelectedFacetsData(),this.dataLayer.selectedFacetsTemplateData?.forEach(t=>{this.createSelectedFacetsComponent(e,t)})}createClearFacetsComponents(e){if(typeof document<"u"){const t=this.dataLayer.searchObject,s=this.config?.templates?.clearFacetsTemplate?.template||L.facets.clearFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=A.render(s,{shouldShow:t.facets.length>0});const i=a.querySelector("."+(this.config?.templates?.clearFacetsTemplate?.containerClass||L.facets.clearFacetsTemplate?.containerClass));i&&(i.addEventListener("click",()=>{this.removeSelectedFacets()}),i.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.removeSelectedFacets()}),e.appendChild(i))}}createSelectedFacetsComponent(e,t){if(typeof document<"u"){const s=this.config?.templates?.selectedFacetsTemplate?.template||L.facets.selectedFacetsTemplate?.template,a=document?.createElement("div");a.innerHTML=A.render(s,t);const i=a.querySelector("."+(this.config?.templates?.selectedFacetsTemplate?.containerClass||L.facets.selectedFacetsTemplate?.containerClass));i&&(i.addEventListener("click",()=>{this.unselectFacet(t)}),i.addEventListener("keyup",r=>{(r.code==="Space"||r.code==="Enter")&&this.unselectFacet(t)}),e.appendChild(i))}}unselectFacet(e){const t=this.dataLayer.searchObject;let s=[...t.facets];e.type==="checkbox"&&(s=s.filter(a=>JSON.stringify(a)!==JSON.stringify(this.extractFacetValue(e)))),setTimeout(()=>{this.dataLayer.setSearchObject({...t,facets:s}),this.generateSelectedFacetsData()},0)}removeSelectedFacets(){const e=this.dataLayer.searchObject;this.dataLayer.setSearchObject({...e,facets:[]})}createFilterByComponent(e){if(typeof document<"u"){const t=this.config?.templates?.filterByTemplate?.template||L.facets.filterByTemplate?.template,s=document?.createElement("div");s.innerHTML=A.render(t,{});const a=s.querySelector("."+(this.config?.templates?.filterByTemplate?.containerClass||L.facets.filterByTemplate?.containerClass));a&&(e.prepend(a),a.addEventListener("click",this.openOverlay.bind(this)),a.addEventListener("keyup",i=>{(i.code==="Space"||i.code==="Enter")&&this.openOverlay()}))}}openOverlay(){B.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(){B.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||L.facets.mainTemplateMobile?.template;if(this.dataLayer.renderingEngine===P.mustache){if(t.innerHTML=A.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 L.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||L.facets.mainTemplateMobile.filterByContainerClass));a&&this.createFilterByComponent(a);const i=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.selectedFacetsContainerClass||L.facets.mainTemplateMobile.selectedFacetsContainerClass));i&&(this.createSelectedFacetsComponents(i),this.createClearFacetsComponents(i));const r=t.querySelector("."+(this.config?.templates?.mainTemplateMobile?.facetsContainerClass||L.facets.mainTemplateMobile.facetsContainerClass));if(r){r.innerHTML="";for(const o of e.facets)this.createFacetItem(o,r,!0)}}}}}class Vn{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??L.pagination.mainTemplate.previousButtonClass,this.nextButtonClass=this.config?.templates?.mainTemplate?.nextButtonClass??L.pagination.mainTemplate.nextButtonClass,this.loadMoreButtonClass=this.config?.templates?.infiniteScrollTemplate?.loadMoreButtonClass??L.pagination.infiniteScrollTemplate.loadMoreButtonClass,typeof document<"u"&&(this.searchPaginationMainContainer=document?.getElementById(this.containerId)),this.initializeSubscriptions(),this.renderMainTemplate(this.generateTemplateData())}get isFirstPage(){return this.dataLayer.searchObject?.page===1}get isLastPage(){return this.dataLayer.parsedData.data.isLastPage}initializeSubscriptions(){this.dataLayer.$searchResults.subscribe(e=>{e&&this.renderMainTemplate(this.generateTemplateData())})}generateTemplateData(){const e={...this.dataLayer.parsedData.data,previousPageLink:this.routerHelper?.searchObjectToUrl({...this.dataLayer.searchObject,page:this.dataLayer.searchObject?.page-1}),nextPageLink:this.routerHelper?.searchObjectToUrl({...this.dataLayer.searchObject,page:this.dataLayer.searchObject?.page+1})};return this.dataLayer.setPaginationData(e),e}goToPage(e,t){const s=this.dataLayer.searchObject;s&&(s.page=e,this.dataLayer.setSearchObject(s));const a=document.querySelector(".searchstax-page-layout-result-container");if(a instanceof HTMLElement){const i=a.querySelector('[tabindex="0"]');i instanceof HTMLElement&&i.focus()}else document.body.tabIndex=-1,document.body.focus();t||(a instanceof HTMLElement?a.scrollIntoView({block:"start",behavior:"auto"}):window?.scrollTo(0,0))}nextPage(e){e?.preventDefault(),e?.stopPropagation(),this.isLastPage||this.goToPage(this.dataLayer.searchObject?.page+1,this.dataLayer.isInfiniteScroll)}previousPage(e){e?.preventDefault(),e?.stopPropagation(),this.isFirstPage||this.goToPage(this.dataLayer.searchObject?.page-1)}overridePaginationEvents(){if(this.searchPaginationMainContainer){const e=this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass),t=this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass),s=this.searchPaginationMainContainer.querySelector("."+this.loadMoreButtonClass);e&&(e.addEventListener("click",this.previousPage.bind(this)),e.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.previousPage(a)})),t&&(t.addEventListener("click",this.nextPage.bind(this)),t.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.nextPage(a)})),s&&(s.addEventListener("click",this.nextPage.bind(this)),s.addEventListener("keydown",a=>{(a.code==="Space"||a.code==="Enter")&&this.nextPage(a)}))}}renderMainTemplate(e){this.searchPaginationMainContainer&&(this.searchPaginationMainContainer.querySelector("."+this.previousButtonClass)?.removeEventListener("click",this.previousPage),this.searchPaginationMainContainer.querySelector("."+this.nextButtonClass)?.removeEventListener("click",this.nextPage));let t=this.config?.templates?.mainTemplate?.template||L.pagination.mainTemplate?.template;this.dataLayer.isInfiniteScroll&&(t=this.config?.templates?.infiniteScrollTemplate?.template||L.pagination.infiniteScrollTemplate?.template),this.dataLayer.renderingEngine===P.mustache&&(this.searchPaginationMainContainer.innerHTML=A.render(t,e),setTimeout(()=>{this.overridePaginationEvents()},0))}}class Bn{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||L.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||L.relatedSearches.relatedSearch.template;if(this.dataLayer.renderingEngine===P.mustache){s.innerHTML=A.render(a,e);const i=s.querySelector("."+(this.config.templates?.relatedSearch?.relatedSearchContainerClass||L.relatedSearches.relatedSearch.relatedSearchContainerClass));i&&(t.appendChild(i),i.addEventListener("click",()=>{this.executeSearch(e)}),i.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||L.relatedSearches.main.template;if(this.dataLayer.renderingEngine===P.mustache&&this.searchRelatedSearchesMainContainer){this.searchRelatedSearchesMainContainer.innerHTML="",this.searchRelatedSearchesMainContainer.innerHTML=A.render(t,e);const s=this.searchRelatedSearchesMainContainer?.querySelector(`.${this.relatedSearchesContainerClass}`);if(s)for(const a of e.relatedSearches)this.addRelatedSearchComponent(a,s)}}}class Hn{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||L.searchFeedback.main?.originalQueryClass));e&&e.addEventListener("click",this.onOriginalQueryClick.bind(this))}renderMainTemplate(e){const t=this.config?.templates?.main?.template||L.searchFeedback.main.template;this.dataLayer.renderingEngine===P.mustache&&(this.searchFeedbackMainContainer.innerHTML=A.render(t,e),setTimeout(()=>{this.attachClick()},0))}}class Un{searchHelper;dataLayer;config;suggestAfterMinChars;containerId;currentInputValue="";autosuggestResults;searchInput;actionButton;autosuggestContainer;buttonState="search";selectedAutosuggestItem=-1;suggestTrigger;searchTrigger;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.searchTrigger=e.searchTrigger,this.suggestTrigger=e.suggestTrigger,this.containerId=e.containerId,this.suggestAfterMinChars=e.config.suggestAfterMinChars,this.suggestAfterMinChars===void 0&&this.getSuggestAfterValue(),this.dataLayer.$locationEnabled.subscribeUntilHasValue(()=>{this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())},200)}renderMainTemplate(){if(typeof document<"u"){const e=document?.getElementById(this.containerId);if(!e)throw new Error("Search input container not found");const t=this.config.templates?.mainTemplate?.template||L.searchInput.mainTemplate.template,s={...this.dataLayer.parsedData.data,locationEnabled:!!this.dataLayer.locationEnabled};if(this.dataLayer.setInputWidgetTemplateData(s),this.dataLayer.renderingEngine===P.mustache){const r=A.render(t,s);e.innerHTML=r,this.dataLayer.setInputTemplateRendered(!0)}const a=this.config.templates?.mainTemplate?.searchInputId||L.searchInput.mainTemplate.searchInputId,i=document?.querySelector(`#${a}`);if(i)this.searchInput=i,i.addEventListener("keyup",this.inputKeyupEvent.bind(this)),i.addEventListener("blur",this.hideAutosuggest.bind(this)),i.addEventListener("paste",this.inputPasteEvent.bind(this));else throw new Error("Input not found")}}createAutosuggestContainer(){this.dataLayer.renderingEngine===P.mustache&&typeof document<"u"&&(this.autosuggestContainer=document?.createElement("div"),this.autosuggestContainer.classList.add("searchstax-autosuggest-container"),this.autosuggestContainer.addEventListener("mouseleave",()=>{this.resetAutosuggestSelection(),this.markActiveAutosuggestItem()}),this.searchInput?.after(this.autosuggestContainer))}getSuggestAfterValue(){this.dataLayer.searchHelper&&this.dataLayer.searchHelper.suggest("*",e=>{this.suggestAfterMinChars=e.metadata.minPrefixChars},[])}actionButtonInit(){typeof document<"u"&&(this.actionButton=document?.getElementById("searchstax-search-input-action-button"),this.actionButton&&this.actionButton.addEventListener("click",()=>{this.executeSearch(this.searchInput?.value??"")}))}attachSubscriptions(){this.dataLayer.$searchTermChange.subscribe(()=>{this.handleSearchTermChange()}),this.dataLayer.$loadingChange.subscribe(()=>{this.handleLoadingChange()}),this.dataLayer.$searchAutosuggest.subscribe(e=>{e&&this.appendSuggestions(e)}),this.dataLayer.$searchObject.subscribe(e=>{e.query!=="undefined"&&e.query!==void 0&&e.query!=="*"&&this.searchInput&&(this.searchInput.value=this.cleanSuggestionTerm(e.query??""))})}handleLoadingChange(){this.dataLayer.loading?this.updateActionButtonState("loading"):this.handleSearchTermChange()}handleSearchTermChange(){this.updateActionButtonState("search")}updateActionButtonState(e){if(this.buttonState=e,this.actionButton)switch(this.actionButton.classList.remove("searchstax-spinner-icon"),this.actionButton.classList.remove("searchstax-search-icon"),e){case"loading":this.actionButton.classList.add("searchstax-spinner-icon");break;case"search":this.actionButton.classList.add("searchstax-search-icon"),this.actionButton.setAttribute("aria-label","search");break}}selectPreviousAutosuggestItem(e){this.selectedAutosuggestItem>0?this.selectedAutosuggestItem--:this.selectedAutosuggestItem===0?(this.selectedAutosuggestItem=-1,e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),B.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,B.setAccessibilityText("No Suggestion selected")):this.selectedAutosuggestItem=0,this.markActiveAutosuggestItem()}resetAutosuggestSelection(){this.selectedAutosuggestItem=-1,this.markActiveAutosuggestItem()}markActiveAutosuggestItem(){if(typeof document<"u"){const e=document?.getElementsByClassName("searchstax-autosuggest-item");for(let t=0;t<e.length;t++){const s=e[t];t===this.selectedAutosuggestItem?(s.classList.add("active"),B.setAccessibilityText(`Selected suggestion: ${s.innerText}`)):s.classList.remove("active")}}}inputKeyupEvent(e){const t=e.key;this.currentInputValue=e.target.value,t==="Enter"?this.suggestionChosen():t==="Escape"?this.hideAutosuggest(e.target):t==="ArrowUp"?this.selectPreviousAutosuggestItem(e.target):t==="ArrowDown"?this.selectNextAutosuggestItem():this.autosuggestHandling(e),this.handleSearchTermChange()}autosuggestHandling(e){this.suggestAfterMinChars&&e.target&&e.target.value.length>=this.suggestAfterMinChars?this.executeSuggest(e.target.value):this.hideAutosuggest()}inputPasteEvent(e){setTimeout(()=>{this.autosuggestHandling(e),this.handleSearchTermChange()},0)}executeSuggest(e){this.suggestTrigger(e)}executeSearch(e){this.hideAutosuggest(),this.searchTrigger(e===""?"*":e)}suggestionChosen(){this.selectedAutosuggestItem>-1?this.autosuggestItemClicked(this.autosuggestResults.suggestions[this.selectedAutosuggestItem]):this.executeSearch(this.currentInputValue)}hideAutosuggest(e){setTimeout(()=>{this.dataLayer.setAutosuggestResults({numFound:0,suggestions:[]}),this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.add("hidden")),this.resetAutosuggestSelection(),e&&e?.focus&&(e?.focus?.(),e.setSelectionRange(e.value.length,e.value.length)),B.setAccessibilityText("No Suggestion selected")},200)}cleanSuggestionTerm(e){return Y.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||L.searchInput.autosuggestItemTemplate?.template;return t.innerHTML=A.render(s,e),t}onSuggestionEnter(e){this.selectedAutosuggestItem=this.autosuggestResults?.suggestions.indexOf(e)||0,this.markActiveAutosuggestItem()}appendSuggestions(e){this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.remove("hidden"));for(const t in e.suggest)if(Object.prototype.hasOwnProperty.call(e.suggest,t)){const s=e.suggest[t];for(const a in s)if(Object.prototype.hasOwnProperty.call(s,a)){const i=s[a];i.numFound?B.setAccessibilityText("Suggestions are available. Use up and down arrows to navigate while focusing input. Use Escape key to escape out of the suggestions",2e3):B.setAccessibilityText("",0),this.autosuggestResults=i,this.dataLayer.setAutosuggestResults(i),i.numFound>0?i.suggestions.forEach(r=>{this.autosuggestContainer&&typeof document<"u"&&this.autosuggestContainer.appendChild(this.createAutosuggestItem(r))}):this.autosuggestContainer&&this.autosuggestContainer.classList.add("hidden")}}}}class Qn{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(()=>{B.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||L.searchResults.noSearchResultTemplate?.template,t=this.dataLayer.searchResultsMetadata?.spellingSuggestion??"";if(this.dataLayer.renderingEngine===P.mustache&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=A.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===P.mustache&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)B.setAccessibilityText("Search has no results"),this.renderNoResultsTemplate();else{B.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||L.searchResults.searchResultTemplate?.template,s=e.map(a=>A.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||L.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||L.searchResults.mainTemplate?.template;this.dataLayer.renderingEngine===P.mustache&&(this.searchResultsMainContainer.innerHTML=A.render(e,{}),setTimeout(()=>{const t=this.config?.templates?.mainTemplate?.searchResultsContainerId?this.config?.templates?.mainTemplate?.searchResultsContainerId:L.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 qn{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||L.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||L.sorting.main.template;if(this.dataLayer.renderingEngine===P.mustache){this.searchSortingMainContainer.innerHTML=A.render(t,e),this.markOptionSelected();const s=document?.getElementById(this.selectId);s&&s.addEventListener("change",a=>{this.setOrderQuery(a.target.value)})}}}class Wn{analyticsKey;containerId;mainContainer;isLightweight;emailOverride;feedbackTextAreaOverride;mainTemplateOverride;lightweightTemplateOverride;focusedElement=null;focusTrapListener=null;lastFocusedElementBeforeModal=null;templateData={feedbackOpen:!1,ratings:[{index:1,isSelected:!1},{index:2,isSelected:!1},{index:3,isSelected:!1},{index:4,isSelected:!1},{index:5,isSelected:!1},{index:6,isSelected:!1},{index:7,isSelected:!1},{index:8,isSelected:!1},{index:9,isSelected:!1},{index:10,isSelected:!1}],emailInput:"",feedbackTextArea:"",charactersLeft:2e3,maxLength:2e3,errors:{rating:!1,email:!1},submitted:!1,thumbsUpActive:!1,thumbsDownActive:!1};thumbsUpValue=10;thumbsDownValue=1;ratedQuestion="";language="";model="";analyticsSrc="";constructor(e){this.analyticsKey=e.analyticsKey,this.containerId=e.containerId??"sf-feedback",this.isLightweight=e.lightweight??!1,this.isLightweight&&this.templateData.ratings.unshift({index:0,isSelected:!1}),this.thumbsUpValue=e.thumbsUpValue??10,this.thumbsDownValue=e.thumbsDownValue??1,this.emailOverride=e.emailOverride,this.feedbackTextAreaOverride=e.feedbackTextAreaOverride,this.mainTemplateOverride=e.mainTemplateOverride,this.lightweightTemplateOverride=e.lightweightTemplateOverride,this.mainContainer=document.getElementById(this.containerId),this.language=e.language??"",this.model=e.model??"",this.analyticsSrc=e.analyticsSrc??"",this.init()}init(){ye.attachAnalyticsScript(this.analyticsSrc),this.renderMainTemplate(this.generateTemplateData())}generateTemplateData(){return this.templateData}renderMainTemplate(e){const t=document.activeElement;(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLAnchorElement)&&(t.type==="radio"||t.type==="button"||t.type==="textarea"||t instanceof HTMLAnchorElement)?this.focusedElement=t:this.focusedElement=null,this.mainContainer;let s=W?.mainTemplate?.template;if(this.mainTemplateOverride&&(s=this.mainTemplateOverride),this.isLightweight&&(s=W.lightweightTemplate?.template,this.lightweightTemplateOverride&&(s=this.lightweightTemplateOverride)),this.mainContainer.innerHTML=A.render(s,e),this.focusedElement&&this.mainContainer){const a=this.focusedElement.type==="radio"?this.focusedElement.getAttribute("id"):this.focusedElement.getAttribute("class"),i=this.focusedElement.type==="radio"?"id":"class",r=this.mainContainer.querySelector(`[${i}="${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],i=s[s.length-1];e.key==="Tab"&&(e.shiftKey?(document.activeElement===a||!t.contains(document.activeElement))&&(e.preventDefault(),i?.focus()):(document.activeElement===i||!t.contains(document.activeElement))&&(e.preventDefault(),a?.focus())),e.key==="Escape"&&(e.preventDefault(),this.closeFeedbackModal())},document.addEventListener("keydown",this.focusTrapListener)}getFocusableElements(e){const t=["button:not([disabled])","input:not([disabled])","textarea:not([disabled])","select:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(e.querySelectorAll(t))}getModalElement(){const e=W.mainTemplate?.modalContainerClass;return this.mainContainer?.querySelector(`.${e}`)||null}attachLightweightEvents(){const e=W.lightweightTemplate?.thumbsUpButtonClass,t=W.lightweightTemplate?.thumbsDownButtonClass,s=this.mainContainer?.querySelector("."+e),a=this.mainContainer?.querySelector("."+t);s&&s.addEventListener("click",()=>{const i=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[this.templateData.ratings.length-1].isSelected&&this.ratedQuestion===i||(this.templateData.thumbsUpActive=!0,this.templateData.thumbsDownActive=!1,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsUpValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=i,this.submit())}),a&&a.addEventListener("click",()=>{const i=this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea;this.templateData.ratings[0].isSelected&&this.ratedQuestion===i||(this.templateData.thumbsUpActive=!1,this.templateData.thumbsDownActive=!0,this.templateData.ratings.forEach(r=>{r.isSelected=r.index===this.thumbsDownValue}),this.renderMainTemplate(this.generateTemplateData()),this.ratedQuestion=i,this.submit())})}attachSubmitButtonEvents(){const e=W.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.checkIfValid()})}checkIfValid(){const e=this.mainContainer?.querySelector("#"+W.mainTemplate?.emailInputId);this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,B.setAccessibilityText("Please enter a valid email address.")),this.templateData.ratings.some(a=>a.isSelected)?this.templateData.errors.rating=!1:(this.templateData.errors.rating=!0,B.setAccessibilityText("Please Rate your experience.")),this.templateData.errors.rating||this.templateData.errors.email?this.renderMainTemplate(this.generateTemplateData()):this.submit()}submit(){this.templateData.submitted=!0;const e=this.templateData.ratings.find(t=>t.isSelected)?.index;e!==void 0&&(ye.trackFeedback({trackApiKey:this.analyticsKey,email:this.emailOverride&&this.isLightweight?this.emailOverride():this.templateData.emailInput,rating:e,feedback:this.feedbackTextAreaOverride&&this.isLightweight?this.feedbackTextAreaOverride():this.templateData.feedbackTextArea,model:this.model?this.model:void 0,language:this.language?this.language:void 0}),this.showCheckmarkAnimation(),B.setAccessibilityText("Feedback has been sent.",1e3),this.mainContainer?.querySelector("."+W.mainTemplate?.checkmarkClass)?setTimeout(()=>{this.closeFeedbackModal(),this.renderMainTemplate(this.generateTemplateData())},2e3):(setTimeout(()=>{this.closeFeedbackModal()},500),this.renderMainTemplate(this.generateTemplateData())))}validateEmail(e){return e===""?!0:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}attachEmailInputEvents(){const e=this.mainContainer?.querySelector("#"+W.mainTemplate?.emailInputId);e&&(e.addEventListener("input",()=>{this.templateData.emailInput=e.value}),e.addEventListener("blur",()=>{setTimeout(()=>{this.validateEmail(e.value)?this.templateData.errors.email=!1:(this.templateData.errors.email=!0,B.setAccessibilityText("Please enter a valid email address.")),this.renderMainTemplate(this.generateTemplateData())},300)}))}attachTextAreaEvents(){const e=this.mainContainer?.querySelector("#"+W.mainTemplate?.feedbackTextAreaId);e&&e.addEventListener("input",()=>{this.templateData.feedbackTextArea=e.value,this.templateData.charactersLeft=this.templateData.maxLength-e.value.length;const t=this.mainContainer?.querySelector("."+W.mainTemplate?.charactersRemainingContainerclass);t&&(t.innerText=this.templateData.charactersLeft+"")})}attachRatingEvents(){const e=W.mainTemplate?.ratingInputclass,t=this.mainContainer?.querySelectorAll("."+e);t&&t.forEach(s=>{s.addEventListener("click",a=>{const i=a.target.value;this.templateData.ratings.forEach(r=>{r.isSelected=r.index+""===i}),this.templateData.errors.rating=!1,this.renderMainTemplate(this.generateTemplateData())})})}attachOpenModalEvent(){const e=W.mainTemplate?.openModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",s=>{s.preventDefault(),this.toggleModal()})}toggleModal(){this.templateData.feedbackOpen?this.closeFeedbackModal():this.openFeedbackModal()}closeModalEvent(){const e=W.mainTemplate?.closeModalButtonClass,t=this.mainContainer?.querySelector("."+e);t&&t.addEventListener("click",()=>{this.closeFeedbackModal()})}openFeedbackModal(){this.lastFocusedElementBeforeModal=document.activeElement,this.templateData.feedbackOpen=!0,this.renderMainTemplate(this.generateTemplateData()),setTimeout(()=>{const e=this.getModalElement();if(e){const t=this.getFocusableElements(e);t.length>0&&t[0].focus()}this.attachFocusTrap()},0),B.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),B.setAccessibilityText("Feedback form closed",1e3)}showCheckmarkAnimation(){const e=W.mainTemplate?.submitButtonClass,t=this.mainContainer?.querySelector("."+e);t&&(t.disabled=!0);const s=W.mainTemplate?.checkmarkClass,a=this.mainContainer?.querySelector("."+s);a&&a.classList.remove("hidden");const i=W.mainTemplate?.submitButtonTextClass,r=this.mainContainer?.querySelector("."+i);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 Yn{dataLayer;config;containerId;answerContainer=null;showMoreVisible=!1;renderFeedbackWidget=!1;clicked=!1;renderedWithShowMore=!1;constructor(e){this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId,this.renderFeedbackWidget=this.config.feedbackwidget?.renderFeedbackWidget||!1,this.config.showMoreAfterWordCount&&(this.dataLayer.answerWidgetShowMoreLimit=this.config.showMoreAfterWordCount),typeof document<"u"&&(this.answerContainer=document?.getElementById(this.containerId)),this.config.testString?(this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())):this.initializeSubscriptions(),this.dataLayer.setIsAnswerWidgetCreated(!0)}initializeSubscriptions(){this.dataLayer.$answer.subscribe(()=>{this.clicked?this.showMoreVisible=!1:this.showMoreVisible=this.dataLayer.parsedData.shouldShowAnswerLoadMore,this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerLoading.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answerError.subscribe(e=>{e&&setTimeout(()=>{this.renderMainTemplate(this.generateTemplateData())},100)}),this.dataLayer.$searchObject.subscribe(()=>{this.clicked=!1,this.renderedWithShowMore=!1,this.showMoreVisible=!1}),this.dataLayer.$paginationData.subscribe(()=>{this.renderMainTemplate(this.generateTemplateData())}),this.dataLayer.$answer.subscribe(e=>{e&&setTimeout(()=>{this.initializeWidget()},600)}),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.$answer.getValue()&&setTimeout(()=>{this.initializeWidget()},600)})}searchstaxFeedbackTextAreaOverride(){return"Question: "+(this.dataLayer.searchObject.query==="undefined"?"":this.dataLayer.searchObject.query)+" Answer: "+this.dataLayer.parsedData.getAnswerData}initializeWidget(){this.renderFeedbackWidget&&document.getElementById("feedbackWidgetContainer")&&!this.dataLayer.answerLoading&&new Wn({analyticsKey:this.dataLayer.parsedData.trackingData.trackApiKey,containerId:"feedbackWidgetContainer",lightweight:!0,model:this.dataLayer.parsedData.trackingData.model,language:this.dataLayer.parsedData.trackingData.language,emailOverride:this.config.feedbackwidget?.emailOverride,feedbackTextAreaOverride:this.config.feedbackwidget?.searchstaxFeedbackTextAreaOverride??this.searchstaxFeedbackTextAreaOverride.bind(this),thumbsUpValue:this.config.feedbackwidget?.thumbsUpValue??10,thumbsDownValue:this.config.feedbackwidget?.thumbsDownValue??0,lightweightTemplateOverride:this.config.feedbackwidget?.lightweightTemplateOverride})}showMore(e){e.preventDefault(),this.clicked=!0,this.showMoreVisible=!1,this.renderMainTemplate(this.generateTemplateData()),this.config.testString||setTimeout(()=>{this.initializeWidget()},600)}attachClickEventToShowMore(){const e=document.querySelector(".searchstax-answer-load-more-button");e&&e.addEventListener("click",this.showMore.bind(this))}trackLinkClick(e){e.preventDefault(),e.stopPropagation();const s=e.target.getAttribute("href");ye.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||L.answer.main.template;this.dataLayer.renderingEngine===P.mustache?(!this.renderedWithShowMore||!e.answerLoading||this.clicked)&&(e.showMoreButtonVisible&&(this.renderedWithShowMore=!0),this.answerContainer.innerHTML=A.render(t,e),setTimeout(()=>{this.attachClickEventToShowMore(),this.attachLinkTracking()},100)):setTimeout(()=>{this.attachLinkTracking()},500)}generateTemplateData(){this.config.testString&&this.dataLayer.setAnswerData(this.config.testString??"");const e={...this.dataLayer.parsedData.data,showMoreButtonVisible:this.showMoreVisible};return this.config.testString&&(e.searchExecuted=!0),this.dataLayer.setAnswerFullData(e),e}}class Ss{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||L.location.mainTemplate.template,s={...this.dataLayer.parsedData.data};if(this.dataLayer.setLocationWidgetTemplateData(s),this.dataLayer.renderingEngine===P.mustache){const a=A.render(t,s);e.innerHTML=a;const i=this.config.templates?.mainTemplate?.locationInputId||L.location.mainTemplate.locationInputId,r=document?.querySelector(`#${i}`);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||L.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||L.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===P.mustache&&this.locationInput&&(this.locationInput.value=this.dataLayer.searchLocationCoordinatesDecoded)}getCurrentLocation(){navigator.geolocation?navigator.geolocation.getCurrentPosition(e=>{const t=e.coords.latitude.toString(),s=e.coords.longitude.toString(),a=Math.floor(parseFloat(t)*100)/100,i=Math.floor(parseFloat(s)*100)/100;this.dataLayer.setSearchLat(a+""),this.dataLayer.setSearchLong(i+"");const r=this.locationDecodeCoordinatesToAddress;r?r(a+"",i+"").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 Y.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===P.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 Jn{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=P.mustache;constructor(e=P.mustache){e&&(this.renderEngine=e)}setRenderingEngine(e=P.mustache){this.dataLayer.setRenderingEngine(e)}handleHooks(){this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&this.dataLayer.$searchResults.subscribe(e=>{this.dataLayer.searchstaxConfig.hooks.afterSearch(e,this.dataLayer.searchResultUnparsedData)}),setTimeout(()=>{this.dataLayer.$searchObject.subscribe(e=>{e.query!==this.previousQuery&&this.dataLayer.setAnswerData(""),e.query!==""&&e.query!==void 0&&e.query!=="undefined"?(this.search(e),e.query!==this.previousQuery&&this.startSSE(e.query)):this.dataLayer.searchLocationConfig?.locationSearchEnabled&&!this.dataLayer.searchLocationConfig?.locationValuesOverride?this.getMetadata(e):this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue),this.previousQuery=e.query})},10),this.dataLayer.$searchResults.subscribe(e=>{e&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&ye.trackSearch({...this.dataLayer.parsedData.trackingData,impressions:this.dataLayer.searchResultsMetadata.impressions})})}startSSE(e){this.eventSource&&(this.eventSource?.close(),this.dataLayer.setAnswerData("")),this.dataLayer.turnAIAnswerGenerationOn===!0&&this.dataLayer.questionURL&&this.dataLayer.searchObject.query!==void 0&&this.dataLayer.searchObject.query!=="undefined"&&(this.eventSource=this.searchHelper?.startSSE(e,this.parseAnswerResultsResponse.bind(this)))}attachAnalyticsScript(e){ye.attachAnalyticsScript(e)}initialize(e){if(this.dataLayer=new rn("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 dn({...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 s=(e.response?.docs??[]).map((i,r)=>({...i,position:r+1})),a=[];for(const i of s)a.push({relatedSearch:i.related_search,position:i.position});this.dataLayer.setSearchRelatedSearches(s),this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&a.length&&ye.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=st.extractSearchResultsMetadata(e),s=this.dataLayer.searchLocationConfig?.locationValuesOverride?.locationFilterDefaultValue??t.location?.filter?.defaultValue;!this.dataLayer.searchRadius&&s&&this.dataLayer.setSearchRadius(s),this.dataLayer.setSearchResultsMetadata(t)}parseSearchResultsResponse(e){this.handleRouter(),this.dataLayer.setItemsPerPage(parseInt(e.responseHeader.params.rows)),this.dataLayer.setModel(e.responseHeader.params.model);let t=st.combineResultsWithMetadata(e),s=st.extractFacets(e);this.dataLayer.setSearchFacets(s),this.dataLayer.searchstaxConfig?.hooks?.afterSearch&&(t=this.dataLayer.searchstaxConfig.hooks.afterSearch(t,e)),this.dataLayer.setSearchExternalPromotions(e.externalLinks??[]),this.parseSearchResultsResponseMetadata(e),this.dataLayer.setSearchResultUnparsedData(e),this.dataLayer.setSearchResults(t)}parseAnswerResultsResponse(e){this.handleRouter(),e!==Ve.question&&e!==Ve.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 Un({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 Ss({containerId:e,config:t,dataLayer:this.dataLayer}),t?.locationValuesOverride?.locationFilterDefaultValue&&this.dataLayer.setSearchRadius(t?.locationValuesOverride?.locationFilterDefaultValue)):this.dataLayer.$searchResultsMetadata.subscribeUntilHasValue(()=>{this.searchLocationWidget=new Ss({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 Yn({containerId:e,config:t,dataLayer:this.dataLayer})}addSearchResultsWidget(e,t){this.searchResultsConfig||(this.searchResultsConfig=t,this.searchResultsWidget=new Qn({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 Vn({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper})}addSearchFeedbackWidget(e,t){this.searchFeedbackConfig=t,this.searchFeedbackWidget=new Hn({containerId:e,config:t,dataLayer:this.dataLayer,searchTrigger:this.executeSearch.bind(this)})}addSearchSortingWidget(e,t){this.searchSortingConfig=t,this.searchSortingWidget=new qn({containerId:e,config:t,dataLayer:this.dataLayer})}addRelatedSearchesWidget(e,t){this.relatedSearchesConfig=t,this.relatedSearchesWidget=new Bn({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=new $n({containerId:e,config:t,dataLayer:this.dataLayer,routerHelper:this.routerHelper},this.cacheFacets.bind(this))}executeSearch(e,t){const s={...this.dataLayer.searchObject};s.query=Y.removeXSSRiskyTags(e),s.page=1,s.facets=[],s.location={...s.location},this.locationObserver&&this.dataLayer.$locationDecodingLoading.unsubscribe(this.locationObserver),this.locationObserver=this.dataLayer.$locationDecodingLoading.subscribeUntil(()=>{s.location.address=this.dataLayer.searchLocation,s.location.radius=this.dataLayer.searchRadius,s.location.lat=this.dataLayer.searchLat,s.location.lon=this.dataLayer.searchLong,this.dataLayer.forceNotCorrect=!!t;let a=this.routerHelper?.searchObjectToParams(s);a&&(a=this.routerHelper?.extractParamsThatDoNotStartWithRouteName(a)),a&&(s.additionalProps=Object.keys(a).map(i=>a?{key:i,value:a[i]}:{key:"",value:""})),this.dataLayer.setSearchObject(s),this.dataLayer.lastSearchValue=s.query},!1)}executeSuggest(e){let t={term:e,queryParams:[]};this.dataLayer.searchInputConfig?.hooks?.beforeAutosuggest&&(t=this.dataLayer.searchInputConfig.hooks.beforeAutosuggest(t)),t&&t.term!==void 0&&t.queryParams!==void 0&&this.suggest(t.term,t.queryParams)}trackRelatedSearchClick(e){this.dataLayer.searchResultsMetadata&&this.dataLayer.searchRelatedSearches&&!this.dataLayer.cookiesDisabled&&ye.trackRelatedSearchClick({...this.dataLayer.parsedData.trackingData,relatedSearch:e,totalRelatredSearches:this.dataLayer.searchRelatedSearches?.length??0})}executeLinkClick(e){let t=st.findResultByUniqueId(e,this.dataLayer.searchResults??[]);t&&(this.searchResultsConfig?.hooks?.afterLinkClick&&(t=this.searchResultsConfig.hooks.afterLinkClick(t)),t&&this.dataLayer.searchResultsMetadata&&!this.dataLayer.cookiesDisabled&&ye.trackClick({result:t,...this.dataLayer.parsedData.trackingData}).then(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}).catch(()=>{typeof window<"u"&&(window.location.href=t?.url??"")}))}setPage(e){this.searchPaginationWidget?.goToPage(e)}setCookiesDisabled(e){this.dataLayer.setCookiesDisabled(e)}changeResultTemplate(e){this.searchResultsConfig&&(this.searchResultsConfig.templates=this.searchResultsConfig?.templates?{...this.searchResultsConfig?.templates,...e}:e,this.searchResultsWidget?.changeTemplate())}}exports.Searchstax=Jn;