@liip/liipgpt 0.0.13 → 0.0.15

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.
@@ -22,7 +22,7 @@ class Bt {
22
22
  pe.set(e, String(t));
23
23
  }
24
24
  }
25
- const je = globalThis.localStorage ?? new Bt();
25
+ const He = globalThis.localStorage ?? new Bt();
26
26
  function Qe() {
27
27
  return {
28
28
  async: !1,
@@ -110,12 +110,12 @@ const O = {
110
110
  fencesBeginRegex: (h) => new RegExp(`^ {0,${Math.min(3, h - 1)}}(?:\`\`\`|~~~)`),
111
111
  headingBeginRegex: (h) => new RegExp(`^ {0,${Math.min(3, h - 1)}}#`),
112
112
  htmlBeginRegex: (h) => new RegExp(`^ {0,${Math.min(3, h - 1)}}<(?:[a-z].*>|!--)`, "i")
113
- }, Ft = /^(?:[ \t]*(?:\n|$))+/, Mt = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Ht = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, Te = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, jt = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, wt = /(?:[*+-]|\d{1,9}[.)])/, xt = $(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, wt).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/).getRegex(), Xe = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Ut = /^[^\n]+/, We = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Gt = $(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", We).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Zt = $(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, wt).getRegex(), ze = "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", Ke = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Qt = $("^ {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", Ke).replace("tag", ze).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), yt = $(Xe).replace("hr", Te).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", ze).getRegex(), Xt = $(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", yt).getRegex(), Ve = {
113
+ }, Ft = /^(?:[ \t]*(?:\n|$))+/, Mt = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, jt = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, Te = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Ht = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, wt = /(?:[*+-]|\d{1,9}[.)])/, xt = $(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, wt).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/).getRegex(), Xe = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Ut = /^[^\n]+/, We = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Gt = $(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", We).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Zt = $(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, wt).getRegex(), ze = "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", Ke = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Qt = $("^ {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", Ke).replace("tag", ze).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), yt = $(Xe).replace("hr", Te).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", ze).getRegex(), Xt = $(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", yt).getRegex(), Ve = {
114
114
  blockquote: Xt,
115
115
  code: Mt,
116
116
  def: Gt,
117
- fences: Ht,
118
- heading: jt,
117
+ fences: jt,
118
+ heading: Ht,
119
119
  hr: Te,
120
120
  html: Qt,
121
121
  lheading: xt,
@@ -138,7 +138,7 @@ const O = {
138
138
  lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
139
139
  paragraph: $(Xe).replace("hr", Te).replace("heading", ` *#{1,6} *[^
140
140
  ]`).replace("lheading", xt).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
141
- }, Vt = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Jt = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, vt = /^( {2,}|\\)\n(?!\s*$)/, Yt = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, De = /[\p{P}\p{S}]/u, Je = /[\s\p{P}\p{S}]/u, St = /[^\s\p{P}\p{S}]/u, en = $(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Je).getRegex(), tn = /(?!~)[\p{P}\p{S}]/u, nn = /(?!~)[\s\p{P}\p{S}]/u, rn = /(?:[^\s\p{P}\p{S}]|~)/u, sn = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, an = $(/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, "u").replace(/punct/g, De).getRegex(), Rt = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", on = $(Rt, "gu").replace(/notPunctSpace/g, St).replace(/punctSpace/g, Je).replace(/punct/g, De).getRegex(), ln = $(Rt, "gu").replace(/notPunctSpace/g, rn).replace(/punctSpace/g, nn).replace(/punct/g, tn).getRegex(), cn = $("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, St).replace(/punctSpace/g, Je).replace(/punct/g, De).getRegex(), un = $(/\\(punct)/, "gu").replace(/punct/g, De).getRegex(), hn = $(/^<(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(), pn = $(Ke).replace("(?:-->|$)", "-->").getRegex(), fn = $("^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", pn).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Ce = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, dn = $(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", Ce).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Tt = $(/^!?\[(label)\]\[(ref)\]/).replace("label", Ce).replace("ref", We).getRegex(), Et = $(/^!?\[(ref)\](?:\[\])?/).replace("ref", We).getRegex(), gn = $("reflink|nolink(?!\\()", "g").replace("reflink", Tt).replace("nolink", Et).getRegex(), Ye = {
141
+ }, Vt = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Jt = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, vt = /^( {2,}|\\)\n(?!\s*$)/, Yt = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, De = /[\p{P}\p{S}]/u, Je = /[\s\p{P}\p{S}]/u, St = /[^\s\p{P}\p{S}]/u, en = $(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Je).getRegex(), tn = /(?!~)[\p{P}\p{S}]/u, nn = /(?!~)[\s\p{P}\p{S}]/u, rn = /(?:[^\s\p{P}\p{S}]|~)/u, sn = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, an = $(/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, "u").replace(/punct/g, De).getRegex(), Rt = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", on = $(Rt, "gu").replace(/notPunctSpace/g, St).replace(/punctSpace/g, Je).replace(/punct/g, De).getRegex(), ln = $(Rt, "gu").replace(/notPunctSpace/g, rn).replace(/punctSpace/g, nn).replace(/punct/g, tn).getRegex(), cn = $("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, St).replace(/punctSpace/g, Je).replace(/punct/g, De).getRegex(), un = $(/\\(punct)/, "gu").replace(/punct/g, De).getRegex(), hn = $(/^<(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(), pn = $(Ke).replace("(?:-->|$)", "-->").getRegex(), fn = $("^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", pn).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Ie = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, dn = $(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", Ie).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Tt = $(/^!?\[(label)\]\[(ref)\]/).replace("label", Ie).replace("ref", We).getRegex(), Et = $(/^!?\[(ref)\](?:\[\])?/).replace("ref", We).getRegex(), gn = $("reflink|nolink(?!\\()", "g").replace("reflink", Tt).replace("nolink", Et).getRegex(), Ye = {
142
142
  _backpedal: Se,
143
143
  // only used for GFM url
144
144
  anyPunctuation: un,
@@ -161,8 +161,8 @@ const O = {
161
161
  url: Se
162
162
  }, kn = {
163
163
  ...Ye,
164
- link: $(/^!?\[(label)\]\((.*?)\)/).replace("label", Ce).getRegex(),
165
- reflink: $(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Ce).getRegex()
164
+ link: $(/^!?\[(label)\]\((.*?)\)/).replace("label", Ie).getRegex(),
165
+ reflink: $(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Ie).getRegex()
166
166
  }, Ge = {
167
167
  ...Ye,
168
168
  emStrongRDelimAst: ln,
@@ -174,7 +174,7 @@ const O = {
174
174
  ...Ge,
175
175
  br: $(vt).replace("{2,}", "*").getRegex(),
176
176
  text: $(Ge.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
177
- }, Ie = {
177
+ }, Ce = {
178
178
  normal: Ve,
179
179
  gfm: Wt,
180
180
  pedantic: Kt
@@ -384,16 +384,16 @@ ${g}` : g;
384
384
  if ((x == null ? void 0 : x.type) === "code")
385
385
  break;
386
386
  if ((x == null ? void 0 : x.type) === "blockquote") {
387
- const I = x, R = I.raw + `
387
+ const C = x, R = C.raw + `
388
388
  ` + n.join(`
389
389
  `), B = this.blockquote(R);
390
- i[i.length - 1] = B, s = s.substring(0, s.length - I.raw.length) + B.raw, r = r.substring(0, r.length - I.text.length) + B.text;
390
+ i[i.length - 1] = B, s = s.substring(0, s.length - C.raw.length) + B.raw, r = r.substring(0, r.length - C.text.length) + B.text;
391
391
  break;
392
392
  } else if ((x == null ? void 0 : x.type) === "list") {
393
- const I = x, R = I.raw + `
393
+ const C = x, R = C.raw + `
394
394
  ` + n.join(`
395
395
  `), B = this.list(R);
396
- i[i.length - 1] = B, s = s.substring(0, s.length - x.raw.length) + B.raw, r = r.substring(0, r.length - I.raw.length) + B.raw, n = R.substring(i.at(-1).raw.length).split(`
396
+ i[i.length - 1] = B, s = s.substring(0, s.length - x.raw.length) + B.raw, r = r.substring(0, r.length - C.raw.length) + B.raw, n = R.substring(i.at(-1).raw.length).split(`
397
397
  `);
398
398
  continue;
399
399
  }
@@ -428,8 +428,8 @@ ${g}` : g;
428
428
  l = t[0], e = e.substring(l.length);
429
429
  let m = t[2].split(`
430
430
  `, 1)[0].replace(this.rules.other.listReplaceTabs, (ge) => " ".repeat(3 * ge.length)), x = e.split(`
431
- `, 1)[0], I = !m.trim(), R = 0;
432
- if (this.options.pedantic ? (R = 2, g = m.trimStart()) : I ? R = t[1].length + 1 : (R = t[2].search(this.rules.other.nonSpaceChar), R = R > 4 ? 1 : R, g = m.slice(R), R += t[1].length), I && this.rules.other.blankLine.test(x) && (l += x + `
431
+ `, 1)[0], C = !m.trim(), R = 0;
432
+ if (this.options.pedantic ? (R = 2, g = m.trimStart()) : C ? R = t[1].length + 1 : (R = t[2].search(this.rules.other.nonSpaceChar), R = R > 4 ? 1 : R, g = m.slice(R), R += t[1].length), C && this.rules.other.blankLine.test(x) && (l += x + `
433
433
  `, e = e.substring(x.length + 1), o = !0), !o) {
434
434
  const ge = this.rules.other.nextBulletRegex(R), F = this.rules.other.hrRegex(R), X = this.rules.other.fencesBeginRegex(R), ke = this.rules.other.headingBeginRegex(R), Ee = this.rules.other.htmlBeginRegex(R);
435
435
  for (; e; ) {
@@ -442,12 +442,12 @@ ${g}` : g;
442
442
  g += `
443
443
  ` + ee.slice(R);
444
444
  else {
445
- if (I || m.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || X.test(m) || ke.test(m) || F.test(m))
445
+ if (C || m.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || X.test(m) || ke.test(m) || F.test(m))
446
446
  break;
447
447
  g += `
448
448
  ` + x;
449
449
  }
450
- !I && !x.trim() && (I = !0), l += ae + `
450
+ !C && !x.trim() && (C = !0), l += ae + `
451
451
  `, e = e.substring(ae.length + 1), m = ee.slice(R);
452
452
  }
453
453
  }
@@ -667,12 +667,12 @@ ${g}` : g;
667
667
  tokens: this.lexer.inlineTokens(R)
668
668
  };
669
669
  }
670
- const I = x.slice(2, -2);
670
+ const C = x.slice(2, -2);
671
671
  return {
672
672
  type: "strong",
673
673
  raw: x,
674
- text: I,
675
- tokens: this.lexer.inlineTokens(I)
674
+ text: C,
675
+ tokens: this.lexer.inlineTokens(C)
676
676
  };
677
677
  }
678
678
  }
@@ -782,17 +782,17 @@ class U {
782
782
  };
783
783
  const t = {
784
784
  other: O,
785
- block: Ie.normal,
785
+ block: Ce.normal,
786
786
  inline: ye.normal
787
787
  };
788
- this.options.pedantic ? (t.block = Ie.pedantic, t.inline = ye.pedantic) : this.options.gfm && (t.block = Ie.gfm, this.options.breaks ? t.inline = ye.breaks : t.inline = ye.gfm), this.tokenizer.rules = t;
788
+ this.options.pedantic ? (t.block = Ce.pedantic, t.inline = ye.pedantic) : this.options.gfm && (t.block = Ce.gfm, this.options.breaks ? t.inline = ye.breaks : t.inline = ye.gfm), this.tokenizer.rules = t;
789
789
  }
790
790
  /**
791
791
  * Expose Rules
792
792
  */
793
793
  static get rules() {
794
794
  return {
795
- block: Ie,
795
+ block: Ce,
796
796
  inline: ye
797
797
  };
798
798
  }
@@ -990,9 +990,9 @@ class U {
990
990
  if ((o = this.options.extensions) != null && o.startInline) {
991
991
  let m = 1 / 0;
992
992
  const x = e.slice(1);
993
- let I;
993
+ let C;
994
994
  this.options.extensions.startInline.forEach((R) => {
995
- I = R.call({ lexer: this }, x), typeof I == "number" && I >= 0 && (m = Math.min(m, I));
995
+ C = R.call({ lexer: this }, x), typeof C == "number" && C >= 0 && (m = Math.min(m, C));
996
996
  }), m < 1 / 0 && m >= 0 && (g = e.substring(0, m + 1));
997
997
  }
998
998
  if (l = this.tokenizer.inlineText(g)) {
@@ -1630,7 +1630,7 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1630
1630
  */
1631
1631
  (function(h, e) {
1632
1632
  (function(t) {
1633
- var n = t.setTimeout, s = t.clearTimeout, r = t.XMLHttpRequest, i = t.XDomainRequest, a = t.ActiveXObject, u = t.EventSource, o = t.document, l = t.Promise, g = t.fetch, m = t.Response, x = t.TextDecoder, I = t.TextEncoder, R = t.AbortController;
1633
+ var n = t.setTimeout, s = t.clearTimeout, r = t.XMLHttpRequest, i = t.XDomainRequest, a = t.ActiveXObject, u = t.EventSource, o = t.document, l = t.Promise, g = t.fetch, m = t.Response, x = t.TextDecoder, C = t.TextEncoder, R = t.AbortController;
1634
1634
  if (typeof window < "u" && typeof o < "u" && !("readyState" in o) && o.body == null && (o.readyState = "loading", window.addEventListener("load", function(c) {
1635
1635
  o.readyState = "complete";
1636
1636
  }, !1)), r == null && a != null && (r = function() {
@@ -1689,21 +1689,21 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1689
1689
  return 3;
1690
1690
  throw new Error();
1691
1691
  }
1692
- for (var p = 65533, b = "", k = this.bitsNeeded, y = this.codePoint, C = 0; C < c.length; C += 1) {
1693
- var v = c[C];
1692
+ for (var p = 65533, b = "", k = this.bitsNeeded, y = this.codePoint, I = 0; I < c.length; I += 1) {
1693
+ var v = c[I];
1694
1694
  k !== 0 && (v < 128 || v > 191 || !f(y << 6 | v & 63, k - 6, d(k, y))) && (k = 0, y = p, b += String.fromCharCode(y)), k === 0 ? (v >= 0 && v <= 127 ? (k = 0, y = v) : v >= 192 && v <= 223 ? (k = 6 * 1, y = v & 31) : v >= 224 && v <= 239 ? (k = 6 * 2, y = v & 15) : v >= 240 && v <= 247 ? (k = 6 * 3, y = v & 7) : (k = 0, y = p), k !== 0 && !f(y, k, d(k, y)) && (k = 0, y = p)) : (k -= 6, y = y << 6 | v & 63), k === 0 && (y <= 65535 ? b += String.fromCharCode(y) : (b += String.fromCharCode(55296 + (y - 65535 - 1 >> 10)), b += String.fromCharCode(56320 + (y - 65535 - 1 & 1023))));
1695
1695
  }
1696
1696
  return this.bitsNeeded = k, this.codePoint = y, b;
1697
1697
  };
1698
1698
  var ge = function() {
1699
1699
  try {
1700
- return new x().decode(new I().encode("test"), { stream: !0 }) === "test";
1700
+ return new x().decode(new C().encode("test"), { stream: !0 }) === "test";
1701
1701
  } catch (c) {
1702
1702
  console.debug("TextDecoder does not support streaming option. Using polyfill instead: " + c);
1703
1703
  }
1704
1704
  return !1;
1705
1705
  };
1706
- (x == null || I == null || !ge()) && (x = de);
1706
+ (x == null || C == null || !ge()) && (x = de);
1707
1707
  var F = function() {
1708
1708
  };
1709
1709
  function X(c) {
@@ -1728,7 +1728,7 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1728
1728
  }
1729
1729
  w !== 0 && (b = 2, d.readyState = 2, d.status = w, d.statusText = A, d._contentType = K, d.onreadystatechange());
1730
1730
  }
1731
- }, C = function() {
1731
+ }, I = function() {
1732
1732
  if (y(), b === 2 || b === 3) {
1733
1733
  b = 3;
1734
1734
  var w = "";
@@ -1741,7 +1741,7 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1741
1741
  }, v = function(w, A) {
1742
1742
  if ((A == null || A.preventDefault == null) && (A = {
1743
1743
  preventDefault: F
1744
- }), C(), b === 1 || b === 2 || b === 3) {
1744
+ }), I(), b === 1 || b === 2 || b === 3) {
1745
1745
  if (b = 4, k !== 0 && (s(k), k = 0), d.readyState = 4, w === "load")
1746
1746
  d.onload(A);
1747
1747
  else if (w === "error")
@@ -1753,11 +1753,11 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1753
1753
  d.onreadystatechange();
1754
1754
  }
1755
1755
  }, T = function(w) {
1756
- p != null && (p.readyState === 4 ? (!("onload" in p) || !("onerror" in p) || !("onabort" in p)) && v(p.responseText === "" ? "error" : "load", w) : p.readyState === 3 ? "onprogress" in p || C() : p.readyState === 2 && y());
1756
+ p != null && (p.readyState === 4 ? (!("onload" in p) || !("onerror" in p) || !("onabort" in p)) && v(p.responseText === "" ? "error" : "load", w) : p.readyState === 3 ? "onprogress" in p || I() : p.readyState === 2 && y());
1757
1757
  }, _ = function() {
1758
1758
  k = n(function() {
1759
1759
  _();
1760
- }, 500), p.readyState === 3 && C();
1760
+ }, 500), p.readyState === 3 && I();
1761
1761
  };
1762
1762
  "onload" in p && (p.onload = function(w) {
1763
1763
  v("load", w);
@@ -1765,7 +1765,7 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1765
1765
  v("error", w);
1766
1766
  }), "onabort" in p && (p.onabort = function(w) {
1767
1767
  v("abort", w);
1768
- }), "onprogress" in p && (p.onprogress = C), "onreadystatechange" in p && (p.onreadystatechange = function(w) {
1768
+ }), "onprogress" in p && (p.onprogress = I), "onreadystatechange" in p && (p.onreadystatechange = function(w) {
1769
1769
  T(w);
1770
1770
  }), ("contentType" in p || !("ontimeout" in r.prototype)) && (f += (f.indexOf("?") === -1 ? "?" : "&") + "padding=true"), p.open(c, f, !0), "readyState" in p && (k = n(function() {
1771
1771
  _();
@@ -1803,8 +1803,8 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1803
1803
  function Ee(c) {
1804
1804
  for (var f = /* @__PURE__ */ Object.create(null), d = c.split(`\r
1805
1805
  `), p = 0; p < d.length; p += 1) {
1806
- var b = d[p], k = b.split(": "), y = k.shift(), C = k.join(": ");
1807
- f[ke(y)] = C;
1806
+ var b = d[p], k = b.split(": "), y = k.shift(), I = k.join(": ");
1807
+ f[ke(y)] = I;
1808
1808
  }
1809
1809
  this._map = f;
1810
1810
  }
@@ -1815,10 +1815,10 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1815
1815
  }
1816
1816
  ae.prototype.open = function(c, f, d, p, b, k, y) {
1817
1817
  c.open("GET", b);
1818
- var C = 0;
1818
+ var I = 0;
1819
1819
  c.onprogress = function() {
1820
- var T = c.responseText, _ = T.slice(C);
1821
- C += _.length, d(_);
1820
+ var T = c.responseText, _ = T.slice(I);
1821
+ I += _.length, d(_);
1822
1822
  }, c.onerror = function(T) {
1823
1823
  T.preventDefault(), p(new Error("NetworkError"));
1824
1824
  }, c.onload = function() {
@@ -1844,16 +1844,16 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1844
1844
  function tt() {
1845
1845
  }
1846
1846
  tt.prototype.open = function(c, f, d, p, b, k, y) {
1847
- var C = null, v = new R(), T = v.signal, _ = new x();
1847
+ var I = null, v = new R(), T = v.signal, _ = new x();
1848
1848
  return g(b, {
1849
1849
  headers: y,
1850
1850
  credentials: k ? "include" : "same-origin",
1851
1851
  signal: T,
1852
1852
  cache: "no-store"
1853
1853
  }).then(function(w) {
1854
- return C = w.body.getReader(), f(w.status, w.statusText, w.headers.get("Content-Type"), new ee(w.headers)), new l(function(A, K) {
1854
+ return I = w.body.getReader(), f(w.status, w.statusText, w.headers.get("Content-Type"), new ee(w.headers)), new l(function(A, K) {
1855
1855
  var we = function() {
1856
- C.read().then(function(M) {
1856
+ I.read().then(function(M) {
1857
1857
  if (M.done)
1858
1858
  A(void 0);
1859
1859
  else {
@@ -1873,7 +1873,7 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1873
1873
  p(w);
1874
1874
  }), {
1875
1875
  abort: function() {
1876
- C != null && C.cancel(), v.abort();
1876
+ I != null && I.cancel(), v.abort();
1877
1877
  }
1878
1878
  };
1879
1879
  };
@@ -1928,11 +1928,11 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1928
1928
  oe.call(this, c), this.error = f.error;
1929
1929
  }
1930
1930
  st.prototype = Object.create(oe.prototype);
1931
- var Ne = -1, te = 0, le = 1, be = 2, qe = -1, ne = 0, Oe = 1, it = 2, _t = 3, It = /^text\/event\-stream(;.*)?$/i, Ct = 1e3, At = 18e6, Be = function(c, f) {
1931
+ var Ne = -1, te = 0, le = 1, be = 2, qe = -1, ne = 0, Oe = 1, it = 2, _t = 3, Ct = /^text\/event\-stream(;.*)?$/i, It = 1e3, At = 18e6, Be = function(c, f) {
1932
1932
  var d = c == null ? f : parseInt(c, 10);
1933
1933
  return d !== d && (d = f), Fe(d);
1934
1934
  }, Fe = function(c) {
1935
- return Math.min(Math.max(c, Ct), At);
1935
+ return Math.min(Math.max(c, It), At);
1936
1936
  }, ce = function(c, f, d) {
1937
1937
  try {
1938
1938
  typeof f == "function" && f.call(c, d);
@@ -1949,39 +1949,39 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1949
1949
  var zt = g != null && m != null && "body" in m.prototype;
1950
1950
  function Dt(c, f, d) {
1951
1951
  f = String(f);
1952
- var p = !!d.withCredentials, b = d.lastEventIdQueryParameterName || "lastEventId", k = Fe(1e3), y = Be(d.heartbeatTimeout, 45e3), C = "", v = k, T = !1, _ = 0, w = d.headers || {}, A = d.Transport, K = zt && A == null ? void 0 : new X(A != null ? new A() : Lt()), we = A != null && typeof A != "string" ? new A() : K == null ? new tt() : new ae(), M = void 0, P = 0, Q = Ne, ue = "", $e = "", V = "", _e = "", N = ne, Me = 0, re = 0, Pt = function(z, L, H, j) {
1952
+ var p = !!d.withCredentials, b = d.lastEventIdQueryParameterName || "lastEventId", k = Fe(1e3), y = Be(d.heartbeatTimeout, 45e3), I = "", v = k, T = !1, _ = 0, w = d.headers || {}, A = d.Transport, K = zt && A == null ? void 0 : new X(A != null ? new A() : Lt()), we = A != null && typeof A != "string" ? new A() : K == null ? new tt() : new ae(), M = void 0, P = 0, Q = Ne, ue = "", $e = "", V = "", _e = "", N = ne, Me = 0, re = 0, Pt = function(z, L, j, H) {
1953
1953
  if (Q === te)
1954
- if (z === 200 && H != null && It.test(H)) {
1954
+ if (z === 200 && j != null && Ct.test(j)) {
1955
1955
  Q = le, T = Date.now(), v = k, c.readyState = le;
1956
1956
  var q = new Pe("open", {
1957
1957
  status: z,
1958
1958
  statusText: L,
1959
- headers: j
1959
+ headers: H
1960
1960
  });
1961
1961
  c.dispatchEvent(q), ce(c, c.onopen, q);
1962
1962
  } else {
1963
1963
  var D = "";
1964
- z !== 200 ? (L && (L = L.replace(/\s+/g, " ")), D = "EventSource's response has a status " + z + " " + L + " that is not 200. Aborting the connection.") : D = "EventSource's response has a Content-Type specifying an unsupported type: " + (H == null ? "-" : H.replace(/\s+/g, " ")) + ". Aborting the connection.", He();
1964
+ z !== 200 ? (L && (L = L.replace(/\s+/g, " ")), D = "EventSource's response has a status " + z + " " + L + " that is not 200. Aborting the connection.") : D = "EventSource's response has a Content-Type specifying an unsupported type: " + (j == null ? "-" : j.replace(/\s+/g, " ")) + ". Aborting the connection.", je();
1965
1965
  var q = new Pe("error", {
1966
1966
  status: z,
1967
1967
  statusText: L,
1968
- headers: j
1968
+ headers: H
1969
1969
  });
1970
1970
  c.dispatchEvent(q), ce(c, c.onerror, q), console.error(D);
1971
1971
  }
1972
1972
  }, Nt = function(z) {
1973
1973
  if (Q === le) {
1974
- for (var L = -1, H = 0; H < z.length; H += 1) {
1975
- var j = z.charCodeAt(H);
1976
- (j === 10 || j === 13) && (L = H);
1974
+ for (var L = -1, j = 0; j < z.length; j += 1) {
1975
+ var H = z.charCodeAt(j);
1976
+ (H === 10 || H === 13) && (L = j);
1977
1977
  }
1978
1978
  var q = (L !== -1 ? _e : "") + z.slice(0, L + 1);
1979
1979
  _e = (L === -1 ? _e : "") + z.slice(L + 1), z !== "" && (T = Date.now(), _ += z.length);
1980
1980
  for (var D = 0; D < q.length; D += 1) {
1981
- var j = q.charCodeAt(D);
1982
- if (N === qe && j === 10)
1981
+ var H = q.charCodeAt(D);
1982
+ if (N === qe && H === 10)
1983
1983
  N = ne;
1984
- else if (N === qe && (N = ne), j === 13 || j === 10) {
1984
+ else if (N === qe && (N = ne), H === 13 || H === 10) {
1985
1985
  if (N !== ne) {
1986
1986
  N === Oe && (re = D + 1);
1987
1987
  var J = q.slice(Me, re - 1), Y = q.slice(re + (re < D && q.charCodeAt(re) === 32 ? 1 : 0), D);
@@ -1992,7 +1992,7 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
1992
1992
  }
1993
1993
  if (N === ne) {
1994
1994
  if (ue !== "") {
1995
- C = $e, V === "" && (V = "message");
1995
+ I = $e, V === "" && (V = "message");
1996
1996
  var he = new rt(V, {
1997
1997
  data: ue.slice(1),
1998
1998
  lastEventId: $e
@@ -2002,9 +2002,9 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
2002
2002
  }
2003
2003
  ue = "", V = "";
2004
2004
  }
2005
- N = j === 13 ? qe : ne;
2005
+ N = H === 13 ? qe : ne;
2006
2006
  } else
2007
- N === ne && (Me = D, N = Oe), N === Oe ? j === 58 && (re = D + 1, N = it) : N === it && (N = _t);
2007
+ N === ne && (Me = D, N = Oe), N === Oe ? H === 58 && (re = D + 1, N = it) : N === it && (N = _t);
2008
2008
  }
2009
2009
  }
2010
2010
  }, ot = function(z) {
@@ -2015,7 +2015,7 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
2015
2015
  var L = new st("error", { error: z });
2016
2016
  c.dispatchEvent(L), ce(c, c.onerror, L), z != null && console.error(z);
2017
2017
  }
2018
- }, He = function() {
2018
+ }, je = function() {
2019
2019
  Q = be, M != null && (M.abort(), M = void 0), P !== 0 && (s(P), P = 0), c.readyState = be;
2020
2020
  }, xe = function() {
2021
2021
  if (P = 0, Q !== Ne) {
@@ -2031,27 +2031,27 @@ var vn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
2031
2031
  }
2032
2032
  T = !1, _ = 0, P = n(function() {
2033
2033
  xe();
2034
- }, y), Q = te, ue = "", V = "", $e = C, _e = "", Me = 0, re = 0, N = ne;
2034
+ }, y), Q = te, ue = "", V = "", $e = I, _e = "", Me = 0, re = 0, N = ne;
2035
2035
  var L = f;
2036
- if (f.slice(0, 5) !== "data:" && f.slice(0, 5) !== "blob:" && C !== "") {
2037
- var H = f.indexOf("?");
2038
- L = H === -1 ? f : f.slice(0, H + 1) + f.slice(H + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function(Y, he) {
2036
+ if (f.slice(0, 5) !== "data:" && f.slice(0, 5) !== "blob:" && I !== "") {
2037
+ var j = f.indexOf("?");
2038
+ L = j === -1 ? f : f.slice(0, j + 1) + f.slice(j + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function(Y, he) {
2039
2039
  return he === b ? "" : Y;
2040
- }), L += (f.indexOf("?") === -1 ? "?" : "&") + b + "=" + encodeURIComponent(C);
2040
+ }), L += (f.indexOf("?") === -1 ? "?" : "&") + b + "=" + encodeURIComponent(I);
2041
2041
  }
2042
- var j = c.withCredentials, q = {};
2042
+ var H = c.withCredentials, q = {};
2043
2043
  q.Accept = "text/event-stream";
2044
2044
  var D = c.headers;
2045
2045
  if (D != null)
2046
2046
  for (var J in D)
2047
2047
  Object.prototype.hasOwnProperty.call(D, J) && (q[J] = D[J]);
2048
2048
  try {
2049
- M = we.open(K, Pt, Nt, ot, L, j, q);
2049
+ M = we.open(K, Pt, Nt, ot, L, H, q);
2050
2050
  } catch (Y) {
2051
- throw He(), Y;
2051
+ throw je(), Y;
2052
2052
  }
2053
2053
  };
2054
- c.url = f, c.readyState = te, c.withCredentials = p, c.headers = w, c._close = He, xe();
2054
+ c.url = f, c.readyState = te, c.withCredentials = p, c.headers = w, c._close = je, xe();
2055
2055
  }
2056
2056
  Z.prototype = Object.create(me.prototype), Z.prototype.CONNECTING = te, Z.prototype.OPEN = le, Z.prototype.CLOSED = be, Z.prototype.close = function() {
2057
2057
  this._close();
@@ -2112,27 +2112,27 @@ const gt = (h) => Object.fromEntries(Object.entries(h).filter(([e, t]) => t != n
2112
2112
  } catch {
2113
2113
  return h;
2114
2114
  }
2115
- }, En = (h) => ({
2116
- url: h.usedLinks.url,
2117
- title: h.usedLinks.title,
2118
- referenceNumber: h.usedLinks.number,
2119
- domainName: Tn(h.usedLinks.url),
2120
- breadcrumb: [],
2121
- // TODO: use Title ans split > to create this breadcrumb
2122
- generated: {
2123
- title: h.usedLinks.title ?? "",
2124
- // TODO: Exclude the breadcrumbs
2125
- summary: h.usedLinks.description ?? h.usedLinks.summary ?? ""
2126
- }
2127
- }), kt = (h, e) => {
2115
+ }, En = (h) => {
2116
+ let e = [], t = h.usedLinks.title ?? "";
2117
+ return t.includes(">") && (e = t.split(">").map((n) => n.trim()), t = e.pop() ?? ""), {
2118
+ url: h.usedLinks.url,
2119
+ title: h.usedLinks.title,
2120
+ referenceNumber: h.usedLinks.number,
2121
+ domainName: Tn(h.usedLinks.url),
2122
+ breadcrumb: e,
2123
+ generated: {
2124
+ summary: h.usedLinks.description ?? h.usedLinks.summary ?? ""
2125
+ }
2126
+ };
2127
+ }, kt = (h, e) => {
2128
2128
  const t = h.all.length, n = En(e);
2129
2129
  return n.referenceNumber = t + 1, h.all.push(n), h;
2130
- }, $n = dt.NativeEventSource || dt.EventSourcePolyfill, In = {
2130
+ }, $n = dt.NativeEventSource || dt.EventSourcePolyfill, Cn = {
2131
2131
  Positive: "positive",
2132
2132
  Negative: "negative"
2133
2133
  };
2134
2134
  let mt;
2135
- class Cn {
2135
+ class In {
2136
2136
  constructor({ apiUrl: e, apiKey: t = "X9hL4Gp5W2D7eRtF" }) {
2137
2137
  S(this, "apiUrl");
2138
2138
  S(this, "apiKey");
@@ -2141,33 +2141,36 @@ class Cn {
2141
2141
  this.apiUrl = e, this.apiKey = t, this.metadata = this.getUserData(), mt = this;
2142
2142
  }
2143
2143
  async getUserData() {
2144
- var n;
2145
- const e = je.getItem("uID"), t = await this.fetchData(
2146
- "/log",
2147
- {},
2148
- {
2149
- method: "POST",
2150
- headers: {
2151
- Accept: "application/json",
2152
- "Content-Type": "application/json"
2153
- },
2154
- body: JSON.stringify({
2155
- referrer: ((n = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : n.referrer) || null,
2156
- // initialQuery: initialQuery, TODO
2157
- uID: e
2158
- })
2159
- }
2160
- );
2161
- if ("maintenance" in t && t.maintenance)
2162
- return {
2163
- mode: "maintenance"
2144
+ var e;
2145
+ try {
2146
+ const t = He.getItem("uID"), n = await this.fetchData(
2147
+ "/log",
2148
+ {},
2149
+ {
2150
+ method: "POST",
2151
+ headers: {
2152
+ Accept: "application/json",
2153
+ "Content-Type": "application/json"
2154
+ },
2155
+ body: JSON.stringify({
2156
+ referrer: ((e = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : e.referrer) || null,
2157
+ // initialQuery: initialQuery, TODO
2158
+ uID: t
2159
+ })
2160
+ }
2161
+ );
2162
+ if ("maintenance" in n && n.maintenance)
2163
+ return { mode: "maintenance" };
2164
+ if (!("id" in n))
2165
+ throw new Error("Invalid response format: missing user id");
2166
+ return He.setItem("uID", n.id), {
2167
+ mode: "ready",
2168
+ userId: n.id,
2169
+ conversationId: n.cID
2164
2170
  };
2165
- if (!("id" in t)) throw new Error("Could not retrieve a user id");
2166
- return je.setItem("uID", t.id), {
2167
- mode: "ready",
2168
- userId: t.id,
2169
- conversationId: t.cID
2170
- };
2171
+ } catch (t) {
2172
+ throw t instanceof Response ? new Error(`Failed to initialize client: ${t.status} - ${await t.text()}`) : new Error(`Failed to initialize client: ${t instanceof Error ? t.message : "Unknown error"}`);
2173
+ }
2171
2174
  }
2172
2175
  static getInstance() {
2173
2176
  return mt;
@@ -2188,7 +2191,7 @@ class Cn {
2188
2191
  return s;
2189
2192
  }
2190
2193
  async fetchData(e, t = {}, n = {}) {
2191
- return (await fetch(
2194
+ const s = await fetch(
2192
2195
  `${this.apiUrl}${e}?${new URLSearchParams(gt(t)).toString()}`,
2193
2196
  {
2194
2197
  ...n,
@@ -2197,7 +2200,12 @@ class Cn {
2197
2200
  "api-key": this.apiKey
2198
2201
  }
2199
2202
  }
2200
- )).json();
2203
+ );
2204
+ if (!s.ok) {
2205
+ const r = await s.text();
2206
+ throw new Error(`API request failed: ${s.status} - ${r}`);
2207
+ }
2208
+ return s.json();
2201
2209
  }
2202
2210
  async fetchSSE(e, t = {}) {
2203
2211
  return new $n(
@@ -2215,16 +2223,20 @@ class Cn {
2215
2223
  return this.postData("/quickfeedback", t, "Got an error when trying to post quick feedback");
2216
2224
  }
2217
2225
  async feedback(e) {
2218
- if ((await this.metadata).mode !== "ready")
2219
- throw new Error("Can not post feedback unless we are in ready mode");
2220
- const n = await je.getItem("uID"), s = {
2221
- ...e,
2222
- rID: this.lastRequestId,
2223
- uID: n
2224
- };
2225
- return this.postData("/feedback", s, "Got an error when trying to post feedback");
2226
+ try {
2227
+ if ((await this.metadata).mode !== "ready")
2228
+ throw new Error("Can not post feedback unless we are in ready mode");
2229
+ const n = await He.getItem("uID"), s = {
2230
+ ...e,
2231
+ rID: this.lastRequestId,
2232
+ uID: n
2233
+ };
2234
+ return this.postData("/feedback", s, "Got an error when trying to post feedback");
2235
+ } catch (t) {
2236
+ throw t instanceof Response ? new Error(`Feedback submission failed: ${t.status} - ${await t.text()}`) : new Error(`Feedback submission failed: ${t instanceof Error ? t.message : "Unknown error"}`);
2237
+ }
2226
2238
  }
2227
- async getClassification(e) {
2239
+ async getClassification(e = {}) {
2228
2240
  return (await this.fetchData("/chatconfig", e)).classification;
2229
2241
  }
2230
2242
  async classification(e) {
@@ -2241,8 +2253,23 @@ class Cn {
2241
2253
  async getPredefinedQuestions(e) {
2242
2254
  return (await this.fetchData("/topics/questions", e)).predefinedQuestions;
2243
2255
  }
2256
+ async getChatConfig() {
2257
+ return this.fetchData("/chatconfig", {});
2258
+ }
2244
2259
  async getMenu(e) {
2245
- return (await this.fetchData("/chatconfig", e)).menu[e.language] ?? [];
2260
+ try {
2261
+ return (await this.getChatConfig()).menu[e.language] ?? [];
2262
+ } catch (t) {
2263
+ throw new Error(`Failed to load menu: ${t instanceof Error ? t.message : "Unknown error"}`);
2264
+ }
2265
+ }
2266
+ async getUsedLanguages() {
2267
+ try {
2268
+ const e = await this.getChatConfig();
2269
+ return Object.keys(e.menu);
2270
+ } catch (e) {
2271
+ throw new Error(`Failed to load languages: ${e instanceof Error ? e.message : "Unknown error"}`);
2272
+ }
2246
2273
  }
2247
2274
  async chatInternal(e, t = {}) {
2248
2275
  const n = await this.metadata;
@@ -2357,6 +2384,6 @@ class Cn {
2357
2384
  }
2358
2385
  }
2359
2386
  export {
2360
- Cn as LiipGPTClient,
2361
- In as QuickFeedbackType
2387
+ In as LiipGPTClient,
2388
+ Cn as QuickFeedbackType
2362
2389
  };