You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
42 KiB
1 line
42 KiB
"use strict";(self.webpackChunkjupyter_web=self.webpackChunkjupyter_web||[]).push([[5462],{25462:(jt,oe,E)=>{E.r(oe),E.d(oe,{commonmarkLanguage:()=>qe,deleteMarkupBackward:()=>Ye,insertNewlineContinueMarkup:()=>Ge,markdown:()=>Ot,markdownKeymap:()=>We,markdownLanguage:()=>te});var u,t,A=E(98698),et=E(75555),S=E(68266),tt=E(73853),b=E(95207),c=E(24809);class j{static create(e,r,n,s,i){return new j(e,r,n,s+(s<<8)+e+(r<<4)|0,i,[],[])}constructor(e,r,n,s,i,o,a){this.type=e,this.value=r,this.from=n,this.hash=s,this.end=i,this.children=o,this.positions=a,this.hashProp=[[b.md.contextHash,s]]}addChild(e,r){e.prop(b.md.contextHash)!=this.hash&&(e=new b.mp(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(r)}toTree(e,r=this.end){let n=this.children.length-1;return n>=0&&(r=Math.max(r,this.positions[n]+this.children[n].length+this.from)),new b.mp(e.types[this.type],this.children,this.positions,r-this.from).balance({makeTree:(s,i,o)=>new b.mp(b.Jq.none,s,i,o,this.hashProp)})}}(t=u||(u={}))[t.Document=1]="Document",t[t.CodeBlock=2]="CodeBlock",t[t.FencedCode=3]="FencedCode",t[t.Blockquote=4]="Blockquote",t[t.HorizontalRule=5]="HorizontalRule",t[t.BulletList=6]="BulletList",t[t.OrderedList=7]="OrderedList",t[t.ListItem=8]="ListItem",t[t.ATXHeading1=9]="ATXHeading1",t[t.ATXHeading2=10]="ATXHeading2",t[t.ATXHeading3=11]="ATXHeading3",t[t.ATXHeading4=12]="ATXHeading4",t[t.ATXHeading5=13]="ATXHeading5",t[t.ATXHeading6=14]="ATXHeading6",t[t.SetextHeading1=15]="SetextHeading1",t[t.SetextHeading2=16]="SetextHeading2",t[t.HTMLBlock=17]="HTMLBlock",t[t.LinkReference=18]="LinkReference",t[t.Paragraph=19]="Paragraph",t[t.CommentBlock=20]="CommentBlock",t[t.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",t[t.Escape=22]="Escape",t[t.Entity=23]="Entity",t[t.HardBreak=24]="HardBreak",t[t.Emphasis=25]="Emphasis",t[t.StrongEmphasis=26]="StrongEmphasis",t[t.Link=27]="Link",t[t.Image=28]="Image",t[t.InlineCode=29]="InlineCode",t[t.HTMLTag=30]="HTMLTag",t[t.Comment=31]="Comment",t[t.ProcessingInstruction=32]="ProcessingInstruction",t[t.Autolink=33]="Autolink",t[t.HeaderMark=34]="HeaderMark",t[t.QuoteMark=35]="QuoteMark",t[t.ListMark=36]="ListMark",t[t.LinkMark=37]="LinkMark",t[t.EmphasisMark=38]="EmphasisMark",t[t.CodeMark=39]="CodeMark",t[t.CodeText=40]="CodeText",t[t.CodeInfo=41]="CodeInfo",t[t.LinkTitle=42]="LinkTitle",t[t.LinkLabel=43]="LinkLabel",t[t.URL=44]="URL";class rt{constructor(e,r){this.start=e,this.content=r,this.marks=[],this.parsers=[]}}class nt{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return O(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,r=0,n=0){for(let s=r;s<e;s++)n+=9==this.text.charCodeAt(s)?4-n%4:1;return n}findColumn(e){let r=0;for(let n=0;r<this.text.length&&n<e;r++)n+=9==this.text.charCodeAt(r)?4-n%4:1;return r}scrub(){if(!this.baseIndent)return this.text;let e="";for(let r=0;r<this.basePos;r++)e+=" ";return e+this.text.slice(this.basePos)}}function ae(t,e,r){if(r.pos==r.text.length||t!=e.block&&r.indent>=e.stack[r.depth+1].value+r.baseIndent)return!0;if(r.indent>=r.baseIndent+4)return!1;let n=(t.type==u.OrderedList?q:U)(r,e,!1);return n>0&&(t.type!=u.BulletList||$(r,e,!1)<0)&&r.text.charCodeAt(r.pos+n-1)==t.value}const le={[u.Blockquote]:(t,e,r)=>62==r.next&&(r.markers.push(g(u.QuoteMark,e.lineStart+r.pos,e.lineStart+r.pos+1)),r.moveBase(r.pos+(B(r.text.charCodeAt(r.pos+1))?2:1)),t.end=e.lineStart+r.text.length,!0),[u.ListItem]:(t,e,r)=>!(r.indent<r.baseIndent+t.value&&r.next>-1)&&(r.moveBaseColumn(r.baseIndent+t.value),!0),[u.OrderedList]:ae,[u.BulletList]:ae,[u.Document]:()=>!0};function B(t){return 32==t||9==t||10==t||13==t}function O(t,e=0){for(;e<t.length&&B(t.charCodeAt(e));)e++;return e}function he(t,e,r){for(;e>r&&B(t.charCodeAt(e-1));)e--;return e}function fe(t){if(96!=t.next&&126!=t.next)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;if(e<t.pos+3)return-1;if(96==t.next)for(let r=e;r<t.text.length;r++)if(96==t.text.charCodeAt(r))return-1;return e}function ue(t){return 62!=t.next?-1:32==t.text.charCodeAt(t.pos+1)?2:1}function $(t,e,r){if(42!=t.next&&45!=t.next&&95!=t.next)return-1;let n=1;for(let s=t.pos+1;s<t.text.length;s++){let i=t.text.charCodeAt(s);if(i==t.next)n++;else if(!B(i))return-1}return r&&45==t.next&&ce(t)>-1&&t.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(be.SetextHeading)>-1||n<3?-1:1}function de(t,e){for(let r=t.stack.length-1;r>=0;r--)if(t.stack[r].type==e)return!0;return!1}function U(t,e,r){return 45!=t.next&&43!=t.next&&42!=t.next||t.pos!=t.text.length-1&&!B(t.text.charCodeAt(t.pos+1))||!(!r||de(e,u.BulletList)||t.skipSpace(t.pos+2)<t.text.length)?-1:1}function q(t,e,r){let n=t.pos,s=t.next;for(;s>=48&&s<=57;){if(n++,n==t.text.length)return-1;s=t.text.charCodeAt(n)}return n==t.pos||n>t.pos+9||46!=s&&41!=s||n<t.text.length-1&&!B(t.text.charCodeAt(n+1))||r&&!de(e,u.OrderedList)&&(t.skipSpace(n+1)==t.text.length||n>t.pos+1||49!=t.next)?-1:n+1-t.pos}function pe(t){if(35!=t.next)return-1;let e=t.pos+1;for(;e<t.text.length&&35==t.text.charCodeAt(e);)e++;if(e<t.text.length&&32!=t.text.charCodeAt(e))return-1;let r=e-t.pos;return r>6?-1:r}function ce(t){if(45!=t.next&&61!=t.next||t.indent>=t.baseIndent+4)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;let r=e;for(;e<t.text.length&&B(t.text.charCodeAt(e));)e++;return e==t.text.length?r:-1}const Q=/^[ \t]*$/,me=/-->/,ge=/\?>/,Z=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,me],[/^\s*<\?/,ge],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?: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|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,Q],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Q]];function ke(t,e,r){if(60!=t.next)return-1;let n=t.text.slice(t.pos);for(let s=0,i=Z.length-(r?1:0);s<i;s++)if(Z[s][0].test(n))return s;return-1}function Le(t,e){let r=t.countIndent(e,t.pos,t.indent),n=t.countIndent(t.skipSpace(e),e,r);return n>=r+5?r+1:n}function H(t,e,r){let n=t.length-1;n>=0&&t[n].to==e&&t[n].type==u.CodeText?t[n].to=r:t.push(g(u.CodeText,e,r))}const D={LinkReference:void 0,IndentedCode(t,e){let r=e.baseIndent+4;if(e.indent<r)return!1;let n=e.findColumn(r),s=t.lineStart+n,i=t.lineStart+e.text.length,o=[],a=[];for(H(o,s,i);t.nextLine()&&e.depth>=t.stack.length;)if(e.pos==e.text.length){H(a,t.lineStart-1,t.lineStart);for(let l of e.markers)a.push(l)}else{if(e.indent<r)break;{if(a.length){for(let f of a)f.type==u.CodeText?H(o,f.from,f.to):o.push(f);a=[]}H(o,t.lineStart-1,t.lineStart);for(let f of e.markers)o.push(f);i=t.lineStart+e.text.length;let l=t.lineStart+e.findColumn(e.baseIndent+4);l<i&&H(o,l,i)}}return a.length&&(a=a.filter(l=>l.type!=u.CodeText),a.length&&(e.markers=a.concat(e.markers))),t.addNode(t.buffer.writeElements(o,-s).finish(u.CodeBlock,i-s),s),!0},FencedCode(t,e){let r=fe(e);if(r<0)return!1;let n=t.lineStart+e.pos,s=e.next,i=r-e.pos,o=e.skipSpace(r),a=he(e.text,e.text.length,o),l=[g(u.CodeMark,n,n+i)];o<a&&l.push(g(u.CodeInfo,t.lineStart+o,t.lineStart+a));for(let f=!0;t.nextLine()&&e.depth>=t.stack.length;f=!1){let h=e.pos;if(e.indent-e.baseIndent<4)for(;h<e.text.length&&e.text.charCodeAt(h)==s;)h++;if(h-e.pos>=i&&e.skipSpace(h)==e.text.length){for(let p of e.markers)l.push(p);l.push(g(u.CodeMark,t.lineStart+e.pos,t.lineStart+h)),t.nextLine();break}{f||H(l,t.lineStart-1,t.lineStart);for(let m of e.markers)l.push(m);let p=t.lineStart+e.basePos,d=t.lineStart+e.text.length;p<d&&H(l,p,d)}}return t.addNode(t.buffer.writeElements(l,-n).finish(u.FencedCode,t.prevLineEnd()-n),n),!0},Blockquote(t,e){let r=ue(e);return!(r<0)&&(t.startContext(u.Blockquote,e.pos),t.addNode(u.QuoteMark,t.lineStart+e.pos,t.lineStart+e.pos+1),e.moveBase(e.pos+r),null)},HorizontalRule(t,e){if($(e,t,!1)<0)return!1;let r=t.lineStart+e.pos;return t.nextLine(),t.addNode(u.HorizontalRule,r),!0},BulletList(t,e){let r=U(e,t,!1);if(r<0)return!1;t.block.type!=u.BulletList&&t.startContext(u.BulletList,e.basePos,e.next);let n=Le(e,e.pos+1);return t.startContext(u.ListItem,e.basePos,n-e.baseIndent),t.addNode(u.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+r),e.moveBaseColumn(n),null},OrderedList(t,e){let r=q(e,t,!1);if(r<0)return!1;t.block.type!=u.OrderedList&&t.startContext(u.OrderedList,e.basePos,e.text.charCodeAt(e.pos+r-1));let n=Le(e,e.pos+r);return t.startContext(u.ListItem,e.basePos,n-e.baseIndent),t.addNode(u.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+r),e.moveBaseColumn(n),null},ATXHeading(t,e){let r=pe(e);if(r<0)return!1;let n=e.pos,s=t.lineStart+n,i=he(e.text,e.text.length,n),o=i;for(;o>n&&e.text.charCodeAt(o-1)==e.next;)o--;(o==i||o==n||!B(e.text.charCodeAt(o-1)))&&(o=e.text.length);let a=t.buffer.write(u.HeaderMark,0,r).writeElements(t.parser.parseInline(e.text.slice(n+r+1,o),s+r+1),-s);o<e.text.length&&a.write(u.HeaderMark,o-n,i-n);let l=a.finish(u.ATXHeading1-1+r,e.text.length-n);return t.nextLine(),t.addNode(l,s),!0},HTMLBlock(t,e){let r=ke(e,0,!1);if(r<0)return!1;let n=t.lineStart+e.pos,s=Z[r][1],i=[],o=s!=Q;for(;!s.test(e.text)&&t.nextLine();){if(e.depth<t.stack.length){o=!1;break}for(let f of e.markers)i.push(f)}o&&t.nextLine();let a=s==me?u.CommentBlock:s==ge?u.ProcessingInstructionBlock:u.HTMLBlock,l=t.prevLineEnd();return t.addNode(t.buffer.writeElements(i,-n).finish(a,l-n),n),!0},SetextHeading:void 0};class st{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,r,n){if(-1==this.stage)return!1;let s=n.content+"\n"+r.scrub(),i=this.advance(s);return i>-1&&i<s.length&&this.complete(e,n,i)}finish(e,r){return(2==this.stage||3==this.stage)&&O(r.content,this.pos)==r.content.length&&this.complete(e,r,r.content.length)}complete(e,r,n){return e.addLeafElement(r,g(u.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(!1===e&&(this.stage=-1),!1)}advance(e){for(;;){if(-1==this.stage)return-1;if(0==this.stage){if(!this.nextStage(He(e,this.pos,this.start,!0)))return-1;if(58!=e.charCodeAt(this.pos))return this.stage=-1;this.elts.push(g(u.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else{if(1!=this.stage){if(2==this.stage){let r=O(e,this.pos),n=0;if(r>this.pos){let s=Me(e,r,this.start);if(s){let i=G(e,s.to-this.start);i>0&&(this.nextStage(s),n=i)}}return n||(n=G(e,this.pos)),n>0&&n<e.length?n:-1}return G(e,this.pos)}if(!this.nextStage(Ee(e,O(e,this.pos),this.start)))return-1}}}}function G(t,e){for(;e<t.length;e++){let r=t.charCodeAt(e);if(10==r)break;if(!B(r))return-1}return e}class it{nextLine(e,r,n){let s=r.depth<e.stack.length?-1:ce(r),i=r.next;if(s<0)return!1;let o=g(u.HeaderMark,e.lineStart+r.pos,e.lineStart+s);return e.nextLine(),e.addLeafElement(n,g(61==i?u.SetextHeading1:u.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),o])),!0}finish(){return!1}}const be={LinkReference:(t,e)=>91==e.content.charCodeAt(0)?new st(e):null,SetextHeading:()=>new it},ot=[(t,e)=>pe(e)>=0,(t,e)=>fe(e)>=0,(t,e)=>ue(e)>=0,(t,e)=>U(e,t,!0)>=0,(t,e)=>q(e,t,!0)>=0,(t,e)=>$(e,t,!0)>=0,(t,e)=>ke(e,0,!0)>=0],at={text:"",end:0};class lt{constructor(e,r,n,s){this.parser=e,this.input=r,this.ranges=s,this.line=new nt,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=s[s.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=s[0].from,this.block=j.create(u.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new dt(n,r):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(null!=this.stoppedAt&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let n=0;;){let s=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;n<e.markers.length&&(!s||e.markers[n].from<s.end);){let i=e.markers[n++];this.addNode(i.type,i.from,i.to)}if(!s)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let n of this.parser.blockParsers)if(n){let s=n(this,e);if(0!=s){if(1==s)return null;e.forward();continue e}}break}let r=new rt(this.lineStart+e.pos,e.text.slice(e.pos));for(let n of this.parser.leafBlockParsers)if(n){let s=n(this,r);s&&r.parsers.push(s)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4)for(let n of this.parser.endLeafBlock)if(n(this,e,r))break e;for(let n of r.parsers)if(n.nextLine(this,e,r))return null;r.content+="\n"+e.scrub();for(let n of e.markers)r.marks.push(n)}return this.finishLeaf(r),null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let r=this.fragments.takeNodes(this);return!!r&&(this.absoluteLineStart+=r,this.lineStart=ve(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0)}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let r=at;if(r.end=e,e>=this.to)r.text="";else if(r.text=this.lineChunkAt(e),r.end+=r.text.length,this.ranges.length>1){let n=this.absoluteLineStart,s=this.rangeI;for(;this.ranges[s].to<r.end;){s++;let i=this.ranges[s].from,o=this.lineChunkAt(i);r.end=i+o.length,r.text=r.text.slice(0,this.ranges[s-1].to-n)+o,n=r.end-r.text.length}}return r}readLine(){let{line:e}=this,{text:r,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(r);e.depth<this.stack.length;e.depth++){let s=this.stack[e.depth],i=this.parser.skipContextMarkup[s.type];if(!i)throw new Error("Unhandled block context "+u[s.type]);if(!i(s,this,e))break;e.forward()}}lineChunkAt(e){let n,r=this.input.chunk(e);if(this.input.lineChunks)n="\n"==r?"":r;else{let s=r.indexOf("\n");n=s<0?r:r.slice(0,s)}return e+n.length>this.to?n.slice(0,this.to-e):n}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,r,n=0){this.block=j.create(e,n,this.lineStart+r,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,r,n=0){this.startContext(this.parser.getNodeType(e),r,n)}addNode(e,r,n){"number"==typeof e&&(e=new b.mp(this.parser.nodeSet.types[e],P,P,(n??this.prevLineEnd())-r)),this.block.addChild(e,r-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,r){this.addNode(this.buffer.writeElements(W(r.children,e.marks),-r.from).finish(r.type,r.to-r.from),r.from)}finishContext(){let e=this.stack.pop(),r=this.stack[this.stack.length-1];r.addChild(e.toTree(this.parser.nodeSet),e.from-r.from),this.block=r}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?we(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let n of e.parsers)if(n.finish(this,e))return;let r=W(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(r,-e.start).finish(u.Paragraph,e.content.length),e.start)}elt(e,r,n,s){return"string"==typeof e?g(this.parser.getNodeType(e),r,n,s):new xe(e,r)}get buffer(){return new Ce(this.parser.nodeSet)}}function we(t,e,r,n,s){let i=t[e].to,o=[],a=[],l=r.from+n;function f(h,p){for(;p?h>=i:h>i;){let d=t[e+1].from-i;n+=d,h+=d,e++,i=t[e].to}}for(let h=r.firstChild;h;h=h.nextSibling){f(h.from+n,!0);let d,p=h.from+n,m=s.get(h.tree);m?d=m:h.to+n>i?(d=we(t,e,h,n,s),f(h.to+n,!1)):d=h.toTree(),o.push(d),a.push(p-l)}return f(r.to+n,!1),new b.mp(r.type,o,a,r.to+n-l,r.tree?r.tree.propValues:void 0)}class X extends b._b{constructor(e,r,n,s,i,o,a,l,f){super(),this.nodeSet=e,this.blockParsers=r,this.leafBlockParsers=n,this.blockNames=s,this.endLeafBlock=i,this.skipContextMarkup=o,this.inlineParsers=a,this.inlineNames=l,this.wrappers=f,this.nodeTypes=Object.create(null);for(let h of e.types)this.nodeTypes[h.name]=h.id}createParse(e,r,n){let s=new lt(this,e,r,n);for(let i of this.wrappers)s=i(s,e,r,n);return s}configure(e){let r=K(e);if(!r)return this;let{nodeSet:n,skipContextMarkup:s}=this,i=this.blockParsers.slice(),o=this.leafBlockParsers.slice(),a=this.blockNames.slice(),l=this.inlineParsers.slice(),f=this.inlineNames.slice(),h=this.endLeafBlock.slice(),p=this.wrappers;if(R(r.defineNodes)){s=Object.assign({},s);let m,d=n.types.slice();for(let L of r.defineNodes){let{name:k,block:C,composite:x,style:w}="string"==typeof L?{name:L}:L;if(d.some(v=>v.name==k))continue;x&&(s[d.length]=(v,Tt,zt)=>x(Tt,zt,v.value));let M=d.length,y=x?["Block","BlockContext"]:C?M>=u.ATXHeading1&&M<=u.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;d.push(b.Jq.define({id:M,name:k,props:y&&[[b.md.group,y]]})),w&&(m||(m={}),Array.isArray(w)||w instanceof c.Vp?m[k]=w:Object.assign(m,w))}n=new b.Lj(d),m&&(n=n.extend((0,c.Gv)(m)))}if(R(r.props)&&(n=n.extend(...r.props)),R(r.remove))for(let d of r.remove){let m=this.blockNames.indexOf(d),L=this.inlineNames.indexOf(d);m>-1&&(i[m]=o[m]=void 0),L>-1&&(l[L]=void 0)}if(R(r.parseBlock))for(let d of r.parseBlock){let m=a.indexOf(d.name);if(m>-1)i[m]=d.parse,o[m]=d.leaf;else{let L=d.before?F(a,d.before):d.after?F(a,d.after)+1:a.length-1;i.splice(L,0,d.parse),o.splice(L,0,d.leaf),a.splice(L,0,d.name)}d.endLeaf&&h.push(d.endLeaf)}if(R(r.parseInline))for(let d of r.parseInline){let m=f.indexOf(d.name);if(m>-1)l[m]=d.parse;else{let L=d.before?F(f,d.before):d.after?F(f,d.after)+1:f.length-1;l.splice(L,0,d.parse),f.splice(L,0,d.name)}}return r.wrap&&(p=p.concat(r.wrap)),new X(n,i,o,a,h,s,l,f,p)}getNodeType(e){let r=this.nodeTypes[e];if(null==r)throw new RangeError(`Unknown node type '${e}'`);return r}parseInline(e,r){let n=new ft(this,e,r);e:for(let s=r;s<n.end;){let i=n.char(s);for(let o of this.inlineParsers)if(o){let a=o(n,i,s);if(a>=0){s=a;continue e}}s++}return n.resolveMarkers(0)}}function R(t){return null!=t&&t.length>0}function K(t){if(!Array.isArray(t))return t;if(0==t.length)return null;let e=K(t[0]);if(1==t.length)return e;let r=K(t.slice(1));if(!r||!e)return e||r;let n=(o,a)=>(o||P).concat(a||P),s=e.wrap,i=r.wrap;return{props:n(e.props,r.props),defineNodes:n(e.defineNodes,r.defineNodes),parseBlock:n(e.parseBlock,r.parseBlock),parseInline:n(e.parseInline,r.parseInline),remove:n(e.remove,r.remove),wrap:s?i?(o,a,l,f)=>s(i(o,a,l,f),a,l,f):s:i}}function F(t,e){let r=t.indexOf(e);if(r<0)throw new RangeError(`Position specified relative to unknown parser ${e}`);return r}let Se=[b.Jq.none];for(let e,t=1;e=u[t];t++)Se[t]=b.Jq.define({id:t,name:e,props:t>=u.Escape?[]:[[b.md.group,t in le?["Block","BlockContext"]:["Block","LeafBlock"]]],top:"Document"==e});const P=[];class Ce{constructor(e){this.nodeSet=e,this.content=[],this.nodes=[]}write(e,r,n,s=0){return this.content.push(e,r,n,4+4*s),this}writeElements(e,r=0){for(let n of e)n.writeTo(this,r);return this}finish(e,r){return b.mp.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:e,length:r})}}class J{constructor(e,r,n,s=P){this.type=e,this.from=r,this.to=n,this.children=s}writeTo(e,r){let n=e.content.length;e.writeElements(this.children,r),e.content.push(this.type,this.from+r,this.to+r,e.content.length+4-n)}toTree(e){return new Ce(e).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}}class xe{constructor(e,r){this.tree=e,this.from=r}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return P}writeTo(e,r){e.nodes.push(this.tree),e.content.push(e.nodes.length-1,this.from+r,this.to+r,-1)}toTree(){return this.tree}}function g(t,e,r,n){return new J(t,e,r,n)}const Ae={resolve:"Emphasis",mark:"EmphasisMark"},Be={resolve:"Emphasis",mark:"EmphasisMark"},N={},V={};class I{constructor(e,r,n,s){this.type=e,this.from=r,this.to=n,this.side=s}}const Ie="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";let T=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{T=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}const Y={Escape(t,e,r){if(92!=e||r==t.end-1)return-1;let n=t.char(r+1);for(let s=0;s<Ie.length;s++)if(Ie.charCodeAt(s)==n)return t.append(g(u.Escape,r,r+2));return-1},Entity(t,e,r){if(38!=e)return-1;let n=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(t.slice(r+1,r+31));return n?t.append(g(u.Entity,r,r+1+n[0].length)):-1},InlineCode(t,e,r){if(96!=e||r&&96==t.char(r-1))return-1;let n=r+1;for(;n<t.end&&96==t.char(n);)n++;let s=n-r,i=0;for(;n<t.end;n++)if(96==t.char(n)){if(i++,i==s&&96!=t.char(n+1))return t.append(g(u.InlineCode,r,n+1,[g(u.CodeMark,r,r+s),g(u.CodeMark,n+1-s,n+1)]))}else i=0;return-1},HTMLTag(t,e,r){if(60!=e||r==t.end-1)return-1;let n=t.slice(r+1,t.end),s=/^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(n);if(s)return t.append(g(u.Autolink,r,r+1+s[0].length,[g(u.LinkMark,r,r+1),g(u.URL,r+1,r+s[0].length),g(u.LinkMark,r+s[0].length,r+1+s[0].length)]));let i=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(n);if(i)return t.append(g(u.Comment,r,r+1+i[0].length));let o=/^\?[^]*?\?>/.exec(n);if(o)return t.append(g(u.ProcessingInstruction,r,r+1+o[0].length));let a=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(n);return a?t.append(g(u.HTMLTag,r,r+1+a[0].length)):-1},Emphasis(t,e,r){if(95!=e&&42!=e)return-1;let n=r+1;for(;t.char(n)==e;)n++;let s=t.slice(r-1,r),i=t.slice(n,n+1),o=T.test(s),a=T.test(i),l=/\s|^$/.test(s),f=/\s|^$/.test(i),h=!f&&(!a||l||o),p=!l&&(!o||f||a),d=h&&(42==e||!p||o),m=p&&(42==e||!h||a);return t.append(new I(95==e?Ae:Be,r,n,(d?1:0)|(m?2:0)))},HardBreak(t,e,r){if(92==e&&10==t.char(r+1))return t.append(g(u.HardBreak,r,r+2));if(32==e){let n=r+1;for(;32==t.char(n);)n++;if(10==t.char(n)&&n>=r+2)return t.append(g(u.HardBreak,r,n+1))}return-1},Link:(t,e,r)=>91==e?t.append(new I(N,r,r+1,1)):-1,Image:(t,e,r)=>33==e&&91==t.char(r+1)?t.append(new I(V,r,r+2,1)):-1,LinkEnd(t,e,r){if(93!=e)return-1;for(let n=t.parts.length-1;n>=0;n--){let s=t.parts[n];if(s instanceof I&&(s.type==N||s.type==V)){if(!s.side||t.skipSpace(s.to)==r&&!/[(\[]/.test(t.slice(r+1,r+2)))return t.parts[n]=null,-1;let i=t.takeContent(n),o=t.parts[n]=ht(t,i,s.type==N?u.Link:u.Image,s.from,r+1);if(s.type==N)for(let a=0;a<n;a++){let l=t.parts[a];l instanceof I&&l.type==N&&(l.side=0)}return o.to}}return-1}};function ht(t,e,r,n,s){let{text:i}=t,o=t.char(s),a=s;if(e.unshift(g(u.LinkMark,n,n+(r==u.Image?2:1))),e.push(g(u.LinkMark,s-1,s)),40==o){let h,l=t.skipSpace(s+1),f=Ee(i,l-t.offset,t.offset);f&&(l=t.skipSpace(f.to),l!=f.to&&(h=Me(i,l-t.offset,t.offset),h&&(l=t.skipSpace(h.to)))),41==t.char(l)&&(e.push(g(u.LinkMark,s,s+1)),a=l+1,f&&e.push(f),h&&e.push(h),e.push(g(u.LinkMark,l,a)))}else if(91==o){let l=He(i,s-t.offset,t.offset,!1);l&&(e.push(l),a=l.to)}return g(r,n,a,e)}function Ee(t,e,r){if(60==t.charCodeAt(e)){for(let s=e+1;s<t.length;s++){let i=t.charCodeAt(s);if(62==i)return g(u.URL,e+r,s+1+r);if(60==i||10==i)return!1}return null}{let s=0,i=e;for(let o=!1;i<t.length;i++){let a=t.charCodeAt(i);if(B(a))break;if(o)o=!1;else if(40==a)s++;else if(41==a){if(!s)break;s--}else 92==a&&(o=!0)}return i>e?g(u.URL,e+r,i+r):i==t.length&&null}}function Me(t,e,r){let n=t.charCodeAt(e);if(39!=n&&34!=n&&40!=n)return!1;let s=40==n?41:n;for(let i=e+1,o=!1;i<t.length;i++){let a=t.charCodeAt(i);if(o)o=!1;else{if(a==s)return g(u.LinkTitle,e+r,i+1+r);92==a&&(o=!0)}}return null}function He(t,e,r,n){for(let s=!1,i=e+1,o=Math.min(t.length,i+999);i<o;i++){let a=t.charCodeAt(i);if(s)s=!1;else{if(93==a)return!n&&g(u.LinkLabel,e+r,i+1+r);if(n&&!B(a)&&(n=!1),91==a)return!1;92==a&&(s=!0)}}return null}class ft{constructor(e,r,n){this.parser=e,this.text=r,this.offset=n,this.parts=[]}char(e){return e>=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,r){return this.text.slice(e-this.offset,r-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,r,n,s,i){return this.append(new I(e,r,n,(s?1:0)|(i?2:0)))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let r=this.parts[e];if(r instanceof I&&(r.type==N||r.type==V))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let n=e;n<this.parts.length;n++){let s=this.parts[n];if(!(s instanceof I&&s.type.resolve&&2&s.side))continue;let a,i=s.type==Ae||s.type==Be,o=s.to-s.from,l=n-1;for(;l>=e;l--){let k=this.parts[l];if(k instanceof I&&1&k.side&&k.type==s.type&&!(i&&(1&s.side||2&k.side)&&(k.to-k.from+o)%3==0&&((k.to-k.from)%3||o%3))){a=k;break}}if(!a)continue;let f=s.type.resolve,h=[],p=a.from,d=s.to;if(i){let k=Math.min(2,a.to-a.from,o);p=a.to-k,d=s.from+k,f=1==k?"Emphasis":"StrongEmphasis"}a.type.mark&&h.push(this.elt(a.type.mark,p,a.to));for(let k=l+1;k<n;k++)this.parts[k]instanceof J&&h.push(this.parts[k]),this.parts[k]=null;s.type.mark&&h.push(this.elt(s.type.mark,s.from,d));let m=this.elt(f,p,d,h);this.parts[l]=i&&a.from!=p?new I(a.type,a.from,p,a.side):null,(this.parts[n]=i&&s.to!=d?new I(s.type,d,s.to,s.side):null)?this.parts.splice(n,0,m):this.parts[n]=m}let r=[];for(let n=e;n<this.parts.length;n++){let s=this.parts[n];s instanceof J&&r.push(s)}return r}findOpeningDelimiter(e){for(let r=this.parts.length-1;r>=0;r--){let n=this.parts[r];if(n instanceof I&&n.type==e)return r}return null}takeContent(e){let r=this.resolveMarkers(e);return this.parts.length=e,r}skipSpace(e){return O(this.text,e-this.offset)+this.offset}elt(e,r,n,s){return"string"==typeof e?g(this.parser.getNodeType(e),r,n,s):new xe(e,r)}}function W(t,e){if(!e.length)return t;if(!t.length)return e;let r=t.slice(),n=0;for(let s of e){for(;n<r.length&&r[n].to<s.to;)n++;if(n<r.length&&r[n].from<s.from){let i=r[n];i instanceof J&&(r[n]=new J(i.type,i.from,i.to,W(i.children,[s])))}else r.splice(n++,0,s)}return r}const ut=[u.CodeBlock,u.ListItem,u.OrderedList,u.BulletList];class dt{constructor(e,r){this.fragments=e,this.input=r,this.i=0,this.fragment=null,this.fragmentEnd=-1,this.cursor=null,e.length&&(this.fragment=e[this.i++])}nextFragment(){this.fragment=this.i<this.fragments.length?this.fragments[this.i++]:null,this.cursor=null,this.fragmentEnd=-1}moveTo(e,r){for(;this.fragment&&this.fragment.to<=e;)this.nextFragment();if(!this.fragment||this.fragment.from>(e?e-1:0))return!1;if(this.fragmentEnd<0){let i=this.fragment.to;for(;i>0&&"\n"!=this.input.read(i-1,i);)i--;this.fragmentEnd=i?i-1:0}let n=this.cursor;n||(n=this.cursor=this.fragment.tree.cursor(),n.firstChild());let s=e+this.fragment.offset;for(;n.to<=s;)if(!n.parent())return!1;for(;;){if(n.from>=s)return this.fragment.from<=r;if(!n.childAfter(s))return!1}}matches(e){let r=this.cursor.tree;return r&&r.prop(b.md.contextHash)==e}takeNodes(e){let r=this.cursor,n=this.fragment.offset,s=this.fragmentEnd-(this.fragment.openEnd?1:0),i=e.absoluteLineStart,o=i,a=e.block.children.length,l=o,f=a;for(;;){if(r.to-n>s){if(r.type.isAnonymous&&r.firstChild())continue;break}let h=ve(r.from-n,e.ranges);if(r.to-n<=e.ranges[e.rangeI].to)e.addNode(r.tree,h);else{let p=new b.mp(e.parser.nodeSet.types[u.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(p,r.tree),e.addNode(p,h)}if(r.type.is("Block")&&(ut.indexOf(r.type.id)<0?(o=r.to-n,a=e.block.children.length):(o=l,a=f,l=r.to-n,f=e.block.children.length)),!r.nextSibling())break}for(;e.block.children.length>a;)e.block.children.pop(),e.block.positions.pop();return o-i}}function ve(t,e){let r=t;for(let n=1;n<e.length;n++){let s=e[n-1].to,i=e[n].from;s<t&&(r-=i-s)}return r}const pt=(0,c.Gv)({"Blockquote/...":c.pJ.quote,HorizontalRule:c.pJ.contentSeparator,"ATXHeading1/... SetextHeading1/...":c.pJ.heading1,"ATXHeading2/... SetextHeading2/...":c.pJ.heading2,"ATXHeading3/...":c.pJ.heading3,"ATXHeading4/...":c.pJ.heading4,"ATXHeading5/...":c.pJ.heading5,"ATXHeading6/...":c.pJ.heading6,"Comment CommentBlock":c.pJ.comment,Escape:c.pJ.escape,Entity:c.pJ.character,"Emphasis/...":c.pJ.emphasis,"StrongEmphasis/...":c.pJ.strong,"Link/... Image/...":c.pJ.link,"OrderedList/... BulletList/...":c.pJ.list,"BlockQuote/...":c.pJ.quote,"InlineCode CodeText":c.pJ.monospace,"URL Autolink":c.pJ.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":c.pJ.processingInstruction,"CodeInfo LinkLabel":c.pJ.labelName,LinkTitle:c.pJ.string,Paragraph:c.pJ.content}),ct=new X(new b.Lj(Se).extend(pt),Object.keys(D).map(t=>D[t]),Object.keys(D).map(t=>be[t]),Object.keys(D),ot,le,Object.keys(Y).map(t=>Y[t]),Object.keys(Y),[]);function mt(t,e,r){let n=[];for(let s=t.firstChild,i=e;;s=s.nextSibling){let o=s?s.from:r;if(o>i&&n.push({from:i,to:o}),!s)break;i=s.to}return n}const kt={resolve:"Strikethrough",mark:"StrikethroughMark"},Lt={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":c.pJ.strikethrough}},{name:"StrikethroughMark",style:c.pJ.processingInstruction}],parseInline:[{name:"Strikethrough",parse(t,e,r){if(126!=e||126!=t.char(r+1)||126==t.char(r+2))return-1;let n=t.slice(r-1,r),s=t.slice(r+2,r+3),i=/\s|^$/.test(n),o=/\s|^$/.test(s),a=T.test(n),l=T.test(s);return t.addDelimiter(kt,r,r+2,!o&&(!l||i||a),!i&&(!a||o||l))},after:"Emphasis"}]};function z(t,e,r=0,n,s=0){let i=0,o=!0,a=-1,l=-1,f=!1,h=()=>{n.push(t.elt("TableCell",s+a,s+l,t.parser.parseInline(e.slice(a,l),s+a)))};for(let p=r;p<e.length;p++){let d=e.charCodeAt(p);124!=d||f?(f||32!=d&&9!=d)&&(a<0&&(a=p),l=p+1):((!o||a>-1)&&i++,o=!1,n&&(a>-1&&h(),n.push(t.elt("TableDelimiter",p+s,p+s+1))),a=l=-1),f=!f&&92==d}return a>-1&&(i++,n&&h()),i}function Pe(t,e){for(let r=e;r<t.length;r++){let n=t.charCodeAt(r);if(124==n)return!0;92==n&&r++}return!1}const Ne=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;class ye{constructor(){this.rows=null}nextLine(e,r,n){if(null==this.rows){let s;if(this.rows=!1,(45==r.next||58==r.next||124==r.next)&&Ne.test(s=r.text.slice(r.pos))){let i=[];z(e,n.content,0,i,n.start)==z(e,s,r.pos)&&(this.rows=[e.elt("TableHeader",n.start,n.start+n.content.length,i),e.elt("TableDelimiter",e.lineStart+r.pos,e.lineStart+r.text.length)])}}else if(this.rows){let s=[];z(e,r.text,r.pos,s,e.lineStart),this.rows.push(e.elt("TableRow",e.lineStart+r.pos,e.lineStart+r.text.length,s))}return!1}finish(e,r){return!!this.rows&&(e.addLeafElement(r,e.elt("Table",r.start,r.start+r.content.length,this.rows)),!0)}}const bt={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":c.pJ.heading}},"TableRow",{name:"TableCell",style:c.pJ.content},{name:"TableDelimiter",style:c.pJ.processingInstruction}],parseBlock:[{name:"Table",leaf:(t,e)=>Pe(e.content,0)?new ye:null,endLeaf(t,e,r){if(r.parsers.some(s=>s instanceof ye)||!Pe(e.text,e.basePos))return!1;let n=t.peekLine();return Ne.test(n)&&z(t,e.text,e.basePos)==z(t,n,e.basePos)},before:"SetextHeading"}]};class wt{nextLine(){return!1}finish(e,r){return e.addLeafElement(r,e.elt("Task",r.start,r.start+r.content.length,[e.elt("TaskMarker",r.start,r.start+3),...e.parser.parseInline(r.content.slice(3),r.start+3)])),!0}}const St={defineNodes:[{name:"Task",block:!0,style:c.pJ.list},{name:"TaskMarker",style:c.pJ.atom}],parseBlock:[{name:"TaskList",leaf:(t,e)=>/^\[[ xX]\][ \t]/.test(e.content)&&"ListItem"==t.parentType().name?new wt:null,after:"SetextHeading"}]},Oe=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,Re=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,Ct=/[\w-]+\.[\w-]+($|\/)/,Je=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,Te=/\/[a-zA-Z\d@.]+/gy;function ze(t,e,r,n){let s=0;for(let i=e;i<r;i++)t[i]==n&&s++;return s}function je(t,e){Je.lastIndex=e;let r=Je.exec(t);if(!r)return-1;let n=r[0][r[0].length-1];return"_"==n||"-"==n?-1:e+r[0].length-("."==n?1:0)}const At=[bt,St,Lt,{parseInline:[{name:"Autolink",parse(t,e,r){let n=r-t.offset;if(n&&/\w/.test(t.text[n-1]))return-1;Oe.lastIndex=n;let s=Oe.exec(t.text),i=-1;if(!s)return-1;if(s[1]||s[2]){if(i=function xt(t,e){Re.lastIndex=e;let r=Re.exec(t);if(!r||Ct.exec(r[0])[0].indexOf("_")>-1)return-1;let n=e+r[0].length;for(;;){let i,s=t[n-1];if(/[?!.,:*_~]/.test(s)||")"==s&&ze(t,e,n,")")>ze(t,e,n,"("))n--;else{if(";"!=s||!(i=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(t.slice(e,n))))break;n=e+i.index}}return n}(t.text,n+s[0].length),i>-1&&t.hasOpenLink){i=n+/([^\[\]]|\[[^\]]*\])*/.exec(t.text.slice(n,i))[0].length}}else s[3]?i=je(t.text,n):(i=je(t.text,n+s[0].length),i>-1&&"xmpp:"==s[0]&&(Te.lastIndex=i,s=Te.exec(t.text),s&&(i=s.index+s[0].length)));return i<0?-1:(t.addElement(t.elt("URL",r,i+t.offset)),i+t.offset)}}]}];function De(t,e,r){return(n,s,i)=>{if(s!=t||n.char(i+1)==t)return-1;let o=[n.elt(r,i,i+1)];for(let a=i+1;a<n.end;a++){let l=n.char(a);if(l==t)return n.addElement(n.elt(e,i,a+1,o.concat(n.elt(r,a,a+1))));if(92==l&&o.push(n.elt("Escape",a,2+a++)),B(l))break}return-1}}const Bt={defineNodes:[{name:"Superscript",style:c.pJ.special(c.pJ.content)},{name:"SuperscriptMark",style:c.pJ.processingInstruction}],parseInline:[{name:"Superscript",parse:De(94,"Superscript","SuperscriptMark")}]},It={defineNodes:[{name:"Subscript",style:c.pJ.special(c.pJ.content)},{name:"SubscriptMark",style:c.pJ.processingInstruction}],parseInline:[{name:"Subscript",parse:De(126,"Subscript","SubscriptMark")}]},Et={defineNodes:[{name:"Emoji",style:c.pJ.character}],parseInline:[{name:"Emoji",parse(t,e,r){let n;return 58==e&&(n=/^[a-zA-Z_0-9]+:/.exec(t.slice(r+1,t.end)))?t.addElement(t.elt("Emoji",r,r+1+n[0].length)):-1}}]};var Xe=E(71030);const Fe=(0,S.kU)({commentTokens:{block:{open:"\x3c!--",close:"--\x3e"}}}),$e=new b.md,Ue=ct.configure({props:[S.x0.add(t=>!t.is("Block")||t.is("Document")||null!=_(t)||function Mt(t){return"OrderedList"==t.name||"BulletList"==t.name}(t)?void 0:(e,r)=>({from:r.doc.lineAt(e.from).to,to:e.to})),$e.add(_),S.uj.add({Document:()=>null}),S.pp.add({Document:Fe})]});function _(t){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(t.name);return e?+e[1]:void 0}function Ht(t,e){let r=t;for(;;){let s,n=r.nextSibling;if(!n||null!=(s=_(n.type))&&s<=e)break;r=n}return r.to}const vt=S.rs.of((t,e,r)=>{for(let n=(0,S.qz)(t).resolveInner(r,-1);n&&!(n.from<e);n=n.parent){let s=n.type.prop($e);if(null==s)continue;let i=Ht(n,s);if(i>r)return{from:r,to:i}}return null});function ee(t){return new S.SQ(Fe,t,[vt],"markdown")}const qe=ee(Ue),te=ee(Ue.configure([At,It,Bt,Et,{props:[S.x0.add({Table:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})})]}]));class re{constructor(e,r,n,s,i,o,a){this.node=e,this.from=r,this.to=n,this.spaceBefore=s,this.spaceAfter=i,this.type=o,this.item=a}blank(e,r=!0){let n=this.spaceBefore+("Blockquote"==this.node.name?">":"");if(null!=e){for(;n.length<e;)n+=" ";return n}for(let s=this.to-this.from-n.length-this.spaceAfter.length;s>0;s--)n+=" ";return n+(r?this.spaceAfter:"")}marker(e,r){let n="OrderedList"==this.node.name?String(+Ze(this.item,e)[2]+r):"";return this.spaceBefore+n+this.type+this.spaceAfter}}function Qe(t,e){let r=[],n=[];for(let s=t;s;s=s.parent){if("FencedCode"==s.name)return n;("ListItem"==s.name||"Blockquote"==s.name)&&r.push(s)}for(let s=r.length-1;s>=0;s--){let o,i=r[s],a=e.lineAt(i.from),l=i.from-a.from;if("Blockquote"==i.name&&(o=/^ *>( ?)/.exec(a.text.slice(l))))n.push(new re(i,l,l+o[0].length,"",o[1],">",null));else if("ListItem"==i.name&&"OrderedList"==i.parent.name&&(o=/^( *)\d+([.)])( *)/.exec(a.text.slice(l)))){let f=o[3],h=o[0].length;f.length>=4&&(f=f.slice(0,f.length-4),h-=4),n.push(new re(i.parent,l,l+h,o[1],f,o[2],i))}else if("ListItem"==i.name&&"BulletList"==i.parent.name&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(a.text.slice(l)))){let f=o[4],h=o[0].length;f.length>4&&(f=f.slice(0,f.length-4),h-=4);let p=o[2];o[3]&&(p+=o[3].replace(/[xX]/," ")),n.push(new re(i.parent,l,l+h,o[1],f,p,i))}}return n}function Ze(t,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(t.from,t.from+10))}function ne(t,e,r,n=0){for(let s=-1,i=t;;){if("ListItem"==i.name){let a=Ze(i,e),l=+a[2];if(s>=0){if(l!=s+1)return;r.push({from:i.from+a[1].length,to:i.from+a[0].length,insert:String(s+2+n)})}s=l}let o=i.nextSibling;if(!o)break;i=o}}function se(t,e){let r=/^[ \t]*/.exec(t)[0].length;if(!r||"\t"!=e.facet(S.c))return t;let s="";for(let i=(0,A.IS)(t,4,r);i>0;)i>=4?(s+="\t",i-=4):(s+=" ",i--);return s+t.slice(r)}const Ge=({state:t,dispatch:e})=>{let r=(0,S.qz)(t),{doc:n}=t,s=null,i=t.changeByRange(o=>{if(!o.empty||!te.isActiveAt(t,o.from,0))return s={range:o};let a=o.from,l=n.lineAt(a),f=Qe(r.resolveInner(a,-1),n);for(;f.length&&f[f.length-1].from>a-l.from;)f.pop();if(!f.length)return s={range:o};let h=f[f.length-1];if(h.to-h.spaceAfter.length>a-l.from)return s={range:o};let p=a>=h.to-h.spaceAfter.length&&!/\S/.test(l.text.slice(h.to));if(h.item&&p){let C=h.node.firstChild,x=h.node.getChild("ListItem","ListItem");if(C.to>=a||x&&x.to<a||l.from>0&&!/[^\s>]/.test(n.lineAt(l.from-1).text)){let M,w=f.length>1?f[f.length-2]:null,y="";w&&w.item?(M=l.from+w.from,y=w.marker(n,1)):M=l.from+(w?w.to:0);let v=[{from:M,to:a,insert:y}];return"OrderedList"==h.node.name&&ne(h.item,n,v,-2),w&&"OrderedList"==w.node.name&&ne(w.item,n,v),{range:A.jT.cursor(M+y.length),changes:v}}{let w=Ve(f,t,l);return{range:A.jT.cursor(a+w.length+1),changes:{from:l.from,insert:w+t.lineBreak}}}}if("Blockquote"==h.node.name&&p&&l.from){let C=n.lineAt(l.from-1),x=/>\s*$/.exec(C.text);if(x&&x.index==h.from){let w=t.changes([{from:C.from+x.index,to:C.to},{from:l.from+h.from,to:l.to}]);return{range:o.map(w),changes:w}}}let d=[];"OrderedList"==h.node.name&&ne(h.item,n,d);let m=h.item&&h.item.from<l.from,L="";if(!m||/^[\s\d.)\-+*>]*/.exec(l.text)[0].length>=h.to)for(let C=0,x=f.length-1;C<=x;C++)L+=C!=x||m?f[C].blank(C<x?(0,A.IS)(l.text,4,f[C+1].from)-L.length:null):f[C].marker(n,1);let k=a;for(;k>l.from&&/\s/.test(l.text.charAt(k-l.from-1));)k--;return L=se(L,t),function Nt(t,e){if("OrderedList"!=t.name&&"BulletList"!=t.name)return!1;let r=t.firstChild,n=t.getChild("ListItem","ListItem");if(!n)return!1;let s=e.lineAt(r.to),i=e.lineAt(n.from),o=/^[\s>]*$/.test(s.text);return s.number+(o?0:1)<i.number}(h.node,t.doc)&&(L=Ve(f,t,l)+t.lineBreak+L),d.push({from:k,to:a,insert:t.lineBreak+L}),{range:A.jT.cursor(k+L.length+1),changes:d}});return!s&&(e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0)};function Ke(t){return"QuoteMark"==t.name||"ListMark"==t.name}function Ve(t,e,r){let n="";for(let s=0,i=t.length-2;s<=i;s++)n+=t[s].blank(s<i?(0,A.IS)(r.text,4,Math.min(r.text.length,t[s+1].from))-n.length:null,s<i);return se(n,e)}const Ye=({state:t,dispatch:e})=>{let r=(0,S.qz)(t),n=null,s=t.changeByRange(i=>{let o=i.from,{doc:a}=t;if(i.empty&&te.isActiveAt(t,i.from)){let l=a.lineAt(o),f=Qe(function yt(t,e){let s,r=t.resolveInner(e,-1),n=e;for(Ke(r)&&(n=r.from,r=r.parent);s=r.childBefore(n);)if(Ke(s))n=s.from;else{if("OrderedList"!=s.name&&"BulletList"!=s.name)break;r=s.lastChild,n=r.to}return r}(r,o),a);if(f.length){let h=f[f.length-1],p=h.to-h.spaceAfter.length+(h.spaceAfter?1:0);if(o-l.from>p&&!/\S/.test(l.text.slice(p,o-l.from)))return{range:A.jT.cursor(l.from+p),changes:{from:l.from+p,to:o}};if(o-l.from==p&&(!h.item||l.from<=h.item.from||!/\S/.test(l.text.slice(0,h.to)))){let d=l.from+h.from;if(h.item&&h.node.from<h.item.from&&/\S/.test(l.text.slice(h.from,h.to))){let m=h.blank((0,A.IS)(l.text,4,h.to)-(0,A.IS)(l.text,4,h.from));return d==l.from&&(m=se(m,t)),{range:A.jT.cursor(d+m.length),changes:{from:d,to:l.from+h.to,insert:m}}}if(d<o)return{range:A.jT.cursor(d),changes:{from:d,to:o}}}}}return n={range:i}});return!n&&(e(t.update(s,{scrollIntoView:!0,userEvent:"delete"})),!0)},We=[{key:"Enter",run:Ge},{key:"Backspace",run:Ye}],_e=(0,Xe.html)({matchClosingTags:!1});function Ot(t={}){let{codeLanguages:e,defaultCodeLanguage:r,addKeymap:n=!0,base:{parser:s}=qe,completeHTMLTags:i=!0,htmlTagLanguage:o=_e}=t;if(!(s instanceof X))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let f,a=t.extensions?[t.extensions]:[],l=[o.support];r instanceof S.ri?(l.push(r.support),f=r.language):r&&(f=r);let h=e||f?function Pt(t,e){return r=>{if(r&&t){let n=null;if(r=/\S*/.exec(r)[0],n="function"==typeof t?t(r):S.c6.matchLanguageName(t,r,!0),n instanceof S.c6)return n.support?n.support.language.parser:S.Be.getSkippingParser(n.load());if(n)return n.parser}return e?e.parser:null}}(e,f):void 0;a.push(function gt(t){let{codeParser:e,htmlParser:r}=t;return{wrap:(0,b.FE)((s,i)=>{let o=s.type.id;if(!e||o!=u.CodeBlock&&o!=u.FencedCode){if(r&&(o==u.HTMLBlock||o==u.HTMLTag||o==u.CommentBlock))return{parser:r,overlay:mt(s.node,s.from,s.to)}}else{let a="";if(o==u.FencedCode){let f=s.node.getChild(u.CodeInfo);f&&(a=i.read(f.from,f.to))}let l=e(a);if(l)return{parser:l,overlay:f=>f.type.id==u.CodeText}}return null})}}({codeParser:h,htmlParser:o.language.parser})),n&&l.push(A.Wl.high(et.$f.of(We)));let p=ee(s.configure(a));return i&&l.push(p.data.of({autocomplete:Rt})),new S.ri(p,l)}function Rt(t){let{state:e,pos:r}=t,n=/<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(r-25,r));if(!n)return null;let s=(0,S.qz)(e).resolveInner(r,-1);for(;s&&!s.type.isTop;){if("CodeBlock"==s.name||"FencedCode"==s.name||"ProcessingInstructionBlock"==s.name||"CommentBlock"==s.name||"Link"==s.name||"Image"==s.name)return null;s=s.parent}return{from:r-n[0].length,to:r,options:Jt(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let ie=null;function Jt(){if(ie)return ie;let t=(0,Xe.htmlCompletionSource)(new tt.TK(A.yy.create({extensions:_e}),0,!0));return ie=t?t.options:[]}}}]); |