@burger-editor/client 4.0.0-alpha.25 → 4.0.0-alpha.26

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.
package/dist/client.js CHANGED
@@ -1,3 +1,48 @@
1
+ /**
2
+ *
3
+ * @param el
4
+ * @param frameSemantics
5
+ */
6
+ function changeFrameSemantics(el, frameSemantics) {
7
+ const containerFrame = el.querySelector('[data-bge-container-frame]');
8
+ if (!containerFrame) {
9
+ throw new Error('Container frame not found');
10
+ }
11
+ // Determine target elements
12
+ const frameTagName = frameSemantics === 'div' ? 'div' : frameSemantics;
13
+ const groupTagName = frameSemantics === 'div' ? 'div' : 'li';
14
+ // Create new container frame element
15
+ const newFrame = document.createElement(frameTagName);
16
+ copyAttributes(containerFrame, newFrame);
17
+ // Transform groups
18
+ const groups = containerFrame.querySelectorAll('[data-bge-group]');
19
+ for (const group of groups) {
20
+ const newGroup = document.createElement(groupTagName);
21
+ copyAttributes(group, newGroup);
22
+ // Move all child content
23
+ while (group.firstChild) {
24
+ newGroup.append(group.firstChild);
25
+ }
26
+ newFrame.append(newGroup);
27
+ }
28
+ // Replace old frame with new frame
29
+ containerFrame.parentNode?.replaceChild(newFrame, containerFrame);
30
+ }
31
+ /**
32
+ * Copy all attributes from source to target element
33
+ * @param source - Source element
34
+ * @param target - Target element
35
+ */
36
+ function copyAttributes(source, target) {
37
+ for (const attr of source.attributes) {
38
+ target.setAttribute(attr.name, attr.value);
39
+ }
40
+ if (source.className) {
41
+ // Copy classes
42
+ target.className = source.className;
43
+ }
44
+ }
45
+
1
46
  const CSS_LAYER = {
2
47
  base: 'bge-component-bases',
3
48
  components: 'bge-components',
@@ -140,6 +185,7 @@ async function createPlainStructuredBlockElement(data, createItemElement) {
140
185
  container.append(frame);
141
186
  const itemElements = await createItemElements(data.items, createItemElement);
142
187
  frame.append(...itemElements);
188
+ changeFrameSemantics(container, data.containerProps.frameSemantics ?? 'div');
143
189
  return container;
144
190
  }
145
191
  /**
@@ -311,7 +357,7 @@ function kebabCase(str) {
311
357
  }
312
358
 
313
359
  /**
314
- * marked v16.3.0 - a markdown parser
360
+ * marked v16.4.0 - a markdown parser
315
361
  * Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)
316
362
  * https://github.com/markedjs/marked
317
363
  */
@@ -321,32 +367,32 @@ function kebabCase(str) {
321
367
  * The code in this file is generated from files in ./src/
322
368
  */
323
369
 
324
- function L(){return {async:false,breaks:false,extensions:null,gfm:true,hooks:null,pedantic:false,renderer:null,silent:false,tokenizer:null,walkTokens:null}}var O=L();function G(l){O=l;}var E={exec:()=>null};function h$1(l,e=""){let t=typeof l=="string"?l:l.source,n={replace:(r,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(m.caret,"$1"),t=t.replace(r,s),n},getRegex:()=>new RegExp(t,e)};return n}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]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:l=>new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}#`),htmlBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}<(?:[a-z].*>|!--)`,"i")},xe=/^(?:[ \t]*(?:\n|$))+/,be=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Re=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,C=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Oe=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,j=/(?:[*+-]|\d{1,9}[.)])/,se=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ie$2=h$1(se).replace(/bull/g,j).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(),Te=h$1(se).replace(/bull/g,j).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(),F=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,we=/^[^\n]+/,Q=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ye=h$1(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Q).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Pe=h$1(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,j).getRegex(),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",U=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Se=h$1("^ {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(),oe=h$1(F).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),$e=h$1(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",oe).getRegex(),K={blockquote:$e,code:be,def:ye,fences:Re,heading:Oe,hr:C,html:Se,lheading:ie$2,list:Pe,newline:xe,paragraph:oe,table:E,text:we},re$1=h$1("^ *([^\\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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),_e={...K,lheading:Te,table:re$1,paragraph:h$1(F).replace("hr",C).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",re$1).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()},Le={...K,html:h$1(`^ *(?: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:E,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:h$1(F).replace("hr",C).replace("heading",` *#{1,6} *[^
325
- ]`).replace("lheading",ie$2).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Me=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ze=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ae=/^( {2,}|\\)\n(?!\s*$)/,Ae=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,D=/[\p{P}\p{S}]/u,W=/[\s\p{P}\p{S}]/u,le=/[^\s\p{P}\p{S}]/u,Ee=h$1(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,W).getRegex(),ue=/(?!~)[\p{P}\p{S}]/u,Ce=/(?!~)[\s\p{P}\p{S}]/u,Ie=/(?:[^\s\p{P}\p{S}]|~)/u,Be=/\[[^\[\]]*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,pe=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,qe=h$1(pe,"u").replace(/punct/g,D).getRegex(),ve=h$1(pe,"u").replace(/punct/g,ue).getRegex(),ce="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",De=h$1(ce,"gu").replace(/notPunctSpace/g,le).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),He=h$1(ce,"gu").replace(/notPunctSpace/g,Ie).replace(/punctSpace/g,Ce).replace(/punct/g,ue).getRegex(),Ze=h$1("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,le).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ge=h$1(/\\(punct)/,"gu").replace(/punct/g,D).getRegex(),Ne=h$1(/^<(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(),je=h$1(U).replace("(?:-->|$)","-->").getRegex(),Fe=h$1("^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",je).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),q=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`[^`]*`|[^\[\]\\`])*?/,Qe=h$1(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),he=h$1(/^!?\[(label)\]\[(ref)\]/).replace("label",q).replace("ref",Q).getRegex(),de=h$1(/^!?\[(ref)\](?:\[\])?/).replace("ref",Q).getRegex(),Ue=h$1("reflink|nolink(?!\\()","g").replace("reflink",he).replace("nolink",de).getRegex(),X={_backpedal:E,anyPunctuation:Ge,autolink:Ne,blockSkip:Be,br:ae,code:ze,del:E,emStrongLDelim:qe,emStrongRDelimAst:De,emStrongRDelimUnd:Ze,escape:Me,link:Qe,nolink:de,punctuation:Ee,reflink:he,reflinkSearch:Ue,tag:Fe,text:Ae,url:E},Ke={...X,link:h$1(/^!?\[(label)\]\((.*?)\)/).replace("label",q).getRegex(),reflink:h$1(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",q).getRegex()},N={...X,emStrongRDelimAst:He,emStrongLDelim:ve,url:h$1(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},We={...N,br:h$1(ae).replace("{2,}","*").getRegex(),text:h$1(N.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},I={normal:K,gfm:_e,pedantic:Le},M={normal:X,gfm:N,breaks:We,pedantic:Ke};var Xe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ke=l=>Xe[l];function w(l,e){if(e){if(m.escapeTest.test(l))return l.replace(m.escapeReplace,ke)}else if(m.escapeTestNoEncode.test(l))return l.replace(m.escapeReplaceNoEncode,ke);return l}function J(l){try{l=encodeURI(l).replace(m.percentDecode,"%");}catch{return null}return l}function V(l,e){let t=l.replace(m.findPipe,(i,s,o)=>{let a=false,u=s;for(;--u>=0&&o[u]==="\\";)a=!a;return a?"|":" |"}),n=t.split(m.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(m.slashPipe,"|");return n}function z(l,e,t){let n=l.length;if(n===0)return "";let r=0;for(;r<n;){let i=l.charAt(n-r-1);if(i===e&&true)r++;else break}return l.slice(0,n-r)}function ge(l,e){if(l.indexOf(e[1])===-1)return -1;let t=0;for(let n=0;n<l.length;n++)if(l[n]==="\\")n++;else if(l[n]===e[0])t++;else if(l[n]===e[1]&&(t--,t<0))return n;return t>0?-2:-1}function fe(l,e,t,n,r){let i=e.href,s=e.title||null,o=l[1].replace(r.other.outputLinkReplace,"$1");n.state.inLink=true;let a={type:l[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:s,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=false,a}function Je(l,e,t){let n=l.match(t.other.indentCodeCompensation);if(n===null)return e;let r=n[1];return e.split(`
370
+ function L(){return {async:false,breaks:false,extensions:null,gfm:true,hooks:null,pedantic:false,renderer:null,silent:false,tokenizer:null,walkTokens:null}}var T=L();function G(u){T=u;}var I={exec:()=>null};function d(u,e=""){let t=typeof u=="string"?u:u.source,n={replace:(r,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(m.caret,"$1"),t=t.replace(r,s),n},getRegex:()=>new RegExp(t,e)};return n}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]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:u=>new RegExp(`^( {0,3}${u})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}#`),htmlBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}<(?:[a-z].*>|!--)`,"i")},be=/^(?:[ \t]*(?:\n|$))+/,Re=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Te=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,E=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Oe=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,F=/(?:[*+-]|\d{1,9}[.)])/,ie$2=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oe=d(ie$2).replace(/bull/g,F).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(),we=d(ie$2).replace(/bull/g,F).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(),j=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ye=/^[^\n]+/,Q=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Pe=d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Q).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Se=d(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,F).getRegex(),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",U=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$e=d("^ {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(),ae=d(j).replace("hr",E).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(),_e=d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ae).getRegex(),K={blockquote:_e,code:Re,def:Pe,fences:Te,heading:Oe,hr:E,html:$e,lheading:oe,list:Se,newline:be,paragraph:ae,table:I,text:ye},re$1=d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",E).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(),Le={...K,lheading:we,table:re$1,paragraph:d(j).replace("hr",E).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",re$1).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()},Me={...K,html:d(`^ *(?: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:I,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:d(j).replace("hr",E).replace("heading",` *#{1,6} *[^
371
+ ]`).replace("lheading",oe).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ze=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ae=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,le=/^( {2,}|\\)\n(?!\s*$)/,Ie=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,D=/[\p{P}\p{S}]/u,W=/[\s\p{P}\p{S}]/u,ue=/[^\s\p{P}\p{S}]/u,Ee=d(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,W).getRegex(),pe=/(?!~)[\p{P}\p{S}]/u,Ce=/(?!~)[\s\p{P}\p{S}]/u,Be=/(?:[^\s\p{P}\p{S}]|~)/u,qe=/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,ce=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ve=d(ce,"u").replace(/punct/g,D).getRegex(),De=d(ce,"u").replace(/punct/g,pe).getRegex(),he="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",He=d(he,"gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ze=d(he,"gu").replace(/notPunctSpace/g,Be).replace(/punctSpace/g,Ce).replace(/punct/g,pe).getRegex(),Ge=d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ne=d(/\\(punct)/,"gu").replace(/punct/g,D).getRegex(),Fe=d(/^<(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(),je=d(U).replace("(?:-->|$)","-->").getRegex(),Qe=d("^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",je).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),q=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Ue=d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),de=d(/^!?\[(label)\]\[(ref)\]/).replace("label",q).replace("ref",Q).getRegex(),ke=d(/^!?\[(ref)\](?:\[\])?/).replace("ref",Q).getRegex(),Ke=d("reflink|nolink(?!\\()","g").replace("reflink",de).replace("nolink",ke).getRegex(),se=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,X={_backpedal:I,anyPunctuation:Ne,autolink:Fe,blockSkip:qe,br:le,code:Ae,del:I,emStrongLDelim:ve,emStrongRDelimAst:He,emStrongRDelimUnd:Ge,escape:ze,link:Ue,nolink:ke,punctuation:Ee,reflink:de,reflinkSearch:Ke,tag:Qe,text:Ie,url:I},We={...X,link:d(/^!?\[(label)\]\((.*?)\)/).replace("label",q).getRegex(),reflink:d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",q).getRegex()},N={...X,emStrongRDelimAst:Ze,emStrongLDelim:De,url:d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",se).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:d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",se).getRegex()},Xe={...N,br:d(le).replace("{2,}","*").getRegex(),text:d(N.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},C={normal:K,gfm:Le,pedantic:Me},M={normal:X,gfm:N,breaks:Xe,pedantic:We};var Je={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ge=u=>Je[u];function w(u,e){if(e){if(m.escapeTest.test(u))return u.replace(m.escapeReplace,ge)}else if(m.escapeTestNoEncode.test(u))return u.replace(m.escapeReplaceNoEncode,ge);return u}function J(u){try{u=encodeURI(u).replace(m.percentDecode,"%");}catch{return null}return u}function V(u,e){let t=u.replace(m.findPipe,(i,s,o)=>{let a=false,l=s;for(;--l>=0&&o[l]==="\\";)a=!a;return a?"|":" |"}),n=t.split(m.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(m.slashPipe,"|");return n}function z(u,e,t){let n=u.length;if(n===0)return "";let r=0;for(;r<n;){let i=u.charAt(n-r-1);if(i===e&&true)r++;else break}return u.slice(0,n-r)}function fe(u,e){if(u.indexOf(e[1])===-1)return -1;let t=0;for(let n=0;n<u.length;n++)if(u[n]==="\\")n++;else if(u[n]===e[0])t++;else if(u[n]===e[1]&&(t--,t<0))return n;return t>0?-2:-1}function me(u,e,t,n,r){let i=e.href,s=e.title||null,o=u[1].replace(r.other.outputLinkReplace,"$1");n.state.inLink=true;let a={type:u[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:s,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=false,a}function Ve(u,e,t){let n=u.match(t.other.indentCodeCompensation);if(n===null)return e;let r=n[1];return e.split(`
326
372
  `).map(i=>{let s=i.match(t.other.beginningSpace);if(s===null)return i;let[o]=s;return o.length>=r.length?i.slice(r.length):i}).join(`
327
- `)}var y=class{options;rules;lexer;constructor(e){this.options=e||O;}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return {type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return {type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:z(n,`
328
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Je(n,t[3]||"",this.rules);return {type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=z(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim());}return {type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return {type:"hr",raw:z(t[0],`
373
+ `)}var y=class{options;rules;lexer;constructor(e){this.options=e||T;}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return {type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return {type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:z(n,`
374
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Ve(n,t[3]||"",this.rules);return {type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=z(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim());}return {type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return {type:"hr",raw:z(t[0],`
329
375
  `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=z(t[0],`
330
376
  `).split(`
331
- `),r="",i="",s=[];for(;n.length>0;){let o=false,a=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))a.push(n[u]),o=true;else if(!o)a.push(n[u]);else break;n=n.slice(u);let p=a.join(`
332
- `),c=p.replace(this.rules.other.blockquoteSetextReplace,`
377
+ `),r="",i="",s=[];for(;n.length>0;){let o=false,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=true;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
378
+ `),p=c.replace(this.rules.other.blockquoteSetextReplace,`
333
379
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
334
- ${p}`:p,i=i?`${i}
335
- ${c}`:c;let f=this.lexer.state.top;if(this.lexer.state.top=true,this.lexer.blockTokens(c,s,true),this.lexer.state.top=f,n.length===0)break;let k=s.at(-1);if(k?.type==="code")break;if(k?.type==="blockquote"){let x=k,g=x.raw+`
380
+ ${c}`:c,i=i?`${i}
381
+ ${p}`:p;let g=this.lexer.state.top;if(this.lexer.state.top=true,this.lexer.blockTokens(p,s,true),this.lexer.state.top=g,n.length===0)break;let h=s.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let R=h,f=R.raw+`
336
382
  `+n.join(`
337
- `),T=this.blockquote(g);s[s.length-1]=T,r=r.substring(0,r.length-x.raw.length)+T.raw,i=i.substring(0,i.length-x.text.length)+T.text;break}else if(k?.type==="list"){let x=k,g=x.raw+`
383
+ `),O=this.blockquote(f);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;break}else if(h?.type==="list"){let R=h,f=R.raw+`
338
384
  `+n.join(`
339
- `),T=this.list(g);s[s.length-1]=T,r=r.substring(0,r.length-k.raw.length)+T.raw,i=i.substring(0,i.length-x.raw.length)+T.raw,n=g.substring(s.at(-1).raw.length).split(`
340
- `);continue}}return {type:"blockquote",raw:r,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:false,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=false;for(;e;){let u=false,p="",c="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let f=t[2].split(`
341
- `,1)[0].replace(this.rules.other.listReplaceTabs,H=>" ".repeat(3*H.length)),k=e.split(`
342
- `,1)[0],x=!f.trim(),g=0;if(this.options.pedantic?(g=2,c=f.trimStart()):x?g=t[1].length+1:(g=t[2].search(this.rules.other.nonSpaceChar),g=g>4?1:g,c=f.slice(g),g+=t[1].length),x&&this.rules.other.blankLine.test(k)&&(p+=k+`
343
- `,e=e.substring(k.length+1),u=true),!u){let H=this.rules.other.nextBulletRegex(g),ee=this.rules.other.hrRegex(g),te=this.rules.other.fencesBeginRegex(g),ne=this.rules.other.headingBeginRegex(g),me=this.rules.other.htmlBeginRegex(g);for(;e;){let Z=e.split(`
344
- `,1)[0],A;if(k=Z,this.options.pedantic?(k=k.replace(this.rules.other.listReplaceNesting," "),A=k):A=k.replace(this.rules.other.tabCharGlobal," "),te.test(k)||ne.test(k)||me.test(k)||H.test(k)||ee.test(k))break;if(A.search(this.rules.other.nonSpaceChar)>=g||!k.trim())c+=`
345
- `+A.slice(g);else {if(x||f.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||te.test(f)||ne.test(f)||ee.test(f))break;c+=`
346
- `+k;}!x&&!k.trim()&&(x=true),p+=Z+`
347
- `,e=e.substring(Z.length+1),f=A.slice(g);}}i.loose||(o?i.loose=true:this.rules.other.doubleBlankLine.test(p)&&(o=true));let T=null,Y;this.options.gfm&&(T=this.rules.other.listIsTask.exec(c),T&&(Y=T[0]!=="[ ] ",c=c.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:p,task:!!T,checked:Y,loose:false,text:c,tokens:[]}),i.raw+=p;}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let u=0;u<i.items.length;u++)if(this.lexer.state.top=false,i.items[u].tokens=this.lexer.blockTokens(i.items[u].text,[]),!i.loose){let p=i.items[u].tokens.filter(f=>f.type==="space"),c=p.length>0&&p.some(f=>this.rules.other.anyLine.test(f.raw));i.loose=c;}if(i.loose)for(let u=0;u<i.items.length;u++)i.items[u].loose=true;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return {type:"html",block:true,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return {type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;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(`
348
- `):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:true,align:s.align[o]});for(let o of i)s.rows.push(V(o,s.header.length).map((a,u)=>({text:a,tokens:this.lexer.inline(a),header:false,align:s.align[u]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return {type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
349
- `?t[1].slice(0,-1):t[1];return {type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return {type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return {type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return !this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=true:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=false),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=true:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=false),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:false,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=z(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else {let s=ge(t[2],"()");if(s===-2)return;if(s>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,a).trim(),t[3]="";}}let r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3]);}else i=t[3]?t[3].slice(1,-1):"";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)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return {type:"text",raw:s,text:s}}return fe(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){let s=[...r[0]].length-1,o,a,u=s,p=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+s);(r=c.exec(t))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(a=[...o].length,r[3]||r[4]){u+=a;continue}else if((r[5]||r[6])&&s%3&&!((s+a)%3)){p+=a;continue}if(u-=a,u>0)continue;a=Math.min(a,a+u+p);let f=[...r[0]][0].length,k=e.slice(0,s+r.index+f+a);if(Math.min(s,a)%2){let g=k.slice(1,-1);return {type:"em",raw:k,text:g,tokens:this.lexer.inlineTokens(g)}}let x=k.slice(2,-2);return {type:"strong",raw:k,text:x,tokens:this.lexer.inlineTokens(x)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return {type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return {type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else {let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0];}return {type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return {type:"text",raw:t[0],text:t[0],escaped:n}}}};var b=class l{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||O,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};let t={other:m,block:I.normal,inline:M.normal};this.options.pedantic?(t.block=I.pedantic,t.inline=M.pedantic):this.options.gfm&&(t.block=I.gfm,this.options.breaks?t.inline=M.breaks:t.inline=M.gfm),this.tokenizer.rules=t;}static get rules(){return {block:I,inline:M}}static lex(e,t){return new l(t).lex(e)}static lexInline(e,t){return new l(t).inlineTokens(e)}lex(e){e=e.replace(m.carriageReturn,`
385
+ `),O=this.list(f);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(`
386
+ `);continue}}return {type:"blockquote",raw:r,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:false,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=false;for(;e;){let l=false,c="",p="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let g=t[2].split(`
387
+ `,1)[0].replace(this.rules.other.listReplaceTabs,H=>" ".repeat(3*H.length)),h=e.split(`
388
+ `,1)[0],R=!g.trim(),f=0;if(this.options.pedantic?(f=2,p=g.trimStart()):R?f=t[1].length+1:(f=t[2].search(this.rules.other.nonSpaceChar),f=f>4?1:f,p=g.slice(f),f+=t[1].length),R&&this.rules.other.blankLine.test(h)&&(c+=h+`
389
+ `,e=e.substring(h.length+1),l=true),!l){let H=this.rules.other.nextBulletRegex(f),ee=this.rules.other.hrRegex(f),te=this.rules.other.fencesBeginRegex(f),ne=this.rules.other.headingBeginRegex(f),xe=this.rules.other.htmlBeginRegex(f);for(;e;){let Z=e.split(`
390
+ `,1)[0],A;if(h=Z,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),A=h):A=h.replace(this.rules.other.tabCharGlobal," "),te.test(h)||ne.test(h)||xe.test(h)||H.test(h)||ee.test(h))break;if(A.search(this.rules.other.nonSpaceChar)>=f||!h.trim())p+=`
391
+ `+A.slice(f);else {if(R||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||te.test(g)||ne.test(g)||ee.test(g))break;p+=`
392
+ `+h;}!R&&!h.trim()&&(R=true),c+=Z+`
393
+ `,e=e.substring(Z.length+1),g=A.slice(f);}}i.loose||(o?i.loose=true:this.rules.other.doubleBlankLine.test(c)&&(o=true));let O=null,Y;this.options.gfm&&(O=this.rules.other.listIsTask.exec(p),O&&(Y=O[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:c,task:!!O,checked:Y,loose:false,text:p,tokens:[]}),i.raw+=c;}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l=0;l<i.items.length;l++)if(this.lexer.state.top=false,i.items[l].tokens=this.lexer.blockTokens(i.items[l].text,[]),!i.loose){let c=i.items[l].tokens.filter(g=>g.type==="space"),p=c.length>0&&c.some(g=>this.rules.other.anyLine.test(g.raw));i.loose=p;}if(i.loose)for(let l=0;l<i.items.length;l++)i.items[l].loose=true;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return {type:"html",block:true,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return {type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;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(`
394
+ `):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:true,align:s.align[o]});for(let o of i)s.rows.push(V(o,s.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:false,align:s.align[l]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return {type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
395
+ `?t[1].slice(0,-1):t[1];return {type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return {type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return {type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return !this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=true:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=false),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=true:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=false),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:false,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=z(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else {let s=fe(t[2],"()");if(s===-2)return;if(s>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,a).trim(),t[3]="";}}let r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3]);}else i=t[3]?t[3].slice(1,-1):"";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)),me(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)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return {type:"text",raw:s,text:s}}return me(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){let s=[...r[0]].length-1,o,a,l=s,c=0,p=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+s);(r=p.exec(t))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(a=[...o].length,r[3]||r[4]){l+=a;continue}else if((r[5]||r[6])&&s%3&&!((s+a)%3)){c+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l+c);let g=[...r[0]][0].length,h=e.slice(0,s+r.index+g+a);if(Math.min(s,a)%2){let f=h.slice(1,-1);return {type:"em",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}let R=h.slice(2,-2);return {type:"strong",raw:h,text:R,tokens:this.lexer.inlineTokens(R)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return {type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return {type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else {let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0];}return {type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return {type:"text",raw:t[0],text:t[0],escaped:n}}}};var x=class u{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=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};let t={other:m,block:C.normal,inline:M.normal};this.options.pedantic?(t.block=C.pedantic,t.inline=M.pedantic):this.options.gfm&&(t.block=C.gfm,this.options.breaks?t.inline=M.breaks:t.inline=M.gfm),this.tokenizer.rules=t;}static get rules(){return {block:C,inline:M}}static lex(e,t){return new u(t).lex(e)}static lexInline(e,t){return new u(t).inlineTokens(e)}lex(e){e=e.replace(m.carriageReturn,`
350
396
  `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens);}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=false){for(this.options.pedantic&&(e=e.replace(m.tabCharGlobal," ").replace(m.spaceLine,""));e;){let r;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;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let s=t.at(-1);r.raw.length===1&&s!==void 0?s.raw+=`
351
397
  `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
352
398
  `)?"":`
@@ -354,13 +400,13 @@ ${c}`:c;let f=this.lexer.state.top;if(this.lexer.state.top=true,this.lexer.block
354
400
  `+r.text,this.inlineQueue.at(-1).src=s.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
355
401
  `)?"":`
356
402
  `)+r.raw,s.text+=`
357
- `+r.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let s=1/0,o=e.slice(1),a;this.options.extensions.startBlock.forEach(u=>{a=u.call({lexer:this},o),typeof a=="number"&&a>=0&&(s=Math.min(s,a));}),s<1/0&&s>=0&&(i=e.substring(0,s+1));}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let s=t.at(-1);n&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
403
+ `+r.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let s=1/0,o=e.slice(1),a;this.options.extensions.startBlock.forEach(l=>{a=l.call({lexer:this},o),typeof a=="number"&&a>=0&&(s=Math.min(s,a));}),s<1/0&&s>=0&&(i=e.substring(0,s+1));}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let s=t.at(-1);n&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
358
404
  `)?"":`
359
405
  `)+r.raw,s.text+=`
360
406
  `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
361
407
  `)?"":`
362
408
  `)+r.raw,s.text+=`
363
- `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(r);continue}if(e){let s="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(s);break}else throw new Error(s)}}return this.state.top=true,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);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));}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=false,s="";for(;e;){i||(s=""),i=false;let o;if(this.options.extensions?.inline?.some(u=>(o=u.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),true):false))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let u=t.at(-1);o.type==="text"&&u?.type==="text"?(u.raw+=o.raw,u.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,s)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let a=e;if(this.options.extensions?.startInline){let u=1/0,p=e.slice(1),c;this.options.extensions.startInline.forEach(f=>{c=f.call({lexer:this},p),typeof c=="number"&&c>=0&&(u=Math.min(u,c));}),u<1/0&&u>=0&&(a=e.substring(0,u+1));}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(s=o.raw.slice(-1)),i=true;let u=t.at(-1);u?.type==="text"?(u.raw+=o.raw,u.text+=o.text):t.push(o);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return t}};var P=class{options;parser;constructor(e){this.options=e||O;}space(e){return ""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(m.notSpaceStart)?.[0],i=e.replace(m.endingNewline,"")+`
409
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(r);continue}if(e){let s="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(s);break}else throw new Error(s)}}return this.state.top=true,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);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));}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=false,s="";for(;e;){i||(s=""),i=false;let o;if(this.options.extensions?.inline?.some(l=>(o=l.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),true):false))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let l=t.at(-1);o.type==="text"&&l?.type==="text"?(l.raw+=o.raw,l.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,s)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let a=e;if(this.options.extensions?.startInline){let l=1/0,c=e.slice(1),p;this.options.extensions.startInline.forEach(g=>{p=g.call({lexer:this},c),typeof p=="number"&&p>=0&&(l=Math.min(l,p));}),l<1/0&&l>=0&&(a=e.substring(0,l+1));}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(s=o.raw.slice(-1)),i=true;let l=t.at(-1);l?.type==="text"?(l.raw+=o.raw,l.text+=o.text):t.push(o);continue}if(e){let l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return t}};var P=class{options;parser;constructor(e){this.options=e||T;}space(e){return ""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(m.notSpaceStart)?.[0],i=e.replace(m.endingNewline,"")+`
364
410
  `;return r?'<pre><code class="language-'+w(r)+'">'+(n?i:w(i,true))+`</code></pre>
365
411
  `:"<pre><code>"+(n?i:w(i,true))+`</code></pre>
366
412
  `}blockquote({tokens:e}){return `<blockquote>
@@ -378,9 +424,9 @@ ${this.parser.parse(e)}</blockquote>
378
424
  `}tablerow({text:e}){return `<tr>
379
425
  ${e}</tr>
380
426
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return (e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
381
- `}strong({tokens:e}){return `<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return `<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return `<code>${w(e,true)}</code>`}br(e){return "<br>"}del({tokens:e}){return `<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=J(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+w(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=J(e);if(i===null)return w(n);e=i;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${w(t)}"`),s+=">",s}text(e){return "tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:w(e.text)}};var $=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return ""+e}image({text:e}){return ""+e}br(){return ""}};var R=class l{options;renderer;textRenderer;constructor(e){this.options=e||O,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 $;}static parse(e,t){return new l(t).parse(e)}static parseInline(e,t){return new l(t).parseInline(e)}parse(e,t=true){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==false||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=a||"";continue}}let s=i;switch(s.type){case "space":{n+=this.renderer.space(s);continue}case "hr":{n+=this.renderer.hr(s);continue}case "heading":{n+=this.renderer.heading(s);continue}case "code":{n+=this.renderer.code(s);continue}case "table":{n+=this.renderer.table(s);continue}case "blockquote":{n+=this.renderer.blockquote(s);continue}case "list":{n+=this.renderer.list(s);continue}case "html":{n+=this.renderer.html(s);continue}case "def":{n+=this.renderer.def(s);continue}case "paragraph":{n+=this.renderer.paragraph(s);continue}case "text":{let o=s,a=this.renderer.text(o);for(;r+1<e.length&&e[r+1].type==="text";)o=e[++r],a+=`
382
- `+this.renderer.text(o);t?n+=this.renderer.paragraph({type:"paragraph",raw:a,text:a,tokens:[{type:"text",raw:a,text:a,escaped:true}]}):n+=a;continue}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==false||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=o||"";continue}}let s=i;switch(s.type){case "escape":{n+=t.text(s);break}case "html":{n+=t.html(s);break}case "link":{n+=t.link(s);break}case "image":{n+=t.image(s);break}case "strong":{n+=t.strong(s);break}case "em":{n+=t.em(s);break}case "codespan":{n+=t.codespan(s);break}case "br":{n+=t.br(s);break}case "del":{n+=t.del(s);break}case "text":{n+=t.text(s);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}};var S=class{options;block;constructor(e){this.options=e||O;}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?b.lex:b.lexInline}provideParser(){return this.block?R.parse:R.parseInline}};var B=class{defaults=L();options=this.setOptions;parse=this.parseMarkdown(true);parseInline=this.parseMarkdown(false);Parser=R;Renderer=P;TextRenderer=$;Lexer=b;Tokenizer=y;Hooks=S;constructor(...e){this.use(...e);}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case "table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let o of s)n=n.concat(this.walkTokens(o.tokens,t));break}case "list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,t));}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)));}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||false,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===false&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer;}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]));}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens);}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new P(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=n.renderer[o],u=i[o];i[o]=(...p)=>{let c=a.apply(i,p);return c===false&&(c=u.apply(i,p)),c||""};}r.renderer=i;}if(n.tokenizer){let i=this.defaults.tokenizer||new y(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=n.tokenizer[o],u=i[o];i[o]=(...p)=>{let c=a.apply(i,p);return c===false&&(c=u.apply(i,p)),c};}r.tokenizer=i;}if(n.hooks){let i=this.defaults.hooks||new S;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=n.hooks[o],u=i[o];S.passThroughHooks.has(s)?i[o]=p=>{if(this.defaults.async&&S.passThroughHooksRespectAsync.has(s))return Promise.resolve(a.call(i,p)).then(f=>u.call(i,f));let c=a.call(i,p);return u.call(i,c)}:i[o]=(...p)=>{let c=a.apply(i,p);return c===false&&(c=u.apply(i,p)),c};}r.hooks=i;}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a};}this.defaults={...this.defaults,...r};}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return b.lex(e,t??this.defaults)}parser(e,t){return R.parse(e,t??this.defaults)}parseMarkdown(e){return (n,r)=>{let i={...r},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===true&&i.async===false)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));s.hooks&&(s.hooks.options=s,s.hooks.block=e);let a=s.hooks?s.hooks.provideLexer():e?b.lex:b.lexInline,u=s.hooks?s.hooks.provideParser():e?R.parse:R.parseInline;if(s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(n):n).then(p=>a(p,s)).then(p=>s.hooks?s.hooks.processAllTokens(p):p).then(p=>s.walkTokens?Promise.all(this.walkTokens(p,s.walkTokens)).then(()=>p):p).then(p=>u(p,s)).then(p=>s.hooks?s.hooks.postprocess(p):p).catch(o);try{s.hooks&&(n=s.hooks.preprocess(n));let p=a(n,s);s.hooks&&(p=s.hooks.processAllTokens(p)),s.walkTokens&&this.walkTokens(p,s.walkTokens);let c=u(p,s);return s.hooks&&(c=s.hooks.postprocess(c)),c}catch(p){return o(p)}}}onError(e,t){return n=>{if(n.message+=`
383
- Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+w(n.message+"",true)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}};var _=new B;function d(l,e){return _.parse(l,e)}d.options=d.setOptions=function(l){return _.setOptions(l),d.defaults=_.defaults,G(d.defaults),d};d.getDefaults=L;d.defaults=O;d.use=function(...l){return _.use(...l),d.defaults=_.defaults,G(d.defaults),d};d.walkTokens=function(l,e){return _.walkTokens(l,e)};d.parseInline=_.parseInline;d.Parser=R;d.parser=R.parse;d.Renderer=P;d.TextRenderer=$;d.Lexer=b;d.lexer=b.lex;d.Tokenizer=y;d.Hooks=S;d.parse=d;d.options;d.setOptions;d.use;d.walkTokens;d.parseInline;R.parse;b.lex;
427
+ `}strong({tokens:e}){return `<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return `<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return `<code>${w(e,true)}</code>`}br(e){return "<br>"}del({tokens:e}){return `<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=J(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+w(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=J(e);if(i===null)return w(n);e=i;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${w(t)}"`),s+=">",s}text(e){return "tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:w(e.text)}};var $=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return ""+e}image({text:e}){return ""+e}br(){return ""}};var b=class u{options;renderer;textRenderer;constructor(e){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 $;}static parse(e,t){return new u(t).parse(e)}static parseInline(e,t){return new u(t).parseInline(e)}parse(e,t=true){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==false||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=a||"";continue}}let s=i;switch(s.type){case "space":{n+=this.renderer.space(s);continue}case "hr":{n+=this.renderer.hr(s);continue}case "heading":{n+=this.renderer.heading(s);continue}case "code":{n+=this.renderer.code(s);continue}case "table":{n+=this.renderer.table(s);continue}case "blockquote":{n+=this.renderer.blockquote(s);continue}case "list":{n+=this.renderer.list(s);continue}case "html":{n+=this.renderer.html(s);continue}case "def":{n+=this.renderer.def(s);continue}case "paragraph":{n+=this.renderer.paragraph(s);continue}case "text":{let o=s,a=this.renderer.text(o);for(;r+1<e.length&&e[r+1].type==="text";)o=e[++r],a+=`
428
+ `+this.renderer.text(o);t?n+=this.renderer.paragraph({type:"paragraph",raw:a,text:a,tokens:[{type:"text",raw:a,text:a,escaped:true}]}):n+=a;continue}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==false||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=o||"";continue}}let s=i;switch(s.type){case "escape":{n+=t.text(s);break}case "html":{n+=t.html(s);break}case "link":{n+=t.link(s);break}case "image":{n+=t.image(s);break}case "strong":{n+=t.strong(s);break}case "em":{n+=t.em(s);break}case "codespan":{n+=t.codespan(s);break}case "br":{n+=t.br(s);break}case "del":{n+=t.del(s);break}case "text":{n+=t.text(s);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}};var S=class{options;block;constructor(e){this.options=e||T;}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?x.lex:x.lexInline}provideParser(){return this.block?b.parse:b.parseInline}};var B=class{defaults=L();options=this.setOptions;parse=this.parseMarkdown(true);parseInline=this.parseMarkdown(false);Parser=b;Renderer=P;TextRenderer=$;Lexer=x;Tokenizer=y;Hooks=S;constructor(...e){this.use(...e);}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case "table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let o of s)n=n.concat(this.walkTokens(o.tokens,t));break}case "list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,t));}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)));}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||false,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===false&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer;}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]));}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens);}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new P(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=n.renderer[o],l=i[o];i[o]=(...c)=>{let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p||""};}r.renderer=i;}if(n.tokenizer){let i=this.defaults.tokenizer||new y(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=n.tokenizer[o],l=i[o];i[o]=(...c)=>{let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p};}r.tokenizer=i;}if(n.hooks){let i=this.defaults.hooks||new S;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=n.hooks[o],l=i[o];S.passThroughHooks.has(s)?i[o]=c=>{if(this.defaults.async&&S.passThroughHooksRespectAsync.has(s))return (async()=>{let g=await a.call(i,c);return l.call(i,g)})();let p=a.call(i,c);return l.call(i,p)}:i[o]=(...c)=>{if(this.defaults.async)return (async()=>{let g=await a.apply(i,c);return g===false&&(g=await l.apply(i,c)),g})();let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p};}r.hooks=i;}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a};}this.defaults={...this.defaults,...r};}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return x.lex(e,t??this.defaults)}parser(e,t){return b.parse(e,t??this.defaults)}parseMarkdown(e){return (n,r)=>{let i={...r},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===true&&i.async===false)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return (async()=>{let a=s.hooks?await s.hooks.preprocess(n):n,c=await(s.hooks?await s.hooks.provideLexer():e?x.lex:x.lexInline)(a,s),p=s.hooks?await s.hooks.processAllTokens(c):c;s.walkTokens&&await Promise.all(this.walkTokens(p,s.walkTokens));let h=await(s.hooks?await s.hooks.provideParser():e?b.parse:b.parseInline)(p,s);return s.hooks?await s.hooks.postprocess(h):h})().catch(o);try{s.hooks&&(n=s.hooks.preprocess(n));let l=(s.hooks?s.hooks.provideLexer():e?x.lex:x.lexInline)(n,s);s.hooks&&(l=s.hooks.processAllTokens(l)),s.walkTokens&&this.walkTokens(l,s.walkTokens);let p=(s.hooks?s.hooks.provideParser():e?b.parse:b.parseInline)(l,s);return s.hooks&&(p=s.hooks.postprocess(p)),p}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=`
429
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+w(n.message+"",true)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}};var _=new B;function k(u,e){return _.parse(u,e)}k.options=k.setOptions=function(u){return _.setOptions(u),k.defaults=_.defaults,G(k.defaults),k};k.getDefaults=L;k.defaults=T;k.use=function(...u){return _.use(...u),k.defaults=_.defaults,G(k.defaults),k};k.walkTokens=function(u,e){return _.walkTokens(u,e)};k.parseInline=_.parseInline;k.Parser=b;k.parser=b.parse;k.Renderer=P;k.TextRenderer=$;k.Lexer=x;k.lexer=x.lex;k.Tokenizer=y;k.Hooks=S;k.parse=k;k.options;k.setOptions;k.use;k.walkTokens;k.parseInline;b.parse;x.lex;
384
430
 
385
431
  /*
386
432
  * Set up window for Node.js
@@ -501,18 +547,6 @@ function formatByteSize(byteSize, digits = 2, autoFormat = true) {
501
547
  function formatDate(timestamp, format) {
502
548
  return dayjs.unix(timestamp).format(format);
503
549
  }
504
- /**
505
- *
506
- * @param html
507
- */
508
- function strToDOM(html) {
509
- const doc = new DOMParser().parseFromString(html, 'text/html');
510
- const el = doc.body.firstElementChild;
511
- if (!el || !(el instanceof HTMLElement)) {
512
- throw new Error(`Element not found: ${html}`);
513
- }
514
- return el;
515
- }
516
550
 
517
551
  const cache = new Map();
518
552
  /**
@@ -2517,6 +2551,10 @@ function requireIdentifiers () {
2517
2551
 
2518
2552
  const numeric = /^[0-9]+$/;
2519
2553
  const compareIdentifiers = (a, b) => {
2554
+ if (typeof a === 'number' && typeof b === 'number') {
2555
+ return a === b ? 0 : a < b ? -1 : 1
2556
+ }
2557
+
2520
2558
  const anum = numeric.test(a);
2521
2559
  const bnum = numeric.test(b);
2522
2560
 
@@ -2659,11 +2697,25 @@ function requireSemver$1 () {
2659
2697
  other = new SemVer(other, this.options);
2660
2698
  }
2661
2699
 
2662
- return (
2663
- compareIdentifiers(this.major, other.major) ||
2664
- compareIdentifiers(this.minor, other.minor) ||
2665
- compareIdentifiers(this.patch, other.patch)
2666
- )
2700
+ if (this.major < other.major) {
2701
+ return -1
2702
+ }
2703
+ if (this.major > other.major) {
2704
+ return 1
2705
+ }
2706
+ if (this.minor < other.minor) {
2707
+ return -1
2708
+ }
2709
+ if (this.minor > other.minor) {
2710
+ return 1
2711
+ }
2712
+ if (this.patch < other.patch) {
2713
+ return -1
2714
+ }
2715
+ if (this.patch > other.patch) {
2716
+ return 1
2717
+ }
2718
+ return 0
2667
2719
  }
2668
2720
 
2669
2721
  comparePre (other) {
@@ -3684,6 +3736,7 @@ function requireRange () {
3684
3736
  // already replaced the hyphen ranges
3685
3737
  // turn into a set of JUST comparators.
3686
3738
  const parseComparator = (comp, options) => {
3739
+ comp = comp.replace(re[t.BUILD], '');
3687
3740
  debug('comp', comp, options);
3688
3741
  comp = replaceCarets(comp, options);
3689
3742
  debug('caret', comp);
@@ -4887,6 +4940,405 @@ function requireSemver () {
4887
4940
  var semverExports = requireSemver();
4888
4941
  const semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
4889
4942
 
4943
+ /**
4944
+ * テンプレート文字列のプレースホルダーを設定値で置換する
4945
+ * @param template
4946
+ * @param config
4947
+ */
4948
+ function replacePlaceholders(template, config) {
4949
+ return template
4950
+ .replaceAll('%sampleImagePath%', config.sampleImagePath)
4951
+ .replaceAll('%sampleFilePath%', config.sampleFilePath)
4952
+ .replaceAll('%googleMapsApiKey%', config.googleMapsApiKey ?? '');
4953
+ }
4954
+
4955
+ /**
4956
+ *
4957
+ * @param html
4958
+ * @param data
4959
+ */
4960
+ function dataToHtml(html, data) {
4961
+ return frozenPatty(html, {
4962
+ attr: 'bge',
4963
+ typeConvert: true,
4964
+ valueFilter,
4965
+ })
4966
+ .merge(data)
4967
+ .toHTML();
4968
+ }
4969
+
4970
+ class ItemEditorService {
4971
+ #beforeChange;
4972
+ #beforeOpen;
4973
+ #data;
4974
+ #isDisable;
4975
+ #item;
4976
+ #migrate;
4977
+ #migrateElement;
4978
+ #onSubmit;
4979
+ #open;
4980
+ get item() {
4981
+ return this.#item;
4982
+ }
4983
+ constructor(item, seed) {
4984
+ this.#item = item;
4985
+ const options = seed.editorOptions ?? {};
4986
+ if (options.beforeOpen) {
4987
+ this.#beforeOpen = options.beforeOpen;
4988
+ }
4989
+ if (options.open) {
4990
+ this.#open = options.open;
4991
+ }
4992
+ if (options.beforeChange) {
4993
+ this.#beforeChange = options.beforeChange;
4994
+ }
4995
+ if (options.onSubmit) {
4996
+ this.#onSubmit = options.onSubmit;
4997
+ }
4998
+ if (options.migrate) {
4999
+ this.#migrate = options.migrate;
5000
+ }
5001
+ if (options.migrateElement) {
5002
+ this.#migrateElement = options.migrateElement;
5003
+ }
5004
+ if (options.isDisable) {
5005
+ this.#isDisable = options.isDisable;
5006
+ }
5007
+ this.#data = options.customData;
5008
+ }
5009
+ async beforeChange(newValues, editor) {
5010
+ if (this.#beforeChange) {
5011
+ return this.#beforeChange(newValues, editor);
5012
+ }
5013
+ return newValues;
5014
+ }
5015
+ beforeOpen(data, editor) {
5016
+ if (this.#beforeOpen) {
5017
+ return this.#beforeOpen(data, editor);
5018
+ }
5019
+ return data;
5020
+ }
5021
+ getData(customProperty) {
5022
+ return this.#data?.[customProperty] ?? null;
5023
+ }
5024
+ isDisable(item) {
5025
+ return this.#isDisable?.(item) ?? '';
5026
+ }
5027
+ migrate(item) {
5028
+ return this.#migrate ? this.#migrate(item) : item.export();
5029
+ }
5030
+ async migrateElement(data, item) {
5031
+ await this.#migrateElement?.(data, item);
5032
+ }
5033
+ onSubmit(e, submitter) {
5034
+ return this.#onSubmit?.(e, submitter);
5035
+ }
5036
+ async open(data, editor) {
5037
+ await this.#open?.(data, editor);
5038
+ }
5039
+ setData(customProperty, value) {
5040
+ if (!this.#data) {
5041
+ return;
5042
+ }
5043
+ this.#data[customProperty] = value;
5044
+ }
5045
+ }
5046
+
5047
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5048
+ const elMap = new WeakMap();
5049
+ let Item$1 = class Item {
5050
+ editor;
5051
+ name;
5052
+ #el;
5053
+ #engine;
5054
+ #service;
5055
+ #version;
5056
+ get el() {
5057
+ return this.#el;
5058
+ }
5059
+ get version() {
5060
+ return this.#version;
5061
+ }
5062
+ // eslint-disable-next-line no-restricted-syntax
5063
+ constructor(engine, seed, el) {
5064
+ elMap.set(el, this);
5065
+ this.#el = el;
5066
+ this.#el.addEventListener('click', (e) => {
5067
+ e.preventDefault();
5068
+ e.stopPropagation();
5069
+ void this.#openEditor();
5070
+ });
5071
+ this.#engine = engine;
5072
+ this.name = seed.name;
5073
+ this.#version = seed.version;
5074
+ this.#service = new ItemEditorService(this, seed);
5075
+ this.editor = engine.itemEditorDialog;
5076
+ }
5077
+ export() {
5078
+ return dataFromHtml(this.el.innerHTML);
5079
+ }
5080
+ async import(newData, fromDialogChanges = false) {
5081
+ const currentData = this.export();
5082
+ let data = {
5083
+ ...currentData,
5084
+ ...newData,
5085
+ };
5086
+ if (fromDialogChanges) {
5087
+ data = await this.#service.beforeChange(data, this.editor);
5088
+ }
5089
+ this.el.innerHTML = dataToHtml(this.el.innerHTML, data);
5090
+ if (this.#isOld(this.#engine.items)) {
5091
+ await this.#service.migrateElement(data, this);
5092
+ }
5093
+ }
5094
+ isDisable() {
5095
+ return this.#service.isDisable(this);
5096
+ }
5097
+ #isOld(currentItems) {
5098
+ const originVersion = currentItems.get(this.name)?.version ?? '0.0.0';
5099
+ const isOld = semver.lt(this.#version, originVersion);
5100
+ return isOld;
5101
+ }
5102
+ async #openEditor() {
5103
+ await this.editor.open(this.#service);
5104
+ }
5105
+ static async create(engine, name, initData = {}) {
5106
+ const seed = engine.items.get(name);
5107
+ if (!seed) {
5108
+ throw new Error(`Item seed not found: ${name}`);
5109
+ }
5110
+ const version = seed.version;
5111
+ const wrapper = document.createElement('div');
5112
+ wrapper.dataset.bgi = name;
5113
+ wrapper.dataset.bgiVer = version;
5114
+ wrapper.innerHTML = replacePlaceholders(seed.template, engine.config);
5115
+ const item = new Item(engine, seed, wrapper);
5116
+ await item.import(initData);
5117
+ return item;
5118
+ }
5119
+ static rebind(engine, el) {
5120
+ const name = el.dataset.bgi;
5121
+ if (!name) {
5122
+ throw new Error('data-bgi not found');
5123
+ }
5124
+ const seed = engine.items.get(name);
5125
+ if (!seed) {
5126
+ throw new Error(`Item seed not found: ${name}`);
5127
+ }
5128
+ const item = new Item(engine, seed, el);
5129
+ return item;
5130
+ }
5131
+ static getInstance(el) {
5132
+ return elMap.get(el);
5133
+ }
5134
+ };
5135
+
5136
+ /**
5137
+ * グリッドアイテムを追加または削除する
5138
+ * @param $items - 子要素の配列
5139
+ * @param engine - BurgerEditorEngineインスタンス
5140
+ * @param addOrRemove - 1: 追加, -1: 削除
5141
+ * @param items - アイテムの配列
5142
+ * @param updateItem
5143
+ * @description
5144
+ * グリッドアイテムの追加/削除を行う:
5145
+ * - 追加の場合:
5146
+ * 1. 最後の要素をクローン
5147
+ * 2. クローンを親要素に追加
5148
+ * 3. クローン内のアイテムを初期化してitemsに追加
5149
+ * - 削除の場合:
5150
+ * 1. 最後の要素を削除
5151
+ * 2. itemsから対応するアイテムを削除
5152
+ */
5153
+ function updateGridItems($items, engine, addOrRemove, items, updateItem) {
5154
+ const $lastItem = $items.at(-1);
5155
+ if (!$lastItem) {
5156
+ return;
5157
+ }
5158
+ // Add
5159
+ if (addOrRemove === 1) {
5160
+ const $newItem = $lastItem.cloneNode(true);
5161
+ $lastItem.parentElement?.append($newItem);
5162
+ const $newItems = $newItem.querySelectorAll('[data-bge-group]');
5163
+ for (const $item of $newItems) {
5164
+ const item = Item$1.rebind(engine, $item);
5165
+ const newItems = [...items];
5166
+ newItems[newItems.length] = item;
5167
+ updateItem(newItems);
5168
+ }
5169
+ return;
5170
+ }
5171
+ // Remove
5172
+ const removeCount = $lastItem.querySelectorAll('[data-bge-group]').length;
5173
+ $lastItem.remove();
5174
+ const newItems = [...items];
5175
+ newItems.splice(-removeCount);
5176
+ updateItem(newItems);
5177
+ }
5178
+
5179
+ var _a;
5180
+ const bbMap = new WeakMap();
5181
+ let _lastUID = 0;
5182
+ class BurgerBlock {
5183
+ #createItemElement;
5184
+ #items = [];
5185
+ #uid;
5186
+ get items() {
5187
+ return this.#items;
5188
+ }
5189
+ set items(items) {
5190
+ this.#items = items;
5191
+ }
5192
+ get id() {
5193
+ return this.el.id;
5194
+ }
5195
+ get el() {
5196
+ return bbMap.get(this);
5197
+ }
5198
+ // eslint-disable-next-line no-restricted-syntax
5199
+ constructor(createItemElement) {
5200
+ this.#uid = _lastUID++;
5201
+ this.#createItemElement = createItemElement;
5202
+ }
5203
+ /**
5204
+ * Change the semantic type of container frame and groups
5205
+ * @param frameSemantics - The semantic type to change to
5206
+ */
5207
+ changeFrameSemantics(frameSemantics) {
5208
+ changeFrameSemantics(this.el, frameSemantics);
5209
+ }
5210
+ clone() {
5211
+ const originalData = this.#export();
5212
+ const newBlock = _a.create(originalData, this.#createItemElement);
5213
+ return newBlock;
5214
+ }
5215
+ existNext() {
5216
+ return !!this.el.nextElementSibling;
5217
+ }
5218
+ existPrev() {
5219
+ return !!this.el.previousElementSibling;
5220
+ }
5221
+ exportOptions() {
5222
+ return exportOptions(this.el);
5223
+ }
5224
+ getHTMLStringify() {
5225
+ return this.el.outerHTML;
5226
+ }
5227
+ async importJSONString(jsonString) {
5228
+ const data = JSON.parse(jsonString);
5229
+ try {
5230
+ await this.#import(data);
5231
+ }
5232
+ catch (error) {
5233
+ throw new Error(`ImportError: ${error instanceof Error ? error.message : error}`);
5234
+ }
5235
+ }
5236
+ importOptions(options) {
5237
+ importOptions(this.el, options);
5238
+ }
5239
+ importTypes(extractor) {
5240
+ for (const [i, item] of this.items.entries()) {
5241
+ void item.import(extractor(i, item));
5242
+ }
5243
+ }
5244
+ is(block) {
5245
+ return this.#uid === block.#uid;
5246
+ }
5247
+ isDisable() {
5248
+ let msg = '';
5249
+ for (const type of this.items) {
5250
+ msg = type.isDisable();
5251
+ if (msg) {
5252
+ break;
5253
+ }
5254
+ }
5255
+ return msg;
5256
+ }
5257
+ isMutable() {
5258
+ return this.el.matches(':not([data-bge-container*=":immutable"])');
5259
+ }
5260
+ remove() {
5261
+ this.el.remove();
5262
+ }
5263
+ toJSONStringify(space) {
5264
+ return JSON.stringify(this.#export(), null, space);
5265
+ }
5266
+ updateGridItems(addOrRemove, engine) {
5267
+ updateGridItems([...this.el.querySelectorAll('[data-bge-group]')], engine, addOrRemove, this.items, (items) => (this.items = items));
5268
+ }
5269
+ #create(data) {
5270
+ return createPlainStructuredBlockElement(data, this.#createItemElement);
5271
+ }
5272
+ #export() {
5273
+ return parseHTMLToBlockData(this.el);
5274
+ }
5275
+ #fallbackBlockData(html) {
5276
+ return {
5277
+ name: 'text',
5278
+ containerProps: {
5279
+ type: 'grid',
5280
+ columns: 1,
5281
+ },
5282
+ classList: [],
5283
+ items: [[{ name: 'wysiwyg', data: { wysiwyg: html } }]],
5284
+ };
5285
+ }
5286
+ async #import(data) {
5287
+ this.el.replaceWith(await createPlainStructuredBlockElement(data, this.#createItemElement));
5288
+ }
5289
+ async #rebind(el) {
5290
+ if (isBurgerBlockElement(el)) {
5291
+ const itemContainers = el.querySelectorAll('[data-bge-item]');
5292
+ for (const itemContainer of itemContainers) {
5293
+ const itemElements = itemContainer.querySelectorAll('[data-bgi]');
5294
+ for (const itemElement of itemElements) {
5295
+ await this.#createItemElement(itemElement);
5296
+ }
5297
+ }
5298
+ return el;
5299
+ }
5300
+ // eslint-disable-next-line no-console
5301
+ console.error('%o is not a burger block', el);
5302
+ const fallbackEl = await createPlainStructuredBlockElement(this.#fallbackBlockData(el.outerHTML), this.#createItemElement);
5303
+ el.replaceWith(fallbackEl);
5304
+ return fallbackEl;
5305
+ }
5306
+ #set(el) {
5307
+ bbMap.set(this, el);
5308
+ _a.#blocks.set(this.el, this);
5309
+ }
5310
+ static #blocks = new WeakMap();
5311
+ static async create(data, createItemElement) {
5312
+ const block = new _a(createItemElement);
5313
+ const el = await block.#create(data);
5314
+ block.#set(el);
5315
+ return block;
5316
+ }
5317
+ static async rebind(el, createItemElement) {
5318
+ const block = new _a(createItemElement);
5319
+ const newEl = await block.#rebind(el);
5320
+ block.#set(newEl);
5321
+ return block;
5322
+ }
5323
+ static getBlock(el) {
5324
+ const block = this.#blocks.get(el);
5325
+ if (!block) {
5326
+ throw new Error('Do not get BurgerBlock instance.');
5327
+ }
5328
+ return block;
5329
+ }
5330
+ }
5331
+ _a = BurgerBlock;
5332
+ /**
5333
+ *
5334
+ * @param el
5335
+ */
5336
+ function isBurgerBlockElement(el) {
5337
+ return el.matches([
5338
+ '[data-bge-name][data-bge-container]:has(>[data-bge-container-frame]>[data-bge-group]>[data-bge-item])',
5339
+ ].join(','));
5340
+ }
5341
+
4890
5342
  /**
4891
5343
  *
4892
5344
  * @param doc
@@ -6505,472 +6957,6 @@ class BurgerEditorEngine {
6505
6957
  }
6506
6958
  }
6507
6959
 
6508
- /**
6509
- * テンプレート文字列のプレースホルダーを設定値で置換する
6510
- * @param template
6511
- * @param config
6512
- */
6513
- function replacePlaceholders(template, config) {
6514
- return template
6515
- .replaceAll('%sampleImagePath%', config.sampleImagePath)
6516
- .replaceAll('%sampleFilePath%', config.sampleFilePath)
6517
- .replaceAll('%googleMapsApiKey%', config.googleMapsApiKey ?? '');
6518
- }
6519
-
6520
- /**
6521
- *
6522
- * @param html
6523
- * @param data
6524
- */
6525
- function dataToHtml(html, data) {
6526
- return frozenPatty(html, {
6527
- attr: 'bge',
6528
- typeConvert: true,
6529
- valueFilter,
6530
- })
6531
- .merge(data)
6532
- .toHTML();
6533
- }
6534
-
6535
- class ItemEditorService {
6536
- #beforeChange;
6537
- #beforeOpen;
6538
- #data;
6539
- #isDisable;
6540
- #item;
6541
- #migrate;
6542
- #migrateElement;
6543
- #onSubmit;
6544
- #open;
6545
- get item() {
6546
- return this.#item;
6547
- }
6548
- constructor(item, seed) {
6549
- this.#item = item;
6550
- const options = seed.editorOptions ?? {};
6551
- if (options.beforeOpen) {
6552
- this.#beforeOpen = options.beforeOpen;
6553
- }
6554
- if (options.open) {
6555
- this.#open = options.open;
6556
- }
6557
- if (options.beforeChange) {
6558
- this.#beforeChange = options.beforeChange;
6559
- }
6560
- if (options.onSubmit) {
6561
- this.#onSubmit = options.onSubmit;
6562
- }
6563
- if (options.migrate) {
6564
- this.#migrate = options.migrate;
6565
- }
6566
- if (options.migrateElement) {
6567
- this.#migrateElement = options.migrateElement;
6568
- }
6569
- if (options.isDisable) {
6570
- this.#isDisable = options.isDisable;
6571
- }
6572
- this.#data = options.customData;
6573
- }
6574
- async beforeChange(newValues, editor) {
6575
- if (this.#beforeChange) {
6576
- return this.#beforeChange(newValues, editor);
6577
- }
6578
- return newValues;
6579
- }
6580
- beforeOpen(data, editor) {
6581
- if (this.#beforeOpen) {
6582
- return this.#beforeOpen(data, editor);
6583
- }
6584
- return data;
6585
- }
6586
- getData(customProperty) {
6587
- return this.#data?.[customProperty] ?? null;
6588
- }
6589
- isDisable(item) {
6590
- return this.#isDisable?.(item) ?? '';
6591
- }
6592
- migrate(item) {
6593
- return this.#migrate ? this.#migrate(item) : item.export();
6594
- }
6595
- async migrateElement(data, item) {
6596
- await this.#migrateElement?.(data, item);
6597
- }
6598
- onSubmit(e, submitter) {
6599
- return this.#onSubmit?.(e, submitter);
6600
- }
6601
- async open(data, editor) {
6602
- await this.#open?.(data, editor);
6603
- }
6604
- setData(customProperty, value) {
6605
- if (!this.#data) {
6606
- return;
6607
- }
6608
- this.#data[customProperty] = value;
6609
- }
6610
- }
6611
-
6612
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6613
- const elMap = new WeakMap();
6614
- let Item$1 = class Item {
6615
- editor;
6616
- name;
6617
- #el;
6618
- #engine;
6619
- #service;
6620
- #version;
6621
- get el() {
6622
- return this.#el;
6623
- }
6624
- get version() {
6625
- return this.#version;
6626
- }
6627
- // eslint-disable-next-line no-restricted-syntax
6628
- constructor(engine, seed, el) {
6629
- elMap.set(el, this);
6630
- this.#el = el;
6631
- this.#el.addEventListener('click', (e) => {
6632
- e.preventDefault();
6633
- e.stopPropagation();
6634
- void this.#openEditor();
6635
- });
6636
- this.#engine = engine;
6637
- this.name = seed.name;
6638
- this.#version = seed.version;
6639
- this.#service = new ItemEditorService(this, seed);
6640
- this.editor = engine.itemEditorDialog;
6641
- }
6642
- export() {
6643
- return dataFromHtml(this.el.innerHTML);
6644
- }
6645
- async import(newData, fromDialogChanges = false) {
6646
- const currentData = this.export();
6647
- let data = {
6648
- ...currentData,
6649
- ...newData,
6650
- };
6651
- if (fromDialogChanges) {
6652
- data = await this.#service.beforeChange(data, this.editor);
6653
- }
6654
- this.el.innerHTML = dataToHtml(this.el.innerHTML, data);
6655
- if (this.#isOld(this.#engine.items)) {
6656
- await this.#service.migrateElement(data, this);
6657
- }
6658
- }
6659
- isDisable() {
6660
- return this.#service.isDisable(this);
6661
- }
6662
- async upgrade() {
6663
- if (!this.#isOld(this.#engine.items)) {
6664
- return;
6665
- }
6666
- const newTemplate = this.#engine.items.get(this.name)?.template;
6667
- if (!newTemplate) {
6668
- return;
6669
- }
6670
- const newEl = strToDOM(newTemplate);
6671
- const v = newEl.dataset.bgiVer;
6672
- const itemEditor = BurgerEditorEngine.getItemSeed(this.name);
6673
- const currentData = itemEditor
6674
- ? // @ts-ignore
6675
- itemEditor.migrate(this)
6676
- : this.export();
6677
- const newTemplateData = dataFromHtml(newEl.innerHTML);
6678
- const data = { ...newTemplateData, ...currentData };
6679
- this.el.innerHTML = newEl.innerHTML;
6680
- this.el.dataset.bgiVer = v;
6681
- await this.import(data);
6682
- this.#version = v;
6683
- }
6684
- #isOld(currentItems) {
6685
- const originVersion = currentItems.get(this.name)?.version ?? '0.0.0';
6686
- const isOld = semver.lt(this.#version, originVersion);
6687
- return isOld;
6688
- }
6689
- async #openEditor() {
6690
- await this.editor.open(this.#service);
6691
- }
6692
- static async create(engine, name, initData = {}) {
6693
- const seed = engine.items.get(name);
6694
- if (!seed) {
6695
- throw new Error(`Item seed not found: ${name}`);
6696
- }
6697
- const version = seed.version;
6698
- const wrapper = document.createElement('div');
6699
- wrapper.dataset.bgi = name;
6700
- wrapper.dataset.bgiVer = version;
6701
- wrapper.innerHTML = replacePlaceholders(seed.template, engine.config);
6702
- const item = new Item(engine, seed, wrapper);
6703
- await item.import(initData);
6704
- return item;
6705
- }
6706
- static rebind(engine, el) {
6707
- const name = el.dataset.bgi;
6708
- if (!name) {
6709
- throw new Error('data-bgi not found');
6710
- }
6711
- const seed = engine.items.get(name);
6712
- if (!seed) {
6713
- throw new Error(`Item seed not found: ${name}`);
6714
- }
6715
- const item = new Item(engine, seed, el);
6716
- return item;
6717
- }
6718
- static getInstance(el) {
6719
- return elMap.get(el);
6720
- }
6721
- };
6722
-
6723
- /**
6724
- * グリッドアイテムを追加または削除する
6725
- * @param $items - 子要素の配列
6726
- * @param engine - BurgerEditorEngineインスタンス
6727
- * @param addOrRemove - 1: 追加, -1: 削除
6728
- * @param items - アイテムの配列
6729
- * @param updateItem
6730
- * @description
6731
- * グリッドアイテムの追加/削除を行う:
6732
- * - 追加の場合:
6733
- * 1. 最後の要素をクローン
6734
- * 2. クローンを親要素に追加
6735
- * 3. クローン内のアイテムを初期化してitemsに追加
6736
- * - 削除の場合:
6737
- * 1. 最後の要素を削除
6738
- * 2. itemsから対応するアイテムを削除
6739
- */
6740
- function updateGridItems($items, engine, addOrRemove, items, updateItem) {
6741
- const $lastItem = $items.at(-1);
6742
- if (!$lastItem) {
6743
- return;
6744
- }
6745
- // Add
6746
- if (addOrRemove === 1) {
6747
- const $newItem = $lastItem.cloneNode(true);
6748
- $lastItem.parentElement?.append($newItem);
6749
- const $newItems = $newItem.querySelectorAll('[data-bge-group]');
6750
- for (const $item of $newItems) {
6751
- const item = Item$1.rebind(engine, $item);
6752
- const newItems = [...items];
6753
- newItems[newItems.length] = item;
6754
- updateItem(newItems);
6755
- }
6756
- return;
6757
- }
6758
- // Remove
6759
- const removeCount = $lastItem.querySelectorAll('[data-bge-group]').length;
6760
- $lastItem.remove();
6761
- const newItems = [...items];
6762
- newItems.splice(-removeCount);
6763
- updateItem(newItems);
6764
- }
6765
-
6766
- var _a;
6767
- const bbMap = new WeakMap();
6768
- let _lastUID = 0;
6769
- class BurgerBlock {
6770
- #createItemElement;
6771
- #items = [];
6772
- #uid;
6773
- get items() {
6774
- return this.#items;
6775
- }
6776
- set items(items) {
6777
- this.#items = items;
6778
- }
6779
- get id() {
6780
- return this.el.id;
6781
- }
6782
- get el() {
6783
- return bbMap.get(this);
6784
- }
6785
- // eslint-disable-next-line no-restricted-syntax
6786
- constructor(createItemElement) {
6787
- this.#uid = _lastUID++;
6788
- this.#createItemElement = createItemElement;
6789
- }
6790
- /**
6791
- * Change the semantic type of container frame and groups
6792
- * @param frameSemantics - The semantic type to change to
6793
- */
6794
- changeFrameSemantics(frameSemantics) {
6795
- const containerFrame = this.el.querySelector('[data-bge-container-frame]');
6796
- if (!containerFrame) {
6797
- throw new Error('Container frame not found');
6798
- }
6799
- // Determine target elements
6800
- const frameTagName = frameSemantics === 'div' ? 'div' : frameSemantics;
6801
- const groupTagName = frameSemantics === 'div' ? 'div' : 'li';
6802
- // Create new container frame element
6803
- const newFrame = document.createElement(frameTagName);
6804
- this.#copyAttributes(containerFrame, newFrame);
6805
- // Transform groups
6806
- const groups = containerFrame.querySelectorAll('[data-bge-group]');
6807
- for (const group of groups) {
6808
- const newGroup = document.createElement(groupTagName);
6809
- this.#copyAttributes(group, newGroup);
6810
- // Move all child content
6811
- while (group.firstChild) {
6812
- newGroup.append(group.firstChild);
6813
- }
6814
- newFrame.append(newGroup);
6815
- }
6816
- // Replace old frame with new frame
6817
- containerFrame.parentNode?.replaceChild(newFrame, containerFrame);
6818
- // Update internal references
6819
- _a.#blocks.set(this.el, this);
6820
- // Update options with new frameSemantics
6821
- const currentOptions = this.exportOptions();
6822
- this.importOptions({
6823
- ...currentOptions,
6824
- containerProps: {
6825
- ...currentOptions.containerProps,
6826
- frameSemantics,
6827
- },
6828
- });
6829
- }
6830
- clone() {
6831
- const originalData = this.#export();
6832
- const newBlock = _a.create(originalData, this.#createItemElement);
6833
- return newBlock;
6834
- }
6835
- existNext() {
6836
- return !!this.el.nextElementSibling;
6837
- }
6838
- existPrev() {
6839
- return !!this.el.previousElementSibling;
6840
- }
6841
- exportOptions() {
6842
- return exportOptions(this.el);
6843
- }
6844
- getHTMLStringify() {
6845
- return this.el.outerHTML;
6846
- }
6847
- async importJSONString(jsonString) {
6848
- const data = JSON.parse(jsonString);
6849
- try {
6850
- await this.#import(data);
6851
- }
6852
- catch (error) {
6853
- throw new Error(`ImportError: ${error instanceof Error ? error.message : error}`);
6854
- }
6855
- }
6856
- importOptions(options) {
6857
- importOptions(this.el, options);
6858
- }
6859
- importTypes(extractor) {
6860
- for (const [i, item] of this.items.entries()) {
6861
- void item.import(extractor(i, item));
6862
- }
6863
- }
6864
- is(block) {
6865
- return this.#uid === block.#uid;
6866
- }
6867
- isDisable() {
6868
- let msg = '';
6869
- for (const type of this.items) {
6870
- msg = type.isDisable();
6871
- if (msg) {
6872
- break;
6873
- }
6874
- }
6875
- return msg;
6876
- }
6877
- isMutable() {
6878
- return this.el.matches(':not([data-bge-container*=":immutable"])');
6879
- }
6880
- remove() {
6881
- this.el.remove();
6882
- }
6883
- toJSONStringify(space) {
6884
- return JSON.stringify(this.#export(), null, space);
6885
- }
6886
- updateGridItems(addOrRemove, engine) {
6887
- updateGridItems([...this.el.querySelectorAll('[data-bge-group]')], engine, addOrRemove, this.items, (items) => (this.items = items));
6888
- }
6889
- /**
6890
- * Copy all attributes from source to target element
6891
- * @param source - Source element
6892
- * @param target - Target element
6893
- */
6894
- #copyAttributes(source, target) {
6895
- for (const attr of source.attributes) {
6896
- target.setAttribute(attr.name, attr.value);
6897
- }
6898
- // Copy classes
6899
- target.className = source.className;
6900
- }
6901
- #create(data) {
6902
- return createPlainStructuredBlockElement(data, this.#createItemElement);
6903
- }
6904
- #export() {
6905
- return parseHTMLToBlockData(this.el);
6906
- }
6907
- #fallbackBlockData(html) {
6908
- return {
6909
- name: 'text',
6910
- containerProps: {
6911
- type: 'grid',
6912
- columns: 1,
6913
- },
6914
- classList: [],
6915
- items: [[{ name: 'wysiwyg', data: { wysiwyg: html } }]],
6916
- };
6917
- }
6918
- async #import(data) {
6919
- this.el.replaceWith(await createPlainStructuredBlockElement(data, this.#createItemElement));
6920
- }
6921
- async #rebind(el) {
6922
- if (isBurgerBlockElement(el)) {
6923
- const itemContainers = el.querySelectorAll('[data-bge-item]');
6924
- for (const itemContainer of itemContainers) {
6925
- const itemElements = itemContainer.querySelectorAll('[data-bgi]');
6926
- for (const itemElement of itemElements) {
6927
- await this.#createItemElement(itemElement);
6928
- }
6929
- }
6930
- return el;
6931
- }
6932
- // eslint-disable-next-line no-console
6933
- console.error('%o is not a burger block', el);
6934
- const fallbackEl = await createPlainStructuredBlockElement(this.#fallbackBlockData(el.outerHTML), this.#createItemElement);
6935
- el.replaceWith(fallbackEl);
6936
- return fallbackEl;
6937
- }
6938
- #set(el) {
6939
- bbMap.set(this, el);
6940
- _a.#blocks.set(this.el, this);
6941
- }
6942
- static #blocks = new WeakMap();
6943
- static async create(data, createItemElement) {
6944
- const block = new _a(createItemElement);
6945
- const el = await block.#create(data);
6946
- block.#set(el);
6947
- return block;
6948
- }
6949
- static async rebind(el, createItemElement) {
6950
- const block = new _a(createItemElement);
6951
- const newEl = await block.#rebind(el);
6952
- block.#set(newEl);
6953
- return block;
6954
- }
6955
- static getBlock(el) {
6956
- const block = this.#blocks.get(el);
6957
- if (!block) {
6958
- throw new Error('Do not get BurgerBlock instance.');
6959
- }
6960
- return block;
6961
- }
6962
- }
6963
- _a = BurgerBlock;
6964
- /**
6965
- *
6966
- * @param el
6967
- */
6968
- function isBurgerBlockElement(el) {
6969
- return el.matches([
6970
- '[data-bge-name][data-bge-container]:has(>[data-bge-container-frame]>[data-bge-group]>[data-bge-item])',
6971
- ].join(','));
6972
- }
6973
-
6974
6960
  const IconAlignBoxCenterStretch = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-align-box-center-stretch\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M3 19v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z\" />\n <path d=\"M11 17h2\" />\n <path d=\"M9 12h6\" />\n <path d=\"M10 7h4\" />\n</svg>";
6975
6961
 
6976
6962
  const IconBlockquote = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-blockquote\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M6 15h15\" />\n <path d=\"M21 19h-15\" />\n <path d=\"M15 11h6\" />\n <path d=\"M21 7h-6\" />\n <path d=\"M9 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2\" />\n <path d=\"M3 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2\" />\n</svg>";
@@ -21940,8 +21926,10 @@ function selectionToInsertionEnd(tr, startLen, bias) {
21940
21926
  }
21941
21927
  var InputRule = class {
21942
21928
  constructor(config) {
21929
+ var _a;
21943
21930
  this.find = config.find;
21944
21931
  this.handler = config.handler;
21932
+ this.undoable = (_a = config.undoable) != null ? _a : true;
21945
21933
  }
21946
21934
  };
21947
21935
  var inputRuleMatcherHandler = (text, find) => {
@@ -22013,12 +22001,14 @@ function run$3(config) {
22013
22001
  if (handler === null || !tr.steps.length) {
22014
22002
  return;
22015
22003
  }
22016
- tr.setMeta(plugin, {
22017
- transform: tr,
22018
- from,
22019
- to,
22020
- text
22021
- });
22004
+ if (rule.undoable) {
22005
+ tr.setMeta(plugin, {
22006
+ transform: tr,
22007
+ from,
22008
+ to,
22009
+ text
22010
+ });
22011
+ }
22022
22012
  view.dispatch(tr);
22023
22013
  matched = true;
22024
22014
  });
@@ -22509,7 +22499,7 @@ var ExtensionManager = class {
22509
22499
  get plugins() {
22510
22500
  const { editor } = this;
22511
22501
  const extensions = sortExtensions([...this.extensions].reverse());
22512
- const allPlugins = extensions.map((extension) => {
22502
+ const allPlugins = extensions.flatMap((extension) => {
22513
22503
  const context = {
22514
22504
  name: extension.name,
22515
22505
  options: extension.options,
@@ -22567,7 +22557,7 @@ var ExtensionManager = class {
22567
22557
  plugins.push(...proseMirrorPlugins);
22568
22558
  }
22569
22559
  return plugins;
22570
- }).flat();
22560
+ });
22571
22561
  return allPlugins;
22572
22562
  }
22573
22563
  /**
@@ -24610,6 +24600,9 @@ var Editor = class extends EventEmitter {
24610
24600
  }
24611
24601
  this.createView(el);
24612
24602
  this.emit("mount", { editor: this });
24603
+ if (this.css && !document.head.contains(this.css)) {
24604
+ document.head.appendChild(this.css);
24605
+ }
24613
24606
  window.setTimeout(() => {
24614
24607
  if (this.isDestroyed) {
24615
24608
  return;
@@ -24725,7 +24718,7 @@ var Editor = class extends EventEmitter {
24725
24718
  this.editorState = state;
24726
24719
  },
24727
24720
  dispatch: (tr) => {
24728
- this.editorState = this.state.apply(tr);
24721
+ this.dispatchTransaction(tr);
24729
24722
  },
24730
24723
  // Stub some commonly accessed properties to prevent errors
24731
24724
  composing: false,
@@ -24735,6 +24728,9 @@ var Editor = class extends EventEmitter {
24735
24728
  },
24736
24729
  {
24737
24730
  get: (obj, key) => {
24731
+ if (this.editorView) {
24732
+ return this.editorView[key];
24733
+ }
24738
24734
  if (key === "state") {
24739
24735
  return this.editorState;
24740
24736
  }
@@ -25098,7 +25094,8 @@ function markInputRule(config) {
25098
25094
  tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
25099
25095
  tr.removeStoredMark(config.type);
25100
25096
  }
25101
- }
25097
+ },
25098
+ undoable: config.undoable
25102
25099
  });
25103
25100
  }
25104
25101
 
@@ -25128,7 +25125,8 @@ function nodeInputRule(config) {
25128
25125
  tr.insert(insertionStart, config.type.create(attributes)).delete(tr.mapping.map(start), tr.mapping.map(end));
25129
25126
  }
25130
25127
  tr.scrollIntoView();
25131
- }
25128
+ },
25129
+ undoable: config.undoable
25132
25130
  });
25133
25131
  }
25134
25132
 
@@ -25143,7 +25141,8 @@ function textblockTypeInputRule(config) {
25143
25141
  return null;
25144
25142
  }
25145
25143
  state.tr.delete(range.from, range.to).setBlockType(range.from, range.from, config.type, attributes);
25146
- }
25144
+ },
25145
+ undoable: config.undoable
25147
25146
  });
25148
25147
  }
25149
25148
  function wrappingInputRule(config) {
@@ -25176,7 +25175,8 @@ function wrappingInputRule(config) {
25176
25175
  if (before && before.type === config.type && canJoin(tr.doc, range.from - 1) && (!config.joinPredicate || config.joinPredicate(match, before))) {
25177
25176
  tr.join(range.from - 1);
25178
25177
  }
25179
- }
25178
+ },
25179
+ undoable: config.undoable
25180
25180
  });
25181
25181
  }
25182
25182
  function canInsertNode(state, nodeType) {
@@ -25495,6 +25495,7 @@ var Code = Mark.create({
25495
25495
  });
25496
25496
 
25497
25497
  // src/code-block.ts
25498
+ var DEFAULT_TAB_SIZE = 4;
25498
25499
  var backtickInputRegex = /^```([a-z]+)?[\s\n]$/;
25499
25500
  var tildeInputRegex = /^~~~([a-z]+)?[\s\n]$/;
25500
25501
  var CodeBlock = Node3.create({
@@ -25506,7 +25507,7 @@ var CodeBlock = Node3.create({
25506
25507
  exitOnArrowDown: true,
25507
25508
  defaultLanguage: null,
25508
25509
  enableTabIndentation: false,
25509
- tabSize: 4,
25510
+ tabSize: DEFAULT_TAB_SIZE,
25510
25511
  HTMLAttributes: {}
25511
25512
  };
25512
25513
  },
@@ -25522,6 +25523,9 @@ var CodeBlock = Node3.create({
25522
25523
  parseHTML: (element) => {
25523
25524
  var _a;
25524
25525
  const { languageClassPrefix } = this.options;
25526
+ if (!languageClassPrefix) {
25527
+ return null;
25528
+ }
25525
25529
  const classNames = [...((_a = element.firstElementChild) == null ? void 0 : _a.classList) || []];
25526
25530
  const languages = classNames.filter((className) => className.startsWith(languageClassPrefix)).map((className) => className.replace(languageClassPrefix, ""));
25527
25531
  const language = languages[0];
@@ -25582,16 +25586,18 @@ var CodeBlock = Node3.create({
25582
25586
  },
25583
25587
  // handle tab indentation
25584
25588
  Tab: ({ editor }) => {
25589
+ var _a;
25585
25590
  if (!this.options.enableTabIndentation) {
25586
25591
  return false;
25587
25592
  }
25593
+ const tabSize = (_a = this.options.tabSize) != null ? _a : DEFAULT_TAB_SIZE;
25588
25594
  const { state } = editor;
25589
25595
  const { selection } = state;
25590
25596
  const { $from, empty } = selection;
25591
25597
  if ($from.parent.type !== this.type) {
25592
25598
  return false;
25593
25599
  }
25594
- const indent = " ".repeat(this.options.tabSize);
25600
+ const indent = " ".repeat(tabSize);
25595
25601
  if (empty) {
25596
25602
  return editor.commands.insertContent(indent);
25597
25603
  }
@@ -25606,9 +25612,11 @@ var CodeBlock = Node3.create({
25606
25612
  },
25607
25613
  // handle shift+tab reverse indentation
25608
25614
  "Shift-Tab": ({ editor }) => {
25615
+ var _a;
25609
25616
  if (!this.options.enableTabIndentation) {
25610
25617
  return false;
25611
25618
  }
25619
+ const tabSize = (_a = this.options.tabSize) != null ? _a : DEFAULT_TAB_SIZE;
25612
25620
  const { state } = editor;
25613
25621
  const { selection } = state;
25614
25622
  const { $from, empty } = selection;
@@ -25617,7 +25625,7 @@ var CodeBlock = Node3.create({
25617
25625
  }
25618
25626
  if (empty) {
25619
25627
  return editor.commands.command(({ tr }) => {
25620
- var _a;
25628
+ var _a2;
25621
25629
  const { pos } = $from;
25622
25630
  const codeBlockStart = $from.start();
25623
25631
  const codeBlockEnd = $from.end();
@@ -25634,8 +25642,8 @@ var CodeBlock = Node3.create({
25634
25642
  charCount += lines[i].length + 1;
25635
25643
  }
25636
25644
  const currentLine = lines[currentLineIndex];
25637
- const leadingSpaces = ((_a = currentLine.match(/^ */)) == null ? void 0 : _a[0]) || "";
25638
- const spacesToRemove = Math.min(leadingSpaces.length, this.options.tabSize);
25645
+ const leadingSpaces = ((_a2 = currentLine.match(/^ */)) == null ? void 0 : _a2[0]) || "";
25646
+ const spacesToRemove = Math.min(leadingSpaces.length, tabSize);
25639
25647
  if (spacesToRemove === 0) {
25640
25648
  return true;
25641
25649
  }
@@ -25656,9 +25664,9 @@ var CodeBlock = Node3.create({
25656
25664
  const text = state.doc.textBetween(from, to, "\n", "\n");
25657
25665
  const lines = text.split("\n");
25658
25666
  const reverseIndentText = lines.map((line) => {
25659
- var _a;
25660
- const leadingSpaces = ((_a = line.match(/^ */)) == null ? void 0 : _a[0]) || "";
25661
- const spacesToRemove = Math.min(leadingSpaces.length, this.options.tabSize);
25667
+ var _a2;
25668
+ const leadingSpaces = ((_a2 = line.match(/^ */)) == null ? void 0 : _a2[0]) || "";
25669
+ const spacesToRemove = Math.min(leadingSpaces.length, tabSize);
25662
25670
  return line.slice(spacesToRemove);
25663
25671
  }).join("\n");
25664
25672
  tr.replaceWith(from, to, state.schema.text(reverseIndentText));
@@ -25909,7 +25917,8 @@ var HorizontalRule = Node3.create({
25909
25917
  name: "horizontalRule",
25910
25918
  addOptions() {
25911
25919
  return {
25912
- HTMLAttributes: {}
25920
+ HTMLAttributes: {},
25921
+ nextNodeType: "paragraph"
25913
25922
  };
25914
25923
  },
25915
25924
  group: "block",
@@ -25935,8 +25944,7 @@ var HorizontalRule = Node3.create({
25935
25944
  } else {
25936
25945
  currentChain.insertContent({ type: this.name });
25937
25946
  }
25938
- return currentChain.command(({ tr, dispatch }) => {
25939
- var _a;
25947
+ return currentChain.command(({ state: chainState, tr, dispatch }) => {
25940
25948
  if (dispatch) {
25941
25949
  const { $to } = tr.selection;
25942
25950
  const posAfter = $to.end();
@@ -25949,7 +25957,8 @@ var HorizontalRule = Node3.create({
25949
25957
  tr.setSelection(TextSelection.create(tr.doc, $to.pos));
25950
25958
  }
25951
25959
  } else {
25952
- const node = (_a = $to.parent.type.contentMatch.defaultType) == null ? void 0 : _a.create();
25960
+ const nodeType = chainState.schema.nodes[this.options.nextNodeType] || $to.parent.type.contentMatch.defaultType;
25961
+ const node = nodeType == null ? void 0 : nodeType.create();
25953
25962
  if (node) {
25954
25963
  tr.insert(posAfter, node);
25955
25964
  tr.setSelection(TextSelection.create(tr.doc, posAfter + 1));
@@ -32610,8 +32619,17 @@ var TableCell$1 = Node3.create({
32610
32619
  colwidth: {
32611
32620
  default: null,
32612
32621
  parseHTML: (element) => {
32622
+ var _a, _b;
32613
32623
  const colwidth = element.getAttribute("colwidth");
32614
32624
  const value = colwidth ? colwidth.split(",").map((width) => parseInt(width, 10)) : null;
32625
+ if (!value) {
32626
+ const cols = (_a = element.closest("table")) == null ? void 0 : _a.querySelectorAll("colgroup > col");
32627
+ const cellIndex = Array.from(((_b = element.parentElement) == null ? void 0 : _b.children) || []).indexOf(element);
32628
+ if (cellIndex && cellIndex > -1 && cols && cols[cellIndex]) {
32629
+ const colWidth = cols[cellIndex].getAttribute("width");
32630
+ return colWidth ? [parseInt(colWidth, 10)] : null;
32631
+ }
32632
+ }
32615
32633
  return value;
32616
32634
  }
32617
32635
  }
@@ -32751,7 +32769,15 @@ var TableView = class {
32751
32769
  return true;
32752
32770
  }
32753
32771
  ignoreMutation(mutation) {
32754
- return mutation.type === "attributes" && (mutation.target === this.table || this.colgroup.contains(mutation.target));
32772
+ const target = mutation.target;
32773
+ const isInsideWrapper = this.dom.contains(target);
32774
+ const isInsideContent = this.contentDOM.contains(target);
32775
+ if (isInsideWrapper && !isInsideContent) {
32776
+ if (mutation.type === "attributes" || mutation.type === "childList" || mutation.type === "characterData") {
32777
+ return true;
32778
+ }
32779
+ }
32780
+ return false;
32755
32781
  }
32756
32782
  };
32757
32783
 
@@ -34544,25 +34570,12 @@ function is_runes() {
34544
34570
  /** @type {Array<() => void>} */
34545
34571
  let micro_tasks = [];
34546
34572
 
34547
- /** @type {Array<() => void>} */
34548
- let idle_tasks = [];
34549
-
34550
34573
  function run_micro_tasks() {
34551
34574
  var tasks = micro_tasks;
34552
34575
  micro_tasks = [];
34553
34576
  run_all(tasks);
34554
34577
  }
34555
34578
 
34556
- function run_idle_tasks() {
34557
- var tasks = idle_tasks;
34558
- idle_tasks = [];
34559
- run_all(tasks);
34560
- }
34561
-
34562
- function has_pending_tasks() {
34563
- return micro_tasks.length > 0 || idle_tasks.length > 0;
34564
- }
34565
-
34566
34579
  /**
34567
34580
  * @param {() => void} fn
34568
34581
  */
@@ -34589,13 +34602,9 @@ function queue_micro_task(fn) {
34589
34602
  * Synchronously run any queued tasks.
34590
34603
  */
34591
34604
  function flush_tasks() {
34592
- if (micro_tasks.length > 0) {
34605
+ while (micro_tasks.length > 0) {
34593
34606
  run_micro_tasks();
34594
34607
  }
34595
-
34596
- if (idle_tasks.length > 0) {
34597
- run_idle_tasks();
34598
- }
34599
34608
  }
34600
34609
 
34601
34610
  /** @import { Derived, Effect } from '#client' */
@@ -34675,7 +34684,7 @@ function apply_adjustments(error) {
34675
34684
  }
34676
34685
  }
34677
34686
 
34678
- /** @import { Derived, Effect, Source } from '#client' */
34687
+ /** @import { Derived, Effect, Source, Value } from '#client' */
34679
34688
 
34680
34689
  /** @type {Set<Batch>} */
34681
34690
  const batches = new Set();
@@ -34737,22 +34746,8 @@ class Batch {
34737
34746
  #deferred = null;
34738
34747
 
34739
34748
  /**
34740
- * True if an async effect inside this batch resolved and
34741
- * its parent branch was already deleted
34742
- */
34743
- #neutered = false;
34744
-
34745
- /**
34746
- * Async effects (created inside `async_derived`) encountered during processing.
34747
- * These run after the rest of the batch has updated, since they should
34748
- * always have the latest values
34749
- * @type {Effect[]}
34750
- */
34751
- #async_effects = [];
34752
-
34753
- /**
34754
- * The same as `#async_effects`, but for effects inside a newly-created
34755
- * `<svelte:boundary>` — these do not prevent the batch from committing
34749
+ * Async effects inside a newly-created `<svelte:boundary>`
34750
+ * these do not prevent the batch from committing
34756
34751
  * @type {Effect[]}
34757
34752
  */
34758
34753
  #boundary_async_effects = [];
@@ -34805,13 +34800,15 @@ class Batch {
34805
34800
 
34806
34801
  previous_batch = null;
34807
34802
 
34803
+ var revert = Batch.apply(this);
34804
+
34808
34805
  for (const root of root_effects) {
34809
34806
  this.#traverse_effect_tree(root);
34810
34807
  }
34811
34808
 
34812
34809
  // if we didn't start any new async work, and no async work
34813
34810
  // is outstanding from a previous flush, commit
34814
- if (this.#async_effects.length === 0 && this.#pending === 0) {
34811
+ if (this.#pending === 0) {
34815
34812
  this.#commit();
34816
34813
 
34817
34814
  var render_effects = this.#render_effects;
@@ -34823,21 +34820,12 @@ class Batch {
34823
34820
 
34824
34821
  // If sources are written to, then work needs to happen in a separate batch, else prior sources would be mixed with
34825
34822
  // newly updated sources, which could lead to infinite loops when effects run over and over again.
34826
- previous_batch = current_batch;
34823
+ previous_batch = this;
34827
34824
  current_batch = null;
34828
34825
 
34829
34826
  flush_queued_effects(render_effects);
34830
34827
  flush_queued_effects(effects);
34831
34828
 
34832
- // Reinstate the current batch if there was no new one created, as `process()` runs in a loop in `flush_effects()`.
34833
- // That method expects `current_batch` to be set, and could run the loop again if effects result in new effects
34834
- // being scheduled but without writes happening in which case no new batch is created.
34835
- if (current_batch === null) {
34836
- current_batch = this;
34837
- } else {
34838
- batches.delete(this);
34839
- }
34840
-
34841
34829
  this.#deferred?.resolve();
34842
34830
  } else {
34843
34831
  this.#defer_effects(this.#render_effects);
@@ -34845,15 +34833,12 @@ class Batch {
34845
34833
  this.#defer_effects(this.#block_effects);
34846
34834
  }
34847
34835
 
34848
- for (const effect of this.#async_effects) {
34849
- update_effect(effect);
34850
- }
34836
+ revert();
34851
34837
 
34852
34838
  for (const effect of this.#boundary_async_effects) {
34853
34839
  update_effect(effect);
34854
34840
  }
34855
34841
 
34856
- this.#async_effects = [];
34857
34842
  this.#boundary_async_effects = [];
34858
34843
  }
34859
34844
 
@@ -34880,12 +34865,8 @@ class Batch {
34880
34865
  } else if ((flags & EFFECT) !== 0) {
34881
34866
  this.#effects.push(effect);
34882
34867
  } else if ((flags & CLEAN) === 0) {
34883
- if ((flags & ASYNC) !== 0) {
34884
- var effects = effect.b?.is_pending()
34885
- ? this.#boundary_async_effects
34886
- : this.#async_effects;
34887
-
34888
- effects.push(effect);
34868
+ if ((flags & ASYNC) !== 0 && effect.b?.is_pending()) {
34869
+ this.#boundary_async_effects.push(effect);
34889
34870
  } else if (is_dirty(effect)) {
34890
34871
  if ((effect.f & BLOCK_EFFECT) !== 0) this.#block_effects.push(effect);
34891
34872
  update_effect(effect);
@@ -34958,25 +34939,17 @@ class Batch {
34958
34939
  }
34959
34940
  }
34960
34941
 
34961
- neuter() {
34962
- this.#neutered = true;
34963
- }
34964
-
34965
34942
  flush() {
34966
34943
  if (queued_root_effects.length > 0) {
34944
+ this.activate();
34967
34945
  flush_effects();
34968
- } else {
34969
- this.#commit();
34970
- }
34971
-
34972
- if (current_batch !== this) {
34973
- // this can happen if a `flushSync` occurred during `flush_effects()`,
34974
- // which is permitted in legacy mode despite being a terrible idea
34975
- return;
34976
- }
34977
34946
 
34978
- if (this.#pending === 0) {
34979
- batches.delete(this);
34947
+ if (current_batch !== null && current_batch !== this) {
34948
+ // this can happen if a new batch was created during `flush_effects()`
34949
+ return;
34950
+ }
34951
+ } else if (this.#pending === 0) {
34952
+ this.#commit();
34980
34953
  }
34981
34954
 
34982
34955
  this.deactivate();
@@ -34986,13 +34959,59 @@ class Batch {
34986
34959
  * Append and remove branches to/from the DOM
34987
34960
  */
34988
34961
  #commit() {
34989
- if (!this.#neutered) {
34990
- for (const fn of this.#callbacks) {
34991
- fn();
34992
- }
34962
+ for (const fn of this.#callbacks) {
34963
+ fn();
34993
34964
  }
34994
34965
 
34995
34966
  this.#callbacks.clear();
34967
+
34968
+ // If there are other pending batches, they now need to be 'rebased' —
34969
+ // in other words, we re-run block/async effects with the newly
34970
+ // committed state, unless the batch in question has a more
34971
+ // recent value for a given source
34972
+ if (batches.size > 1) {
34973
+ this.#previous.clear();
34974
+
34975
+ let is_earlier = true;
34976
+
34977
+ for (const batch of batches) {
34978
+ if (batch === this) {
34979
+ is_earlier = false;
34980
+ continue;
34981
+ }
34982
+
34983
+ for (const [source, value] of this.current) {
34984
+ if (batch.current.has(source)) {
34985
+ if (is_earlier) {
34986
+ // bring the value up to date
34987
+ batch.current.set(source, value);
34988
+ } else {
34989
+ // later batch has more recent value,
34990
+ // no need to re-run these effects
34991
+ continue;
34992
+ }
34993
+ }
34994
+
34995
+ mark_effects(source);
34996
+ }
34997
+
34998
+ if (queued_root_effects.length > 0) {
34999
+ current_batch = batch;
35000
+ const revert = Batch.apply(batch);
35001
+
35002
+ for (const root of queued_root_effects) {
35003
+ batch.#traverse_effect_tree(root);
35004
+ }
35005
+
35006
+ queued_root_effects = [];
35007
+ revert();
35008
+ }
35009
+ }
35010
+
35011
+ current_batch = null;
35012
+ }
35013
+
35014
+ batches.delete(this);
34996
35015
  }
34997
35016
 
34998
35017
  increment() {
@@ -35013,9 +35032,6 @@ class Batch {
35013
35032
  schedule_effect(e);
35014
35033
  }
35015
35034
 
35016
- this.#render_effects = [];
35017
- this.#effects = [];
35018
-
35019
35035
  this.flush();
35020
35036
  } else {
35021
35037
  this.deactivate();
@@ -35055,6 +35071,15 @@ class Batch {
35055
35071
  static enqueue(task) {
35056
35072
  queue_micro_task(task);
35057
35073
  }
35074
+
35075
+ /**
35076
+ * @param {Batch} current_batch
35077
+ */
35078
+ static apply(current_batch) {
35079
+ {
35080
+ return noop;
35081
+ }
35082
+ }
35058
35083
  }
35059
35084
 
35060
35085
  /**
@@ -35077,7 +35102,7 @@ function flushSync(fn) {
35077
35102
  while (true) {
35078
35103
  flush_tasks();
35079
35104
 
35080
- if (queued_root_effects.length === 0 && !has_pending_tasks()) {
35105
+ if (queued_root_effects.length === 0) {
35081
35106
  current_batch?.flush();
35082
35107
 
35083
35108
  // we need to check again, in case we just updated an `$effect.pending()`
@@ -35192,6 +35217,26 @@ function flush_queued_effects(effects) {
35192
35217
  eager_block_effects = null;
35193
35218
  }
35194
35219
 
35220
+ /**
35221
+ * This is similar to `mark_reactions`, but it only marks async/block effects
35222
+ * so that these can re-run after another batch has been committed
35223
+ * @param {Value} value
35224
+ */
35225
+ function mark_effects(value) {
35226
+ if (value.reactions !== null) {
35227
+ for (const reaction of value.reactions) {
35228
+ const flags = reaction.f;
35229
+
35230
+ if ((flags & DERIVED) !== 0) {
35231
+ mark_effects(/** @type {Derived} */ (reaction));
35232
+ } else if ((flags & (ASYNC | BLOCK_EFFECT)) !== 0) {
35233
+ set_signal_status(reaction, DIRTY);
35234
+ schedule_effect(/** @type {Effect} */ (reaction));
35235
+ }
35236
+ }
35237
+ }
35238
+ }
35239
+
35195
35240
  /**
35196
35241
  * @param {Effect} signal
35197
35242
  * @returns {void}
@@ -35535,6 +35580,13 @@ class Boundary {
35535
35580
  this.#anchor.before(this.#offscreen_fragment);
35536
35581
  this.#offscreen_fragment = null;
35537
35582
  }
35583
+
35584
+ // TODO this feels like a little bit of a kludge, but until we
35585
+ // overhaul the boundary/batch relationship it's probably
35586
+ // the most pragmatic solution available to us
35587
+ queue_micro_task(() => {
35588
+ Batch.ensure().flush();
35589
+ });
35538
35590
  }
35539
35591
  }
35540
35592
 
@@ -35812,34 +35864,37 @@ function async_derived(fn, location) {
35812
35864
  var promise = /** @type {Promise<V>} */ (/** @type {unknown} */ (undefined));
35813
35865
  var signal = source(/** @type {V} */ (UNINITIALIZED));
35814
35866
 
35815
- /** @type {Promise<V> | null} */
35816
- var prev = null;
35817
-
35818
35867
  // only suspend in async deriveds created on initialisation
35819
35868
  var should_suspend = !active_reaction;
35820
35869
 
35870
+ /** @type {Map<Batch, ReturnType<typeof deferred<V>>>} */
35871
+ var deferreds = new Map();
35872
+
35821
35873
  async_effect(() => {
35822
35874
 
35875
+ /** @type {ReturnType<typeof deferred<V>>} */
35876
+ var d = deferred();
35877
+ promise = d.promise;
35878
+
35823
35879
  try {
35824
- var p = fn();
35825
- // Make sure to always access the then property to read any signals
35826
- // it might access, so that we track them as dependencies.
35827
- if (prev) Promise.resolve(p).catch(() => {}); // avoid unhandled rejection
35880
+ // If this code is changed at some point, make sure to still access the then property
35881
+ // of fn() to read any signals it might access, so that we track them as dependencies.
35882
+ Promise.resolve(fn()).then(d.resolve, d.reject);
35828
35883
  } catch (error) {
35829
- p = Promise.reject(error);
35884
+ d.reject(error);
35830
35885
  }
35831
35886
 
35832
- var r = () => p;
35833
- promise = prev?.then(r, r) ?? Promise.resolve(p);
35834
-
35835
- prev = promise;
35836
-
35837
35887
  var batch = /** @type {Batch} */ (current_batch);
35838
35888
  var pending = boundary.is_pending();
35839
35889
 
35840
35890
  if (should_suspend) {
35841
35891
  boundary.update_pending_count(1);
35842
- if (!pending) batch.increment();
35892
+ if (!pending) {
35893
+ batch.increment();
35894
+
35895
+ deferreds.get(batch)?.reject(STALE_REACTION);
35896
+ deferreds.set(batch, d);
35897
+ }
35843
35898
  }
35844
35899
 
35845
35900
  /**
@@ -35847,7 +35902,6 @@ function async_derived(fn, location) {
35847
35902
  * @param {unknown} error
35848
35903
  */
35849
35904
  const handler = (value, error = undefined) => {
35850
- prev = null;
35851
35905
 
35852
35906
  if (!pending) batch.activate();
35853
35907
 
@@ -35874,12 +35928,12 @@ function async_derived(fn, location) {
35874
35928
  unset_context();
35875
35929
  };
35876
35930
 
35877
- promise.then(handler, (e) => handler(null, e || 'unknown'));
35931
+ d.promise.then(handler, (e) => handler(null, e || 'unknown'));
35932
+ });
35878
35933
 
35879
- if (batch) {
35880
- return () => {
35881
- queueMicrotask(() => batch.neuter());
35882
- };
35934
+ teardown(() => {
35935
+ for (const d of deferreds.values()) {
35936
+ d.reject(STALE_REACTION);
35883
35937
  }
35884
35938
  });
35885
35939
 
@@ -44011,7 +44065,7 @@ function parseConfig(config) {
44011
44065
  }
44012
44066
  }
44013
44067
 
44014
- const version = "4.0.0-alpha.24";
44068
+ const version = "4.0.0-alpha.25";
44015
44069
  function attachDraftSwitcher(engine) {
44016
44070
  if (engine.hasDraft()) {
44017
44071
  const container = document.createElement("div");