12 |
- function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.apply(this,arguments)}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}let n={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function r(e){n=e}const i=/[&<>"']/,s=new RegExp(i.source,"g"),a=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,o=new RegExp(a.source,"g"),l={"&":"&","<":"<",">":">",'"':""","'":"'"},c=e=>l[e];function h(e,t){if(t){if(i.test(e))return e.replace(s,c)}else if(a.test(e))return e.replace(o,c);return e}const g=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function u(e){return e.replace(g,(e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):"")}const d=/(^|[^\[])\^/g;function p(e,t){let n="string"==typeof e?e:e.source;t=t||"";const r={replace:(e,t)=>{let i="string"==typeof t?t:t.source;return i=i.replace(d,"$1"),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}function f(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const m={exec:()=>null};function w(e,t){const n=e.replace(/\|/g,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&"\\"===n[i];)r=!r;return r?"|":" |"}).split(/ \|/);let r=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(/\\\|/g,"|");return n}function b(e,t,n){const r=e.length;if(0===r)return"";let i=0;for(;i<r;){const s=e.charAt(r-i-1);if(s!==t||n){if(s===t||!n)break;i++}else i++}return e.slice(0,r-i)}function x(e,t,n,r){const i=t.href,s=t.title?h(t.title):null,a=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){r.state.inLink=!0;const e={type:"link",raw:n,href:i,title:s,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,e}return{type:"image",raw:n,href:i,title:s,text:h(a)}}class k{options;rules;lexer;constructor(e){this.options=e||n}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:b(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const r=n[1];return t.split("\n").map(e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=r.length?e.slice(r.length):e}).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=b(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const e=b(t[0].replace(/^ *>[ \t]?/gm,""),"\n"),n=this.lexer.state.top;this.lexer.state.top=!0;const r=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:r,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");const s=new RegExp(`^( {0,3}${n})((?:[\t ][^\\n]*)?(?:\\n|$))`);let a="",o="",l=!1;for(;e;){let n=!1;if(!(t=s.exec(e)))break;if(this.rules.block.hr.test(e))break;a=t[0],e=e.substring(a.length);let r=t[2].split("\n",1)[0].replace(/^\t+/,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],h=0;this.options.pedantic?(h=2,o=r.trimStart()):(h=t[2].search(/[^ ]/),h=h>4?1:h,o=r.slice(h),h+=t[1].length);let g=!1;if(!r&&/^ *$/.test(c)&&(a+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),n=new RegExp(`^ {0,${Math.min(3,h-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),i=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:\`\`\`|~~~)`),s=new RegExp(`^ {0,${Math.min(3,h-1)}}#`);for(;e;){const l=e.split("\n",1)[0];if(c=l,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),i.test(c))break;if(s.test(c))break;if(t.test(c))break;if(n.test(e))break;if(c.search(/[^ ]/)>=h||!c.trim())o+="\n"+c.slice(h);else{if(g)break;if(r.search(/[^ ]/)>=4)break;if(i.test(r))break;if(s.test(r))break;if(n.test(r))break;o+="\n"+c}g||c.trim()||(g=!0),a+=l+"\n",e=e.substring(l.length+1),r=c.slice(h)}}i.loose||(l?i.loose=!0:/\n *\n *$/.test(a)&&(l=!0));let u,d=null;this.options.gfm&&(d=/^\[[ xX]\] /.exec(o),d&&(u="[ ] "!==d[0],o=o.replace(/^\[[ xX]\] +/,""))),i.items.push({type:"list_item",raw:a,task:!!d,checked:u,loose:!1,text:o,tokens:[]}),i.raw+=a}i.items[i.items.length-1].raw=a.trimEnd(),i.items[i.items.length-1].text=o.trimEnd(),i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){const t=i.items[e].tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>/\n.*\n/.test(e.raw));i.loose=n}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){const t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(/\s+/g," "),n=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:r}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const n=w(t[1]),r=t[2].replace(/^\||\| *$/g,"").split("|"),i=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(const e of r)/^ *-+: *$/.test(e)?s.align.push("right"):/^ *:-+: *$/.test(e)?s.align.push("center"):/^ *:-+ *$/.test(e)?s.align.push("left"):s.align.push(null);for(const e of n)s.header.push({text:e,tokens:this.lexer.inline(e)});for(const e of i)s.rows.push(w(e,s.header.length).map(e=>({text:e,tokens:this.lexer.inline(e)})));return s}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:h(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const t=b(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return-1}(t[2],"()");if(e>-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^</.test(n)&&(n=this.options.pedantic&&!/>$/.test(e)?n.slice(1):n.slice(1,-1)),x(t,{href:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n,title:r?r.replace(this.rules.inline.anyPunctuation,"$1"):r},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const e=t[(n[2]||n[1]).replace(/\s+/g," ").toLowerCase()];if(!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return x(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&(!r[3]||!n.match(/[\p{L}\p{N}]/u))&&(!r[1]&&!r[2]||!n||this.rules.inline.punctuation.exec(n))){const n=[...r[0]].length-1;let i,s,a=n,o=0;const l="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+n);null!=(r=l.exec(t));){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(s=[...i].length,r[3]||r[4]){a+=s;continue}if((r[5]||r[6])&&n%3&&!((n+s)%3)){o+=s;continue}if(a-=s,a>0)continue;s=Math.min(s,s+a+o);const t=[...r[0]][0].length,l=e.slice(0,n+r.index+t+s);if(Math.min(n,s)%2){const e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}const c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),r=/^ /.test(e)&&/ $/.test(e);return n&&r&&(e=e.substring(1,e.length-1)),e=h(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=h(t[1]),n="mailto:"+e):(e=h(t[1]),n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=h(t[0]),n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=h(t[0]),n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:h(t[0]),{type:"text",raw:t[0],text:e}}}}const y=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,v=/(?:[*+-]|\d{1,9}[.)])/,_=p(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,v).getRegex(),$=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,z=/(?!\s*\])(?:\\.|[^\[\]\\])+/,R=p(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",z).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),T=p(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,v).getRegex(),E="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",A=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,L=p("^ {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",A).replace("tag",E).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),S=p($).replace("hr",y).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",E).getRegex(),I={blockquote:p(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",S).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:R,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:y,html:L,lheading:_,list:T,newline:/^(?: *(?:\n|$))+/,paragraph:S,table:m,text:/^[^\n]+/},P=p("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",y).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\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",E).getRegex(),C={...I,table:P,paragraph:p($).replace("hr",y).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",P).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",E).getRegex()},B={...I,html:p("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",A).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:m,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:p($).replace("hr",y).replace("heading"," *#{1,6} *[^\n]").replace("lheading",_).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},M=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,O=/^( {2,}|\\)\n(?!\s*$)/,q="\\p{P}\\p{S}",D=p(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,q).getRegex(),j=p(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,q).getRegex(),Z=p("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,q).getRegex(),F=p("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,q).getRegex(),H=p(/\\([punct])/,"gu").replace(/punct/g,q).getRegex(),W=p(/^<(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(),Q=p(A).replace("(?:--\x3e|$)","--\x3e").getRegex(),V=p("^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",Q).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),N=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,U=p(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",N).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Y=p(/^!?\[(label)\]\[(ref)\]/).replace("label",N).replace("ref",z).getRegex(),X=p(/^!?\[(ref)\](?:\[\])?/).replace("ref",z).getRegex(),J={_backpedal:m,anyPunctuation:H,autolink:W,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:O,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:m,emStrongLDelim:j,emStrongRDelimAst:Z,emStrongRDelimUnd:F,escape:M,link:U,nolink:X,punctuation:D,reflink:Y,reflinkSearch:p("reflink|nolink(?!\\()","g").replace("reflink",Y).replace("nolink",X).getRegex(),tag:V,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:m},K={...J,link:p(/^!?\[(label)\]\((.*?)\)/).replace("label",N).getRegex(),reflink:p(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",N).getRegex()},G={...J,escape:p(M).replace("])","~|])").getRegex(),url:p(/^((?: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\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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ee={...G,br:p(O).replace("{2,}","*").getRegex(),text:p(G.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},te={normal:I,gfm:C,pedantic:B},ne={normal:J,gfm:G,breaks:ee,pedantic:K};class re{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||n,this.options.tokenizer=this.options.tokenizer||new k,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={block:te.normal,inline:ne.normal};this.options.pedantic?(t.block=te.pedantic,t.inline=ne.pedantic):this.options.gfm&&(t.block=te.gfm,t.inline=this.options.breaks?ne.breaks:ne.gfm),this.tokenizer.rules=t}static get rules(){return{block:te,inline:ne}}static lex(e,t){return new re(t).lex(e)}static lexInline(e,t){return new re(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){const t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){let n,r,i,s;for(e=this.options.pedantic?e.replace(/\t/g," ").replace(/^ +$/gm,""):e.replace(/^( *)(\t+)/gm,(e,t,n)=>t+" ".repeat(n.length));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0))))if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),1===n.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),r=t[t.length-1],!r||"paragraph"!==r.type&&"text"!==r.type?t.push(n):(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=r.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),r=t[t.length-1],!r||"paragraph"!==r.type&&"text"!==r.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(r.raw+="\n"+n.raw,r.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=r.text);else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(i=e,this.options.extensions&&this.options.extensions.startBlock){let t=Infinity;const n=e.slice(1);let r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))}),t<Infinity&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i)))r=t[t.length-1],s&&"paragraph"===r.type?(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n),s=i.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===r.type?(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,r,i,s,a,o,l=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(l));)e.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(l));)l=l.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(s=this.tokenizer.rules.inline.anyPunctuation.exec(l));)l=l.slice(0,s.index)+"++"+l.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(a||(o=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===n.type&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===n.type&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,l,o))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e))){if(i=e,this.options.extensions&&this.options.extensions.startInline){let t=Infinity;const n=e.slice(1);let r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))}),t<Infinity&&t>=0&&(i=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(i))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),a=!0,r=t[t.length-1],r&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(n.raw.length),t.push(n);return t}}class ie{options;constructor(e){this.options=e||n}code(e,t,n){const r=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",r?'<pre><code class="language-'+h(r)+'">'+(n?e:h(e,!0))+"</code></pre>\n":"<pre><code>"+(n?e:h(e,!0))+"</code></pre>\n"}blockquote(e){return`<blockquote>\n${e}</blockquote>\n`}html(e,t){return e}heading(e,t,n){return`<h${t}>${e}</h${t}>\n`}hr(){return"<hr>\n"}list(e,t,n){const r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"</"+r+">\n"}listitem(e,t,n){return`<li>${e}</li>\n`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p>\n`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"}tablerow(e){return`<tr>\n${e}</tr>\n`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\n`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,n){const r=f(e);if(null===r)return n;let i='<a href="'+(e=r)+'"';return t&&(i+=' title="'+t+'"'),i+=">"+n+"</a>",i}image(e,t,n){const r=f(e);if(null===r)return n;let i=`<img src="${e=r}" alt="${n}"`;return t&&(i+=` title="${t}"`),i+=">",i}text(e){return e}}class se{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class ae{options;renderer;textRenderer;constructor(e){this.options=e||n,this.options.renderer=this.options.renderer||new ie,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new se}static parse(e,t){return new ae(t).parse(e)}static parseInline(e,t){return new ae(t).parseInline(e)}parse(e,t=!0){let n="";for(let r=0;r<e.length;r++){const i=e[r];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){n+=t||"";continue}}switch(i.type){case"space":continue;case"hr":n+=this.renderer.hr();continue;case"heading":{const e=i;n+=this.renderer.heading(this.parseInline(e.tokens),e.depth,u(this.parseInline(e.tokens,this.textRenderer)));continue}case"code":n+=this.renderer.code(i.text,i.lang,!!i.escaped);continue;case"table":{const e=i;let t="",r="";for(let t=0;t<e.header.length;t++)r+=this.renderer.tablecell(this.parseInline(e.header[t].tokens),{header:!0,align:e.align[t]});t+=this.renderer.tablerow(r);let s="";for(let t=0;t<e.rows.length;t++){const n=e.rows[t];r="";for(let t=0;t<n.length;t++)r+=this.renderer.tablecell(this.parseInline(n[t].tokens),{header:!1,align:e.align[t]});s+=this.renderer.tablerow(r)}n+=this.renderer.table(t,s);continue}case"blockquote":{const e=this.parse(i.tokens);n+=this.renderer.blockquote(e);continue}case"list":{const e=i,t=e.ordered,r=e.start,s=e.loose;let a="";for(let t=0;t<e.items.length;t++){const n=e.items[t],r=n.checked,i=n.task;let o="";if(n.task){const e=this.renderer.checkbox(!!r);s?n.tokens.length>0&&"paragraph"===n.tokens[0].type?(n.tokens[0].text=e+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&"text"===n.tokens[0].tokens[0].type&&(n.tokens[0].tokens[0].text=e+" "+n.tokens[0].tokens[0].text)):n.tokens.unshift({type:"text",text:e+" "}):o+=e+" "}o+=this.parse(n.tokens,s),a+=this.renderer.listitem(o,i,!!r)}n+=this.renderer.list(a,t,r);continue}case"html":n+=this.renderer.html(i.text,i.block);continue;case"paragraph":n+=this.renderer.paragraph(this.parseInline(i.tokens));continue;case"text":{let s=i,a=s.tokens?this.parseInline(s.tokens):s.text;for(;r+1<e.length&&"text"===e[r+1].type;)s=e[++r],a+="\n"+(s.tokens?this.parseInline(s.tokens):s.text);n+=t?this.renderer.paragraph(a):a;continue}default:{const e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,t){t=t||this.renderer;let n="";for(let r=0;r<e.length;r++){const i=e[r];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=e||"";continue}}switch(i.type){case"escape":case"text":n+=t.text(i.text);break;case"html":n+=t.html(i.text);break;case"link":n+=t.link(i.href,i.title,this.parseInline(i.tokens,t));break;case"image":n+=t.image(i.href,i.title,i.text);break;case"strong":n+=t.strong(this.parseInline(i.tokens,t));break;case"em":n+=t.em(this.parseInline(i.tokens,t));break;case"codespan":n+=t.codespan(i.text);break;case"br":n+=t.br();break;case"del":n+=t.del(this.parseInline(i.tokens,t));break;default:{const e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}}class oe{options;constructor(e){this.options=e||n}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}const le=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.#e(re.lex,ae.parse);parseInline=this.#e(re.lexInline,ae.parseInline);Parser=ae;Renderer=ie;TextRenderer=se;Lexer=re;Tokenizer=k;Hooks=oe;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{const e=r;for(const r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(const r of e.rows)for(const e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":n=n.concat(this.walkTokens(r.items,t));break;default:{const e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{const i=e[r].flat(Infinity);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{const n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){const t=this.defaults.renderer||new ie(this.defaults);for(const n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if("options"===n)continue;const r=e.renderer[n],i=t[n];t[n]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new k(this.defaults);for(const n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const r=e.tokenizer[n],i=t[n];t[n]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new oe;for(const n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if("options"===n)continue;const r=e.hooks[n],i=t[n];t[n]=oe.passThroughHooks.has(n)?e=>{if(this.defaults.async)return Promise.resolve(r.call(t,e)).then(e=>i.call(t,e));const n=r.call(t,e);return i.call(t,n)}:(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return re.lex(e,t??this.defaults)}parser(e,t){return ae.parse(e,t??this.defaults)}#e(e,t){return(n,r)=>{const i={...r},s={...this.defaults,...i};!0===this.defaults.async&&!1===i.async&&(s.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),s.async=!0);const a=this.#t(!!s.silent,!!s.async);if(null==n)return a(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(s.hooks&&(s.hooks.options=s),s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(n):n).then(t=>e(t,s)).then(e=>s.hooks?s.hooks.processAllTokens(e):e).then(e=>s.walkTokens?Promise.all(this.walkTokens(e,s.walkTokens)).then(()=>e):e).then(e=>t(e,s)).then(e=>s.hooks?s.hooks.postprocess(e):e).catch(a);try{s.hooks&&(n=s.hooks.preprocess(n));let r=e(n,s);s.hooks&&(r=s.hooks.processAllTokens(r)),s.walkTokens&&this.walkTokens(r,s.walkTokens);let i=t(r,s);return s.hooks&&(i=s.hooks.postprocess(i)),i}catch(e){return a(e)}}}#t(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="<p>An error occurred:</p><pre>"+h(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function ce(e,t){return le.parse(e,t)}ce.options=ce.setOptions=function(e){return le.setOptions(e),r(ce.defaults=le.defaults),ce},ce.getDefaults=function(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}},ce.defaults=n,ce.use=function(...e){return le.use(...e),r(ce.defaults=le.defaults),ce},ce.walkTokens=function(e,t){return le.walkTokens(e,t)},ce.parseInline=le.parseInline,ce.Parser=ae,ce.parser=ae.parse,ce.Renderer=ie,ce.TextRenderer=se,ce.Lexer=re,ce.lexer=re.lex,ce.Tokenizer=k,ce.Hooks=oe,ce.parse=ce;const he=Math.min,ge=Math.max,ue=Math.round,de=Math.floor,pe=e=>({x:e,y:e}),fe={left:"right",right:"left",bottom:"top",top:"bottom"},me={start:"end",end:"start"};function we(e,t,n){return ge(e,he(t,n))}function be(e,t){return"function"==typeof e?e(t):e}function xe(e){return e.split("-")[0]}function ke(e){return e.split("-")[1]}function ye(e){return"x"===e?"y":"x"}function ve(e){return"y"===e?"height":"width"}function _e(e){return["top","bottom"].includes(xe(e))?"y":"x"}function $e(e){return ye(_e(e))}function ze(e){return e.replace(/start|end/g,e=>me[e])}function Re(e){return e.replace(/left|right|bottom|top/g,e=>fe[e])}function Te(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function Ee(e,t,n){let{reference:r,floating:i}=e;const s=_e(t),a=$e(t),o=ve(a),l=xe(t),c="y"===s,h=r.x+r.width/2-i.width/2,g=r.y+r.height/2-i.height/2,u=r[o]/2-i[o]/2;let d;switch(l){case"top":d={x:h,y:r.y-i.height};break;case"bottom":d={x:h,y:r.y+r.height};break;case"right":d={x:r.x+r.width,y:g};break;case"left":d={x:r.x-i.width,y:g};break;default:d={x:r.x,y:r.y}}switch(ke(t)){case"start":d[a]-=u*(n&&c?-1:1);break;case"end":d[a]+=u*(n&&c?-1:1)}return d}async function Ae(e,t){var n;void 0===t&&(t={});const{x:r,y:i,platform:s,rects:a,elements:o,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:g="floating",altBoundary:u=!1,padding:d=0}=be(t,e),p=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(d),f=o[u?"floating"===g?"reference":"floating":g],m=Te(await s.getClippingRect({element:null==(n=await(null==s.isElement?void 0:s.isElement(f)))||n?f:f.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(o.floating)),boundary:c,rootBoundary:h,strategy:l})),w="floating"===g?{...a.floating,x:r,y:i}:a.reference,b=await(null==s.getOffsetParent?void 0:s.getOffsetParent(o.floating)),x=await(null==s.isElement?void 0:s.isElement(b))&&await(null==s.getScale?void 0:s.getScale(b))||{x:1,y:1},k=Te(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:w,offsetParent:b,strategy:l}):w);return{top:(m.top-k.top+p.top)/x.y,bottom:(k.bottom-m.bottom+p.bottom)/x.y,left:(m.left-k.left+p.left)/x.x,right:(k.right-m.right+p.right)/x.x}}function Le(e){return Pe(e)?(e.nodeName||"").toLowerCase():"#document"}function Se(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Ie(e){var t;return null==(t=(Pe(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Pe(e){return e instanceof Node||e instanceof Se(e).Node}function Ce(e){return e instanceof Element||e instanceof Se(e).Element}function Be(e){return e instanceof HTMLElement||e instanceof Se(e).HTMLElement}function Me(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof Se(e).ShadowRoot)}function Oe(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Fe(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(i)}function qe(e){return["table","td","th"].includes(Le(e))}function De(e){const t=je(),n=Fe(e);return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some(e=>(n.willChange||"").includes(e))||["paint","layout","strict","content"].some(e=>(n.contain||"").includes(e))}function je(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function Ze(e){return["html","body","#document"].includes(Le(e))}function Fe(e){return Se(e).getComputedStyle(e)}function He(e){return Ce(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function We(e){if("html"===Le(e))return e;const t=e.assignedSlot||e.parentNode||Me(e)&&e.host||Ie(e);return Me(t)?t.host:t}function Qe(e){const t=We(e);return Ze(t)?e.ownerDocument?e.ownerDocument.body:e.body:Be(t)&&Oe(t)?t:Qe(t)}function Ve(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=Qe(e),s=i===(null==(r=e.ownerDocument)?void 0:r.body),a=Se(i);return s?t.concat(a,a.visualViewport||[],Oe(i)?i:[],a.frameElement&&n?Ve(a.frameElement):[]):t.concat(i,Ve(i,[],n))}function Ne(e){const t=Fe(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Be(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,o=ue(n)!==s||ue(r)!==a;return o&&(n=s,r=a),{width:n,height:r,$:o}}function Ue(e){return Ce(e)?e:e.contextElement}function Ye(e){const t=Ue(e);if(!Be(t))return pe(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=Ne(t);let a=(s?ue(n.width):n.width)/r,o=(s?ue(n.height):n.height)/i;return a&&Number.isFinite(a)||(a=1),o&&Number.isFinite(o)||(o=1),{x:a,y:o}}const Xe=/*#__PURE__*/pe(0);function Je(e){const t=Se(e);return je()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Xe}function Ke(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),s=Ue(e);let a=pe(1);t&&(r?Ce(r)&&(a=Ye(r)):a=Ye(e));const o=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Se(e))&&t}(s,n,r)?Je(s):pe(0);let l=(i.left+o.x)/a.x,c=(i.top+o.y)/a.y,h=i.width/a.x,g=i.height/a.y;if(s){const e=Se(s),t=r&&Ce(r)?Se(r):r;let n=e,i=n.frameElement;for(;i&&r&&t!==n;){const e=Ye(i),t=i.getBoundingClientRect(),r=Fe(i),s=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,a=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,c*=e.y,h*=e.x,g*=e.y,l+=s,c+=a,n=Se(i),i=n.frameElement}}return Te({width:h,height:g,x:l,y:c})}const Ge=[":popover-open",":modal"];function et(e){return Ge.some(t=>{try{return e.matches(t)}catch(e){return!1}})}function tt(e){return Ke(Ie(e)).left+He(e).scrollLeft}function nt(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=Se(e),r=Ie(e),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,o=0,l=0;if(i){s=i.width,a=i.height;const e=je();(!e||e&&"fixed"===t)&&(o=i.offsetLeft,l=i.offsetTop)}return{width:s,height:a,x:o,y:l}}(e,n);else if("document"===t)r=function(e){const t=Ie(e),n=He(e),r=e.ownerDocument.body,i=ge(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=ge(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+tt(e);const o=-n.scrollTop;return"rtl"===Fe(r).direction&&(a+=ge(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:o}}(Ie(e));else if(Ce(t))r=function(e,t){const n=Ke(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Be(e)?Ye(e):pe(1);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:i*s.x,y:r*s.y}}(t,n);else{const n=Je(e);r={...t,x:t.x-n.x,y:t.y-n.y}}return Te(r)}function rt(e,t){const n=We(e);return!(n===t||!Ce(n)||Ze(n))&&("fixed"===Fe(n).position||rt(n,t))}function it(e,t,n){const r=Be(t),i=Ie(t),s="fixed"===n,a=Ke(e,!0,s,t);let o={scrollLeft:0,scrollTop:0};const l=pe(0);if(r||!r&&!s)if(("body"!==Le(t)||Oe(i))&&(o=He(t)),r){const e=Ke(t,!0,s,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&(l.x=tt(i));return{x:a.left+o.scrollLeft-l.x,y:a.top+o.scrollTop-l.y,width:a.width,height:a.height}}function st(e,t){return Be(e)&&"fixed"!==Fe(e).position?t?t(e):e.offsetParent:null}function at(e,t){const n=Se(e);if(!Be(e)||et(e))return n;let r=st(e,t);for(;r&&qe(r)&&"static"===Fe(r).position;)r=st(r,t);return r&&("html"===Le(r)||"body"===Le(r)&&"static"===Fe(r).position&&!De(r))?n:r||function(e){let t=We(e);for(;Be(t)&&!Ze(t);){if(De(t))return t;t=We(t)}return null}(e)||n}const ot={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s="fixed"===i,a=Ie(r),o=!!t&&et(t.floating);if(r===a||o&&s)return n;let l={scrollLeft:0,scrollTop:0},c=pe(1);const h=pe(0),g=Be(r);if((g||!g&&!s)&&(("body"!==Le(r)||Oe(a))&&(l=He(r)),Be(r))){const e=Ke(r);c=Ye(r),h.x=e.x+r.clientLeft,h.y=e.y+r.clientTop}return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+h.x,y:n.y*c.y-l.scrollTop*c.y+h.y}},getDocumentElement:Ie,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const s=[..."clippingAncestors"===n?function(e,t){const n=t.get(e);if(n)return n;let r=Ve(e,[],!1).filter(e=>Ce(e)&&"body"!==Le(e)),i=null;const s="fixed"===Fe(e).position;let a=s?We(e):e;for(;Ce(a)&&!Ze(a);){const t=Fe(a),n=De(a);n||"fixed"!==t.position||(i=null),(s?!n&&!i:!n&&"static"===t.position&&i&&["absolute","fixed"].includes(i.position)||Oe(a)&&!n&&rt(e,a))?r=r.filter(e=>e!==a):i=t,a=We(a)}return t.set(e,r),r}(t,this._c):[].concat(n),r],a=s.reduce((e,n)=>{const r=nt(t,n,i);return e.top=ge(r.top,e.top),e.right=he(r.right,e.right),e.bottom=he(r.bottom,e.bottom),e.left=ge(r.left,e.left),e},nt(t,s[0],i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:at,getElementRects:async function(e){const t=this.getOffsetParent||at,n=this.getDimensions;return{reference:it(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,...await n(e.floating)}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=Ne(e);return{width:t,height:n}},getScale:Ye,isElement:Ce,isRTL:function(e){return"rtl"===Fe(e).direction}},lt=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:o,platform:l,elements:c}=t,{mainAxis:h=!0,crossAxis:g=!0,fallbackPlacements:u,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:f=!0,...m}=be(e,t);if(null!=(n=s.arrow)&&n.alignmentOffset)return{};const w=xe(i),b=xe(o)===o,x=await(null==l.isRTL?void 0:l.isRTL(c.floating)),k=u||(b||!f?[Re(o)]:function(e){const t=Re(e);return[ze(e),t,ze(t)]}(o));u||"none"===p||k.push(...function(e,t,n,r){const i=ke(e);let s=function(e,t,n){const r=["left","right"],i=["right","left"],s=["top","bottom"],a=["bottom","top"];switch(e){case"top":case"bottom":return n?t?i:r:t?r:i;case"left":case"right":return t?s:a;default:return[]}}(xe(e),"start"===n,r);return i&&(s=s.map(e=>e+"-"+i),t&&(s=s.concat(s.map(ze)))),s}(o,f,p,x));const y=[o,...k],v=await Ae(t,m),_=[];let $=(null==(r=s.flip)?void 0:r.overflows)||[];if(h&&_.push(v[w]),g){const e=function(e,t,n){void 0===n&&(n=!1);const r=ke(e),i=$e(e),s=ve(i);let a="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Re(a)),[a,Re(a)]}(i,a,x);_.push(v[e[0]],v[e[1]])}if($=[...$,{placement:i,overflows:_}],!_.every(e=>e<=0)){var z,R;const e=((null==(z=s.flip)?void 0:z.index)||0)+1,t=y[e];if(t)return{data:{index:e,overflows:$},reset:{placement:t}};let n=null==(R=$.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:R.placement;if(!n)switch(d){case"bestFit":{var T;const e=null==(T=$.map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:T[0];e&&(n=e);break}case"initialPlacement":n=o}if(i!==n)return{reset:{placement:n}}}return{}}}};var ct;function ht(e,t,n){if(!e.s){if(n instanceof ut){if(!n.s)return void(n.o=ht.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(ht.bind(null,e,t),ht.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var gt=function(t){try{t.preventDefault();var n=t.target;if(!yt.url)return console.error("LangChat Chat Widget: No URL provided"),yt.disableErrorAlert||alert("Could not send chat message: No URL provided"),Promise.resolve();var r=document.getElementById("langchat-chat-widget__submit");r.setAttribute("disabled","");var i=new Headers;i.append("Content-Type","application/json"),i.append("Accept","text/event-stream"),i.append("Authorization","Bearer "+yt.apiKey);var s=n.elements.message.value,a=e({},yt.user,{messages:[{role:"user",content:s}],threadId:yt.threadId,timestamp:Date.now()});return Promise.resolve(pt(s,a.timestamp,"user")).then(function(){function e(){return r.removeAttribute("disabled"),!1}n.reset(),_t.prepend(zt);var t=function(e,t){try{var n=Promise.resolve(fetch(yt.url,{method:"POST",headers:i,body:JSON.stringify(a)})).then(function(e){return zt.remove(),Promise.resolve(Et(e)).then(function(){})})}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}(0,function(e){zt.remove(),console.error("LangChat Chat Widget:",e),yt.disableErrorAlert||alert("Could not send message: "+e.message)});return t&&t.then?t.then(e):e()})}catch(t){return Promise.reject(t)}},ut=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var s=1&i?t:n;if(s){try{ht(r,1,s(this.v))}catch(e){ht(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?ht(r,1,t?t(i):i):n?ht(r,1,n(i)):ht(r,2,i)}catch(e){ht(r,2,e)}},r},e}();function dt(e){return e instanceof ut&&1&e.s}var pt=function(e,t,n){try{var r=document.createElement("div");r.classList.add("langchat-chat-widget__message"),r.classList.add("langchat-chat-widget__message--"+n),r.id="langchat-chat-widget__message--"+n+"--"+t;var i=document.createElement("p");return Promise.resolve(ce(e,{renderer:xt})).then(function(e){i.innerHTML=e,r.appendChild(i);var n=document.createElement("p");n.classList.add("langchat-chat-widget__message-timestamp"),n.textContent=("0"+new Date(t).getHours()).slice(-2)+":"+("0"+new Date(t).getMinutes()).slice(-2),r.appendChild(n),_t.prepend(r)})}catch(e){return Promise.reject(e)}},ft="langchat-web-sdk",mt="langchat-button-open",wt="langchat-button-close",bt="langchat-chat-widget__container",xt=new ce.Renderer,kt=xt.link;xt.link=function(e,t,n){return kt.call(xt,e,t,n).replace(/^<a /,'<a target="_blank" rel="nofollow" ')};var yt=e({element:null,url:"",apiKey:"",threadId:null,user:{},greetingMessage:null,disableErrorAlert:!1},null==(ct=window.langchatChatWidget)?void 0:ct.config),vt=function(){},_t=document.createElement("div");_t.id="langchat-chat-widget__messages_history";var $t=document.createElement("div");$t.id="langchat-chat-widget__backdrop";var zt=document.createElement("div");function Rt(e){document.getElementById(mt).style.display="none",document.getElementById(wt).style.display="block";var t=document.getElementById(bt);t.style.display="block",document.getElementById("langchat-chat-widget__title_text").innerText="LangChat聊天助手",document.getElementById("langchat-chat-widget__copyright").innerText="LangChat",document.getElementById("langchat-chat-widget__body").prepend(_t),yt.greetingMessage&&0===_t.children.length&&pt(yt.greetingMessage,Date.now(),"system");var n=document.getElementById("langchat-chat-widget__btn");vt=function(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:o="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,c=Ue(e),h=i||s?[...c?Ve(c):[],...Ve(t)]:[];h.forEach(e=>{i&&e.addEventListener("scroll",n,{passive:!0}),s&&e.addEventListener("resize",n)});const g=c&&o?function(e,t){let n,r=null;const i=Ie(e);function s(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function a(o,l){void 0===o&&(o=!1),void 0===l&&(l=1),s();const{left:c,top:h,width:g,height:u}=e.getBoundingClientRect();if(o||t(),!g||!u)return;const d={rootMargin:-de(h)+"px "+-de(i.clientWidth-(c+g))+"px "+-de(i.clientHeight-(h+u))+"px "+-de(c)+"px",threshold:ge(0,he(1,l))||1};let p=!0;function f(e){const t=e[0].intersectionRatio;if(t!==l){if(!p)return a();t?a(!1,t):n=setTimeout(()=>{a(!1,1e-7)},100)}p=!1}try{r=new IntersectionObserver(f,{...d,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(f,d)}r.observe(e)}(!0),s}(c,n):null;let u,d=-1,p=null;a&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var e;null==(e=p)||e.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let f=l?Ke(e):null;return l&&function t(){const r=Ke(e);!f||r.x===f.x&&r.y===f.y&&r.width===f.width&&r.height===f.height||n(),f=r,u=requestAnimationFrame(t)}(),n(),()=>{var e;h.forEach(e=>{i&&e.removeEventListener("scroll",n),s&&e.removeEventListener("resize",n)}),null==g||g(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(u)}}(n,t,function(){var e;((e,t,n)=>{const r=new Map,i={platform:ot,...n},s={...i.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,o=s.filter(Boolean),l=await(null==a.isRTL?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:g}=Ee(c,r,l),u=r,d={},p=0;for(let n=0;n<o.length;n++){const{name:s,fn:f}=o[n],{x:m,y:w,data:b,reset:x}=await f({x:h,y:g,initialPlacement:r,placement:u,strategy:i,middlewareData:d,rects:c,platform:a,elements:{reference:e,floating:t}});h=null!=m?m:h,g=null!=w?w:g,d={...d,[s]:{...d[s],...b}},x&&p<=50&&(p++,"object"==typeof x&&(x.placement&&(u=x.placement),x.rects&&(c=!0===x.rects?await a.getElementRects({reference:e,floating:t,strategy:i}):x.rects),({x:h,y:g}=Ee(c,u,l))),n=-1)}return{x:h,y:g,placement:u,strategy:i,middlewareData:d}})(e,t,{...i,platform:s})})(n,t,{placement:"top-start",middleware:[lt(),(e={crossAxis:!0,padding:8},void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:o={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=be(e,t),c={x:n,y:r},h=await Ae(t,l),g=_e(xe(i)),u=ye(g);let d=c[u],p=c[g];s&&(d=we(d+h["y"===u?"top":"left"],d,d-h["y"===u?"bottom":"right"])),a&&(p=we(p+h["y"===g?"top":"left"],p,p-h["y"===g?"bottom":"right"]));const f=o.fn({...t,[u]:d,[g]:p});return{...f,data:{x:f.x-n,y:f.y-r}}}})],strategy:"fixed"}).then(function(e){var n=e.x,r=e.y;console.log(n,r),Object.assign(t.style,{left:n-350+"px",top:r-10+"px"})})}),document.getElementById("langchat-chat-widget__form").addEventListener("submit",gt)}function Tt(){document.getElementById(mt).style.display="block",document.getElementById(wt).style.display="none",$t.remove(),document.getElementById(bt).style.display="none",vt(),vt=function(){}}zt.id="langchat-chat-widget__thinking_bubble",zt.innerHTML='\n <span class="circle"></span>\n <span class="circle"></span>\n <span class="circle"></span>\n ';var Et=function(e){try{var n,r,i=function(e){var t,r;if(n)return e;yt.threadId=null!=(t=null!=(r=yt.threadId)?r:s)?t:""!==o?o:null};if(!e.body)return console.error("LangChat Chat Widget: Streamed response has no body",e),yt.disableErrorAlert||alert("Received a streamed response but no body was found. Please make sure the API response is configured correctly."),Promise.resolve();var s=e.headers.get("x-thread-id"),a="",o="",l=Date.now(),c=e.body.getReader(),h=function(e,t,n){for(var r;;){var i=e();if(dt(i)&&(i=i.v),!i)return s;if(i.then){r=0;break}var s=n();if(s&&s.then){if(!dt(s)){r=1;break}s=s.s}if(t){var a=t();if(a&&a.then&&!dt(a)){r=2;break}}}var o=new ut,l=ht.bind(null,o,2);return(0===r?i.then(h):1===r?s.then(c):a.then(g)).then(void 0,l),o;function c(r){s=r;do{if(t&&(a=t())&&a.then&&!dt(a))return void a.then(g).then(void 0,l);if(!(i=e())||dt(i)&&!i.v)return void ht(o,1,s);if(i.then)return void i.then(h).then(void 0,l);dt(s=n())&&(s=s.v)}while(!s||!s.then);s.then(c).then(void 0,l)}function h(e){e?(s=n())&&s.then?s.then(c).then(void 0,l):c(s):ht(o,1,s)}function g(){(i=e())?i.then?i.then(h).then(void 0,l):h(i):ht(o,1,s)}}(function(){return!(r||n)},void 0,function(){return Promise.resolve(c.read()).then(function(e){var i=e.value;if(!e.done&&void 0!==i){for(var s,o=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return t(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}(e))){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}((new TextDecoder).decode(i,{stream:!0}).split("\n"));!(s=o()).done;){var c=s.value;if(c.startsWith("data:{")||c.startsWith("{")){var h="";c.startsWith("data:{")&&(h=c.slice(5).trim()),c.startsWith("{")&&(h=c.trim());try{var g=JSON.parse(h).choices[0];if("STOP"===g.finishReason)return void(n=1);a+=g.delta.content}catch(e){console.error("Failed to parse JSON:",e)}}}return Promise.resolve(function(e,t,n){try{var r=_t.querySelector("#langchat-chat-widget__message--"+n+"--"+t);return Promise.resolve(function(){if(r){var i=r.querySelector("p");return Promise.resolve(ce(e,{renderer:xt})).then(function(e){i.innerHTML=e})}return Promise.resolve(pt(e,t,n)).then(function(){})}())}catch(e){return Promise.reject(e)}}(a,l,"system")).then(function(){})}r=1})});return Promise.resolve(h&&h.then?h.then(i):i(h))}catch(e){return Promise.reject(e)}},At={open:Rt,close:Tt,config:yt,init:function(){try{var e=null;null==yt.element?null==(e=document.getElementById(ft))&&((e=document.createElement("div")).id=ft,document.body.appendChild(e)):e=yt.element,e.innerHTML='<div id="langchat-chat-widget__container"><div id="langchat-chat-widget__header"><div id="langchat-chat-widget__title"><svg height="3em" id="langchat-chat-widget__title_icon" viewBox="0 0 24 24" width="3em" xmlns="http://www.w3.org/2000/svg"><path d="M17.753 14a2.25 2.25 0 0 1 2.25 2.25v.904A3.75 3.75 0 0 1 18.696 20c-1.565 1.344-3.806 2-6.696 2s-5.128-.656-6.69-2a3.75 3.75 0 0 1-1.306-2.843v-.908A2.25 2.25 0 0 1 6.254 14zm0 1.5h-11.5a.75.75 0 0 0-.75.75v.907c0 .655.287 1.278.784 1.706C7.545 19.945 9.441 20.5 12 20.5s4.458-.557 5.72-1.64a2.25 2.25 0 0 0 .783-1.707v-.905a.75.75 0 0 0-.75-.75M11.9 2.006L12 2a.75.75 0 0 1 .743.648l.007.102l-.001.749h3.5a2.25 2.25 0 0 1 2.25 2.25v4.505a2.25 2.25 0 0 1-2.25 2.25h-8.5a2.25 2.25 0 0 1-2.25-2.25V5.75A2.25 2.25 0 0 1 7.75 3.5l3.5-.001V2.75a.75.75 0 0 1 .649-.743L12 2zM16.25 5h-8.5a.75.75 0 0 0-.75.75v4.504c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75V5.75a.75.75 0 0 0-.75-.75m-6.5 1.5a1.25 1.25 0 1 1 0 2.498a1.25 1.25 0 0 1 0-2.498m4.492 0a1.25 1.25 0 1 1 0 2.498a1.25 1.25 0 0 1 0-2.498"/></svg><span id="langchat-chat-widget__title_text"></span></div></div><div id="langchat-chat-widget__body"><form id="langchat-chat-widget__form"><input aria-label="Message" autocomplete="off" id="langchat-chat-widget__input" name="message" placeholder="Ask me a question…" required type="text"><button id="langchat-chat-widget__submit" type="submit"><svg height="26" viewBox="0 0 26 26" width="26" xmlns="http://www.w3.org/2000/svg"><g fill="none"><path d="M24 0v24H0V0zM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"></path><path d="m21.433 4.861l-6 15.5a1 1 0 0 1-1.624.362l-3.382-3.235l-2.074 2.073a.5.5 0 0 1-.853-.354v-4.519L2.309 9.723a1 1 0 0 1 .442-1.691l17.5-4.5a1 1 0 0 1 1.181 1.329ZM19 6.001L8.032 13.152l1.735 1.66L19 6Z" fill="currentColor"></path></g></svg></button></form><div id="langchat-chat-widget__bottom"><a href="https://github.com/tycoding/langchat" id="langchat-chat-widget__branding" target="_blank">Powered by <span id="langchat-chat-widget__copyright">LangChat</span></a></div></div></div><div data-langchat-chat-widget-button id="langchat-chat-widget__btn"><svg class="icon" height="48" id="langchat-button-open" p-id="16714" t="1723177956363" version="1.1" viewBox="0 0 1024 1024" width="48" xmlns="http://www.w3.org/2000/svg"><path d="M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z" fill="#1972F5" p-id="16715"></path><path d="M508.76416 286.72c-134.36928 0-242.52416 94.6176-242.52416 211.29216a207.36 207.36 0 0 0 103.936 174.08v65.06496a13.53728 13.53728 0 0 0 13.53728 14.336 16.384 16.384 0 0 0 6.7584-1.67936l65.88416-43.95008a261.55008 261.55008 0 0 0 51.52768 4.21888c134.41024 0 242.56512-94.6176 242.56512-211.29216 0.83968-117.4528-108.1344-212.0704-241.68448-212.0704z m-109.03552 245.92384a28.672 28.672 0 1 1 28.672-28.672 28.50816 28.50816 0 0 1-28.672 28.672z m110.6944 0a28.672 28.672 0 1 1 28.672-28.672 29.63456 29.63456 0 0 1-28.65152 28.672z m106.496 0a28.672 28.672 0 1 1 28.672-28.672 29.04064 29.04064 0 0 1-28.672 28.672z m0 0" fill="#FFFFFF" p-id="16716"></path></svg><svg class="icon" height="48" id="langchat-button-close" p-id="6658" style="display: none" t="1723178083363" version="1.1" viewBox="0 0 1024 1024" width="48" xmlns="http://www.w3.org/2000/svg"><path d="M512 0c282.784 0 512 229.216 512 512s-229.216 512-512 512S0 794.784 0 512 229.216 0 512 0z m-133.952 335.648l-41.792 41.792L470.816 512l-134.56 134.56 41.792 41.792 134.56-134.56 133.952 133.952 41.792-41.792L554.4 512l133.952-133.952-41.792-41.792-133.952 133.952-134.56-134.56z" fill="#1972F5" p-id="6659"></path></svg></div>';var t=document.createElement("style");return t.innerHTML=":root{--langchat-chat-widget-bg-color:#fff;--langchat-chat-widget-border-color:#e2e2e2;--langchat-chat-widget-shadow:0 0 8rem 0 rgba(0,0,0,.1),0rem 2rem 4rem -3rem rgba(0,0,0,.5);--langchat-chat-widget-primary-color-text:#000;--langchat-chat-widget-secondary-color-text:#979797;--langchat-chat-widget-user-message-text-color:#fff;--langchat-chat-widget-user-message-bg-color:#2c91ed;--langchat-chat-widget-system-message-text-color:#000;--langchat-chat-widget-system-message-bg-color:#e4e4e4;--langchat-chat-widget-primary-color:#2c91ed;--langchat-chat-widget-header-height:4rem;--langchat-chat-widget-button-transition:background-color 0.2s ease-in-out,opacity 0.2s ease-in-out,transform 0.2s ease-in-out;--langchat-chat-widget-title-weight:600;--langchat-chat-widget-button-weight:500;--langchat-chat-widget-border-radius:1rem}@media (prefers-color-scheme:dark){:root{--langchat-chat-widget-bg-color:#2d2d30;--langchat-chat-widget-border-color:#424244;--langchat-chat-widget-shadow:0 0 8rem 0 rgba(0,0,0,.1),0rem 2rem 4rem -3rem rgba(0,0,0,.5);--langchat-chat-widget-primary-color-text:#fff;--langchat-chat-widget-secondary-color-text:#818183;--langchat-chat-widget-user-message-text-color:#fff;--langchat-chat-widget-user-message-bg-color:#2c91ed;--langchat-chat-widget-system-message-text-color:#fff;--langchat-chat-widget-system-message-bg-color:#424244}}[data-theme=light]{--langchat-chat-widget-bg-color:#fff;--langchat-chat-widget-border-color:#e2e2e2;--langchat-chat-widget-shadow:0 0 8rem 0 rgba(0,0,0,.1),0rem 2rem 4rem -3rem rgba(0,0,0,.5);--langchat-chat-widget-primary-color-text:#000;--langchat-chat-widget-secondary-color-text:#979797;--langchat-chat-widget-user-message-text-color:#fff;--langchat-chat-widget-user-message-bg-color:#2c91ed;--langchat-chat-widget-system-message-text-color:#000;--langchat-chat-widget-system-message-bg-color:#e4e4e4}[data-theme=dark]{--langchat-chat-widget-bg-color:#2d2d30;--langchat-chat-widget-border-color:#424244;--langchat-chat-widget-shadow:0 0 8rem 0 rgba(0,0,0,.1),0rem 2rem 4rem -3rem rgba(0,0,0,.5);--langchat-chat-widget-primary-color-text:#fff;--langchat-chat-widget-secondary-color-text:#818183;--langchat-chat-widget-user-message-text-color:#fff;--langchat-chat-widget-user-message-bg-color:#2c91ed;--langchat-chat-widget-system-message-text-color:#fff;--langchat-chat-widget-system-message-bg-color:#424244}#langchat-chat-widget__container{background-color:var(--langchat-chat-widget-bg-color);border-radius:var(--langchat-chat-widget-border-radius);bottom:85px;box-shadow:var(--langchat-chat-widget-shadow);box-sizing:border-box;color:var(--langchat-chat-widget-primary-color-text);display:none;font-family:inherit;font-size:1rem;height:40rem;opacity:1;overflow:hidden;position:fixed;right:24px;transform:scale(1);transform-origin:bottom right;transition:transform .3s ease-out,opacity .3s ease-out;width:25rem;z-index:9999}#langchat-chat-widget__btn{align-items:center;bottom:28px;cursor:pointer;display:flex;justify-content:center;position:absolute;right:28px}#langchat-chat-widget__container *{box-sizing:border-box}#langchat-chat-widget__container :focus{outline:none}#langchat-chat-widget__backdrop{background-color:transparent;box-sizing:border-box;height:100vh;left:0;position:fixed;top:0;width:100vw;z-index:9998}#langchat-chat-widget__header{align-items:center;background-color:#1972f5!important;color:#fff;display:flex;height:var(--langchat-chat-widget-header-height);justify-content:space-between;padding:1rem}#langchat-chat-widget__title{align-items:center;display:flex;font-weight:var(--langchat-chat-widget-title-weight);justify-content:center;width:60%}#langchat-chat-widget__title_icon{margin-right:.2rem}#langchat-chat-widget__title_icon path{fill:var(--langchat-chat-widget-bg-color)}#langchat-chat-widget__title_text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%}#langchat-chat-widget__bottom{margin-top:7px;text-align:center}#langchat-chat-widget__branding{color:#898686;font-size:.75rem;text-decoration:none}#langchat-chat-widget__branding>span{color:#898686}#langchat-chat-widget__body{box-shadow:inset 0 2rem 2rem -2rem rgba(0,0,0,.05),inset 0 -2rem 2rem -2rem rgba(0,0,0,.05);display:flex;flex-direction:column;height:calc(100% - var(--langchat-chat-widget-header-height));padding:.6rem 1rem .5rem;position:relative;width:100%}#langchat-chat-widget__messages_history{-ms-overflow-style:none;display:flex;flex-direction:column-reverse;flex-grow:1;overflow-y:auto;scrollbar-width:none}#langchat-chat-widget__messages_history::-webkit-scrollbar{display:none}#langchat-chat-widget__messages_history .langchat-chat-widget__message{animation:fade-in .75s;border-radius:var(--langchat-chat-widget-border-radius);margin-bottom:.5rem;max-width:85%;padding:.5rem 1rem}#langchat-chat-widget__messages_history p{word-wrap:break-word;margin:0}#langchat-chat-widget__messages_history img{max-width:100%;-o-object-fit:cover;object-fit:cover}#langchat-chat-widget__messages_history code{display:inline-block;max-width:100%;overflow-x:auto;vertical-align:bottom}#langchat-chat-widget__messages_history\n.langchat-chat-widget__message\n.langchat-chat-widget__message-timestamp{font-size:.8rem;margin-top:.3rem;opacity:.5}#langchat-chat-widget__messages_history\n.langchat-chat-widget__message.langchat-chat-widget__message--system{align-self:flex-start;background-color:var(--langchat-chat-widget-system-message-bg-color);border-radius:1.125rem 1.125rem 1.125rem 0}#langchat-chat-widget__messages_history\n.langchat-chat-widget__message.langchat-chat-widget__message--system\np{color:var(--langchat-chat-widget-system-message-text-color)}#langchat-chat-widget__messages_history\n.langchat-chat-widget__message.langchat-chat-widget__message--user{align-self:flex-end;background-color:var(--langchat-chat-widget-user-message-bg-color);border-radius:1.125rem 1.125rem 0 1.125rem}#langchat-chat-widget__messages_history\n.langchat-chat-widget__message.langchat-chat-widget__message--user\np{color:var(--langchat-chat-widget-user-message-text-color)}#langchat-chat-widget__messages_history\n.langchat-chat-widget__message.langchat-chat-widget__message--user\n.langchat-chat-widget__message-timestamp{text-align:right}@keyframes fade-in{0%{opacity:0}to{opacity:1}}#langchat-chat-widget__thinking_bubble{align-items:center;animation:fade-in .75s;background-color:var(--langchat-chat-widget-system-message-bg-color);border-radius:var(--langchat-chat-widget-border-radius);display:flex;justify-content:space-between;margin-bottom:.5rem;padding:1rem;width:80px}#langchat-chat-widget__thinking_bubble .circle{animation:bounce 1.5s infinite;background-color:var(--langchat-chat-widget-system-message-text-color);border-radius:50%;height:12px;opacity:.5;width:12px}#langchat-chat-widget__thinking_bubble .circle:first-child{animation-delay:1s}#langchat-chat-widget__thinking_bubble .circle:nth-child(2){animation-delay:1.1s}#langchat-chat-widget__thinking_bubble .circle:nth-child(3){animation-delay:1.2s}@keyframes bounce{0%{transform:translateY(0)}20%{transform:translateY(-.5rem)}40%{transform:translateY(0)}to{transform:translateY(0)}}#langchat-chat-widget__form{display:flex;gap:.5rem;margin-bottom:0;margin-top:1rem;position:relative;width:100%}#langchat-chat-widget__input{background:none;border:1px solid var(--langchat-chat-widget-border-color);border-radius:23px;color:inherit;flex-grow:1;font:inherit;padding:.5rem 1rem;resize:none}#langchat-chat-widget__input:focus{box-shadow:none;outline:none}#langchat-chat-widget__submit{align-items:center;background-color:transparent;border:none;border-radius:50%;color:inherit;color:var(--langchat-chat-widget-primary-color);cursor:pointer;display:flex;justify-content:center;line-height:2rem;min-height:2rem;position:relative;transition:var(--langchat-chat-widget-button-transition)}#langchat-chat-widget__submit:hover{transform:scale(1.05);transition-duration:0s}#langchat-chat-widget__submit:active{transform:scale(.95);transition-duration:0s}#langchat-chat-widget__submit[disabled]{background-color:var(--langchat-chat-widget-border-color);cursor:default;opacity:.5}",document.head.insertBefore(t,document.head.firstChild),Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){var e,t;null==(e=document.getElementById(mt))||e.addEventListener("click",Rt),null==(t=document.getElementById(wt))||t.addEventListener("click",Tt)})}catch(e){return Promise.reject(e)}}};window.langchatChatWidget=At;export{At as default};
- //# sourceMappingURL=index.module.js.map
|