advaisor-chatbot 1.7.1-beta.8 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/testchatbot.js +263 -209
  2. package/package.json +1 -1
@@ -1,13 +1,13 @@
1
1
  (() => {
2
- // node_modules/marked/lib/marked.esm.js
3
- function L() {
2
+ // ../node_modules/marked/lib/marked.esm.js
3
+ function M() {
4
4
  return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
5
5
  }
6
- var T = L();
7
- function Z(u3) {
8
- T = u3;
6
+ var O = M();
7
+ function G(u3) {
8
+ O = u3;
9
9
  }
10
- var C = { exec: () => null };
10
+ var _ = { exec: () => null };
11
11
  function k(u3, e = "") {
12
12
  let t = typeof u3 == "string" ? u3 : u3.source, n = { replace: (r, i) => {
13
13
  let s = typeof i == "string" ? i : i.source;
@@ -15,82 +15,85 @@
15
15
  }, getRegex: () => new RegExp(t, e) };
16
16
  return n;
17
17
  }
18
- var me = (() => {
18
+ var be = (() => {
19
19
  try {
20
20
  return !!new RegExp("(?<=1)(?<!1)");
21
21
  } catch {
22
22
  return false;
23
23
  }
24
24
  })();
25
- var m = { 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]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ 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: (u3) => new RegExp(`^( {0,3}${u3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}#`), htmlBeginRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}<(?:[a-z].*>|!--)`, "i") };
26
- var xe = /^(?:[ \t]*(?:\n|$))+/;
27
- var be = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
28
- var Re = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
29
- var I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
30
- var Te = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
31
- var N = /(?:[*+-]|\d{1,9}[.)])/;
32
- var re = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
33
- var se = k(re).replace(/bull/g, N).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();
34
- var Oe = k(re).replace(/bull/g, N).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();
35
- var Q = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
36
- var we = /^[^\n]+/;
25
+ var m = { 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, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ 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, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (u3) => new RegExp(`^( {0,3}${u3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}#`), htmlBeginRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}<(?:[a-z].*>|!--)`, "i"), blockquoteBeginRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}>`) };
26
+ var Re = /^(?:[ \t]*(?:\n|$))+/;
27
+ var Oe = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
28
+ var Te = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
29
+ var C = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
30
+ var we = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
31
+ var Q = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
32
+ var se = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
33
+ var ie = k(se).replace(/bull/g, Q).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();
34
+ var ye = k(se).replace(/bull/g, Q).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();
35
+ var j = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
36
+ var Pe = /^[^\n]+/;
37
37
  var F = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
38
- var ye = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", F).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
39
- var Pe = k(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, N).getRegex();
38
+ var Se = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", F).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
39
+ var $e = k(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Q).getRegex();
40
40
  var v = "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";
41
- var j = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
42
- var Se = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", j).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
43
- var ie = k(Q).replace("hr", I).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", v).getRegex();
44
- var $e = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ie).getRegex();
45
- var U = { blockquote: $e, code: be, def: ye, fences: Re, heading: Te, hr: I, html: Se, lheading: se, list: Pe, newline: xe, paragraph: ie, table: C, text: we };
46
- var te = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).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", v).getRegex();
47
- var _e = { ...U, lheading: Oe, table: te, paragraph: k(Q).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", te).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", v).getRegex() };
48
- var Le = { ...U, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", j).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: C, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(Q).replace("hr", I).replace("heading", ` *#{1,6} *[^
49
- ]`).replace("lheading", se).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
50
- var Me = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
51
- var ze = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
52
- var oe = /^( {2,}|\\)\n(?!\s*$)/;
41
+ var U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
42
+ var _e = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", U).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
43
+ var oe = k(j).replace("hr", C).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[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
44
+ var Le = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", oe).getRegex();
45
+ var K = { blockquote: Le, code: Oe, def: Se, fences: Te, heading: we, hr: C, html: _e, lheading: ie, list: $e, newline: Re, paragraph: oe, table: _, text: Pe };
46
+ var ne = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", C).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[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
47
+ var Me = { ...K, lheading: ye, table: ne, paragraph: k(j).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ne).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex() };
48
+ var ze = { ...K, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).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: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(j).replace("hr", C).replace("heading", ` *#{1,6} *[^
49
+ ]`).replace("lheading", ie).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
50
+ var Ee = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
51
+ var Ie = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
52
+ var ae = /^( {2,}|\\)\n(?!\s*$)/;
53
53
  var Ae = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
54
- var D = /[\p{P}\p{S}]/u;
55
- var K = /[\s\p{P}\p{S}]/u;
56
- var ae = /[^\s\p{P}\p{S}]/u;
57
- var Ce = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, K).getRegex();
54
+ var z = /[\p{P}\p{S}]/u;
55
+ var H = /[\s\p{P}\p{S}]/u;
56
+ var W = /[^\s\p{P}\p{S}]/u;
57
+ var Ce = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, H).getRegex();
58
58
  var le = /(?!~)[\p{P}\p{S}]/u;
59
- var Ie = /(?!~)[\s\p{P}\p{S}]/u;
60
- var Ee = /(?:[^\s\p{P}\p{S}]|~)/u;
61
- var Be = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", me ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
62
- var ue = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
63
- var qe = k(ue, "u").replace(/punct/g, D).getRegex();
64
- var ve = k(ue, "u").replace(/punct/g, le).getRegex();
59
+ var Be = /(?!~)[\s\p{P}\p{S}]/u;
60
+ var De = /(?:[^\s\p{P}\p{S}]|~)/u;
61
+ var qe = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", be ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
62
+ var ue = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
63
+ var ve = k(ue, "u").replace(/punct/g, z).getRegex();
64
+ var He = k(ue, "u").replace(/punct/g, le).getRegex();
65
65
  var pe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
66
- var De = k(pe, "gu").replace(/notPunctSpace/g, ae).replace(/punctSpace/g, K).replace(/punct/g, D).getRegex();
67
- var He = k(pe, "gu").replace(/notPunctSpace/g, Ee).replace(/punctSpace/g, Ie).replace(/punct/g, le).getRegex();
68
- var Ze = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ae).replace(/punctSpace/g, K).replace(/punct/g, D).getRegex();
69
- var Ge = k(/\\(punct)/, "gu").replace(/punct/g, D).getRegex();
70
- var Ne = k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
71
- var Qe = k(j).replace("(?:-->|$)", "-->").getRegex();
72
- var Fe = k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Qe).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
73
- var q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/;
74
- var je = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
66
+ var Ze = k(pe, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, z).getRegex();
67
+ var Ge = k(pe, "gu").replace(/notPunctSpace/g, De).replace(/punctSpace/g, Be).replace(/punct/g, le).getRegex();
68
+ var Ne = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, z).getRegex();
69
+ var Qe = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, z).getRegex();
70
+ var je = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
71
+ var Fe = k(je, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, z).getRegex();
72
+ var Ue = k(/\\(punct)/, "gu").replace(/punct/g, z).getRegex();
73
+ var Ke = k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
74
+ var We = k(U).replace("(?:-->|$)", "-->").getRegex();
75
+ var Xe = k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", We).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
76
+ var q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
77
+ var Je = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
75
78
  var ce = k(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", F).getRegex();
76
79
  var he = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", F).getRegex();
77
- var Ue = k("reflink|nolink(?!\\()", "g").replace("reflink", ce).replace("nolink", he).getRegex();
78
- var ne = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
79
- var W = { _backpedal: C, anyPunctuation: Ge, autolink: Ne, blockSkip: Be, br: oe, code: ze, del: C, emStrongLDelim: qe, emStrongRDelimAst: De, emStrongRDelimUnd: Ze, escape: Me, link: je, nolink: he, punctuation: Ce, reflink: ce, reflinkSearch: Ue, tag: Fe, text: Ae, url: C };
80
- var Ke = { ...W, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() };
81
- var G = { ...W, emStrongRDelimAst: He, emStrongLDelim: ve, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ne).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\S]|[^\s~\\]))\1(?=[^~]|$)/, text: k(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ne).getRegex() };
82
- var We = { ...G, br: k(oe).replace("{2,}", "*").getRegex(), text: k(G.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
83
- var E = { normal: U, gfm: _e, pedantic: Le };
84
- var M = { normal: W, gfm: G, breaks: We, pedantic: Ke };
85
- var Xe = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
86
- var ke = (u3) => Xe[u3];
87
- function w(u3, e) {
80
+ var Ve = k("reflink|nolink(?!\\()", "g").replace("reflink", ce).replace("nolink", he).getRegex();
81
+ var re = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
82
+ var X = { _backpedal: _, anyPunctuation: Ue, autolink: Ke, blockSkip: qe, br: ae, code: Ie, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: ve, emStrongRDelimAst: Ze, emStrongRDelimUnd: Ne, escape: Ee, link: Je, nolink: he, punctuation: Ce, reflink: ce, reflinkSearch: Ve, tag: Xe, text: Ae, url: _ };
83
+ var Ye = { ...X, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() };
84
+ var N = { ...X, emStrongRDelimAst: Ge, emStrongLDelim: He, delLDelim: Qe, delRDelim: Fe, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", re).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\S]|[^\s~\\]))\1(?=[^~]|$)/, text: k(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", re).getRegex() };
85
+ var et = { ...N, br: k(ae).replace("{2,}", "*").getRegex(), text: k(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
86
+ var B = { normal: K, gfm: Me, pedantic: ze };
87
+ var E = { normal: X, gfm: N, breaks: et, pedantic: Ye };
88
+ var tt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
89
+ var ke = (u3) => tt[u3];
90
+ function T(u3, e) {
88
91
  if (e) {
89
92
  if (m.escapeTest.test(u3)) return u3.replace(m.escapeReplace, ke);
90
93
  } else if (m.escapeTestNoEncode.test(u3)) return u3.replace(m.escapeReplaceNoEncode, ke);
91
94
  return u3;
92
95
  }
93
- function X(u3) {
96
+ function J(u3) {
94
97
  try {
95
98
  u3 = encodeURI(u3).replace(m.percentDecode, "%");
96
99
  } catch {
@@ -98,7 +101,7 @@
98
101
  }
99
102
  return u3;
100
103
  }
101
- function J(u3, e) {
104
+ function V(u3, e) {
102
105
  let t = u3.replace(m.findPipe, (i, s, a) => {
103
106
  let o = false, l = s;
104
107
  for (; --l >= 0 && a[l] === "\\"; ) o = !o;
@@ -109,7 +112,7 @@
109
112
  for (; r < n.length; r++) n[r] = n[r].trim().replace(m.slashPipe, "|");
110
113
  return n;
111
114
  }
112
- function z(u3, e, t) {
115
+ function I(u3, e, t) {
113
116
  let n = u3.length;
114
117
  if (n === 0) return "";
115
118
  let r = 0;
@@ -129,13 +132,21 @@
129
132
  else if (u3[n] === e[1] && (t--, t < 0)) return n;
130
133
  return t > 0 ? -2 : -1;
131
134
  }
132
- function ge(u3, e, t, n, r) {
135
+ function ge(u3, e = 0) {
136
+ let t = e, n = "";
137
+ for (let r of u3) if (r === " ") {
138
+ let i = 4 - t % 4;
139
+ n += " ".repeat(i), t += i;
140
+ } else n += r, t++;
141
+ return n;
142
+ }
143
+ function fe(u3, e, t, n, r) {
133
144
  let i = e.href, s = e.title || null, a = u3[1].replace(r.other.outputLinkReplace, "$1");
134
145
  n.state.inLink = true;
135
146
  let o = { type: u3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: i, title: s, text: a, tokens: n.inlineTokens(a) };
136
147
  return n.state.inLink = false, o;
137
148
  }
138
- function Je(u3, e, t) {
149
+ function nt(u3, e, t) {
139
150
  let n = u3.match(t.other.indentCodeCompensation);
140
151
  if (n === null) return e;
141
152
  let r = n[1];
@@ -148,12 +159,12 @@
148
159
  }).join(`
149
160
  `);
150
161
  }
151
- var y = class {
162
+ var w = class {
152
163
  options;
153
164
  rules;
154
165
  lexer;
155
166
  constructor(e) {
156
- this.options = e || T;
167
+ this.options = e || O;
157
168
  }
158
169
  space(e) {
159
170
  let t = this.rules.block.newline.exec(e);
@@ -163,14 +174,14 @@
163
174
  let t = this.rules.block.code.exec(e);
164
175
  if (t) {
165
176
  let n = t[0].replace(this.rules.other.codeRemoveIndent, "");
166
- return { type: "code", raw: t[0], codeBlockStyle: "indented", text: this.options.pedantic ? n : z(n, `
177
+ return { type: "code", raw: t[0], codeBlockStyle: "indented", text: this.options.pedantic ? n : I(n, `
167
178
  `) };
168
179
  }
169
180
  }
170
181
  fences(e) {
171
182
  let t = this.rules.block.fences.exec(e);
172
183
  if (t) {
173
- let n = t[0], r = Je(n, t[3] || "", this.rules);
184
+ let n = t[0], r = nt(n, t[3] || "", this.rules);
174
185
  return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: r };
175
186
  }
176
187
  }
@@ -179,7 +190,7 @@
179
190
  if (t) {
180
191
  let n = t[2].trim();
181
192
  if (this.rules.other.endingHash.test(n)) {
182
- let r = z(n, "#");
193
+ let r = I(n, "#");
183
194
  (this.options.pedantic || !r || this.rules.other.endingSpaceChar.test(r)) && (n = r.trim());
184
195
  }
185
196
  return { type: "heading", raw: t[0], depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
@@ -187,13 +198,13 @@
187
198
  }
188
199
  hr(e) {
189
200
  let t = this.rules.block.hr.exec(e);
190
- if (t) return { type: "hr", raw: z(t[0], `
201
+ if (t) return { type: "hr", raw: I(t[0], `
191
202
  `) };
192
203
  }
193
204
  blockquote(e) {
194
205
  let t = this.rules.block.blockquote.exec(e);
195
206
  if (t) {
196
- let n = z(t[0], `
207
+ let n = I(t[0], `
197
208
  `).split(`
198
209
  `), r = "", i = "", s = [];
199
210
  for (; n.length > 0; ) {
@@ -208,21 +219,21 @@
208
219
  r = r ? `${r}
209
220
  ${p}` : p, i = i ? `${i}
210
221
  ${c}` : c;
211
- let g = this.lexer.state.top;
212
- if (this.lexer.state.top = true, this.lexer.blockTokens(c, s, true), this.lexer.state.top = g, n.length === 0) break;
222
+ let d = this.lexer.state.top;
223
+ if (this.lexer.state.top = true, this.lexer.blockTokens(c, s, true), this.lexer.state.top = d, n.length === 0) break;
213
224
  let h = s.at(-1);
214
225
  if (h?.type === "code") break;
215
226
  if (h?.type === "blockquote") {
216
227
  let R = h, f = R.raw + `
217
228
  ` + n.join(`
218
- `), O = this.blockquote(f);
219
- s[s.length - 1] = O, r = r.substring(0, r.length - R.raw.length) + O.raw, i = i.substring(0, i.length - R.text.length) + O.text;
229
+ `), S = this.blockquote(f);
230
+ s[s.length - 1] = S, r = r.substring(0, r.length - R.raw.length) + S.raw, i = i.substring(0, i.length - R.text.length) + S.text;
220
231
  break;
221
232
  } else if (h?.type === "list") {
222
233
  let R = h, f = R.raw + `
223
234
  ` + n.join(`
224
- `), O = this.list(f);
225
- s[s.length - 1] = O, r = r.substring(0, r.length - h.raw.length) + O.raw, i = i.substring(0, i.length - R.raw.length) + O.raw, n = f.substring(s.at(-1).raw.length).split(`
235
+ `), S = this.list(f);
236
+ s[s.length - 1] = S, r = r.substring(0, r.length - h.raw.length) + S.raw, i = i.substring(0, i.length - R.raw.length) + S.raw, n = f.substring(s.at(-1).raw.length).split(`
226
237
  `);
227
238
  continue;
228
239
  }
@@ -240,25 +251,25 @@ ${c}` : c;
240
251
  let l = false, p = "", c = "";
241
252
  if (!(t = s.exec(e)) || this.rules.block.hr.test(e)) break;
242
253
  p = t[0], e = e.substring(p.length);
243
- let g = t[2].split(`
244
- `, 1)[0].replace(this.rules.other.listReplaceTabs, (O) => " ".repeat(3 * O.length)), h = e.split(`
245
- `, 1)[0], R = !g.trim(), f = 0;
246
- if (this.options.pedantic ? (f = 2, c = g.trimStart()) : R ? f = t[1].length + 1 : (f = t[2].search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, c = g.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (p += h + `
254
+ let d = ge(t[2].split(`
255
+ `, 1)[0], t[1].length), h = e.split(`
256
+ `, 1)[0], R = !d.trim(), f = 0;
257
+ if (this.options.pedantic ? (f = 2, c = d.trimStart()) : R ? f = t[1].length + 1 : (f = d.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, c = d.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (p += h + `
247
258
  `, e = e.substring(h.length + 1), l = true), !l) {
248
- let O = this.rules.other.nextBulletRegex(f), V = this.rules.other.hrRegex(f), Y = this.rules.other.fencesBeginRegex(f), ee = this.rules.other.headingBeginRegex(f), fe = this.rules.other.htmlBeginRegex(f);
259
+ let S = this.rules.other.nextBulletRegex(f), Y = this.rules.other.hrRegex(f), ee = this.rules.other.fencesBeginRegex(f), te = this.rules.other.headingBeginRegex(f), me = this.rules.other.htmlBeginRegex(f), xe = this.rules.other.blockquoteBeginRegex(f);
249
260
  for (; e; ) {
250
- let H = e.split(`
261
+ let Z = e.split(`
251
262
  `, 1)[0], A;
252
- if (h = H, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), A = h) : A = h.replace(this.rules.other.tabCharGlobal, " "), Y.test(h) || ee.test(h) || fe.test(h) || O.test(h) || V.test(h)) break;
263
+ if (h = Z, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), A = h) : A = h.replace(this.rules.other.tabCharGlobal, " "), ee.test(h) || te.test(h) || me.test(h) || xe.test(h) || S.test(h) || Y.test(h)) break;
253
264
  if (A.search(this.rules.other.nonSpaceChar) >= f || !h.trim()) c += `
254
265
  ` + A.slice(f);
255
266
  else {
256
- if (R || g.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || Y.test(g) || ee.test(g) || V.test(g)) break;
267
+ if (R || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ee.test(d) || te.test(d) || Y.test(d)) break;
257
268
  c += `
258
269
  ` + h;
259
270
  }
260
- !R && !h.trim() && (R = true), p += H + `
261
- `, e = e.substring(H.length + 1), g = A.slice(f);
271
+ R = !h.trim(), p += Z + `
272
+ `, e = e.substring(Z.length + 1), d = A.slice(f);
262
273
  }
263
274
  }
264
275
  i.loose || (a ? i.loose = true : this.rules.other.doubleBlankLine.test(p) && (a = true)), i.items.push({ type: "list_item", raw: p, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), i.raw += p;
@@ -283,7 +294,7 @@ ${c}` : c;
283
294
  }
284
295
  }
285
296
  if (!i.loose) {
286
- let p = l.tokens.filter((g) => g.type === "space"), c = p.length > 0 && p.some((g) => this.rules.other.anyLine.test(g.raw));
297
+ let p = l.tokens.filter((d) => d.type === "space"), c = p.length > 0 && p.some((d) => this.rules.other.anyLine.test(d.raw));
287
298
  i.loose = c;
288
299
  }
289
300
  }
@@ -308,18 +319,21 @@ ${c}` : c;
308
319
  table(e) {
309
320
  let t = this.rules.block.table.exec(e);
310
321
  if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
311
- let n = J(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
322
+ let n = V(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
312
323
  `) : [], s = { type: "table", raw: t[0], header: [], align: [], rows: [] };
313
324
  if (n.length === r.length) {
314
325
  for (let a of r) this.rules.other.tableAlignRight.test(a) ? s.align.push("right") : this.rules.other.tableAlignCenter.test(a) ? s.align.push("center") : this.rules.other.tableAlignLeft.test(a) ? s.align.push("left") : s.align.push(null);
315
326
  for (let a = 0; a < n.length; a++) s.header.push({ text: n[a], tokens: this.lexer.inline(n[a]), header: true, align: s.align[a] });
316
- for (let a of i) s.rows.push(J(a, s.header.length).map((o, l) => ({ text: o, tokens: this.lexer.inline(o), header: false, align: s.align[l] })));
327
+ for (let a of i) s.rows.push(V(a, s.header.length).map((o, l) => ({ text: o, tokens: this.lexer.inline(o), header: false, align: s.align[l] })));
317
328
  return s;
318
329
  }
319
330
  }
320
331
  lheading(e) {
321
332
  let t = this.rules.block.lheading.exec(e);
322
- if (t) return { type: "heading", raw: t[0], depth: t[2].charAt(0) === "=" ? 1 : 2, text: t[1], tokens: this.lexer.inline(t[1]) };
333
+ if (t) {
334
+ let n = t[1].trim();
335
+ return { type: "heading", raw: t[0], depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
336
+ }
323
337
  }
324
338
  paragraph(e) {
325
339
  let t = this.rules.block.paragraph.exec(e);
@@ -347,7 +361,7 @@ ${c}` : c;
347
361
  let n = t[2].trim();
348
362
  if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
349
363
  if (!this.rules.other.endAngleBracket.test(n)) return;
350
- let s = z(n.slice(0, -1), "\\");
364
+ let s = I(n.slice(0, -1), "\\");
351
365
  if ((n.length - s.length) % 2 === 0) return;
352
366
  } else {
353
367
  let s = de(t[2], "()");
@@ -362,7 +376,7 @@ ${c}` : c;
362
376
  let s = this.rules.other.pedanticHrefTitle.exec(r);
363
377
  s && (r = s[1], i = s[3]);
364
378
  } else i = t[3] ? t[3].slice(1, -1) : "";
365
- return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? r = r.slice(1) : r = r.slice(1, -1)), ge(t, { href: r && r.replace(this.rules.inline.anyPunctuation, "$1"), title: i && i.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
379
+ return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? r = r.slice(1) : r = r.slice(1, -1)), fe(t, { href: r && r.replace(this.rules.inline.anyPunctuation, "$1"), title: i && i.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
366
380
  }
367
381
  }
368
382
  reflink(e, t) {
@@ -373,15 +387,15 @@ ${c}` : c;
373
387
  let s = n[0].charAt(0);
374
388
  return { type: "text", raw: s, text: s };
375
389
  }
376
- return ge(n, i, n[0], this.lexer, this.rules);
390
+ return fe(n, i, n[0], this.lexer, this.rules);
377
391
  }
378
392
  }
379
393
  emStrong(e, t, n = "") {
380
394
  let r = this.rules.inline.emStrongLDelim.exec(e);
381
- if (!r || r[3] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
382
- if (!(r[1] || r[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
395
+ if (!r || !r[1] && !r[2] && !r[3] && !r[4] || r[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
396
+ if (!(r[1] || r[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
383
397
  let s = [...r[0]].length - 1, a, o, l = s, p = 0, c = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
384
- for (c.lastIndex = 0, t = t.slice(-1 * e.length + s); (r = c.exec(t)) != null; ) {
398
+ for (c.lastIndex = 0, t = t.slice(-1 * e.length + s); (r = c.exec(t)) !== null; ) {
385
399
  if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a) continue;
386
400
  if (o = [...a].length, r[3] || r[4]) {
387
401
  l += o;
@@ -392,7 +406,7 @@ ${c}` : c;
392
406
  }
393
407
  if (l -= o, l > 0) continue;
394
408
  o = Math.min(o, o + l + p);
395
- let g = [...r[0]][0].length, h = e.slice(0, s + r.index + g + o);
409
+ let d = [...r[0]][0].length, h = e.slice(0, s + r.index + d + o);
396
410
  if (Math.min(s, o) % 2) {
397
411
  let f = h.slice(1, -1);
398
412
  return { type: "em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
@@ -413,9 +427,23 @@ ${c}` : c;
413
427
  let t = this.rules.inline.br.exec(e);
414
428
  if (t) return { type: "br", raw: t[0] };
415
429
  }
416
- del(e) {
417
- let t = this.rules.inline.del.exec(e);
418
- if (t) return { type: "del", raw: t[0], text: t[2], tokens: this.lexer.inlineTokens(t[2]) };
430
+ del(e, t, n = "") {
431
+ let r = this.rules.inline.delLDelim.exec(e);
432
+ if (!r) return;
433
+ if (!(r[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
434
+ let s = [...r[0]].length - 1, a, o, l = s, p = this.rules.inline.delRDelim;
435
+ for (p.lastIndex = 0, t = t.slice(-1 * e.length + s); (r = p.exec(t)) !== null; ) {
436
+ if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a || (o = [...a].length, o !== s)) continue;
437
+ if (r[3] || r[4]) {
438
+ l += o;
439
+ continue;
440
+ }
441
+ if (l -= o, l > 0) continue;
442
+ o = Math.min(o, o + l);
443
+ let c = [...r[0]][0].length, d = e.slice(0, s + r.index + c + o), h = d.slice(s, -s);
444
+ return { type: "del", raw: d, text: h, tokens: this.lexer.inlineTokens(h) };
445
+ }
446
+ }
419
447
  }
420
448
  autolink(e) {
421
449
  let t = this.rules.inline.autolink.exec(e);
@@ -454,12 +482,12 @@ ${c}` : c;
454
482
  inlineQueue;
455
483
  tokenizer;
456
484
  constructor(e) {
457
- this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
458
- let t = { other: m, block: E.normal, inline: M.normal };
459
- this.options.pedantic ? (t.block = E.pedantic, t.inline = M.pedantic) : this.options.gfm && (t.block = E.gfm, this.options.breaks ? t.inline = M.breaks : t.inline = M.gfm), this.tokenizer.rules = t;
485
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || O, this.options.tokenizer = this.options.tokenizer || new w(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
486
+ let t = { other: m, block: B.normal, inline: E.normal };
487
+ this.options.pedantic ? (t.block = B.pedantic, t.inline = E.pedantic) : this.options.gfm && (t.block = B.gfm, this.options.breaks ? t.inline = E.breaks : t.inline = E.gfm), this.tokenizer.rules = t;
460
488
  }
461
489
  static get rules() {
462
- return { block: E, inline: M };
490
+ return { block: B, inline: E };
463
491
  }
464
492
  static lex(e, t) {
465
493
  return new u(t).lex(e);
@@ -477,7 +505,7 @@ ${c}` : c;
477
505
  return this.inlineQueue = [], this.tokens;
478
506
  }
479
507
  blockTokens(e, t = [], n = false) {
480
- for (this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, "")); e; ) {
508
+ for (this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, "")); e; ) {
481
509
  let r;
482
510
  if (this.options.extensions?.block?.some((s) => (r = s.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
483
511
  if (r = this.tokenizer.space(e)) {
@@ -575,14 +603,15 @@ ${c}` : c;
575
603
  return this.inlineQueue.push({ src: e, tokens: t }), t;
576
604
  }
577
605
  inlineTokens(e, t = []) {
606
+ this.tokenizer.lexer = this;
578
607
  let n = e, r = null;
579
608
  if (this.tokens.links) {
580
609
  let o = Object.keys(this.tokens.links);
581
- if (o.length > 0) for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null; ) o.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
610
+ if (o.length > 0) for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null; ) o.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
582
611
  }
583
- for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null; ) n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
612
+ for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null; ) n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
584
613
  let i;
585
- for (; (r = this.tokenizer.rules.inline.blockSkip.exec(n)) != null; ) i = r[2] ? r[2].length : 0, n = n.slice(0, r.index + i) + "[" + "a".repeat(r[0].length - i - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
614
+ for (; (r = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null; ) i = r[2] ? r[2].length : 0, n = n.slice(0, r.index + i) + "[" + "a".repeat(r[0].length - i - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
586
615
  n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
587
616
  let s = false, a = "";
588
617
  for (; e; ) {
@@ -619,7 +648,7 @@ ${c}` : c;
619
648
  e = e.substring(o.raw.length), t.push(o);
620
649
  continue;
621
650
  }
622
- if (o = this.tokenizer.del(e)) {
651
+ if (o = this.tokenizer.del(e, n, a)) {
623
652
  e = e.substring(o.raw.length), t.push(o);
624
653
  continue;
625
654
  }
@@ -633,9 +662,9 @@ ${c}` : c;
633
662
  }
634
663
  let l = e;
635
664
  if (this.options.extensions?.startInline) {
636
- let p = 1 / 0, c = e.slice(1), g;
665
+ let p = 1 / 0, c = e.slice(1), d;
637
666
  this.options.extensions.startInline.forEach((h) => {
638
- g = h.call({ lexer: this }, c), typeof g == "number" && g >= 0 && (p = Math.min(p, g));
667
+ d = h.call({ lexer: this }, c), typeof d == "number" && d >= 0 && (p = Math.min(p, d));
639
668
  }), p < 1 / 0 && p >= 0 && (l = e.substring(0, p + 1));
640
669
  }
641
670
  if (o = this.tokenizer.inlineText(l)) {
@@ -655,11 +684,11 @@ ${c}` : c;
655
684
  return t;
656
685
  }
657
686
  };
658
- var P = class {
687
+ var y = class {
659
688
  options;
660
689
  parser;
661
690
  constructor(e) {
662
- this.options = e || T;
691
+ this.options = e || O;
663
692
  }
664
693
  space(e) {
665
694
  return "";
@@ -667,8 +696,8 @@ ${c}` : c;
667
696
  code({ text: e, lang: t, escaped: n }) {
668
697
  let r = (t || "").match(m.notSpaceStart)?.[0], i = e.replace(m.endingNewline, "") + `
669
698
  `;
670
- return r ? '<pre><code class="language-' + w(r) + '">' + (n ? i : w(i, true)) + `</code></pre>
671
- ` : "<pre><code>" + (n ? i : w(i, true)) + `</code></pre>
699
+ return r ? '<pre><code class="language-' + T(r) + '">' + (n ? i : T(i, true)) + `</code></pre>
700
+ ` : "<pre><code>" + (n ? i : T(i, true)) + `</code></pre>
672
701
  `;
673
702
  }
674
703
  blockquote({ tokens: e }) {
@@ -746,7 +775,7 @@ ${e}</tr>
746
775
  return `<em>${this.parser.parseInline(e)}</em>`;
747
776
  }
748
777
  codespan({ text: e }) {
749
- return `<code>${w(e, true)}</code>`;
778
+ return `<code>${T(e, true)}</code>`;
750
779
  }
751
780
  br(e) {
752
781
  return "<br>";
@@ -755,22 +784,22 @@ ${e}</tr>
755
784
  return `<del>${this.parser.parseInline(e)}</del>`;
756
785
  }
757
786
  link({ href: e, title: t, tokens: n }) {
758
- let r = this.parser.parseInline(n), i = X(e);
787
+ let r = this.parser.parseInline(n), i = J(e);
759
788
  if (i === null) return r;
760
789
  e = i;
761
790
  let s = '<a href="' + e + '"';
762
- return t && (s += ' title="' + w(t) + '"'), s += ">" + r + "</a>", s;
791
+ return t && (s += ' title="' + T(t) + '"'), s += ">" + r + "</a>", s;
763
792
  }
764
793
  image({ href: e, title: t, text: n, tokens: r }) {
765
794
  r && (n = this.parser.parseInline(r, this.parser.textRenderer));
766
- let i = X(e);
767
- if (i === null) return w(n);
795
+ let i = J(e);
796
+ if (i === null) return T(n);
768
797
  e = i;
769
- let s = `<img src="${e}" alt="${n}"`;
770
- return t && (s += ` title="${w(t)}"`), s += ">", s;
798
+ let s = `<img src="${e}" alt="${T(n)}"`;
799
+ return t && (s += ` title="${T(t)}"`), s += ">", s;
771
800
  }
772
801
  text(e) {
773
- return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : w(e.text);
802
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : T(e.text);
774
803
  }
775
804
  };
776
805
  var $ = class {
@@ -810,7 +839,7 @@ ${e}</tr>
810
839
  renderer;
811
840
  textRenderer;
812
841
  constructor(e) {
813
- this.options = e || T, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new $();
842
+ this.options = e || O, this.options.renderer = this.options.renderer || new y(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new $();
814
843
  }
815
844
  static parse(e, t) {
816
845
  return new u2(t).parse(e);
@@ -819,6 +848,7 @@ ${e}</tr>
819
848
  return new u2(t).parseInline(e);
820
849
  }
821
850
  parse(e) {
851
+ this.renderer.parser = this;
822
852
  let t = "";
823
853
  for (let n = 0; n < e.length; n++) {
824
854
  let r = e[n];
@@ -889,6 +919,7 @@ ${e}</tr>
889
919
  return t;
890
920
  }
891
921
  parseInline(e, t = this.renderer) {
922
+ this.renderer.parser = this;
892
923
  let n = "";
893
924
  for (let r = 0; r < e.length; r++) {
894
925
  let i = e[r];
@@ -955,11 +986,11 @@ ${e}</tr>
955
986
  return n;
956
987
  }
957
988
  };
958
- var S = class {
989
+ var P = class {
959
990
  options;
960
991
  block;
961
992
  constructor(e) {
962
- this.options = e || T;
993
+ this.options = e || O;
963
994
  }
964
995
  static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
965
996
  static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
@@ -975,24 +1006,24 @@ ${e}</tr>
975
1006
  emStrongMask(e) {
976
1007
  return e;
977
1008
  }
978
- provideLexer() {
979
- return this.block ? x.lex : x.lexInline;
1009
+ provideLexer(e = this.block) {
1010
+ return e ? x.lex : x.lexInline;
980
1011
  }
981
- provideParser() {
982
- return this.block ? b.parse : b.parseInline;
1012
+ provideParser(e = this.block) {
1013
+ return e ? b.parse : b.parseInline;
983
1014
  }
984
1015
  };
985
- var B = class {
986
- defaults = L();
1016
+ var D = class {
1017
+ defaults = M();
987
1018
  options = this.setOptions;
988
1019
  parse = this.parseMarkdown(true);
989
1020
  parseInline = this.parseMarkdown(false);
990
1021
  Parser = b;
991
- Renderer = P;
1022
+ Renderer = y;
992
1023
  TextRenderer = $;
993
1024
  Lexer = x;
994
- Tokenizer = y;
995
- Hooks = S;
1025
+ Tokenizer = w;
1026
+ Hooks = P;
996
1027
  constructor(...e) {
997
1028
  this.use(...e);
998
1029
  }
@@ -1040,7 +1071,7 @@ ${e}</tr>
1040
1071
  }
1041
1072
  "childTokens" in i && i.childTokens && (t.childTokens[i.name] = i.childTokens);
1042
1073
  }), r.extensions = t), n.renderer) {
1043
- let i = this.defaults.renderer || new P(this.defaults);
1074
+ let i = this.defaults.renderer || new y(this.defaults);
1044
1075
  for (let s in n.renderer) {
1045
1076
  if (!(s in i)) throw new Error(`renderer '${s}' does not exist`);
1046
1077
  if (["options", "parser"].includes(s)) continue;
@@ -1053,7 +1084,7 @@ ${e}</tr>
1053
1084
  r.renderer = i;
1054
1085
  }
1055
1086
  if (n.tokenizer) {
1056
- let i = this.defaults.tokenizer || new y(this.defaults);
1087
+ let i = this.defaults.tokenizer || new w(this.defaults);
1057
1088
  for (let s in n.tokenizer) {
1058
1089
  if (!(s in i)) throw new Error(`tokenizer '${s}' does not exist`);
1059
1090
  if (["options", "rules", "lexer"].includes(s)) continue;
@@ -1066,22 +1097,22 @@ ${e}</tr>
1066
1097
  r.tokenizer = i;
1067
1098
  }
1068
1099
  if (n.hooks) {
1069
- let i = this.defaults.hooks || new S();
1100
+ let i = this.defaults.hooks || new P();
1070
1101
  for (let s in n.hooks) {
1071
1102
  if (!(s in i)) throw new Error(`hook '${s}' does not exist`);
1072
1103
  if (["options", "block"].includes(s)) continue;
1073
1104
  let a = s, o = n.hooks[a], l = i[a];
1074
- S.passThroughHooks.has(s) ? i[a] = (p) => {
1075
- if (this.defaults.async && S.passThroughHooksRespectAsync.has(s)) return (async () => {
1076
- let g = await o.call(i, p);
1077
- return l.call(i, g);
1105
+ P.passThroughHooks.has(s) ? i[a] = (p) => {
1106
+ if (this.defaults.async && P.passThroughHooksRespectAsync.has(s)) return (async () => {
1107
+ let d = await o.call(i, p);
1108
+ return l.call(i, d);
1078
1109
  })();
1079
1110
  let c = o.call(i, p);
1080
1111
  return l.call(i, c);
1081
1112
  } : i[a] = (...p) => {
1082
1113
  if (this.defaults.async) return (async () => {
1083
- let g = await o.apply(i, p);
1084
- return g === false && (g = await l.apply(i, p)), g;
1114
+ let d = await o.apply(i, p);
1115
+ return d === false && (d = await l.apply(i, p)), d;
1085
1116
  })();
1086
1117
  let c = o.apply(i, p);
1087
1118
  return c === false && (c = l.apply(i, p)), c;
@@ -1115,16 +1146,16 @@ ${e}</tr>
1115
1146
  if (typeof n > "u" || n === null) return a(new Error("marked(): input parameter is undefined or null"));
1116
1147
  if (typeof n != "string") return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
1117
1148
  if (s.hooks && (s.hooks.options = s, s.hooks.block = e), s.async) return (async () => {
1118
- let o = s.hooks ? await s.hooks.preprocess(n) : n, p = await (s.hooks ? await s.hooks.provideLexer() : e ? x.lex : x.lexInline)(o, s), c = s.hooks ? await s.hooks.processAllTokens(p) : p;
1149
+ let o = s.hooks ? await s.hooks.preprocess(n) : n, p = await (s.hooks ? await s.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(o, s), c = s.hooks ? await s.hooks.processAllTokens(p) : p;
1119
1150
  s.walkTokens && await Promise.all(this.walkTokens(c, s.walkTokens));
1120
- let h = await (s.hooks ? await s.hooks.provideParser() : e ? b.parse : b.parseInline)(c, s);
1151
+ let h = await (s.hooks ? await s.hooks.provideParser(e) : e ? b.parse : b.parseInline)(c, s);
1121
1152
  return s.hooks ? await s.hooks.postprocess(h) : h;
1122
1153
  })().catch(a);
1123
1154
  try {
1124
1155
  s.hooks && (n = s.hooks.preprocess(n));
1125
- let l = (s.hooks ? s.hooks.provideLexer() : e ? x.lex : x.lexInline)(n, s);
1156
+ let l = (s.hooks ? s.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, s);
1126
1157
  s.hooks && (l = s.hooks.processAllTokens(l)), s.walkTokens && this.walkTokens(l, s.walkTokens);
1127
- let c = (s.hooks ? s.hooks.provideParser() : e ? b.parse : b.parseInline)(l, s);
1158
+ let c = (s.hooks ? s.hooks.provideParser(e) : e ? b.parse : b.parseInline)(l, s);
1128
1159
  return s.hooks && (c = s.hooks.postprocess(c)), c;
1129
1160
  } catch (o) {
1130
1161
  return a(o);
@@ -1135,7 +1166,7 @@ ${e}</tr>
1135
1166
  return (n) => {
1136
1167
  if (n.message += `
1137
1168
  Please report this to https://github.com/markedjs/marked.`, e) {
1138
- let r = "<p>An error occurred:</p><pre>" + w(n.message + "", true) + "</pre>";
1169
+ let r = "<p>An error occurred:</p><pre>" + T(n.message + "", true) + "</pre>";
1139
1170
  return t ? Promise.resolve(r) : r;
1140
1171
  }
1141
1172
  if (t) return Promise.reject(n);
@@ -1143,38 +1174,38 @@ Please report this to https://github.com/markedjs/marked.`, e) {
1143
1174
  };
1144
1175
  }
1145
1176
  };
1146
- var _ = new B();
1147
- function d(u3, e) {
1148
- return _.parse(u3, e);
1177
+ var L = new D();
1178
+ function g(u3, e) {
1179
+ return L.parse(u3, e);
1149
1180
  }
1150
- d.options = d.setOptions = function(u3) {
1151
- return _.setOptions(u3), d.defaults = _.defaults, Z(d.defaults), d;
1181
+ g.options = g.setOptions = function(u3) {
1182
+ return L.setOptions(u3), g.defaults = L.defaults, G(g.defaults), g;
1152
1183
  };
1153
- d.getDefaults = L;
1154
- d.defaults = T;
1155
- d.use = function(...u3) {
1156
- return _.use(...u3), d.defaults = _.defaults, Z(d.defaults), d;
1184
+ g.getDefaults = M;
1185
+ g.defaults = O;
1186
+ g.use = function(...u3) {
1187
+ return L.use(...u3), g.defaults = L.defaults, G(g.defaults), g;
1157
1188
  };
1158
- d.walkTokens = function(u3, e) {
1159
- return _.walkTokens(u3, e);
1189
+ g.walkTokens = function(u3, e) {
1190
+ return L.walkTokens(u3, e);
1160
1191
  };
1161
- d.parseInline = _.parseInline;
1162
- d.Parser = b;
1163
- d.parser = b.parse;
1164
- d.Renderer = P;
1165
- d.TextRenderer = $;
1166
- d.Lexer = x;
1167
- d.lexer = x.lex;
1168
- d.Tokenizer = y;
1169
- d.Hooks = S;
1170
- d.parse = d;
1171
- var Dt = d.options;
1172
- var Ht = d.setOptions;
1173
- var Zt = d.use;
1174
- var Gt = d.walkTokens;
1175
- var Nt = d.parseInline;
1176
- var Ft = b.parse;
1177
- var jt = x.lex;
1192
+ g.parseInline = L.parseInline;
1193
+ g.Parser = b;
1194
+ g.parser = b.parse;
1195
+ g.Renderer = y;
1196
+ g.TextRenderer = $;
1197
+ g.Lexer = x;
1198
+ g.lexer = x.lex;
1199
+ g.Tokenizer = w;
1200
+ g.Hooks = P;
1201
+ g.parse = g;
1202
+ var Qt = g.options;
1203
+ var jt = g.setOptions;
1204
+ var Ft = g.use;
1205
+ var Ut = g.walkTokens;
1206
+ var Kt = g.parseInline;
1207
+ var Xt = b.parse;
1208
+ var Jt = x.lex;
1178
1209
 
1179
1210
  // src/sidebar.js
1180
1211
  var ChatSidebar = class extends HTMLElement {
@@ -1704,15 +1735,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
1704
1735
  }
1705
1736
 
1706
1737
  // src/chatbot.js
1707
- d.setOptions({
1738
+ g.setOptions({
1708
1739
  breaks: true,
1709
1740
  gfm: true
1710
1741
  });
1711
1742
  var PACKAGES = [
1743
+ // {
1744
+ // package_id: 30,
1745
+ // endpoint: "/cds_test/ask_stream_v2_vllm_lang",
1746
+ // package_name: "CDS Docs",
1747
+ // },
1712
1748
  {
1713
1749
  package_id: 30,
1714
1750
  endpoint: "/cds_bookshelves/ask_stream_v2_vllm",
1715
- package_name: "All Bookshelves"
1751
+ package_name: "CDS Docs"
1716
1752
  },
1717
1753
  {
1718
1754
  package_id: 2,
@@ -1741,7 +1777,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
1741
1777
  this.selectedPackage = PACKAGES[0];
1742
1778
  }
1743
1779
  connectedCallback() {
1744
- this.apiEndpoint = this.getAttribute("api_endpoint") || "https://silicore.ai:2002/cds_bookshelves/ask_all_bookshelves";
1780
+ this.apiEndpoint = this.getAttribute("api_endpoint") || "http://45.195.82.92:2002/cds_bookshelves/ask_all_bookshelves";
1745
1781
  this.userName = this.getAttribute("user_name") || "Guest";
1746
1782
  this.token = this.getAttribute("token") || null;
1747
1783
  this.render();
@@ -2247,6 +2283,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
2247
2283
  const sendBtn = this.shadowRoot.getElementById("send");
2248
2284
  const input = this.shadowRoot.getElementById("input");
2249
2285
  const body = this.shadowRoot.getElementById("body");
2286
+ this.isTabActive = true;
2287
+ document.addEventListener("visibilitychange", () => {
2288
+ this.isTabActive = !document.hidden;
2289
+ });
2250
2290
  const lightbox = this.shadowRoot.getElementById("lightbox");
2251
2291
  const lightboxImg = this.shadowRoot.getElementById("lightbox-img");
2252
2292
  lightbox.onclick = () => lightbox.classList.remove("active");
@@ -2383,14 +2423,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
2383
2423
  this.abortController = null;
2384
2424
  this.showErrorMessage(
2385
2425
  body,
2386
- "Request timed out after 30 seconds. Please try again."
2426
+ "Request timed Server is very slow or not responding. Please try again."
2387
2427
  );
2388
2428
  botMessageContainer.remove();
2389
2429
  input.disabled = false;
2390
2430
  sendBtn.disabled = false;
2391
2431
  input.focus();
2392
2432
  }
2393
- }, 3e4);
2433
+ }, 6e4);
2394
2434
  const pkg = this.selectedPackage;
2395
2435
  const fullEndpoint = this.apiEndpoint.replace(/\/$/, "") + pkg.endpoint;
2396
2436
  try {
@@ -2422,6 +2462,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
2422
2462
  let lastStatusMessage = "";
2423
2463
  let accumulatedImages = [];
2424
2464
  let historyAccumulatedImages = [];
2465
+ let currentDisplayText = "";
2466
+ let animationFrameId = null;
2467
+ let lastRenderedLength = 0;
2468
+ const speed = 1e3;
2425
2469
  while (true) {
2426
2470
  const { value, done } = await reader.read();
2427
2471
  if (done) break;
@@ -2435,7 +2479,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
2435
2479
  try {
2436
2480
  const data = JSON.parse(jsonStr);
2437
2481
  if (data.image_urls?.length > 0) {
2438
- accumulatedImages = data.image_urls;
2482
+ accumulatedImages.push(...data.image_urls);
2439
2483
  }
2440
2484
  if (data.type === "message") {
2441
2485
  lastStatusMessage = data.text;
@@ -2456,30 +2500,36 @@ Please report this to https://github.com/markedjs/marked.`, e) {
2456
2500
  const newText = data.text;
2457
2501
  accumulatedAnswer += newText;
2458
2502
  const words = newText.split(" ");
2459
- let currentDisplayText = accumulatedAnswer.substring(
2460
- 0,
2461
- accumulatedAnswer.length - newText.length
2462
- );
2463
- if (currentDisplayText) {
2464
- const cleanExisting = this.fixMarkdown(currentDisplayText);
2465
- const htmlExisting = d.parse(cleanExisting);
2466
- contentDiv.innerHTML = htmlExisting;
2467
- await new Promise((resolve) => setTimeout(resolve, 50));
2468
- }
2469
- for (let i = 0; i < newText.length; i++) {
2470
- currentDisplayText += newText[i];
2471
- const safeText = this.ensureClosedCodeBlock(currentDisplayText);
2472
- const cleanReply = this.fixMarkdown(safeText);
2473
- const htmlReply = d.parse(cleanReply);
2474
- contentDiv.innerHTML = htmlReply;
2475
- await new Promise((resolve) => setTimeout(resolve, 3));
2503
+ if (!animationFrameId) {
2504
+ let lastTime = performance.now();
2505
+ const animate = (now) => {
2506
+ const delta = (now - lastTime) / 1e3;
2507
+ lastTime = now;
2508
+ const charsToAdd = Math.floor(delta * speed);
2509
+ if (lastRenderedLength < accumulatedAnswer.length) {
2510
+ lastRenderedLength = Math.min(
2511
+ lastRenderedLength + charsToAdd,
2512
+ accumulatedAnswer.length
2513
+ );
2514
+ currentDisplayText = accumulatedAnswer.slice(0, lastRenderedLength);
2515
+ const safeText = this.ensureClosedCodeBlock(currentDisplayText);
2516
+ const cleanReply = this.fixMarkdown(safeText);
2517
+ contentDiv.innerHTML = g.parse(cleanReply);
2518
+ }
2519
+ if (lastRenderedLength < accumulatedAnswer.length) {
2520
+ animationFrameId = requestAnimationFrame(animate);
2521
+ } else {
2522
+ animationFrameId = null;
2523
+ }
2524
+ };
2525
+ animationFrameId = requestAnimationFrame(animate);
2476
2526
  }
2477
2527
  }
2478
2528
  if (data.is_last) {
2479
2529
  statusDiv.remove();
2480
2530
  typingDiv.style.display = "none";
2481
2531
  const cleanReply = this.fixMarkdown(accumulatedAnswer);
2482
- const htmlReply = d.parse(cleanReply);
2532
+ const htmlReply = g.parse(cleanReply);
2483
2533
  contentDiv.innerHTML = htmlReply;
2484
2534
  const images = accumulatedImages;
2485
2535
  if (images?.length > 0) {
@@ -2516,8 +2566,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
2516
2566
  });
2517
2567
  botMessageContainer.appendChild(gallery);
2518
2568
  }
2569
+ const existingFeedback = botMessageContainer.querySelector(".feedback-form-container");
2570
+ if (existingFeedback) {
2571
+ existingFeedback.remove();
2572
+ }
2519
2573
  const feedbackEl = createFeedbackForm(this.activeChatId, this.token, this.shadowRoot, this.apiEndpoint);
2520
- contentDiv.appendChild(feedbackEl);
2574
+ botMessageContainer.appendChild(feedbackEl);
2521
2575
  break;
2522
2576
  }
2523
2577
  } catch (parseError) {
@@ -2641,7 +2695,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
2641
2695
  body.innerHTML = `<div class="message bot">Loading conversation...</div>`;
2642
2696
  try {
2643
2697
  const res = await fetch(
2644
- "https://myadvaisor.com:2002/customer/user_session_chats",
2698
+ "http://45.195.82.92:2002/customer/user_session_chats",
2645
2699
  {
2646
2700
  method: "POST",
2647
2701
  headers: {
@@ -2682,7 +2736,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
2682
2736
  const cleanReply = this.fixMarkdown(content);
2683
2737
  const contentDiv = document.createElement("div");
2684
2738
  contentDiv.className = "content";
2685
- contentDiv.innerHTML = d.parse(cleanReply);
2739
+ contentDiv.innerHTML = g.parse(cleanReply);
2686
2740
  wrapper.appendChild(contentDiv);
2687
2741
  } else {
2688
2742
  wrapper.textContent = content;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "advaisor-chatbot",
3
- "version": "1.7.1-beta.8",
3
+ "version": "1.8.0",
4
4
  "description": "Embeddable chatbot component",
5
5
  "main": "dist/testchatbot.js",
6
6
  "scripts": {