/*! For license information please see app-d6b822bc91031dd513e1.js.LICENSE.txt */
(()=>{var e={552:function(e,t,r){var n;(function(){function a(e){"use strict";var t={omitExtraWLInCodeBlocks:{defaultValue:!1,describe:"Omit the default extra whiteline added to code blocks",type:"boolean"},noHeaderId:{defaultValue:!1,describe:"Turn on/off generated header id",type:"boolean"},prefixHeaderId:{defaultValue:!1,describe:"Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to true will add a generic 'section-' prefix",type:"string"},rawPrefixHeaderId:{defaultValue:!1,describe:'Setting this option to true will prevent showdown from modifying the prefix. This might result in malformed IDs (if, for instance, the " char is used in the prefix)',type:"boolean"},ghCompatibleHeaderId:{defaultValue:!1,describe:"Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)",type:"boolean"},rawHeaderId:{defaultValue:!1,describe:"Remove only spaces, ' and \" from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids",type:"boolean"},headerLevelStart:{defaultValue:!1,describe:"The header blocks level start",type:"integer"},parseImgDimensions:{defaultValue:!1,describe:"Turn on/off image dimension parsing",type:"boolean"},simplifiedAutoLink:{defaultValue:!1,describe:"Turn on/off GFM autolink style",type:"boolean"},excludeTrailingPunctuationFromURLs:{defaultValue:!1,describe:"Excludes trailing punctuation from links generated with autoLinking",type:"boolean"},literalMidWordUnderscores:{defaultValue:!1,describe:"Parse midword underscores as literal underscores",type:"boolean"},literalMidWordAsterisks:{defaultValue:!1,describe:"Parse midword asterisks as literal asterisks",type:"boolean"},strikethrough:{defaultValue:!1,describe:"Turn on/off strikethrough support",type:"boolean"},tables:{defaultValue:!1,describe:"Turn on/off tables support",type:"boolean"},tablesHeaderId:{defaultValue:!1,describe:"Add an id to table headers",type:"boolean"},ghCodeBlocks:{defaultValue:!0,describe:"Turn on/off GFM fenced code blocks support",type:"boolean"},tasklists:{defaultValue:!1,describe:"Turn on/off GFM tasklist support",type:"boolean"},smoothLivePreview:{defaultValue:!1,describe:"Prevents weird effects in live previews due to incomplete input",type:"boolean"},smartIndentationFix:{defaultValue:!1,describe:"Tries to smartly fix indentation in es6 strings",type:"boolean"},disableForced4SpacesIndentedSublists:{defaultValue:!1,describe:"Disables the requirement of indenting nested sublists by 4 spaces",type:"boolean"},simpleLineBreaks:{defaultValue:!1,describe:"Parses simple line breaks as
(GFM Style)",type:"boolean"},requireSpaceBeforeHeadingText:{defaultValue:!1,describe:"Makes adding a space between `#` and the header text mandatory (GFM Style)",type:"boolean"},ghMentions:{defaultValue:!1,describe:"Enables github @mentions",type:"boolean"},ghMentionsLink:{defaultValue:"https://github.com/{u}",describe:"Changes the link generated by @mentions. Only applies if ghMentions option is enabled.",type:"string"},encodeEmails:{defaultValue:!0,describe:"Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities",type:"boolean"},openLinksInNewWindow:{defaultValue:!1,describe:"Open all links in new windows",type:"boolean"},backslashEscapesHTMLTags:{defaultValue:!1,describe:"Support for HTML Tag escaping. ex:
[^\r]+?<\/pre>)/gm,(function(e,t){var r=t;return(r=r.replace(/^ /gm,"¨0")).replace(/¨0/g,"")})),s.subParser("hashBlock")("","gim"),r.converter._dispatch("hashPreCodeTags.after",e,t,r)})),s.subParser("headers",(function(e,t,r){"use strict";e=r.converter._dispatch("headers.before",e,t,r);var n=isNaN(parseInt(t.headerLevelStart))?1:parseInt(t.headerLevelStart),a=t.smoothLivePreview?/^(.+)[ \t]*\n={2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n=+[ \t]*\n+/gm,o=t.smoothLivePreview?/^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n-+[ \t]*\n+/gm;e=(e=e.replace(a,(function(e,a){var o=s.subParser("spanGamut")(a,t,r),i=t.noHeaderId?"":' id="'+c(a)+'"',l="\n"+e+"\n",t,r)})),r.converter._dispatch("blockQuotes.after",e,t,r)})),s.subParser("codeBlocks",(function(e,t,r){"use strict";return e=r.converter._dispatch("codeBlocks.before",e,t,r),e=(e=(e+="¨0").replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g,(function(e,n,a){var o=n,i=a,c="\n";return o=s.subParser("outdent")(o,t,r),o=s.subParser("encodeCode")(o,t,r),o=(o=(o=s.subParser("detab")(o,t,r)).replace(/^\n+/g,"")).replace(/\n+$/g,""),t.omitExtraWLInCodeBlocks&&(c=""),o="",s.subParser("hashBlock")(o,t,r)+i}))).replace(/¨0/,""),r.converter._dispatch("codeBlocks.after",e,t,r)})),s.subParser("codeSpans",(function(e,t,r){"use strict";return void 0===(e=r.converter._dispatch("codeSpans.before",e,t,r))&&(e=""),e=e.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,(function(e,n,a,o){var i=o;return i=(i=i.replace(/^([ \t]*)/g,"")).replace(/[ \t]*$/g,""),i=n+""+o+c+"
"+(i=s.subParser("encodeCode")(i,t,r))+"
",s.subParser("hashHTMLSpans")(i,t,r)})),r.converter._dispatch("codeSpans.after",e,t,r)})),s.subParser("completeHTMLDocument",(function(e,t,r){"use strict";if(!t.completeHTMLDocument)return e;e=r.converter._dispatch("completeHTMLDocument.before",e,t,r);var n="html",a="\n",s="",o='\n',i="",c="";for(var l in void 0!==r.metadata.parsed.doctype&&(a="\n","html"!==(n=r.metadata.parsed.doctype.toString().toLowerCase())&&"html5"!==n||(o='')),r.metadata.parsed)if(r.metadata.parsed.hasOwnProperty(l))switch(l.toLowerCase()){case"doctype":break;case"title":s=""+r.metadata.parsed.title+" \n";break;case"charset":o="html"===n||"html5"===n?'\n':'\n';break;case"language":case"lang":i=' lang="'+r.metadata.parsed[l]+'"',c+='\n';break;default:c+='\n'}return e=a+"\n\n"+s+o+c+"\n\n"+e.trim()+"\n\n",r.converter._dispatch("completeHTMLDocument.after",e,t,r)})),s.subParser("detab",(function(e,t,r){"use strict";return e=(e=(e=(e=(e=(e=r.converter._dispatch("detab.before",e,t,r)).replace(/\t(?=\t)/g," ")).replace(/\t/g,"¨A¨B")).replace(/¨B(.+?)¨A/g,(function(e,t){for(var r=t,n=4-r.length%4,a=0;a/g,">"),r.converter._dispatch("encodeAmpsAndAngles.after",e,t,r)})),s.subParser("encodeBackslashEscapes",(function(e,t,r){"use strict";return e=(e=(e=r.converter._dispatch("encodeBackslashEscapes.before",e,t,r)).replace(/\\(\\)/g,s.helper.escapeCharactersCallback)).replace(/\\([`*_{}\[\]()>#+.!~=|:-])/g,s.helper.escapeCharactersCallback),r.converter._dispatch("encodeBackslashEscapes.after",e,t,r)})),s.subParser("encodeCode",(function(e,t,r){"use strict";return e=(e=r.converter._dispatch("encodeCode.before",e,t,r)).replace(/&/g,"&").replace(//g,">").replace(/([*_{}\[\]\\=~-])/g,s.helper.escapeCharactersCallback),r.converter._dispatch("encodeCode.after",e,t,r)})),s.subParser("escapeSpecialCharsWithinTagAttributes",(function(e,t,r){"use strict";return e=(e=(e=r.converter._dispatch("escapeSpecialCharsWithinTagAttributes.before",e,t,r)).replace(/<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,(function(e){return e.replace(/(.)<\/?code>(?=.)/g,"$1`").replace(/([\\`*_~=|])/g,s.helper.escapeCharactersCallback)}))).replace(/-]|-[^>])(?:[^-]|-[^-])*)--)>/gi,(function(e){return e.replace(/([\\`*_~=|])/g,s.helper.escapeCharactersCallback)})),r.converter._dispatch("escapeSpecialCharsWithinTagAttributes.after",e,t,r)})),s.subParser("githubCodeBlocks",(function(e,t,r){"use strict";return t.ghCodeBlocks?(e=r.converter._dispatch("githubCodeBlocks.before",e,t,r),e=(e=(e+="¨0").replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g,(function(e,n,a,o){var i=t.omitExtraWLInCodeBlocks?"":"\n";return o=s.subParser("encodeCode")(o,t,r),o=" ",o=s.subParser("hashBlock")(o,t,r),"\n\n¨G"+(r.ghCodeBlocks.push({text:e,codeblock:o})-1)+"G\n\n"}))).replace(/¨0/,""),r.converter._dispatch("githubCodeBlocks.after",e,t,r)):e})),s.subParser("hashBlock",(function(e,t,r){"use strict";return e=(e=r.converter._dispatch("hashBlock.before",e,t,r)).replace(/(^\n+|\n+$)/g,""),e="\n\n¨K"+(r.gHtmlBlocks.push(e)-1)+"K\n\n",r.converter._dispatch("hashBlock.after",e,t,r)})),s.subParser("hashCodeTags",(function(e,t,r){"use strict";return e=r.converter._dispatch("hashCodeTags.before",e,t,r),e=s.helper.replaceRecursiveRegExp(e,(function(e,n,a,o){var i=a+s.subParser("encodeCode")(n,t,r)+o;return"¨C"+(r.gHtmlSpans.push(i)-1)+"C"}),""+(o=(o=(o=s.subParser("detab")(o,t,r)).replace(/^\n+/g,"")).replace(/\n+$/g,""))+i+"
]*>","
","gim"),r.converter._dispatch("hashCodeTags.after",e,t,r)})),s.subParser("hashElement",(function(e,t,r){"use strict";return function(e,t){var n=t;return n=(n=(n=n.replace(/\n\n/g,"\n")).replace(/^\n/,"")).replace(/\n+$/g,""),"\n\n¨K"+(r.gHtmlBlocks.push(n)-1)+"K\n\n"}})),s.subParser("hashHTMLBlocks",(function(e,t,r){"use strict";e=r.converter._dispatch("hashHTMLBlocks.before",e,t,r);var n=["pre","div","h1","h2","h3","h4","h5","h6","blockquote","table","dl","ol","ul","script","noscript","form","fieldset","iframe","math","style","section","header","footer","nav","article","aside","address","audio","canvas","figure","hgroup","output","video","p"],a=function(e,t,n,a){var s=e;return-1!==n.search(/\bmarkdown\b/)&&(s=n+r.converter.makeHtml(t)+a),"\n\n¨K"+(r.gHtmlBlocks.push(s)-1)+"K\n\n"};t.backslashEscapesHTMLTags&&(e=e.replace(/\\<(\/?[^>]+?)>/g,(function(e,t){return"<"+t+">"})));for(var o=0;o]*>)","im"),l="<"+n[o]+"\\b[^>]*>",u=""+n[o]+">";-1!==(i=s.helper.regexIndexOf(e,c));){var d=s.helper.splitAtIndex(e,i),h=s.helper.replaceRecursiveRegExp(d[1],a,l,u,"im");if(h===d[1])break;e=d[0].concat(h)}return e=e.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,s.subParser("hashElement")(e,t,r)),e=(e=s.helper.replaceRecursiveRegExp(e,(function(e){return"\n\n¨K"+(r.gHtmlBlocks.push(e)-1)+"K\n\n"}),"^ {0,3}\x3c!--","--\x3e","gm")).replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,s.subParser("hashElement")(e,t,r)),r.converter._dispatch("hashHTMLBlocks.after",e,t,r)})),s.subParser("hashHTMLSpans",(function(e,t,r){"use strict";function n(e){return"¨C"+(r.gHtmlSpans.push(e)-1)+"C"}return e=(e=(e=(e=(e=r.converter._dispatch("hashHTMLSpans.before",e,t,r)).replace(/<[^>]+?\/>/gi,(function(e){return n(e)}))).replace(/<([^>]+?)>[\s\S]*?<\/\1>/g,(function(e){return n(e)}))).replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g,(function(e){return n(e)}))).replace(/<[^>]+?>/gi,(function(e){return n(e)})),r.converter._dispatch("hashHTMLSpans.after",e,t,r)})),s.subParser("unhashHTMLSpans",(function(e,t,r){"use strict";e=r.converter._dispatch("unhashHTMLSpans.before",e,t,r);for(var n=0;n ]*>\\s* ]*>","^ {0,3}
\\s*
"),c+="
",a.push(c))}for(o=a.length,i=0;i]*>/.test(u)&&(d=!0)}a[i]=u}return e=(e=(e=a.join("\n")).replace(/^\n+/g,"")).replace(/\n+$/g,""),r.converter._dispatch("paragraphs.after",e,t,r)})),s.subParser("runExtension",(function(e,t,r,n){"use strict";if(e.filter)t=e.filter(t,n.converter,r);else if(e.regex){var a=e.regex;a instanceof RegExp||(a=new RegExp(a,"g")),t=t.replace(a,e.replace)}return t})),s.subParser("spanGamut",(function(e,t,r){"use strict";return e=r.converter._dispatch("spanGamut.before",e,t,r),e=s.subParser("codeSpans")(e,t,r),e=s.subParser("escapeSpecialCharsWithinTagAttributes")(e,t,r),e=s.subParser("encodeBackslashEscapes")(e,t,r),e=s.subParser("images")(e,t,r),e=s.subParser("anchors")(e,t,r),e=s.subParser("autoLinks")(e,t,r),e=s.subParser("simplifiedAutoLinks")(e,t,r),e=s.subParser("emoji")(e,t,r),e=s.subParser("underline")(e,t,r),e=s.subParser("italicsAndBold")(e,t,r),e=s.subParser("strikethrough")(e,t,r),e=s.subParser("ellipsis")(e,t,r),e=s.subParser("hashHTMLSpans")(e,t,r),e=s.subParser("encodeAmpsAndAngles")(e,t,r),t.simpleLineBreaks?/\n\n¨K/.test(e)||(e=e.replace(/\n+/g,"
\n")):e=e.replace(/ +\n/g,"
\n"),r.converter._dispatch("spanGamut.after",e,t,r)})),s.subParser("strikethrough",(function(e,t,r){"use strict";return t.strikethrough&&(e=(e=r.converter._dispatch("strikethrough.before",e,t,r)).replace(/(?:~){2}([\s\S]+?)(?:~){2}/g,(function(e,n){return function(e){return t.simplifiedAutoLink&&(e=s.subParser("simplifiedAutoLinks")(e,t,r)),""+e+""}(n)})),e=r.converter._dispatch("strikethrough.after",e,t,r)),e})),s.subParser("stripLinkDefinitions",(function(e,t,r){"use strict";var n=function(n,a,o,i,c,l,u){return a=a.toLowerCase(),e.toLowerCase().split(a).length-1<2?n:(o.match(/^data:.+?\/.+?;base64,/)?r.gUrls[a]=o.replace(/\s/g,""):r.gUrls[a]=s.subParser("encodeAmpsAndAngles")(o,t,r),l?l+u:(u&&(r.gTitles[a]=u.replace(/"|'/g,""")),t.parseImgDimensions&&i&&c&&(r.gDimensions[a]={width:i,height:c}),""))};return e=(e=(e=(e+="¨0").replace(/^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm,n)).replace(/^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm,n)).replace(/¨0/,"")})),s.subParser("tables",(function(e,t,r){"use strict";if(!t.tables)return e;function n(e,n){return""+s.subParser("spanGamut")(e,t,r)+" \n"}function a(e){var a,o=e.split("\n");for(a=0;a"+(c=s.subParser("spanGamut")(c,t,r))+"\n"));for(a=0;a\n\n\n",a=0;a\n";for(var s=0;s\n"}return r+" \n\n"}(_,g)}return e=(e=(e=(e=r.converter._dispatch("tables.before",e,t,r)).replace(/\\(\|)/g,s.helper.escapeCharactersCallback)).replace(/^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm,a)).replace(/^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm,a),r.converter._dispatch("tables.after",e,t,r)})),s.subParser("underline",(function(e,t,r){"use strict";return t.underline?(e=r.converter._dispatch("underline.before",e,t,r),e=(e=t.literalMidWordUnderscores?(e=e.replace(/\b___(\S[\s\S]*?)___\b/g,(function(e,t){return""+t+""}))).replace(/\b__(\S[\s\S]*?)__\b/g,(function(e,t){return""+t+""})):(e=e.replace(/___(\S[\s\S]*?)___/g,(function(e,t){return/\S$/.test(t)?""+t+"":e}))).replace(/__(\S[\s\S]*?)__/g,(function(e,t){return/\S$/.test(t)?""+t+"":e}))).replace(/(_)/g,s.helper.escapeCharactersCallback),e=r.converter._dispatch("underline.after",e,t,r)):e})),s.subParser("unescapeSpecialChars",(function(e,t,r){"use strict";return e=(e=r.converter._dispatch("unescapeSpecialChars.before",e,t,r)).replace(/¨E(\d+)E/g,(function(e,t){var r=parseInt(t);return String.fromCharCode(r)})),r.converter._dispatch("unescapeSpecialChars.after",e,t,r)})),s.subParser("makeMarkdown.blockquote",(function(e,t){"use strict";var r="";if(e.hasChildNodes())for(var n=e.childNodes,a=n.length,o=0;o "+(r=r.trim()).split("\n").join("\n> ")})),s.subParser("makeMarkdown.codeBlock",(function(e,t){"use strict";var r=e.getAttribute("language"),n=e.getAttribute("precodenum");return"```"+r+"\n"+t.preList[n]+"\n```"})),s.subParser("makeMarkdown.codeSpan",(function(e){"use strict";return"`"+e.innerHTML+"`"})),s.subParser("makeMarkdown.emphasis",(function(e,t){"use strict";var r="";if(e.hasChildNodes()){r+="*";for(var n=e.childNodes,a=n.length,o=0;o",e.hasAttribute("width")&&e.hasAttribute("height")&&(t+=" ="+e.getAttribute("width")+"x"+e.getAttribute("height")),e.hasAttribute("title")&&(t+=' "'+e.getAttribute("title")+'"'),t+=")"),t})),s.subParser("makeMarkdown.links",(function(e,t){"use strict";var r="";if(e.hasChildNodes()&&e.hasAttribute("href")){var n=e.childNodes,a=n.length;r="[";for(var o=0;o",e.hasAttribute("title")&&(r+=' "'+e.getAttribute("title")+'"'),r+=")"}return r})),s.subParser("makeMarkdown.list",(function(e,t,r){"use strict";var n="";if(!e.hasChildNodes())return"";for(var a=e.childNodes,o=a.length,i=e.getAttribute("start")||1,c=0;c"+t.preList[r]+""})),s.subParser("makeMarkdown.strikethrough",(function(e,t){"use strict";var r="";if(e.hasChildNodes()){r+="~~";for(var n=e.childNodes,a=n.length,o=0;otr>th"),c=e.querySelectorAll("tbody>tr");for(r=0;r_&&(_=f)}for(r=0;r/g,"\\$1>")).replace(/^#/gm,"\\#")).replace(/^(\s*)([-=]{3,})(\s*)$/,"$1\\$2$3")).replace(/^( {0,3}\d+)\./gm,"$1\\.")).replace(/^( {0,3})([+-])/gm,"$1\\$2")).replace(/]([\s]*)\(/g,"\\]$1\\(")).replace(/^ {0,3}\[([\S \t]*?)]:/gm,"\\[$1]:")})),void 0===(n=function(){"use strict";return s}.call(t,r,t,e))||(e.exports=n)}).call(this)},604:(e,t,r)=>{var n;!function(){"use strict";var a={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function s(e){return function(e,t){var r,n,o,i,c,l,u,d,h,p=1,_=e.length,f="";for(n=0;n<_;n++)if("string"==typeof e[n])f+=e[n];else if("object"==typeof e[n]){if((i=e[n]).keys)for(r=t[p],o=0;o=0),i.type){case"b":r=parseInt(r,10).toString(2);break;case"c":r=String.fromCharCode(parseInt(r,10));break;case"d":case"i":r=parseInt(r,10);break;case"j":r=JSON.stringify(r,null,i.width?parseInt(i.width):0);break;case"e":r=i.precision?parseFloat(r).toExponential(i.precision):parseFloat(r).toExponential();break;case"f":r=i.precision?parseFloat(r).toFixed(i.precision):parseFloat(r);break;case"g":r=i.precision?String(Number(r.toPrecision(i.precision))):parseFloat(r);break;case"o":r=(parseInt(r,10)>>>0).toString(8);break;case"s":r=String(r),r=i.precision?r.substring(0,i.precision):r;break;case"t":r=String(!!r),r=i.precision?r.substring(0,i.precision):r;break;case"T":r=Object.prototype.toString.call(r).slice(8,-1).toLowerCase(),r=i.precision?r.substring(0,i.precision):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=i.precision?r.substring(0,i.precision):r;break;case"x":r=(parseInt(r,10)>>>0).toString(16);break;case"X":r=(parseInt(r,10)>>>0).toString(16).toUpperCase()}a.json.test(i.type)?f+=r:(!a.number.test(i.type)||d&&!i.sign?h="":(h=d?"+":"-",r=r.toString().replace(a.sign,"")),l=i.pad_char?"0"===i.pad_char?"0":i.pad_char.charAt(1):" ",u=i.width-(h+r).length,c=i.width&&u>0?l.repeat(u):"",f+=i.align?h+r+c:"0"===l?h+c+r:c+h+r)}return f}(function(e){if(i[e])return i[e];for(var t,r=e,n=[],s=0;r;){if(null!==(t=a.text.exec(r)))n.push(t[0]);else if(null!==(t=a.modulo.exec(r)))n.push("%");else{if(null===(t=a.placeholder.exec(r)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){s|=1;var o=[],c=t[2],l=[];if(null===(l=a.key.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(l[1]);""!==(c=c.substring(l[0].length));)if(null!==(l=a.key_access.exec(c)))o.push(l[1]);else{if(null===(l=a.index_access.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(l[1])}t[2]=o}else s|=2;if(3===s)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}r=r.substring(t[0].length)}return i[e]=n}(e),arguments)}function o(e,t){return s.apply(null,[e].concat(t||[]))}var i=Object.create(null);"undefined"!=typeof window&&(window.sprintf=s,window.vsprintf=o,void 0===(n=function(){return{sprintf:s,vsprintf:o}}.call(t,r,t,e))||(e.exports=n))}()}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let t;const n=new Uint8Array(16),a=[];for(let e=0;e<256;++e)a.push((e+256).toString(16).slice(1));const s=function(r,s,o){if(e.randomUUID&&!s&&!r)return e.randomUUID();const i=(r=r||{}).random??r.rng?.()??function(){if(!t){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");t=crypto.getRandomValues.bind(crypto)}return t(n)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,s){if((o=o||0)<0||o+16>s.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);for(let e=0;e<16;++e)s[o+e]=i[e];return s}return function(e,t=0){return(a[e[t+0]]+a[e[t+1]]+a[e[t+2]]+a[e[t+3]]+"-"+a[e[t+4]]+a[e[t+5]]+"-"+a[e[t+6]]+a[e[t+7]]+"-"+a[e[t+8]]+a[e[t+9]]+"-"+a[e[t+10]]+a[e[t+11]]+a[e[t+12]]+a[e[t+13]]+a[e[t+14]]+a[e[t+15]]).toLowerCase()}(i)};var o,i,c,l,u;r(604),console.error,o=o||{},i={"(":9,"!":8,"*":7,"/":7,"%":7,"+":6,"-":6,"<":5,"<=":5,">":5,">=":5,"==":4,"!=":4,"&&":3,"||":2,"?":1,"?:":1},c=["(","?"],l={")":["("],":":["?","?:"]},u=/<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;var d={"!":function(e){return!e},"*":function(e,t){return e*t},"/":function(e,t){return e/t},"%":function(e,t){return e%t},"+":function(e,t){return e+t},"-":function(e,t){return e-t},"<":function(e,t){return e":function(e,t){return e>t},">=":function(e,t){return e>=t},"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},"&&":function(e,t){return e&&t},"||":function(e,t){return e||t},"?:":function(e,t,r){if(e)throw t;return r}};var h={contextDelimiter:"",onMissingKey:null};function p(e,t){var r;for(r in this.data=e,this.pluralForms={},this.options={},h)this.options[r]=void 0!==t&&r in t?t[r]:h[r]}p.prototype.getPluralForm=function(e,t){var r,n,a,s,o=this.pluralForms[e];return o||("function"!=typeof(a=(r=this.data[e][""])["Plural-Forms"]||r["plural-forms"]||r.plural_forms)&&(n=function(e){var t,r,n;for(t=e.split(";"),r=0;r=0||i[a]1===e?0:1},f=/^i18n\.(n?gettext|has_translation)(_|$)/,g=function(e){return"string"!=typeof e||""===e?(console.error("The namespace must be a non-empty string."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(e)||(console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."),!1)},m=function(e){return"string"!=typeof e||""===e?(console.error("The hook name must be a non-empty string."),!1):/^__/.test(e)?(console.error("The hook name cannot begin with `__`."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(e)||(console.error("The hook name can only contain numbers, letters, dashes, periods and underscores."),!1)},b=function(e,t){return function(r,n,a,s=10){const o=e[t];if(!m(r))return;if(!g(n))return;if("function"!=typeof a)return void console.error("The hook callback must be a function.");if("number"!=typeof s)return void console.error("If specified, the hook priority must be a number.");const i={callback:a,priority:s,namespace:n};if(o[r]){const e=o[r].handlers;let t;for(t=e.length;t>0&&!(s>=e[t-1].priority);t--);t===e.length?e[t]=i:e.splice(t,0,i),o.__current.forEach((e=>{e.name===r&&e.currentIndex>=t&&e.currentIndex++}))}else o[r]={handlers:[i],runs:0};"hookAdded"!==r&&e.doAction("hookAdded",r,n,a,s)}},w=function(e,t,r=!1){return function(n,a){const s=e[t];if(!m(n))return;if(!r&&!g(a))return;if(!s[n])return 0;let o=0;if(r)o=s[n].handlers.length,s[n]={runs:s[n].runs,handlers:[]};else{const e=s[n].handlers;for(let t=e.length-1;t>=0;t--)e[t].namespace===a&&(e.splice(t,1),o++,s.__current.forEach((e=>{e.name===n&&e.currentIndex>=t&&e.currentIndex--})))}return"hookRemoved"!==n&&e.doAction("hookRemoved",n,a),o}},k=function(e,t){return function(r,n){const a=e[t];return void 0!==n?r in a&&a[r].handlers.some((e=>e.namespace===n)):r in a}},y=function(e,t,r,n){return function(a,...s){const o=e[t];o[a]||(o[a]={handlers:[],runs:0}),o[a].runs++;const i=o[a].handlers;if(!i||!i.length)return r?s[0]:void 0;const c={name:a,currentIndex:0};return(n?async function(){try{o.__current.add(c);let e=r?s[0]:void 0;for(;c.currentIndex0:Array.from(n.__current).some((e=>e.name===r))}},x=function(e,t){return function(r){const n=e[t];if(m(r))return n[r]&&n[r].runs?n[r].runs:0}};class P{constructor(){this.actions=Object.create(null),this.actions.__current=new Set,this.filters=Object.create(null),this.filters.__current=new Set,this.addAction=b(this,"actions"),this.addFilter=b(this,"filters"),this.removeAction=w(this,"actions"),this.removeFilter=w(this,"filters"),this.hasAction=k(this,"actions"),this.hasFilter=k(this,"filters"),this.removeAllActions=w(this,"actions",!0),this.removeAllFilters=w(this,"filters",!0),this.doAction=y(this,"actions",!1,!1),this.doActionAsync=y(this,"actions",!1,!0),this.applyFilters=y(this,"filters",!0,!1),this.applyFiltersAsync=y(this,"filters",!0,!0),this.currentAction=v(this,"actions"),this.currentFilter=v(this,"filters"),this.doingAction=j(this,"actions"),this.doingFilter=j(this,"filters"),this.didAction=x(this,"actions"),this.didFilter=x(this,"filters")}}const S=new P,{addAction:A,addFilter:z,removeAction:C,removeFilter:E,hasAction:M,hasFilter:T,removeAllActions:L,removeAllFilters:I,doAction:$,doActionAsync:O,applyFilters:B,applyFiltersAsync:H,currentAction:F,currentFilter:N,doingAction:R,doingFilter:U,didAction:D,didFilter:q,actions:V,filters:G}=S,W=((e,t,r)=>{const n=new p({}),a=new Set,s=()=>{a.forEach((e=>e()))},o=(e,t="default")=>{n.data[t]={...n.data[t],...e},n.data[t][""]={..._,...n.data[t]?.[""]},delete n.pluralForms[t]},i=(e,t)=>{o(e,t),s()},c=(e="default",t,r,a,s)=>(n.data[e]||o(void 0,e),n.dcnpgettext(e,t,r,a,s)),l=(e="default")=>e,u=(e,t,n)=>{let a=c(n,t,e);return r?(a=r.applyFilters("i18n.gettext_with_context",a,e,t,n),r.applyFilters("i18n.gettext_with_context_"+l(n),a,e,t,n)):a};if(r){const e=e=>{f.test(e)&&s()};r.addAction("hookAdded","core/i18n",e),r.addAction("hookRemoved","core/i18n",e)}return{getLocaleData:(e="default")=>n.data[e],setLocaleData:i,addLocaleData:(e,t="default")=>{n.data[t]={...n.data[t],...e,"":{..._,...n.data[t]?.[""],...e?.[""]}},delete n.pluralForms[t],s()},resetLocaleData:(e,t)=>{n.data={},n.pluralForms={},i(e,t)},subscribe:e=>(a.add(e),()=>a.delete(e)),__:(e,t)=>{let n=c(t,void 0,e);return r?(n=r.applyFilters("i18n.gettext",n,e,t),r.applyFilters("i18n.gettext_"+l(t),n,e,t)):n},_x:u,_n:(e,t,n,a)=>{let s=c(a,void 0,e,t,n);return r?(s=r.applyFilters("i18n.ngettext",s,e,t,n,a),r.applyFilters("i18n.ngettext_"+l(a),s,e,t,n,a)):s},_nx:(e,t,n,a,s)=>{let o=c(s,a,e,t,n);return r?(o=r.applyFilters("i18n.ngettext_with_context",o,e,t,n,a,s),r.applyFilters("i18n.ngettext_with_context_"+l(s),o,e,t,n,a,s)):o},isRTL:()=>"rtl"===u("ltr","text direction"),hasTranslation:(e,t,a)=>{const s=t?t+""+e:e;let o=!!n.data?.[null!=a?a:"default"]?.[s];return r&&(o=r.applyFilters("i18n.has_translation",o,e,t,a),o=r.applyFilters("i18n.has_translation_"+l(a),o,e,t,a)),o}}})(0,0,S),K=(W.getLocaleData.bind(W),W.setLocaleData.bind(W),W.resetLocaleData.bind(W),W.subscribe.bind(W),W.__.bind(W));W._x.bind(W),W._n.bind(W),W._nx.bind(W),W.isRTL.bind(W),W.hasTranslation.bind(W);const Z=(e,t)=>{let r,n,a=e.path;return"string"==typeof e.namespace&&"string"==typeof e.endpoint&&(r=e.namespace.replace(/^\/|\/$/g,""),n=e.endpoint.replace(/^\//,""),a=n?r+"/"+n:r),delete e.namespace,delete e.endpoint,t({...e,path:a})};function X(e){const t=e.split("?"),r=t[1],n=t[0];return r?n+"?"+r.split("&").map((e=>e.split("="))).map((e=>e.map(decodeURIComponent))).sort(((e,t)=>e[0].localeCompare(t[0]))).map((e=>e.map(encodeURIComponent))).map((e=>e.join("="))).join("&"):n}function J(e){try{return decodeURIComponent(e)}catch(t){return e}}function Q(e){return(function(e){let t;try{t=new URL(e,"http://example.com").search.substring(1)}catch(e){}if(t)return t}(e)||"").replace(/\+/g,"%20").split("&").reduce(((e,t)=>{const[r,n=""]=t.split("=").filter(Boolean).map(J);return r&&function(e,t,r){const n=t.length,a=n-1;for(let s=0;s{"link"===t.toLowerCase()&&(e.headers[t]=r.replace(/<([^>]+)>/,((e,t)=>`<${encodeURI(t)}>`)))})),Promise.resolve(t?e.body:new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}}const re=({path:e,url:t,...r},n)=>({...r,url:t&&ee(t,n),path:e&&ee(e,n)}),ne=e=>e.json?e.json():Promise.reject(e),ae=e=>{const{next:t}=(e=>{if(!e)return{};const t=e.match(/<([^>]+)>; rel="next"/);return t?{next:t[1]}:{}})(e.headers.get("link"));return t},se=async(e,t)=>{if(!1===e.parse)return t(e);if(!(e=>{const t=!!e.path&&-1!==e.path.indexOf("per_page=-1"),r=!!e.url&&-1!==e.url.indexOf("per_page=-1");return t||r})(e))return t(e);const r=await we({...re(e,{per_page:100}),parse:!1}),n=await ne(r);if(!Array.isArray(n))return n;let a=ae(r);if(!a)return n;let s=[].concat(n);for(;a;){const t=await we({...e,path:void 0,url:a,parse:!1}),r=await ne(t);s=s.concat(r),a=ae(t)}return s},oe=new Set(["PATCH","PUT","DELETE"]),ie="GET";function ce(e,t){return Q(e)[t]}function le(e,t){return void 0!==ce(e,t)}const ue=(e,t=!0)=>Promise.resolve(((e,t=!0)=>t?204===e.status?null:e.json?e.json():Promise.reject(e):e)(e,t)).catch((e=>de(e,t)));function de(e,t=!0){if(!t)throw e;return(e=>{const t={code:"invalid_json",message:K("The response is not a valid JSON response.")};if(!e||!e.json)throw t;return e.json().catch((()=>{throw t}))})(e).then((e=>{const t={code:"unknown_error",message:K("An unknown error occurred.")};throw e||t}))}function he(e,...t){const r=e.indexOf("?");if(-1===r)return e;const n=Q(e),a=e.substr(0,r);t.forEach((e=>delete n[e]));const s=Y(n);return s?a+"?"+s:a}const pe={Accept:"application/json, */*;q=0.1"},_e={credentials:"include"},fe=[(e,t)=>("string"!=typeof e.url||le(e.url,"_locale")||(e.url=ee(e.url,{_locale:"user"})),"string"!=typeof e.path||le(e.path,"_locale")||(e.path=ee(e.path,{_locale:"user"})),t(e)),Z,(e,t)=>{const{method:r=ie}=e;return oe.has(r.toUpperCase())&&(e={...e,headers:{...e.headers,"X-HTTP-Method-Override":r,"Content-Type":"application/json"},method:"POST"}),t(e)},se],ge=e=>{if(e.status>=200&&e.status<300)return e;throw e};let me=e=>{const{url:t,path:r,data:n,parse:a=!0,...s}=e;let{body:o,headers:i}=e;return i={...pe,...i},n&&(o=JSON.stringify(n),i["Content-Type"]="application/json"),window.fetch(t||r||window.location.href,{..._e,...s,body:o,headers:i}).then((e=>Promise.resolve(e).then(ge).catch((e=>de(e,a))).then((e=>ue(e,a)))),(e=>{if(e&&"AbortError"===e.name)throw e;throw{code:"fetch_error",message:K("You are probably offline.")}}))};function be(e){return fe.reduceRight(((e,t)=>r=>t(r,e)),me)(e).catch((t=>"rest_cookie_invalid_nonce"!==t.code?Promise.reject(t):window.fetch(be.nonceEndpoint).then(ge).then((e=>e.text())).then((t=>(be.nonceMiddleware.nonce=t,be(e))))))}be.use=function(e){fe.unshift(e)},be.setFetchHandler=function(e){me=e},be.createNonceMiddleware=function(e){const t=(e,r)=>{const{headers:n={}}=e;for(const a in n)if("x-wp-nonce"===a.toLowerCase()&&n[a]===t.nonce)return r(e);return r({...e,headers:{...n,"X-WP-Nonce":t.nonce}})};return t.nonce=e,t},be.createPreloadingMiddleware=function(e){const t=Object.fromEntries(Object.entries(e).map((([e,t])=>[X(e),t])));return(e,r)=>{const{parse:n=!0}=e;let a=e.path;if(!a&&e.url){const{rest_route:t,...r}=Q(e.url);"string"==typeof t&&(a=ee(t,r))}if("string"!=typeof a)return r(e);const s=e.method||"GET",o=X(a);if("GET"===s&&t[o]){const e=t[o];return delete t[o],te(e,!!n)}if("OPTIONS"===s&&t[s]&&t[s][o]){const e=t[s][o];return delete t[s][o],te(e,!!n)}return r(e)}},be.createRootURLMiddleware=e=>(t,r)=>Z(t,(t=>{let n,a=t.url,s=t.path;return"string"==typeof s&&(n=e,-1!==e.indexOf("?")&&(s=s.replace("?","&")),s=s.replace(/^\//,""),"string"==typeof n&&-1!==n.indexOf("?")&&(s=s.replace("?","&")),a=n+s),r({...t,url:a})})),be.fetchAllMiddleware=se,be.mediaUploadMiddleware=(e,t)=>{if(!function(e){const t=!!e.method&&"POST"===e.method;return(!!e.path&&-1!==e.path.indexOf("/wp/v2/media")||!!e.url&&-1!==e.url.indexOf("/wp/v2/media"))&&t}(e))return t(e);let r=0;const n=e=>(r++,t({path:`/wp/v2/media/${e}/post-process`,method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch((()=>r<5?n(e):(t({path:`/wp/v2/media/${e}?force=true`,method:"DELETE"}),Promise.reject()))));return t({...e,parse:!1}).catch((t=>{if(!t.headers)return Promise.reject(t);const r=t.headers.get("x-wp-upload-attachment-id");return t.status>=500&&t.status<600&&r?n(r).catch((()=>!1!==e.parse?Promise.reject({code:"post_process",message:K("Media upload failed. If this is a photo or a large image, please scale it down and try again.")}):Promise.reject(t))):de(t,e.parse)})).then((t=>ue(t,e.parse)))},be.createThemePreviewMiddleware=e=>(t,r)=>{if("string"==typeof t.url){const r=ce(t.url,"wp_theme_preview");void 0===r?t.url=ee(t.url,{wp_theme_preview:e}):""===r&&(t.url=he(t.url,"wp_theme_preview"))}if("string"==typeof t.path){const r=ce(t.path,"wp_theme_preview");void 0===r?t.path=ee(t.path,{wp_theme_preview:e}):""===r&&(t.path=he(t.path,"wp_theme_preview"))}return r(t)};const we=be;function ke(e){try{return decodeURIComponent(e)}catch(t){return e}}function ye(e="",t){if(!t||!Object.keys(t).length)return e;const r=function(e){const t=/^\S+?(#[^\s\?]*)/.exec(e);if(t)return t[1]}(e)||"";let n=e.replace(r,"");const a=e.indexOf("?");return-1!==a&&(t=Object.assign(function(e){return(function(e){let t;try{t=new URL(e,"http://example.com").search.substring(1)}catch(e){}if(t)return t}(e)||"").replace(/\+/g,"%20").split("&").reduce(((e,t)=>{const[r,n=""]=t.split("=").filter(Boolean).map(ke);return r&&function(e,t,r){const n=t.length,a=n-1;for(let s=0;s{const a=new(r(552).Converter);a.setOption("noHeaderId",!0),a.setOption("simplifiedAutoLink",!0),a.setOption("excludeTrailingPunctuationFromURLs",!0),a.setOption("openLinksInNewWindow",!0);const o=e=>a.makeHtml(e).replace(/<\/?h[1-6]>/g,(e=>e.replace(/h[1-6]/,"h3")));class i{constructor(e){this.config={api_url:"",api_token:"",rest_url:"",rest_nonce:"",chat_id:"",meta:{},l10n:{}},this.chat_log=[],this.first_start=!0,this.chat_closed=!1,this.can_contact=!1,this.config=Object.assign({chat_id:s()},e),this.jc_chat=n.$(".joinchat__chat"),this.jc_scroll=n.$(".joinchat__scroll"),this.jc_bubble=null,this.jc_prompt=null,localStorage.setItem("joinchat_chat_id",this.config.chat_id),this.fetchToken(),setInterval(this.fetchToken.bind(this),15e4),t.addEventListener("joinchat:show",this.startChat.bind(this))}startChat(){this.first_start?(this.first_start=!1,this.disableContact(),this.togglePrompt(!0,!1),this.jc_chat.addEventListener("joinchat:bubbles",(()=>{this.config.quick_questions.length&&(this.jc_chat.addEventListener("click",this.listenOption.bind(this)),this.jc_chat.addEventListener("keydown",this.listenOption.bind(this)),this.doAction(this.config.quick_questions)),this.togglePrompt(!0)}),{once:!0})):this.chat_closed||this.doAction({type:"prompt"})}listenOption(t){var r;if(t.target.closest(".joinchat__option")&&("keydown"!==t.type||t instanceof KeyboardEvent&&("Enter"===t.key||" "===t.key))){const n=t.target,a=n.dataset.type,s=n.dataset.prompt;if("link"===a)return void e.open(s,"_blank").focus();null===(r=this.jc_chat.querySelector(".joinchat__bubble--options"))||void 0===r||r.remove(),this.reply(n.textContent),this.togglePrompt(!0,!1),this.loading(),"direct"===a?this.delay((()=>{this.addMessage(this.prepareMessage(s)),this.togglePrompt(!0)})):this.fetch(s)}}doAction(e){switch((e=this.prepareMessage(e)).type){case"end":this.chat_closed=!0,this.addMessage(e),e.contact?this.enableContact():this.togglePrompt(!0,!1);break;case"text":this.delay((()=>{this.addMessage(e),this.fetch()}));break;case"options":this.addMessage(e),this.jc_chat.querySelector(".joinchat__option").focus();break;case"prompt":this.delay((()=>{this.addMessage(e),this.togglePrompt(!0)}));break;case"stream":this.streamMessage(e)}}prepareMessage(e){let t={type:"text",text:"",html:"",contact:this.can_contact};return"string"==typeof e?(t.html=o(e),t.text=(new DOMParser).parseFromString(e,"text/html").body.textContent||""):Array.isArray(e)?(t.type="options",t.html=e.map((e=>{if(!e.prompt||!e.text)return"";const t=(e.prompt||e.text).replace(/"/g,""");return`${(e.text||e.prompt).replace(//g,">")}`})).join(" "),t.text=e.map((e=>e.text)).join(" | "),t.contact=!1):(Object.assign(t,e),""===t.html&&(t.html=o(t.text)),""===t.text&&(t.text=(new DOMParser).parseFromString(t.html,"text/html").body.textContent||""),"prompt"!==t.type&&"options"!==t.type||(t.contact=!1)),t}addMessage(e){this.logMessage(e.text),this.addBubble(e.html,"prompt"!==e.type?e.type:""),e.contact?this.enableContact():this.disableContact()}streamMessage(e){const t=this.lastBubbleIs("stream");e.html.length>0?t?(this.jc_bubble.innerHTML=e.html,this.scrollTo(this.jc_bubble),this.chat_log.pop(),this.logMessage(e.text)):this.addMessage(e):(t&&this.jc_bubble.classList.remove("joinchat__bubble--stream"),this.togglePrompt(!0))}addBubble(e,r=""){if(this.lastBubbleIs("loading")&&this.jc_bubble.remove(),""===e&&"loading"!==r)return;const n=t.createElement("div");n.className="joinchat__bubble"+(r?" joinchat__bubble--"+r:""),n.insertAdjacentHTML("afterbegin",e),this.jc_bubble=n,this.jc_chat.appendChild(n),this.scrollTo(n),this.jc_chat.dispatchEvent(new CustomEvent("joinchat:bubble",{detail:n}))}loading(){this.lastBubbleIs("loading")||this.addBubble("","loading")}reply(e){this.logMessage(e,"user"),this.addBubble(e,"reply")}lastBubbleIs(e){var t;return null===(t=this.jc_bubble)||void 0===t?void 0:t.classList.contains(`joinchat__bubble--${e}`)}addSources(e){const r=e.map((e=>`${e.title}`)).join("");if(this.jc_bubble){const e=t.createElement("div");e.className="joinchat__sources",e.innerHTML=r,this.jc_bubble.appendChild(e),this.scrollTo("end")}}fetch(e=""){this.togglePrompt(!0,!1),this.loading(),this.fetchAI(e)}fetchAI(e){const t=new Intl.DisplayNames(["en"],{type:"language"});fetch(this.config.api_url,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json",Accept:"text/event-stream,text/plain",Authorization:`Bearer ${this.config.api_token}`},body:JSON.stringify({query:e,conversation_id:this.config.chat_id,post_id:this.config.meta.post_id,language:t.of("site"==this.config.response_language?this.config.meta.site_language:navigator.language),user_id:this.config.meta.user_id})}).then((e=>{var t;if(200!==e.status)throw new Error("Bad request");if(null===(t=e.headers.get("content-type"))||void 0===t?void 0:t.includes("text/event-stream")){let t="",r=[];const n=e.body.pipeThrough(new TextDecoderStream).getReader(),a=()=>{n.read().then((({value:e,done:n})=>{n?this.config.display_sources&&r.length?this.fetchSources(r):this.doAction({type:"stream"}):(e.includes("[DOCUMENT_IDS]:")&&(r=e.split("[DOCUMENT_IDS]:")[1].trim().split(","),e=e.split("[DOCUMENT_IDS]:")[0]),t+=e,this.doAction({type:"stream",text:t}),a())}))};a()}else e.json().then((e=>{this.config.display_sources&&e.documentIds&&e.documentIds.length?(this.doAction({type:"stream",text:e.response}),this.fetchSources(e.documentIds)):this.doAction({type:"prompt",text:e.response})}))})).catch((e=>{console.error("Error on request message:",e),this.doAction({type:"end",text:this.config.error_msg||"🤯",contact:this.config.error_contact})}))}fetchSources(e){we({url:ye(this.config.rest_url+"/get_sources",{ids:e}),method:"GET",headers:{"X-WP-Nonce":this.config.rest_nonce}}).then((e=>{this.addSources(e.sources),this.doAction({type:"stream"})})).catch((e=>{console.error("Error on get sources:",e),this.doAction({type:"stream"})}))}fetchToken(){we({url:this.config.rest_url+"/refresh_token",method:"POST",headers:{"X-WP-Nonce":this.config.rest_nonce}}).then((e=>{e.token&&(this.config.api_token=e.token)})).catch((e=>{var t;(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.token)&&(this.config.api_token=e.data.token),console.error("Error refreshing the request token:",e),setTimeout((()=>this.fetchToken()),5e3)}))}addPrompt(){this.jc_prompt=t.createElement("div"),this.jc_prompt.className="joinchat__prompt joinchat__prompt--disabled joinchat--hidden",this.jc_prompt.insertAdjacentHTML("afterbegin",`\n \n `),n.$(".joinchat__chatbox").appendChild(this.jc_prompt);let e=60;this.prompt$("input").addEventListener("keyup",(function(){this.style.setProperty("--offtop","18px"),this.style.height="0";const t=this.scrollHeight;this.style.setProperty("--offtop",t<=60?"18px":"4px"),this.style.height=t-14+"px",e{this.toggleSubmit();const t=e.target.value.trim();""!==t&&this.hasPersonalInfo(t)&&this.showPersonalInfoWarning(t)}))}prompt$(e){var t;return null===(t=this.jc_prompt)||void 0===t?void 0:t.querySelector(`.joinchat__${e}`)}togglePrompt(e=!0,t=e){e&&null===this.jc_prompt&&this.addPrompt(),this.jc_prompt&&(this.jc_prompt.classList.toggle("joinchat--hidden",!e),this.jc_prompt.classList.toggle("joinchat__prompt--disabled",!t),this.prompt$("submit").disabled=!t,e&&t&&(this.toggleSubmit(),this.delay((()=>{this.scrollTo("end")}),210),n.is_mobile||this.prompt$("input").focus()))}hasPersonalInfo(e){return/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/.test(e)||/(?:\+\d{1,3}[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/.test(e)}showPersonalInfoWarning(e){if(!this.lastBubbleIs("warning")){const e=this.config.l10n.personal_info_warning||"⚠️ Please be careful sharing personal information like emails or phone numbers.";this.addBubble(e,"warning")}}listenPrompt(e){if("keydown"===e.type&&this.jc_prompt.classList.contains("joinchat__prompt--disabled"))return e.preventDefault(),!1;if("keydown"!==e.type||e instanceof KeyboardEvent&&"Enter"===e.key&&!e.shiftKey){e.preventDefault();const t=this.prompt$("input"),r=t.value.trim();""!==r&&(this.reply(r),this.togglePrompt(!0,!1),t.value="",t.removeAttribute("style"),this.fetch(r))}}toggleSubmit(){this.prompt$("submit").disabled=""===this.prompt$("input").value.trim()}enableContact(){var e;n.chatbox&&(this.can_contact=!0,this.togglePrompt(!1),n.$(".joinchat__contact")?(t.dispatchEvent(new Event("joinchat:contact")),null===(e=n.$(".joinchat__optin"))||void 0===e||e.classList.remove("joinchat--hidden")):"999"!==n.settings.telephone&&n.$$(".joinchat__open, .joinchat__optin").forEach((e=>e.classList.remove("joinchat--hidden"))),this.scrollTo("end"))}disableContact(){this.can_contact=!1,n.$$(".joinchat__open, .joinchat__optin, .joinchat__contact").forEach((e=>e.classList.add("joinchat--hidden")))}delay(e,t=0){setTimeout(e.bind(this),t||Math.round(400*Math.random()+400))}scrollTo(e,t="smooth"){const r="end"===e?this.jc_scroll.scrollHeight:e.offsetTop-this.jc_chat.offsetTop;this.jc_scroll.scrollTo({top:r,behavior:t})}logMessage(e,t="ai"){this.chat_log.push({role:t,content:e.replace(/(<([^>]+)>)/gi,"")})}}const c=()=>{n=e.joinchat_obj,new i(joinchat_ai)};joinchat_ai.agents?t.addEventListener("joinchat:agents",(e=>{const t=e.detail.filter((e=>e.online)).length>0;joinchat_ai.agents===(t?"online":"offline")&&c()})):n.is_ready?new i(joinchat_ai):t.addEventListener("joinchat:start",c)})(window,document,window.joinchat_obj||{})})()})();