UNPKG

ai-client-kit

Version:

适用于任意前端框架的 AI 集成套件,支持多模型接入、聊天面板、Function Calling 等。

891 lines 172 kB
const xs = "button{outline:0;border:0;display:flex;justify-content:center;align-items:center;cursor:pointer}button.icon{padding:4px}button.text{padding:0 12px;height:28px}button.square{border-radius:6px}button.circle{border-radius:50%}button.primary{background-color:#0000000a}button.plain{background-color:transparent}button.error{background-color:#ff4d4f;color:#fff}button.primary:hover{background-color:#0000000f}button.plain:hover{background-color:#0000000a}button.error:hover{background-color:#ff7875}button[data-action=copy] .copied-text{display:none}button[data-action=copy].copied .copied-text{display:block}button[data-action=copy].copied svg{display:none}", ws = ".tooltip{position:relative}.tooltip .tooltip-text{visibility:hidden;opacity:0;background-color:#000000b3;color:#fff;border-radius:4px;padding:4px 8px;position:absolute;z-index:1;white-space:nowrap;font-size:12px;transition:opacity .3s}.tooltip .tooltip-text.top-left{bottom:115%;right:0}.tooltip .tooltip-text.top-right{bottom:115%;left:0}.tooltip .tooltip-text.bottom-left{top:115%;right:0}.tooltip .tooltip-text.bottom-right{top:115%;left:0}.tooltip:hover .tooltip-text{visibility:visible;opacity:1}", Ts = ".popup{position:absolute;top:0;left:0;width:100%;height:100%;background-color:#00000080;display:none;align-items:flex-end;z-index:1000}.popup .popup-content-container{background-color:#fff;border-radius:8px 8px 0 0;width:100%;position:relative;transform:translateY(100%);transition:transform .3s ease-in-out}.popup.active .popup-content-container{transform:translateY(0)}.popup-header{display:flex;justify-content:space-between;align-items:center;padding:12px}.popup-header button{font-size:20px;width:20px;height:20px}.popup-title{font-size:14px;font-weight:700}.popup-content{height:300px;overflow-y:auto;padding:0 12px}", ks = ".alert{position:absolute;left:50%;transform:translate(-50%);background-color:#fff;border-radius:8px;box-shadow:0 6px 16px #00000014,0 3px 6px -4px #0000001f,0 9px 28px 8px #0000000d;z-index:1000;pointer-events:all;padding:9px 12px;animation:slide 3s ease-in-out forwards;font-size:12px;white-space:nowrap}@keyframes slide{0%{top:0;opacity:0}10%{top:50px;opacity:1}75%{top:50px;opacity:1}to{top:0;opacity:0}}", bs = "select{border:0;font-size:12px;cursor:pointer;width:100px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}", Rs = '.loading-dots{font-weight:700;margin-left:3px}.loading-dots:after{content:"";animation:typing 1.5s infinite}@keyframes typing{0%{content:"."}33%{content:".."}66%{content:"..."}to{content:"."}}', Ps = ".app-container{height:100%;display:flex;flex-direction:column;background:#fff}.bottom-container{margin:12px}.action-bar{margin-bottom:12px;display:flex;align-items:center;gap:12px}.user-input-container{padding:12px;border-radius:16px;border:1px solid rgba(114,118,139,.16);box-shadow:0 10px 30px #0003}.user-input{border:0;resize:none;width:100%;font-size:14px;line-height:1.5}.button-wrap{display:flex;justify-content:flex-end;align-items:center;gap:12px}.messages-container{flex:1;padding:12px 12px calc(100% - 79px);overflow-x:hidden;overflow-y:auto}.message{max-width:80%;margin-bottom:12px;font-size:14px;line-height:1.5}.content-container{padding:0 14px;border-radius:8px;word-wrap:break-word;overflow-x:auto}.message.user{margin-left:auto}.message.user .content-container{background:#e3f2fd}.message.assistant{margin-right:auto}.message.assistant .content-container{background:#f1f1f1}.button-container{display:flex;margin-top:4px}.button-container button{height:26px;display:flex;align-items:center}.message.user .button-container{justify-content:flex-end}.message.assistant .button-container{justify-content:flex-start}.history-item{padding:10px;border-bottom:1px solid #eee;cursor:pointer;display:flex;justify-content:space-between;align-items:center}.history-item:last-child{border:0}.history-item button{display:none}.history-item:hover button{display:block}.history-item.active{background-color:#f0f0f0;border-left:4px solid #007bff;border-bottom:0}.history-item-container{width:calc(100% - 60px)}.history-time{font-size:12px;color:#666}.history-content{margin-top:5px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.submit-icon,.stop-icon{width:28px;height:28px;display:flex;justify-content:center;align-items:center;background-color:#000;border-radius:50%;color:#fff}.close-icon{transform:translateY(-1px)}", Es = "*{box-sizing:border-box}textarea{padding:0}textarea:focus-visible,select:focus-visible{outline:0}.flex{display:flex}.margin-left-auto{margin-left:auto}:host{position:relative}", $s = [ xs, ws, Ts, ks, bs, Rs, Ps, Es ].join(` `), Wn = document.createElement("template"); Wn.innerHTML = ` <style>${$s}</style> <div class="app-container"> <div class="messages-container" id="messages-container"></div> <div class="bottom-container"> <div class="action-bar"> <select id="model-select"></select> <button class="icon square plain tooltip margin-left-auto" id="create-button" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 1024 1024"><path d="M597.333 128v85.333H170.667v571.094l75.221-59.094h607.445V426.667h85.334V768A42.667 42.667 0 0 1 896 810.667H275.413L85.333 960V170.667A42.667 42.667 0 0 1 128 128h469.333zm213.334 0V0H896v128h128v85.333H896v128h-85.333v-128h-128V128h128z"/></svg> <span class="tooltip-text bottom-left">新聊天</span> </button> <button class="icon square plain tooltip" id="history-button" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 1024 1024"><path d="M512 85.333c235.648 0 426.667 191.019 426.667 426.667S747.648 938.667 512 938.667a424.79 424.79 0 0 1-200.875-50.134L85.333 938.667 135.51 712.96A424.79 424.79 0 0 1 85.333 512C85.333 276.352 276.352 85.333 512 85.333zm0 85.334A341.333 341.333 0 0 0 170.667 512c0 56.96 13.909 111.701 40.106 160.683l14.934 27.904-27.99 125.696L323.5 798.379l27.861 14.89A339.413 339.413 0 0 0 512 853.333a341.333 341.333 0 1 0 0-682.666zm42.667 128V512h170.666v85.333h-256V298.667h85.334z"/></svg> <span class="tooltip-text bottom-left">历史聊天</span> </button> </div> <div class="user-input-container" id="user-input-container"> <textarea class="user-input" id="user-input" placeholder="和我聊天"></textarea> <div class="button-wrap"> <button class="icon square plain tooltip" id="submit-icon" type="button"> <div class="submit-icon"> <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"><path d="M9 16V6.414L5.707 9.707a1 1 0 1 1-1.414-1.414l5-5 .076-.068a1 1 0 0 1 1.338.068l5 5 .068.076a1 1 0 0 1-1.406 1.406l-.076-.068L11 6.414V16a1 1 0 1 1-2 0Z"/></svg> </div> <span class="tooltip-text top-left">发送 (↵)</span> </button> <button style="display: none;" class="icon square plain tooltip" id="stop-icon" type="button"> <div class="stop-icon"> <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"><path d="M4.5 5.75c0-.69.56-1.25 1.25-1.25h8.5c.69 0 1.25.56 1.25 1.25v8.5c0 .69-.56 1.25-1.25 1.25h-8.5c-.69 0-1.25-.56-1.25-1.25v-8.5Z"/></svg> </div> <span class="tooltip-text top-left">停止</span> </button> </div> </div> </div> </div> <div class="popup" id="history-popup"> <div class="popup-content-container"> <div class="popup-header"> <div class="popup-title">历史聊天</div> <button class="icon circle plain" id="history-popup-close" type="button"> <span class="close-icon">x</span> </button> </div> <div class="popup-content" id="history-popup-content"></div> </div> </div> `; function jt() { return { async: !1, breaks: !1, extensions: null, gfm: !0, hooks: null, pedantic: !1, renderer: null, silent: !1, tokenizer: null, walkTokens: null }; } var pe = jt(); function jn(r) { pe = r; } var Oe = { exec: () => null }; function E(r, e = "") { let t = typeof r == "string" ? r : r.source, s = { replace: (n, i) => { let a = typeof i == "string" ? i : i.source; return a = a.replace(H.caret, "$1"), t = t.replace(n, a), s; }, getRegex: () => new RegExp(t, e) }; return s; } var H = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceTabs: /^\t+/, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] /, listReplaceTask: /^\[[ xX]\] +/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (r) => new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}#`), htmlBeginRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}<(?:[a-z].*>|!--)`, "i") }, Ms = /^(?:[ \t]*(?:\n|$))+/, Ss = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, As = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, De = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Os = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, Ft = /(?:[*+-]|\d{1,9}[.)])/, Fn = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, Bn = E(Fn).replace(/bull/g, Ft).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), vs = E(Fn).replace(/bull/g, Ft).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), Bt = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Ds = /^[^\n]+/, Gt = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Ns = E(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Gt).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), _s = E(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Ft).getRegex(), pt = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", qt = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Cs = E("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", qt).replace("tag", pt).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), Gn = E(Bt).replace("hr", De).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", pt).getRegex(), Is = E(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Gn).getRegex(), Vt = { blockquote: Is, code: Ss, def: Ns, fences: As, heading: Os, hr: De, html: Cs, lheading: Bn, list: _s, newline: Ms, paragraph: Gn, table: Oe, text: Ds }, rn = E("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", De).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", pt).getRegex(), Us = { ...Vt, lheading: vs, table: rn, paragraph: E(Bt).replace("hr", De).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", rn).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", pt).getRegex() }, zs = { ...Vt, html: E(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", qt).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: Oe, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: E(Bt).replace("hr", De).replace("heading", ` *#{1,6} *[^ ]`).replace("lheading", Bn).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, Ls = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ys = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, qn = /^( {2,}|\\)\n(?!\s*$)/, Hs = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, gt = /[\p{P}\p{S}]/u, Zt = /[\s\p{P}\p{S}]/u, Vn = /[^\s\p{P}\p{S}]/u, Ws = E(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Zt).getRegex(), Zn = /(?!~)[\p{P}\p{S}]/u, js = /(?!~)[\s\p{P}\p{S}]/u, Fs = /(?:[^\s\p{P}\p{S}]|~)/u, Bs = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g, Kn = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, Gs = E(Kn, "u").replace(/punct/g, gt).getRegex(), qs = E(Kn, "u").replace(/punct/g, Zn).getRegex(), Jn = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", Vs = E(Jn, "gu").replace(/notPunctSpace/g, Vn).replace(/punctSpace/g, Zt).replace(/punct/g, gt).getRegex(), Zs = E(Jn, "gu").replace(/notPunctSpace/g, Fs).replace(/punctSpace/g, js).replace(/punct/g, Zn).getRegex(), Ks = E("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, Vn).replace(/punctSpace/g, Zt).replace(/punct/g, gt).getRegex(), Js = E(/\\(punct)/, "gu").replace(/punct/g, gt).getRegex(), Qs = E(/^<(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(), Xs = E(qt).replace("(?:-->|$)", "-->").getRegex(), er = E("^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", Xs).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), at = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, tr = E(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", at).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Qn = E(/^!?\[(label)\]\[(ref)\]/).replace("label", at).replace("ref", Gt).getRegex(), Xn = E(/^!?\[(ref)\](?:\[\])?/).replace("ref", Gt).getRegex(), nr = E("reflink|nolink(?!\\()", "g").replace("reflink", Qn).replace("nolink", Xn).getRegex(), Kt = { _backpedal: Oe, anyPunctuation: Js, autolink: Qs, blockSkip: Bs, br: qn, code: Ys, del: Oe, emStrongLDelim: Gs, emStrongRDelimAst: Vs, emStrongRDelimUnd: Ks, escape: Ls, link: tr, nolink: Xn, punctuation: Ws, reflink: Qn, reflinkSearch: nr, tag: er, text: Hs, url: Oe }, sr = { ...Kt, link: E(/^!?\[(label)\]\((.*?)\)/).replace("label", at).getRegex(), reflink: E(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", at).getRegex() }, Ct = { ...Kt, emStrongRDelimAst: Zs, emStrongLDelim: qs, url: E(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/, text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/ }, rr = { ...Ct, br: E(qn).replace("{2,}", "*").getRegex(), text: E(Ct.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }, ze = { normal: Vt, gfm: Us, pedantic: zs }, Me = { normal: Kt, gfm: Ct, breaks: rr, pedantic: sr }, ir = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, an = (r) => ir[r]; function J(r, e) { if (e) { if (H.escapeTest.test(r)) return r.replace(H.escapeReplace, an); } else if (H.escapeTestNoEncode.test(r)) return r.replace(H.escapeReplaceNoEncode, an); return r; } function on(r) { try { r = encodeURI(r).replace(H.percentDecode, "%"); } catch { return null; } return r; } function ln(r, e) { let t = r.replace(H.findPipe, (i, a, o) => { let l = !1, c = a; for (; --c >= 0 && o[c] === "\\"; ) l = !l; return l ? "|" : " |"; }), s = t.split(H.splitPipe), n = 0; if (s[0].trim() || s.shift(), s.length > 0 && !s.at(-1)?.trim() && s.pop(), e) if (s.length > e) s.splice(e); else for (; s.length < e; ) s.push(""); for (; n < s.length; n++) s[n] = s[n].trim().replace(H.slashPipe, "|"); return s; } function Se(r, e, t) { let s = r.length; if (s === 0) return ""; let n = 0; for (; n < s && r.charAt(s - n - 1) === e; ) n++; return r.slice(0, s - n); } function ar(r, e) { if (r.indexOf(e[1]) === -1) return -1; let t = 0; for (let s = 0; s < r.length; s++) if (r[s] === "\\") s++; else if (r[s] === e[0]) t++; else if (r[s] === e[1] && (t--, t < 0)) return s; return t > 0 ? -2 : -1; } function cn(r, e, t, s, n) { let i = e.href, a = e.title || null, o = r[1].replace(n.other.outputLinkReplace, "$1"); s.state.inLink = !0; let l = { type: r[0].charAt(0) === "!" ? "image" : "link", raw: t, href: i, title: a, text: o, tokens: s.inlineTokens(o) }; return s.state.inLink = !1, l; } function or(r, e, t) { let s = r.match(t.other.indentCodeCompensation); if (s === null) return e; let n = s[1]; return e.split(` `).map((i) => { let a = i.match(t.other.beginningSpace); if (a === null) return i; let [o] = a; return o.length >= n.length ? i.slice(n.length) : i; }).join(` `); } var ot = class { options; rules; lexer; constructor(r) { this.options = r || pe; } space(r) { let e = this.rules.block.newline.exec(r); if (e && e[0].length > 0) return { type: "space", raw: e[0] }; } code(r) { let e = this.rules.block.code.exec(r); if (e) { let t = e[0].replace(this.rules.other.codeRemoveIndent, ""); return { type: "code", raw: e[0], codeBlockStyle: "indented", text: this.options.pedantic ? t : Se(t, ` `) }; } } fences(r) { let e = this.rules.block.fences.exec(r); if (e) { let t = e[0], s = or(t, e[3] || "", this.rules); return { type: "code", raw: t, lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2], text: s }; } } heading(r) { let e = this.rules.block.heading.exec(r); if (e) { let t = e[2].trim(); if (this.rules.other.endingHash.test(t)) { let s = Se(t, "#"); (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (t = s.trim()); } return { type: "heading", raw: e[0], depth: e[1].length, text: t, tokens: this.lexer.inline(t) }; } } hr(r) { let e = this.rules.block.hr.exec(r); if (e) return { type: "hr", raw: Se(e[0], ` `) }; } blockquote(r) { let e = this.rules.block.blockquote.exec(r); if (e) { let t = Se(e[0], ` `).split(` `), s = "", n = "", i = []; for (; t.length > 0; ) { let a = !1, o = [], l; for (l = 0; l < t.length; l++) if (this.rules.other.blockquoteStart.test(t[l])) o.push(t[l]), a = !0; else if (!a) o.push(t[l]); else break; t = t.slice(l); let c = o.join(` `), u = c.replace(this.rules.other.blockquoteSetextReplace, ` $1`).replace(this.rules.other.blockquoteSetextReplace2, ""); s = s ? `${s} ${c}` : c, n = n ? `${n} ${u}` : u; let d = this.lexer.state.top; if (this.lexer.state.top = !0, this.lexer.blockTokens(u, i, !0), this.lexer.state.top = d, t.length === 0) break; let g = i.at(-1); if (g?.type === "code") break; if (g?.type === "blockquote") { let y = g, x = y.raw + ` ` + t.join(` `), P = this.blockquote(x); i[i.length - 1] = P, s = s.substring(0, s.length - y.raw.length) + P.raw, n = n.substring(0, n.length - y.text.length) + P.text; break; } else if (g?.type === "list") { let y = g, x = y.raw + ` ` + t.join(` `), P = this.list(x); i[i.length - 1] = P, s = s.substring(0, s.length - g.raw.length) + P.raw, n = n.substring(0, n.length - y.raw.length) + P.raw, t = x.substring(i.at(-1).raw.length).split(` `); continue; } } return { type: "blockquote", raw: s, tokens: i, text: n }; } } list(r) { let e = this.rules.block.list.exec(r); if (e) { let t = e[1].trim(), s = t.length > 1, n = { type: "list", raw: "", ordered: s, start: s ? +t.slice(0, -1) : "", loose: !1, items: [] }; t = s ? `\\d{1,9}\\${t.slice(-1)}` : `\\${t}`, this.options.pedantic && (t = s ? t : "[*+-]"); let i = this.rules.other.listItemRegex(t), a = !1; for (; r; ) { let l = !1, c = "", u = ""; if (!(e = i.exec(r)) || this.rules.block.hr.test(r)) break; c = e[0], r = r.substring(c.length); let d = e[2].split(` `, 1)[0].replace(this.rules.other.listReplaceTabs, (F) => " ".repeat(3 * F.length)), g = r.split(` `, 1)[0], y = !d.trim(), x = 0; if (this.options.pedantic ? (x = 2, u = d.trimStart()) : y ? x = e[1].length + 1 : (x = e[2].search(this.rules.other.nonSpaceChar), x = x > 4 ? 1 : x, u = d.slice(x), x += e[1].length), y && this.rules.other.blankLine.test(g) && (c += g + ` `, r = r.substring(g.length + 1), l = !0), !l) { let F = this.rules.other.nextBulletRegex(x), C = this.rules.other.hrRegex(x), T = this.rules.other.fencesBeginRegex(x), Pe = this.rules.other.headingBeginRegex(x), ce = this.rules.other.htmlBeginRegex(x); for (; r; ) { let K = r.split(` `, 1)[0], ie; if (g = K, this.options.pedantic ? (g = g.replace(this.rules.other.listReplaceNesting, " "), ie = g) : ie = g.replace(this.rules.other.tabCharGlobal, " "), T.test(g) || Pe.test(g) || ce.test(g) || F.test(g) || C.test(g)) break; if (ie.search(this.rules.other.nonSpaceChar) >= x || !g.trim()) u += ` ` + ie.slice(x); else { if (y || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || T.test(d) || Pe.test(d) || C.test(d)) break; u += ` ` + g; } !y && !g.trim() && (y = !0), c += K + ` `, r = r.substring(K.length + 1), d = ie.slice(x); } } n.loose || (a ? n.loose = !0 : this.rules.other.doubleBlankLine.test(c) && (a = !0)); let P = null, A; this.options.gfm && (P = this.rules.other.listIsTask.exec(u), P && (A = P[0] !== "[ ] ", u = u.replace(this.rules.other.listReplaceTask, ""))), n.items.push({ type: "list_item", raw: c, task: !!P, checked: A, loose: !1, text: u, tokens: [] }), n.raw += c; } let o = n.items.at(-1); if (o) o.raw = o.raw.trimEnd(), o.text = o.text.trimEnd(); else return; n.raw = n.raw.trimEnd(); for (let l = 0; l < n.items.length; l++) if (this.lexer.state.top = !1, n.items[l].tokens = this.lexer.blockTokens(n.items[l].text, []), !n.loose) { let c = n.items[l].tokens.filter((d) => d.type === "space"), u = c.length > 0 && c.some((d) => this.rules.other.anyLine.test(d.raw)); n.loose = u; } if (n.loose) for (let l = 0; l < n.items.length; l++) n.items[l].loose = !0; return n; } } html(r) { let e = this.rules.block.html.exec(r); if (e) return { type: "html", block: !0, raw: e[0], pre: e[1] === "pre" || e[1] === "script" || e[1] === "style", text: e[0] }; } def(r) { let e = this.rules.block.def.exec(r); if (e) { let t = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", n = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3]; return { type: "def", tag: t, raw: e[0], href: s, title: n }; } } table(r) { let e = this.rules.block.table.exec(r); if (!e || !this.rules.other.tableDelimiter.test(e[2])) return; let t = ln(e[1]), s = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), n = e[3]?.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(` `) : [], i = { type: "table", raw: e[0], header: [], align: [], rows: [] }; if (t.length === s.length) { for (let a of s) this.rules.other.tableAlignRight.test(a) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(a) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(a) ? i.align.push("left") : i.align.push(null); for (let a = 0; a < t.length; a++) i.header.push({ text: t[a], tokens: this.lexer.inline(t[a]), header: !0, align: i.align[a] }); for (let a of n) i.rows.push(ln(a, i.header.length).map((o, l) => ({ text: o, tokens: this.lexer.inline(o), header: !1, align: i.align[l] }))); return i; } } lheading(r) { let e = this.rules.block.lheading.exec(r); if (e) return { type: "heading", raw: e[0], depth: e[2].charAt(0) === "=" ? 1 : 2, text: e[1], tokens: this.lexer.inline(e[1]) }; } paragraph(r) { let e = this.rules.block.paragraph.exec(r); if (e) { let t = e[1].charAt(e[1].length - 1) === ` ` ? e[1].slice(0, -1) : e[1]; return { type: "paragraph", raw: e[0], text: t, tokens: this.lexer.inline(t) }; } } text(r) { let e = this.rules.block.text.exec(r); if (e) return { type: "text", raw: e[0], text: e[0], tokens: this.lexer.inline(e[0]) }; } escape(r) { let e = this.rules.inline.escape.exec(r); if (e) return { type: "escape", raw: e[0], text: e[1] }; } tag(r) { let e = this.rules.inline.tag.exec(r); if (e) return !this.lexer.state.inLink && this.rules.other.startATag.test(e[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(e[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(e[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(e[0]) && (this.lexer.state.inRawBlock = !1), { type: "html", raw: e[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: !1, text: e[0] }; } link(r) { let e = this.rules.inline.link.exec(r); if (e) { let t = e[2].trim(); if (!this.options.pedantic && this.rules.other.startAngleBracket.test(t)) { if (!this.rules.other.endAngleBracket.test(t)) return; let i = Se(t.slice(0, -1), "\\"); if ((t.length - i.length) % 2 === 0) return; } else { let i = ar(e[2], "()"); if (i === -2) return; if (i > -1) { let a = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + i; e[2] = e[2].substring(0, i), e[0] = e[0].substring(0, a).trim(), e[3] = ""; } } let s = e[2], n = ""; if (this.options.pedantic) { let i = this.rules.other.pedanticHrefTitle.exec(s); i && (s = i[1], n = i[3]); } else n = e[3] ? e[3].slice(1, -1) : ""; return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(t) ? s = s.slice(1) : s = s.slice(1, -1)), cn(e, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: n && n.replace(this.rules.inline.anyPunctuation, "$1") }, e[0], this.lexer, this.rules); } } reflink(r, e) { let t; if ((t = this.rules.inline.reflink.exec(r)) || (t = this.rules.inline.nolink.exec(r))) { let s = (t[2] || t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), n = e[s.toLowerCase()]; if (!n) { let i = t[0].charAt(0); return { type: "text", raw: i, text: i }; } return cn(t, n, t[0], this.lexer, this.rules); } } emStrong(r, e, t = "") { let s = this.rules.inline.emStrongLDelim.exec(r); if (!(!s || s[3] && t.match(this.rules.other.unicodeAlphaNumeric)) && (!(s[1] || s[2]) || !t || this.rules.inline.punctuation.exec(t))) { let n = [...s[0]].length - 1, i, a, o = n, l = 0, c = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd; for (c.lastIndex = 0, e = e.slice(-1 * r.length + n); (s = c.exec(e)) != null; ) { if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i) continue; if (a = [...i].length, s[3] || s[4]) { o += a; continue; } else if ((s[5] || s[6]) && n % 3 && !((n + a) % 3)) { l += a; continue; } if (o -= a, o > 0) continue; a = Math.min(a, a + o + l); let u = [...s[0]][0].length, d = r.slice(0, n + s.index + u + a); if (Math.min(n, a) % 2) { let y = d.slice(1, -1); return { type: "em", raw: d, text: y, tokens: this.lexer.inlineTokens(y) }; } let g = d.slice(2, -2); return { type: "strong", raw: d, text: g, tokens: this.lexer.inlineTokens(g) }; } } } codespan(r) { let e = this.rules.inline.code.exec(r); if (e) { let t = e[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(t), n = this.rules.other.startingSpaceChar.test(t) && this.rules.other.endingSpaceChar.test(t); return s && n && (t = t.substring(1, t.length - 1)), { type: "codespan", raw: e[0], text: t }; } } br(r) { let e = this.rules.inline.br.exec(r); if (e) return { type: "br", raw: e[0] }; } del(r) { let e = this.rules.inline.del.exec(r); if (e) return { type: "del", raw: e[0], text: e[2], tokens: this.lexer.inlineTokens(e[2]) }; } autolink(r) { let e = this.rules.inline.autolink.exec(r); if (e) { let t, s; return e[2] === "@" ? (t = e[1], s = "mailto:" + t) : (t = e[1], s = t), { type: "link", raw: e[0], text: t, href: s, tokens: [{ type: "text", raw: t, text: t }] }; } } url(r) { let e; if (e = this.rules.inline.url.exec(r)) { let t, s; if (e[2] === "@") t = e[0], s = "mailto:" + t; else { let n; do n = e[0], e[0] = this.rules.inline._backpedal.exec(e[0])?.[0] ?? ""; while (n !== e[0]); t = e[0], e[1] === "www." ? s = "http://" + e[0] : s = e[0]; } return { type: "link", raw: e[0], text: t, href: s, tokens: [{ type: "text", raw: t, text: t }] }; } } inlineText(r) { let e = this.rules.inline.text.exec(r); if (e) { let t = this.lexer.state.inRawBlock; return { type: "text", raw: e[0], text: e[0], escaped: t }; } } }, ne = class It { tokens; options; state; tokenizer; inlineQueue; constructor(e) { this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || pe, this.options.tokenizer = this.options.tokenizer || new ot(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: !1, inRawBlock: !1, top: !0 }; let t = { other: H, block: ze.normal, inline: Me.normal }; this.options.pedantic ? (t.block = ze.pedantic, t.inline = Me.pedantic) : this.options.gfm && (t.block = ze.gfm, this.options.breaks ? t.inline = Me.breaks : t.inline = Me.gfm), this.tokenizer.rules = t; } static get rules() { return { block: ze, inline: Me }; } static lex(e, t) { return new It(t).lex(e); } static lexInline(e, t) { return new It(t).inlineTokens(e); } lex(e) { e = e.replace(H.carriageReturn, ` `), this.blockTokens(e, this.tokens); for (let t = 0; t < this.inlineQueue.length; t++) { let s = this.inlineQueue[t]; this.inlineTokens(s.src, s.tokens); } return this.inlineQueue = [], this.tokens; } blockTokens(e, t = [], s = !1) { for (this.options.pedantic && (e = e.replace(H.tabCharGlobal, " ").replace(H.spaceLine, "")); e; ) { let n; if (this.options.extensions?.block?.some((a) => (n = a.call({ lexer: this }, e, t)) ? (e = e.substring(n.raw.length), t.push(n), !0) : !1)) continue; if (n = this.tokenizer.space(e)) { e = e.substring(n.raw.length); let a = t.at(-1); n.raw.length === 1 && a !== void 0 ? a.raw += ` ` : t.push(n); continue; } if (n = this.tokenizer.code(e)) { e = e.substring(n.raw.length); let a = t.at(-1); a?.type === "paragraph" || a?.type === "text" ? (a.raw += ` ` + n.raw, a.text += ` ` + n.text, this.inlineQueue.at(-1).src = a.text) : t.push(n); continue; } if (n = this.tokenizer.fences(e)) { e = e.substring(n.raw.length), t.push(n); continue; } if (n = this.tokenizer.heading(e)) { e = e.substring(n.raw.length), t.push(n); continue; } if (n = this.tokenizer.hr(e)) { e = e.substring(n.raw.length), t.push(n); continue; } if (n = this.tokenizer.blockquote(e)) { e = e.substring(n.raw.length), t.push(n); continue; } if (n = this.tokenizer.list(e)) { e = e.substring(n.raw.length), t.push(n); continue; } if (n = this.tokenizer.html(e)) { e = e.substring(n.raw.length), t.push(n); continue; } if (n = this.tokenizer.def(e)) { e = e.substring(n.raw.length); let a = t.at(-1); a?.type === "paragraph" || a?.type === "text" ? (a.raw += ` ` + n.raw, a.text += ` ` + n.raw, this.inlineQueue.at(-1).src = a.text) : this.tokens.links[n.tag] || (this.tokens.links[n.tag] = { href: n.href, title: n.title }); continue; } if (n = this.tokenizer.table(e)) { e = e.substring(n.raw.length), t.push(n); continue; } if (n = this.tokenizer.lheading(e)) { e = e.substring(n.raw.length), t.push(n); continue; } let i = e; if (this.options.extensions?.startBlock) { let a = 1 / 0, o = e.slice(1), l; this.options.extensions.startBlock.forEach((c) => { l = c.call({ lexer: this }, o), typeof l == "number" && l >= 0 && (a = Math.min(a, l)); }), a < 1 / 0 && a >= 0 && (i = e.substring(0, a + 1)); } if (this.state.top && (n = this.tokenizer.paragraph(i))) { let a = t.at(-1); s && a?.type === "paragraph" ? (a.raw += ` ` + n.raw, a.text += ` ` + n.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : t.push(n), s = i.length !== e.length, e = e.substring(n.raw.length); continue; } if (n = this.tokenizer.text(e)) { e = e.substring(n.raw.length); let a = t.at(-1); a?.type === "text" ? (a.raw += ` ` + n.raw, a.text += ` ` + n.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : t.push(n); continue; } if (e) { let a = "Infinite loop on byte: " + e.charCodeAt(0); if (this.options.silent) { console.error(a); break; } else throw new Error(a); } } return this.state.top = !0, t; } inline(e, t = []) { return this.inlineQueue.push({ src: e, tokens: t }), t; } inlineTokens(e, t = []) { let s = e, n = null; if (this.tokens.links) { let o = Object.keys(this.tokens.links); if (o.length > 0) for (; (n = this.tokenizer.rules.inline.reflinkSearch.exec(s)) != null; ) o.includes(n[0].slice(n[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, n.index) + "[" + "a".repeat(n[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex)); } for (; (n = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; ) s = s.slice(0, n.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex); for (; (n = this.tokenizer.rules.inline.blockSkip.exec(s)) != null; ) s = s.slice(0, n.index) + "[" + "a".repeat(n[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex); let i = !1, a = ""; for (; e; ) { i || (a = ""), i = !1; let o; if (this.options.extensions?.inline?.some((c) => (o = c.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), !0) : !1)) continue; if (o = this.tokenizer.escape(e)) { e = e.substring(o.raw.length), t.push(o); continue; } if (o = this.tokenizer.tag(e)) { e = e.substring(o.raw.length), t.push(o); continue; } if (o = this.tokenizer.link(e)) { e = e.substring(o.raw.length), t.push(o); continue; } if (o = this.tokenizer.reflink(e, this.tokens.links)) { e = e.substring(o.raw.length); let c = t.at(-1); o.type === "text" && c?.type === "text" ? (c.raw += o.raw, c.text += o.text) : t.push(o); continue; } if (o = this.tokenizer.emStrong(e, s, a)) { e = e.substring(o.raw.length), t.push(o); continue; } if (o = this.tokenizer.codespan(e)) { e = e.substring(o.raw.length), t.push(o); continue; } if (o = this.tokenizer.br(e)) { e = e.substring(o.raw.length), t.push(o); continue; } if (o = this.tokenizer.del(e)) { e = e.substring(o.raw.length), t.push(o); continue; } if (o = this.tokenizer.autolink(e)) { e = e.substring(o.raw.length), t.push(o); continue; } if (!this.state.inLink && (o = this.tokenizer.url(e))) { e = e.substring(o.raw.length), t.push(o); continue; } let l = e; if (this.options.extensions?.startInline) { let c = 1 / 0, u = e.slice(1), d; this.options.extensions.startInline.forEach((g) => { d = g.call({ lexer: this }, u), typeof d == "number" && d >= 0 && (c = Math.min(c, d)); }), c < 1 / 0 && c >= 0 && (l = e.substring(0, c + 1)); } if (o = this.tokenizer.inlineText(l)) { e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (a = o.raw.slice(-1)), i = !0; let c = t.at(-1); c?.type === "text" ? (c.raw += o.raw, c.text += o.text) : t.push(o); continue; } if (e) { let c = "Infinite loop on byte: " + e.charCodeAt(0); if (this.options.silent) { console.error(c); break; } else throw new Error(c); } } return t; } }, lt = class { options; parser; constructor(r) { this.options = r || pe; } space(r) { return ""; } code({ text: r, lang: e, escaped: t }) { let s = (e || "").match(H.notSpaceStart)?.[0], n = r.replace(H.endingNewline, "") + ` `; return s ? '<pre><code class="language-' + J(s) + '">' + (t ? n : J(n, !0)) + `</code></pre> ` : "<pre><code>" + (t ? n : J(n, !0)) + `</code></pre> `; } blockquote({ tokens: r }) { return `<blockquote> ${this.parser.parse(r)}</blockquote> `; } html({ text: r }) { return r; } heading({ tokens: r, depth: e }) { return `<h${e}>${this.parser.parseInline(r)}</h${e}> `; } hr(r) { return `<hr> `; } list(r) { let e = r.ordered, t = r.start, s = ""; for (let a = 0; a < r.items.length; a++) { let o = r.items[a]; s += this.listitem(o); } let n = e ? "ol" : "ul", i = e && t !== 1 ? ' start="' + t + '"' : ""; return "<" + n + i + `> ` + s + "</" + n + `> `; } listitem(r) { let e = ""; if (r.task) { let t = this.checkbox({ checked: !!r.checked }); r.loose ? r.tokens[0]?.type === "paragraph" ? (r.tokens[0].text = t + " " + r.tokens[0].text, r.tokens[0].tokens && r.tokens[0].tokens.length > 0 && r.tokens[0].tokens[0].type === "text" && (r.tokens[0].tokens[0].text = t + " " + J(r.tokens[0].tokens[0].text), r.tokens[0].tokens[0].escaped = !0)) : r.tokens.unshift({ type: "text", raw: t + " ", text: t + " ", escaped: !0 }) : e += t + " "; } return e += this.parser.parse(r.tokens, !!r.loose), `<li>${e}</li> `; } checkbox({ checked: r }) { return "<input " + (r ? 'checked="" ' : "") + 'disabled="" type="checkbox">'; } paragraph({ tokens: r }) { return `<p>${this.parser.parseInline(r)}</p> `; } table(r) { let e = "", t = ""; for (let n = 0; n < r.header.length; n++) t += this.tablecell(r.header[n]); e += this.tablerow({ text: t }); let s = ""; for (let n = 0; n < r.rows.length; n++) { let i = r.rows[n]; t = ""; for (let a = 0; a < i.length; a++) t += this.tablecell(i[a]); s += this.tablerow({ text: t }); } return s && (s = `<tbody>${s}</tbody>`), `<table> <thead> ` + e + `</thead> ` + s + `</table> `; } tablerow({ text: r }) { return `<tr> ${r}</tr> `; } tablecell(r) { let e = this.parser.parseInline(r.tokens), t = r.header ? "th" : "td"; return (r.align ? `<${t} align="${r.align}">` : `<${t}>`) + e + `</${t}> `; } strong({ tokens: r }) { return `<strong>${this.parser.parseInline(r)}</strong>`; } em({ tokens: r }) { return `<em>${this.parser.parseInline(r)}</em>`; } codespan({ text: r }) { return `<code>${J(r, !0)}</code>`; } br(r) { return "<br>"; } del({ tokens: r }) { return `<del>${this.parser.parseInline(r)}</del>`; } link({ href: r, title: e, tokens: t }) { let s = this.parser.parseInline(t), n = on(r); if (n === null) return s; r = n; let i = '<a href="' + r + '"'; return e && (i += ' title="' + J(e) + '"'), i += ">" + s + "</a>", i; } image({ href: r, title: e, text: t, tokens: s }) { s && (t = this.parser.parseInline(s, this.parser.textRenderer)); let n = on(r); if (n === null) return J(t); r = n; let i = `<img src="${r}" alt="${t}"`; return e && (i += ` title="${J(e)}"`), i += ">", i; } text(r) { return "tokens" in r && r.tokens ? this.parser.parseInline(r.tokens) : "escaped" in r && r.escaped ? r.text : J(r.text); } }, Jt = class { strong({ text: r }) { return r; } em({ text: r }) { return r; } codespan({ text: r }) { return r; } del({ text: r }) { return r; } html({ text: r }) { return r; } text({ text: r }) { return r; } link({ text: r }) { return "" + r; } image({ text: r }) { return "" + r; } br() { return ""; } }, se = class Ut { options; renderer; textRenderer; constructor(e) { this.options = e || pe, this.options.renderer = this.options.renderer || new lt(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new Jt(); } static parse(e, t) { return new Ut(t).parse(e); } static parseInline(e, t) { return new Ut(t).parseInline(e); } parse(e, t = !0) { let s = ""; for (let n = 0; n < e.length; n++) { let i = e[n]; if (this.options.extensions?.renderers?.[i.type]) { let o = i, l = this.options.extensions.renderers[o.type].call({ parser: this }, o); if (l !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(o.type)) { s += l || ""; continue; } } let a = i; switch (a.type) { case "space": { s += this.renderer.space(a); continue; } case "hr": { s += this.renderer.hr(a); continue; } case "heading": { s += this.renderer.heading(a); continue; } case "code": { s += this.renderer.code(a); continue; } case "table": { s += this.renderer.table(a); continue; } case "blockquote": { s += this.renderer.blockquote(a); continue; } case "list": { s += this.renderer.list(a); continue; } case "html": { s += this.renderer.html(a); continue; } case "paragraph": { s += this.renderer.paragraph(a); continue; } case "text": { let o = a, l = this.renderer.text(o); for (; n + 1 < e.length && e[n + 1].type === "text"; ) o = e[++n], l += ` ` + this.renderer.text(o); t ? s += this.renderer.paragraph({ type: "paragraph", raw: l, text: l, tokens: [{ type: "text", raw: l, text: l, escaped: !0 }] }) : s += l; continue; } default: { let o = 'Token with "' + a.type + '" type was not found.'; if (this.options.silent) return console.error(o), ""; throw new Error(o); } } } return s; } parseInline(e, t = this.renderer) { let s = ""; for (let n = 0; n < e.length; n++) { let i = e[n]; if (this.options.extensions?.renderers?.[i.type]) { let o = this.options.extensions.renderers[i.type].call({ parser: this }, i); if (o !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) { s += o || ""; continue; } } let a = i; switch (a.type) { case "escape": { s += t.text(a); break; } case "html": { s += t.html(a); break; } case "link": { s += t.link(a); break; } case "image": { s += t.image(a); break; } case "strong": { s += t.strong(a); break; } case "em": { s += t.em(a); break; } case "codespan": { s += t.codespan(a); break; } case "br": { s += t.br(a); break; } case "del": { s += t.del(a); break; } case "