reactjs-tiptap-editor 1.0.18 → 1.0.20
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/lib/{ActionMenuButton-Df077oOH.cjs → ActionMenuButton-BPgqKDXT.cjs} +1 -1
- package/lib/{ActionMenuButton-BOjCHFTA.js → ActionMenuButton-CMXWxvWu.js} +1 -1
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +23 -23
- package/lib/Blockquote.cjs +3 -3
- package/lib/Blockquote.js +33 -28
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +16 -10
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +2 -2
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +21 -22
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +2 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +2 -2
- package/lib/CodeBlock.cjs +20 -44
- package/lib/CodeBlock.js +1385 -4012
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +2 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +3 -3
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +2 -2
- package/lib/{Drawer-DwrlY_lY.cjs → Drawer-BivLAzMN.cjs} +1 -1
- package/lib/{Drawer-DxOoRiGQ.js → Drawer-BmVmgJsc.js} +3 -3
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +12 -12
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +17 -17
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +2 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +2 -2
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +4 -4
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +4 -4
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +9 -9
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +3 -3
- package/lib/History.cjs +1 -1
- package/lib/History.js +5 -3
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +2 -2
- package/lib/{Iframe-AhNV5WH5.js → Iframe-CAUrccA0.js} +7 -7
- package/lib/{Iframe-C6pBw-AF.cjs → Iframe-hwg9FxhU.cjs} +1 -1
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +6 -5
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +36 -36
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +13 -13
- package/lib/{Indent-DZ5PcJA4.js → Indent-3MoIatX1.js} +2 -2
- package/lib/{Indent-Do-X0AsY.cjs → Indent-MuSU0kXz.cjs} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +24 -18
- package/lib/Katex-BPQ7_A3w.cjs +4 -0
- package/lib/{Katex-bIgoenn_.js → Katex-xS-XZKQc.js} +398 -421
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +3 -3
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +3 -3
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-B0ZaACZO.cjs → LinkEditBlock-DLDY-8Ax.cjs} +1 -1
- package/lib/{LinkEditBlock-D_cF9fnc.js → LinkEditBlock-Dhvz7DCA.js} +26 -26
- package/lib/MarkdownPaste.cjs +1 -1
- package/lib/MarkdownPaste.js +1 -1
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +4 -4
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.js +41 -42
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +5 -5
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +2 -2
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +8 -8
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +6 -6
- package/lib/{SlashCommandNodeView-Ba03hlVZ.cjs → SlashCommandNodeView-CavaOSwo.cjs} +1 -1
- package/lib/{SlashCommandNodeView-cg0x3NRF.js → SlashCommandNodeView-RnDRm4Z1.js} +6 -6
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +2 -2
- package/lib/{Table-KqLiT5wG.js → Table-DN4TuDz1.js} +35 -35
- package/lib/{Table-ddU2LSc6.cjs → Table-m32ZhtxF.cjs} +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +2 -2
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +3 -3
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +3 -3
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +2 -2
- package/lib/{Twitter-C1Lzqc7u.js → Twitter-B2FDarxE.js} +9 -9
- package/lib/{Twitter-BIiR78Jh.cjs → Twitter-CJhQLKYS.cjs} +1 -1
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +4 -4
- package/lib/_commonjsHelpers-B4e78b8K.js +28 -0
- package/lib/_commonjsHelpers-BTDuMlIz.cjs +1 -0
- package/lib/bubble.cjs +6 -6
- package/lib/bubble.js +2136 -1822
- package/lib/{clsx-eGVyq7ot.js → clsx-Bg-2aTKh.js} +11 -11
- package/lib/{clsx-BWE7vnna.cjs → clsx-DSAWW32g.cjs} +1 -1
- package/lib/components/Bubble/RichTextBubbleCodeBlock.d.ts +1 -0
- package/lib/components/Bubble/index.d.ts +1 -0
- package/lib/{dropdown-menu-oSKIntXM.cjs → dropdown-menu-C0VlKIZC.cjs} +1 -1
- package/lib/{dropdown-menu-CexIkt_V.js → dropdown-menu-CWd8VVRO.js} +1 -1
- package/lib/extensions/CodeBlock/CodeBlock.d.ts +3 -18
- package/lib/extensions/Image/Image.d.ts +1 -0
- package/lib/{index-DHUN85fV.js → index-B2a7NqnN.js} +1149 -1019
- package/lib/{index-D0lc95kr.cjs → index-C3dgmjIF.cjs} +1 -1
- package/lib/{index-zig3Dj7A.cjs → index-C4WLt4NA.cjs} +9 -7
- package/lib/{index-RIXs7STX.js → index-CbkpBnTX.js} +1 -1
- package/lib/{index-BnW6t8z6.js → index-CjLxMm5d.js} +1 -1
- package/lib/{index-mfGK4pFo.js → index-D0EmqTpe.js} +167 -153
- package/lib/{index-C6xmkxrQ.js → index-DXtVL0al.js} +140 -138
- package/lib/{index-CJ9pyCM4.cjs → index-DlxZt4_j.cjs} +1 -1
- package/lib/{index-D_8P0LE5.js → index-P5_MyY0i.js} +1 -1
- package/lib/{index-DUpSE1Gb.cjs → index-TcJ2UKnv.cjs} +1 -1
- package/lib/index-czmcFIW7.cjs +1 -0
- package/lib/index-fbGGohBT.cjs +12 -0
- package/lib/index.cjs +1 -1
- package/lib/index.js +12 -12
- package/lib/{popover-BYSZ3zBi.js → popover-BrSDMb_n.js} +1 -1
- package/lib/{popover-BcHDZqBt.cjs → popover-UUKfPWue.cjs} +1 -1
- package/lib/{renderNodeView-BrM5kUj_.js → renderNodeView-CbxCTni3.js} +2 -2
- package/lib/{renderNodeView-D1zydtli.cjs → renderNodeView-DFVrJy0l.cjs} +1 -1
- package/lib/{separator-BmixLrnJ.cjs → separator-LH5EzF0T.cjs} +1 -1
- package/lib/{separator-CFKVxAea.js → separator-fpWkZkoh.js} +14 -14
- package/lib/style.css +1 -1
- package/lib/{updatePosition-CBRjbQMH.js → updatePosition-BGD41Hbg.js} +2 -2
- package/lib/{updatePosition-CfmY5Trk.cjs → updatePosition-CQE1ct18.cjs} +1 -1
- package/package.json +4 -2
- package/lib/Katex-CIC9ygbL.cjs +0 -4
- package/lib/delete-node-CosiBes5.cjs +0 -1
- package/lib/delete-node-eQHsyyhR.js +0 -24
- package/lib/extensions/CodeBlock/components/NodeViewCodeBlock/NodeViewCodeBlock.d.ts +0 -1
- package/lib/index-BUTn2LY6.cjs +0 -1
- package/lib/index-BtxvYLJ1.cjs +0 -12
- package/lib/select-C5SHDLFj.js +0 -120
- package/lib/select-DHjzKkcu.cjs +0 -1
- package/lib/textarea-CasDcv3u.cjs +0 -1
- package/lib/textarea-DNLrJoRl.js +0 -20
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
`);else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=n.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Ft.hasOwnProperty(o)&&this.parser.normalizeLists&&Xn(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:Un.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,f=this.needsBlock;if(Dt.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(s),this.needsBlock=f}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
3
3
|
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=n.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,n,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(o,t.attrs||null,n,t.preserveWhitespace);a&&(s=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,n,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,n),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,n,i){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,n){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(n)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=F.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):kt(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,n,i){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,i)),s}enterInner(e,t,n,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=gt(e,s,o.options);o.options&ae&&o.content.length==0&&(l|=ae);let a=F.none;return n=n.filter(c=>(o.type?o.type.allowsMarkType(c.type):kt(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new we(e,t,a,i,null,l)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=ce)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let f=a>0||a==0&&i?this.nodes[a].type:n&&a>=s?n.node(a-s).type:null;if(!f||f.name!=c&&!f.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}}function Xn(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Ft.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function Yn(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function wt(r){let e={};for(let t in r)e[t]=r[t];return e}function kt(r,e){let t=e.schema.nodes;for(let n in t){let i=t[n];if(!i.allowsMarkType(r))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:f}=l.edge(a);if(c==e||s.indexOf(f)<0&&o(f))return!0}};if(o(i.contentMatch))return!0}}class Qe{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Oe(t).createDocumentFragment());let i=n,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],f=this.serializeMark(c,o.isInline,t);f&&(s.push([c,i]),i.appendChild(f.dom),i=f.contentDOM||f.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:i}=Se(Oe(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&Se(Oe(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return Se(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Qe(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=xt(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return xt(e.marks)}}function xt(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function Oe(r){return r.document||window.document}const vt=new WeakMap;function Qn(r){let e=vt.get(r);return e===void 0&&vt.set(r,e=Zn(r)),e}function Zn(r){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let i=0;i<n.length;i++)t(n[i]);else for(let i in n)t(n[i])}return t(r),e}function Se(r,e,t,n){if(typeof e=="string")return{dom:r.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(s=Qn(n))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?r.createElementNS(t,i):r.createElement(i),c=e[1],f=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){f=2;for(let u in c)if(c[u]!=null){let d=u.indexOf(" ");d>0?a.setAttributeNS(u.slice(0,d),u.slice(d+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=f;u<e.length;u++){let d=e[u];if(d===0){if(u<e.length-1||u>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=Se(r,d,t,n);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Lt=65535,Wt=Math.pow(2,16);function Gn(r,e){return r+e*Wt}function St(r){return r&Lt}function er(r){return(r-(r&Lt))/Wt}const Jt=1,jt=2,be=4,Ht=8;class Ve{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Ht)>0}get deletedBefore(){return(this.delInfo&(Jt|be))>0}get deletedAfter(){return(this.delInfo&(jt|be))>0}get deletedAcross(){return(this.delInfo&be)>0}}class ${constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&$.empty)return $.empty}recover(e){let t=0,n=St(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+er(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],f=this.ranges[l+o],u=a+c;if(e<=u){let d=c?e==a?-1:e==u?1:t:t,h=a+i+(d<0?0:f);if(n)return h;let p=e==(t<0?a:u)?null:Gn(l/3,e-a),m=e==a?jt:e==u?Jt:be;return(t<0?e!=a:e!=u)&&(m|=Ht),new Ve(h,m,p)}i+=f-c}return n?e+i:new Ve(e+i,0,null)}touches(e,t){let n=0,i=St(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?n:0);if(a>e)break;let c=this.ranges[l+s],f=a+c;if(e<=f&&l==i*3)return!0;n+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],f=this.ranges[i+n];e(l,l+c,a,a+f),s+=f-c}}invert(){return new $(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?$.empty:new $(e<0?[0,-e,0]:[0,0,e])}}$.empty=new $([]);class fe{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new fe(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new fe;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return n?e:new Ve(e,i,null)}}const Pe=Object.create(null);class O{getMap(){return $.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Pe[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Pe)throw new RangeError("Duplicate use of step JSON ID "+e);return Pe[e]=t,t.prototype.jsonID=e,t}}class T{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new T(e,null)}static fail(e){return new T(null,e)}static fromReplace(e,t,n,i){try{return T.ok(e.replace(t,n,i))}catch(s){if(s instanceof Ln)return T.fail(s.message);throw s}}}function Ze(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let s=r.child(i);s.content.size&&(s=s.copy(Ze(s.content,e,s))),s.isInline&&(s=e(s,t,i)),n.push(s)}return w.fromArray(n)}class U extends O{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),s=new k(Ze(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return T.fromReplace(e,this.from,this.to,s)}invert(){return new W(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new U(t.pos,n.pos,this.mark)}merge(e){return e instanceof U&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new U(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new U(t.from,t.to,e.markFromJSON(t.mark))}}O.jsonID("addMark",U);class W extends O{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new k(Ze(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return T.fromReplace(e,this.from,this.to,n)}invert(){return new U(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new W(t.pos,n.pos,this.mark)}merge(e){return e instanceof W&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new W(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new W(t.from,t.to,e.markFromJSON(t.mark))}}O.jsonID("removeMark",W);class X extends O{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return T.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return T.fromReplace(e,this.pos,this.pos+1,new k(w.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new X(this.pos,t.marks[i]);return new X(this.pos,this.mark)}}return new Z(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new X(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new X(t.pos,e.markFromJSON(t.mark))}}O.jsonID("addNodeMark",X);class Z extends O{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return T.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return T.fromReplace(e,this.pos,this.pos+1,new k(w.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new X(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Z(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Z(t.pos,e.markFromJSON(t.mark))}}O.jsonID("removeNodeMark",Z);class R extends O{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&Ke(e,this.from,this.to)?T.fail("Structure replace would overwrite content"):T.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new $([this.from,this.to-this.from,this.slice.size])}invert(e){return new R(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new R(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof R)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?k.empty:new k(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new R(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?k.empty:new k(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new R(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new R(t.from,t.to,k.fromJSON(e,t.slice),!!t.structure)}}O.jsonID("replace",R);class N extends O{constructor(e,t,n,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Ke(e,this.from,this.gapFrom)||Ke(e,this.gapTo,this.to)))return T.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return T.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?T.fromReplace(e,this.from,this.to,n):T.fail("Content does not fit in gap")}getMap(){return new $([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new N(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||s>n.pos?null:new N(t.pos,n.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new N(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}}O.jsonID("replaceAround",N);function Ke(r,e,t){let n=r.resolve(e),i=t-e,s=n.depth;for(;i>0&&s>0&&n.indexAfter(s)==n.node(s).childCount;)s--,i--;if(i>0){let o=n.node(s).maybeChild(n.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function tr(r,e,t,n){let i=[],s=[],o,l;r.doc.nodesBetween(e,t,(a,c,f)=>{if(!a.isInline)return;let u=a.marks;if(!n.isInSet(u)&&f.type.allowsMarkType(n.type)){let d=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=n.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(o&&o.to==d&&o.mark.eq(u[m])?o.to=h:i.push(o=new W(d,h,u[m])));l&&l.to==d?l.to=h:s.push(l=new U(d,h,n))}}),i.forEach(a=>r.step(a)),s.forEach(a=>r.step(a))}function nr(r,e,t,n){let i=[],s=0;r.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(n instanceof Ye){let c=o.marks,f;for(;f=n.isInSet(c);)(a||(a=[])).push(f),c=f.removeFromSet(c)}else n?n.isInSet(o.marks)&&(a=[n]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let f=0;f<a.length;f++){let u=a[f],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&u.eq(i[h].style)&&(d=p)}d?(d.to=c,d.step=s):i.push({style:u,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>r.step(new W(o.from,o.to,o.style)))}function Ge(r,e,t,n=t.contentMatch,i=!0){let s=r.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),f=l+c.nodeSize,u=n.matchType(c.type);if(!u)o.push(new R(l,f,k.empty));else{n=u;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||r.step(new W(l,f,c.marks[d]));if(i&&c.isText&&t.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new k(w.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new R(l+d.index,l+d.index+d[0].length,p))}}l=f}if(!n.validEnd){let a=n.fillBefore(w.empty,!0);r.replace(l,l,new k(a,0,0))}for(let a=o.length-1;a>=0;a--)r.step(o[a])}function rr(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function se(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,s=0;;--n){let o=r.$from.node(n),l=r.$from.index(n)+i,a=r.$to.indexAfter(n)-s;if(n<r.depth&&o.canReplace(l,a,t))return n;if(n==0||o.type.spec.isolating||!rr(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function ir(r,e,t){let{$from:n,$to:i,depth:s}=e,o=n.before(s+1),l=i.after(s+1),a=o,c=l,f=w.empty,u=0;for(let p=s,m=!1;p>t;p--)m||n.index(p)>0?(m=!0,f=w.from(n.node(p).copy(f)),u++):a--;let d=w.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,d=w.from(i.node(p).copy(d)),h++):c++;r.step(new N(a,c,o,l,new k(f.append(d),u,h),f.size-u,!0))}function et(r,e,t=null,n=r){let i=sr(r,e),s=i&&or(n,e);return s?i.map(bt).concat({type:e,attrs:t}).concat(s.map(bt)):null}function bt(r){return{type:r,attrs:null}}function sr(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.contentMatchAt(n).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(n,i,o)?s:null}function or(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.child(n),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=n;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function lr(r,e,t){let n=w.empty;for(let o=t.length-1;o>=0;o--){if(n.size){let l=t[o].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=w.from(t[o].type.create(t[o].attrs,n))}let i=e.start,s=e.end;r.step(new N(i,s,i,s,new k(n,0,0),t.length,!0))}function ar(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=r.steps.length;r.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(n,a)&&cr(r.doc,r.mapping.slice(s).map(l),n)){let c=null;if(n.schema.linebreakReplacement){let h=n.whitespace=="pre",p=!!n.contentMatch.matchType(n.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Vt(r,o,l,s),Ge(r,r.mapping.slice(s).map(l,1),n,void 0,c===null);let f=r.mapping.slice(s),u=f.map(l,1),d=f.map(l+o.nodeSize,1);return r.step(new N(u,d,u+1,d-1,new k(w.from(n.create(a,null,o.marks)),0,0),1,!0)),c===!0&&_t(r,o,l,s),!1}})}function _t(r,e,t,n){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=r.mapping.slice(n).map(t+1+s+o.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Vt(r,e,t,n){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=r.mapping.slice(n).map(t+1+s);r.replaceWith(o,o+1,e.type.schema.text(`
|
|
4
4
|
`))}})}function cr(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function fr(r,e,t,n,i){let s=r.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(n,null,i||s.marks);if(s.isLeaf)return r.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new N(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new k(w.from(o),0,0),1,!0))}function V(r,e,t=1,n){let i=r.resolve(e),s=i.depth-t,o=n&&n[n.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,f=t-2;c>s;c--,f--){let u=i.node(c),d=i.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(d,u.childCount),p=n&&n[f+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=n&&n[f]||u;if(!u.canReplace(d+1,u.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(s),a=n&&n[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function ur(r,e,t=1,n){let i=r.doc.resolve(e),s=w.empty,o=w.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=w.from(i.node(l).copy(s));let f=n&&n[c];o=w.from(f?f.type.create(f.attrs,o):i.node(l).copy(o))}r.step(new R(e,e,new k(s.append(o),t,t),!0))}function Y(r,e){let t=r.resolve(e),n=t.index();return Kt(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function dr(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==n?r.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!r.type.allowsMarks(s.marks))return!1}return t.validEnd}function Kt(r,e){return!!(r&&e&&!r.isLeaf&&dr(r,e))}function Te(r,e,t=-1){let n=r.resolve(e);for(let i=n.depth;;i--){let s,o,l=n.index(i);if(i==n.depth?(s=n.nodeBefore,o=n.nodeAfter):t>0?(s=n.node(i+1),l++,o=n.node(i).maybeChild(l)):(s=n.node(i).maybeChild(l-1),o=n.node(i+1)),s&&!s.isTextblock&&Kt(s,o)&&n.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?n.before(i):n.after(i)}}function hr(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,s=r.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let f=o.whitespace=="pre",u=!!o.contentMatch.matchType(i);f&&!u?n=!1:!f&&u&&(n=!0)}let l=r.steps.length;if(n===!1){let f=r.doc.resolve(e+t);Vt(r,f.node(),f.before(),l)}o.inlineContent&&Ge(r,e+t-1,o,s.node().contentMatchAt(s.index()),n==null);let a=r.mapping.slice(l),c=a.map(e-t);if(r.step(new R(c,a.map(e+t,-1),k.empty,!0)),n===!0){let f=r.doc.resolve(c);_t(r,f.node(),f.before(),r.steps.length)}return r}function pr(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let s=n.index(i);if(n.node(i).canReplaceWith(s,s,t))return n.before(i+1);if(s>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let s=n.indexAfter(i);if(n.node(i).canReplaceWith(s,s,t))return n.after(i+1);if(s<n.node(i).childCount)return null}return null}function mr(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=n.depth;o>=0;o--){let l=o==n.depth?0:n.pos<=(n.start(o+1)+n.end(o+1))/2?-1:1,a=n.index(o)+(l>0?1:0),c=n.node(o),f=!1;if(s==1)f=c.canReplace(a,a,i);else{let u=c.contentMatchAt(a).findWrapping(i.firstChild.type);f=u&&c.canReplaceWith(a,a,u[0])}if(f)return l==0?n.pos:l<0?n.before(o+1):n.after(o+1)}return null}function Ae(r,e,t=e,n=k.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),s=r.resolve(t);return qt(i,s,n)?new R(e,t,n):new gr(i,s,n).fit()}function qt(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class gr{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=w.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=w.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let s=this.placed,o=n.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new k(s,o,l);return e>-1?new N(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new R(n.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,s=null;n?(s=$e(this.unplaced.content,n-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],f,u=null;if(t==1&&(o?c.matchType(o.type)||(u=c.fillBefore(w.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:n,frontierDepth:l,parent:s,inject:u};if(t==2&&o&&(f=c.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:l,parent:s,wrap:f};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=$e(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new k(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=$e(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new k(oe(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new k(oe(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=n?n.content:o.content,a=o.openStart-e,c=0,f=[],{match:u,type:d}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)f.push(i.child(m));u=u.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,f.push(Ut(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=le(this.placed,t,w.from(f)),this.frontier[t].match=u,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?k.empty:new k(oe(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new k(oe(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Be(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Be(e,t,i,n,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],f=Be(e,l,c,a,!0);if(!f||f.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=le(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=le(this.placed,this.depth,w.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(w.empty,!0);t.childCount&&(this.placed=le(this.placed,this.frontier.length,t))}}function oe(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(oe(r.firstChild.content,e-1,t)))}function le(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(le(r.lastChild.content,e-1,t)))}function $e(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function Ut(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,Ut(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(w.empty,!0)))),r.copy(n)}function Be(r,e,t,n,i){let s=r.node(e),o=i?r.indexAfter(e):r.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=n.fillBefore(s.content,!0,o);return l&&!yr(t,s.content,o)?l:null}function yr(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function wr(r){return r.spec.defining||r.spec.definingForContent}function kr(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),s=r.doc.resolve(t);if(qt(i,s,n))return r.step(new R(e,t,n));let o=Yt(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let d=i.depth,h=i.pos-1;d>0;d--,h--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(d)>-1?l=d:i.before(d)==h&&o.splice(1,0,-d)}let a=o.indexOf(l),c=[],f=n.openStart;for(let d=n.content,h=0;;h++){let p=d.firstChild;if(c.push(p),h==n.openStart)break;d=p.content}for(let d=f-1;d>=0;d--){let h=c[d],p=wr(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))f=d;else if(p||!h.type.isTextblock)break}for(let d=n.openStart;d>=0;d--){let h=(d+f+1)%(n.openStart+1),p=c[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let x=i.node(g-1),S=i.index(g-1);if(x.canReplaceWith(S,S,p.type,p.marks))return r.replace(i.before(g),y?s.after(g):t,new k(Xt(n.content,0,n.openStart,h),h,n.openEnd))}}let u=r.steps.length;for(let d=o.length-1;d>=0&&(r.replace(e,t,n),!(r.steps.length>u));d--){let h=o[d];h<0||(e=i.before(h),t=s.after(h))}}function Xt(r,e,t,n,i){if(e<t){let s=r.firstChild;r=r.replaceChild(0,s.copy(Xt(s.content,e+1,t,n,s)))}if(e>n){let s=i.contentMatchAt(0),o=s.fillBefore(r).append(r);r=o.append(s.matchFragment(o).fillBefore(w.empty,!0))}return r}function xr(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=pr(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new k(w.from(n),0,0))}function vr(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t),s=Yt(n,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),i.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),i.indexAfter(l-1))))return r.delete(n.before(l),i.after(l))}for(let o=1;o<=n.depth&&o<=i.depth;o++)if(e-n.start(o)==n.depth-o&&t>n.end(o)&&i.end(o)-t!=i.depth-o&&n.start(o-1)==i.start(o-1)&&n.node(o-1).canReplace(n.index(o-1),i.index(o-1)))return r.delete(n.before(o),t);r.delete(e,t)}function Yt(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let s=r.start(i);if(s<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class ee extends O{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return T.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return T.fromReplace(e,this.pos,this.pos+1,new k(w.from(i),0,t.isLeaf?0:1))}getMap(){return $.empty}invert(e){return new ee(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ee(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ee(t.pos,t.attr,t.value)}}O.jsonID("attr",ee);class ue extends O{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return T.ok(n)}getMap(){return $.empty}invert(e){return new ue(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ue(t.attr,t.value)}}O.jsonID("docAttr",ue);let te=class extends Error{};te=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};te.prototype=Object.create(Error.prototype);te.prototype.constructor=te;te.prototype.name="TransformError";class Qt{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new fe}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new te(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let i=this.mapping.maps[n];n&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=k.empty){let i=Ae(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new k(w.from(n),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return kr(this,e,t,n),this}replaceRangeWith(e,t,n){return xr(this,e,t,n),this}deleteRange(e,t){return vr(this,e,t),this}lift(e,t){return ir(this,e,t),this}join(e,t=1){return hr(this,e,t),this}wrap(e,t){return lr(this,e,t),this}setBlockType(e,t=e,n,i=null){return ar(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return fr(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new ee(e,t,n)),this}setDocAttribute(e,t){return this.step(new ue(e,t)),this}addNodeMark(e,t){return this.step(new X(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof F)t.isInSet(n.marks)&&this.step(new Z(e,t));else{let i=n.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new Z(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,n){return ur(this,e,t,n),this}addMark(e,t,n){return tr(this,e,t,n),this}removeMark(e,t,n){return nr(this,e,t,n),this}clearIncompatible(e,t,n){return Ge(this,e,t,n),this}}const De=Object.create(null);class C{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Zt(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=k.empty){let n=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],f=e.mapping.slice(s);e.replaceRange(f.map(a.pos),f.map(c.pos),l?k.empty:t),l==0&&Ct(e,s,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(n),c=a.map(o.pos),f=a.map(l.pos);s?e.deleteRange(c,f):(e.replaceRangeWith(c,f,t),Ct(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new P(e):G(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?G(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):G(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new L(e.node(0))}static atStart(e){return G(e,e,0,0,1)||new L(e)}static atEnd(e){return G(e,e,e.content.size,e.childCount,-1)||new L(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=De[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in De)throw new RangeError("Duplicate use of selection JSON ID "+e);return De[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}}C.prototype.visible=!0;class Zt{constructor(e,t){this.$from=e,this.$to=t}}let Mt=!1;function Et(r){!Mt&&!r.parent.inlineContent&&(Mt=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class P extends C{constructor(e,t=e){Et(e),Et(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return C.near(n);let i=e.resolve(t.map(this.anchor));return new P(i.parent.inlineContent?i:n,n)}replace(e,t=k.empty){if(super.replace(e,t),t==k.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof P&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Re(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new P(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let s=C.findFrom(t,n,!0)||C.findFrom(t,-n,!0);if(s)t=s.$head;else return C.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(C.findFrom(e,-n,!0)||C.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new P(e,t)}}C.jsonID("text",P);class Re{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Re(e.map(this.anchor),e.map(this.head))}resolve(e){return P.between(e.resolve(this.anchor),e.resolve(this.head))}}class E extends C{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return n?C.near(s):new E(s)}content(){return new k(w.from(this.node),0,0)}eq(e){return e instanceof E&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new tt(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new E(e.resolve(t.anchor))}static create(e,t){return new E(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}E.prototype.visible=!1;C.jsonID("node",E);class tt{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Re(n,n):new tt(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&E.isSelectable(n)?new E(t):C.near(t)}}class L extends C{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=k.empty){if(t==k.empty){e.delete(0,e.doc.content.size);let n=C.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new L(e)}map(e){return new L(e)}eq(e){return e instanceof L}getBookmark(){return Sr}}C.jsonID("all",L);const Sr={map(){return this},resolve(r){return new L(r)}};function G(r,e,t,n,i,s=!1){if(e.inlineContent)return P.create(r,t);for(let o=n-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&E.isSelectable(l))return E.create(r,t-(i<0?l.nodeSize:0))}else{let a=G(r,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function Ct(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof R||i instanceof N))return;let s=r.mapping.maps[n],o;s.forEach((l,a,c,f)=>{o==null&&(o=f)}),r.setSelection(C.near(r.doc.resolve(o),t))}function Tt(r,e){return!e||!r?r:r.bind(e)}class ke{constructor(e,t,n){this.name=e,this.init=Tt(t.init,n),this.apply=Tt(t.apply,n)}}new ke("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new ke("selection",{init(r,e){return r.selection||C.atStart(e.doc)},apply(r){return r.selection}}),new ke("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new ke("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}});function Gt(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=Gt(i,e,{})),t[n]=i}return t}class br{constructor(e){this.spec=e,this.props={},e.props&&Gt(e.props,this,this.props),this.key=e.key?e.key.key:en("plugin")}getState(e){return e[this.key]}}const Fe=Object.create(null);function en(r){return r in Fe?r+"$"+ ++Fe[r]:(Fe[r]=0,r+"$")}class Mr{constructor(e="key"){this.key=en(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ne=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function tn(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const nn=(r,e,t)=>{let n=tn(r,t);if(!n)return!1;let i=nt(n);if(!i){let o=n.blockRange(),l=o&&se(o);return l==null?!1:(e&&e(r.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(dn(r,i,e,-1))return!0;if(n.parent.content.size==0&&(ne(s,"end")||E.isSelectable(s)))for(let o=n.depth;;o--){let l=Ae(r.doc,n.before(o),n.after(o),k.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(ne(s,"end")?C.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):E.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||n.node(o-1).childCount>1)break}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Er=(r,e,t)=>{let n=tn(r,t);if(!n)return!1;let i=nt(n);return i?rn(r,i,e):!1},Cr=(r,e,t)=>{let n=on(r,t);if(!n)return!1;let i=rt(n);return i?rn(r,i,e):!1};function rn(r,e,t){let n=e.nodeBefore,i=n,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let f=i.lastChild;if(!f)return!1;i=f}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let f=l.firstChild;if(!f)return!1;l=f}let c=Ae(r.doc,s,a,k.empty);if(!c||c.from!=s||c instanceof R&&c.slice.size>=a-s)return!1;if(t){let f=r.tr.step(c);f.setSelection(P.create(f.doc,s)),t(f.scrollIntoView())}return!0}function ne(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}const sn=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;s=nt(n)}let o=s&&s.nodeBefore;return!o||!E.isSelectable(o)?!1:(e&&e(r.tr.setSelection(E.create(r.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function nt(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function on(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const ln=(r,e,t)=>{let n=on(r,t);if(!n)return!1;let i=rt(n);if(!i)return!1;let s=i.nodeAfter;if(dn(r,i,e,1))return!0;if(n.parent.content.size==0&&(ne(s,"start")||E.isSelectable(s))){let o=Ae(r.doc,n.before(),n.after(),k.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(ne(s,"start")?C.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):E.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},an=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;s=rt(n)}let o=s&&s.nodeAfter;return!o||!E.isSelectable(o)?!1:(e&&e(r.tr.setSelection(E.create(r.doc,s.pos)).scrollIntoView()),!0)};function rt(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}const Tr=(r,e)=>{let t=r.selection,n=t instanceof E,i;if(n){if(t.node.isTextblock||!Y(r.doc,t.from))return!1;i=t.from}else if(i=Te(r.doc,t.from,-1),i==null)return!1;if(e){let s=r.tr.join(i);n&&s.setSelection(E.create(s.doc,i-r.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Ar=(r,e)=>{let t=r.selection,n;if(t instanceof E){if(t.node.isTextblock||!Y(r.doc,t.to))return!1;n=t.to}else if(n=Te(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},Rr=(r,e)=>{let{$from:t,$to:n}=r.selection,i=t.blockRange(n),s=i&&se(i);return s==null?!1:(e&&e(r.tr.lift(i,s).scrollIntoView()),!0)},cn=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
5
|
-
`).scrollIntoView()),!0)};function it(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Nr=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=it(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,o.createAndFill());a.setSelection(C.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},fn=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof L||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=it(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,l=r.tr.insert(o,s.createAndFill());l.setSelection(P.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},un=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(V(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&se(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function Ir(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof E&&e.selection.node.isBlock)return!n.parentOffset||!V(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let h=n.depth;;h--)if(n.node(h).isBlock){a=n.end(h)==n.pos+(n.depth-h),c=n.start(h)==n.pos-(n.depth-h),l=it(n.node(h-1).contentMatchAt(n.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let f=e.tr;(e.selection instanceof P||e.selection instanceof L)&&f.deleteSelection();let u=f.mapping.map(n.pos),d=V(f.doc,u,s.length,s);if(d||(s[0]=l?{type:l}:null,d=V(f.doc,u,s.length,s)),!d)return!1;if(f.split(u,s.length,s),!a&&c&&n.node(o).type!=l){let h=f.mapping.map(n.before(o)),p=f.doc.resolve(h);l&&n.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&f.setNodeMarkup(f.mapping.map(n.before(o)),l)}return t&&t(f.scrollIntoView()),!0}}const zr=Ir(),Or=(r,e)=>{let{$from:t,to:n}=r.selection,i,s=t.sharedDepth(n);return s==0?!1:(i=t.before(s),e&&e(r.tr.setSelection(E.create(r.doc,i))),!0)};function Pr(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,s=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(s-1,s)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Y(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function dn(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Pr(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=w.empty;for(let y=o.length-1;y>=0;y--)p=w.from(o[y].create(null,p));p=w.from(i.copy(p));let m=r.tr.step(new N(e.pos-1,h,e.pos,h,new k(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Y(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=s.type.spec.isolating||n>0&&a?null:C.findFrom(e,1),u=f&&f.$from.blockRange(f.$to),d=u&&se(u);if(d!=null&&d>=e.depth)return t&&t(r.tr.lift(u,d).scrollIntoView()),!0;if(c&&ne(s,"start",!0)&&ne(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=w.empty;for(let S=p.length-1;S>=0;S--)y=w.from(p[S].copy(y));let x=r.tr.step(new N(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new k(y,p.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function hn(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(P.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}const $r=hn(-1),Br=hn(1);function Dr(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&et(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function At(r,e=null){return function(t,n){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(r,e)))if(a.type==r)i=!0;else{let f=t.doc.resolve(c),u=f.index();i=f.parent.canReplaceWith(u,u+1,r)}})}if(!i)return!1;if(n){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,r,e)}n(s.scrollIntoView())}return!0}}function st(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}st(Ne,nn,sn);st(Ne,ln,an);st(cn,fn,un,zr);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Fr(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=n?t.tr:null;return Lr(l,o,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function Lr(r,e,t,n=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new He(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new He(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=et(s,t,n,e);return l?(r&&Wr(r,e,l,i,t),!0):!1}function Wr(r,e,t,n,i){let s=w.empty;for(let f=t.length-1;f>=0;f--)s=w.from(t[f].type.create(t[f].attrs,s));r.step(new N(e.start-(n?2:0),e.end,e.start,e.end,new k(s,0,0),t.length,!0));let o=0;for(let f=0;f<t.length;f++)t[f].type==i&&(o=f+1);let l=t.length-o,a=e.start+t.length-(n?2:0),c=e.parent;for(let f=e.startIndex,u=e.endIndex,d=!0;f<u;f++,d=!1)!d&&V(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(f).nodeSize;return r}function Jr(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,o=>o.childCount>0&&o.firstChild.type==r);return s?t?n.node(s.depth-1).type==r?jr(e,t,r,s):Hr(e,t,s):!0:!1}}function jr(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);s<o&&(i.step(new N(s-1,o,s,o,new k(w.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new He(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth));const l=se(n);if(l==null)return!1;i.lift(n,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return Y(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Hr(r,e,t){let n=r.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=i.child(p).nodeSize,n.delete(h-1,h+1);let s=n.doc.resolve(t.start),o=s.nodeAfter;if(n.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),f=s.index(-1);if(!c.canReplace(f+(l?0:1),f+1,o.content.append(a?w.empty:w.from(i))))return!1;let u=s.pos,d=u+o.nodeSize;return n.step(new N(u-(l?1:0),d+(a?1:0),u+1,d-1,new k((l?w.empty:w.from(i.copy(w.empty))).append(a?w.empty:w.from(i.copy(w.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function _r(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,c=>c.childCount>0&&c.firstChild.type==r);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=r)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,f=w.from(c?r.create():null),u=new k(w.from(r.create(null,w.from(l.type.create(null,f)))),c?3:1,0),d=s.start,h=s.end;t(e.tr.step(new N(d-(c?3:1),h,d,h,u,1,!0)).scrollIntoView())}return!0}}var Vr=Object.defineProperty,ot=(r,e)=>{for(var t in e)Vr(r,t,{get:e[t],enumerable:!0})};function pn(r){const{state:e,transaction:t}=r;let{selection:n}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return n},get doc(){return i},get tr(){return n=t.selection,i=t.doc,s=t.storedMarks,t}}}var Kr=class{constructor(r){this.editor=r.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=r.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:r,editor:e,state:t}=this,{view:n}=e,{tr:i}=t,s=this.buildProps(i);return Object.fromEntries(Object.entries(r).map(([o,l])=>[o,(...c)=>{const f=l(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&n.dispatch(i),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(r,e=!0){const{rawCommands:t,editor:n,state:i}=this,{view:s}=n,o=[],l=!!r,a=r||i.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(u=>u===!0)),f={...Object.fromEntries(Object.entries(t).map(([u,d])=>[u,(...p)=>{const m=this.buildProps(a,e),g=d(...p)(m);return o.push(g),f}])),run:c};return f}createCan(r){const{rawCommands:e,state:t}=this,n=!1,i=r||t.tr,s=this.buildProps(i,n);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,n)}}buildProps(r,e=!0){const{rawCommands:t,editor:n,state:i}=this,{view:s}=n,o={tr:r,editor:n,view:s,state:pn({state:i,transaction:r}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(r,e),can:()=>this.createCan(r),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},mn={};ot(mn,{blur:()=>qr,clearContent:()=>Ur,clearNodes:()=>Xr,command:()=>Yr,createParagraphNear:()=>Qr,cut:()=>Zr,deleteCurrentNode:()=>Gr,deleteNode:()=>ei,deleteRange:()=>ti,deleteSelection:()=>ni,enter:()=>ri,exitCode:()=>ii,extendMarkRange:()=>oi,first:()=>li,focus:()=>fi,forEach:()=>ui,insertContent:()=>di,insertContentAt:()=>mi,joinBackward:()=>wi,joinDown:()=>yi,joinForward:()=>ki,joinItemBackward:()=>xi,joinItemForward:()=>vi,joinTextblockBackward:()=>Si,joinTextblockForward:()=>bi,joinUp:()=>gi,keyboardShortcut:()=>Ei,lift:()=>Ci,liftEmptyBlock:()=>Ti,liftListItem:()=>Ai,newlineInCode:()=>Ri,resetAttributes:()=>Ni,scrollIntoView:()=>Ii,selectAll:()=>zi,selectNodeBackward:()=>Oi,selectNodeForward:()=>Pi,selectParentNode:()=>$i,selectTextblockEnd:()=>Bi,selectTextblockStart:()=>Di,setContent:()=>Li,setMark:()=>is,setMeta:()=>ss,setNode:()=>ls,setNodeSelection:()=>as,setTextDirection:()=>cs,setTextSelection:()=>fs,sinkListItem:()=>us,splitBlock:()=>ds,splitListItem:()=>hs,toggleList:()=>ps,toggleMark:()=>ms,toggleNode:()=>gs,toggleWrap:()=>ys,undoInputRule:()=>ws,unsetAllMarks:()=>ks,unsetMark:()=>xs,unsetTextDirection:()=>vs,updateAttributes:()=>Ss,wrapIn:()=>bs,wrapInList:()=>Ms});var qr=()=>({editor:r,view:e})=>(requestAnimationFrame(()=>{var t;r.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())==null||t.removeAllRanges())}),!0),Ur=(r=!0)=>({commands:e})=>e.setContent("",{emitUpdate:r}),Xr=()=>({state:r,tr:e,dispatch:t})=>{const{selection:n}=e,{ranges:i}=n;return t&&i.forEach(({$from:s,$to:o})=>{r.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:f}=e,u=c.resolve(f.map(a)),d=c.resolve(f.map(a+l.nodeSize)),h=u.blockRange(d);if(!h)return;const p=se(h);if(l.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Yr=r=>e=>r(e),Qr=()=>({state:r,dispatch:e})=>fn(r,e),Zr=(r,e)=>({editor:t,tr:n})=>{const{state:i}=t,s=i.doc.slice(r.from,r.to);n.deleteRange(r.from,r.to);const o=n.mapping.map(e);return n.insert(o,s.content),n.setSelection(new v.TextSelection(n.doc.resolve(Math.max(o-1,0)))),!0},Gr=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,n=t.$anchor.node();if(n.content.size>0)return!1;const i=r.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===n.type){if(e){const l=i.before(s),a=i.after(s);r.delete(l,a).scrollIntoView()}return!0}return!1};function I(r,e){if(typeof r=="string"){if(!e.nodes[r])throw Error(`There is no node type named '${r}'. Maybe you forgot to add the extension?`);return e.nodes[r]}return r}var ei=r=>({tr:e,state:t,dispatch:n})=>{const i=I(r,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(n){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},ti=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},ni=()=>({state:r,dispatch:e})=>Ne(r,e),ri=()=>({commands:r})=>r.keyboardShortcut("Enter"),ii=()=>({state:r,dispatch:e})=>Nr(r,e);function si(r){return Object.prototype.toString.call(r)==="[object RegExp]"}function Ce(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:si(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function gn(r,e,t={}){return r.find(n=>n.type===e&&Ce(Object.fromEntries(Object.keys(t).map(i=>[i,n.attrs[i]])),t))}function Rt(r,e,t={}){return!!gn(r,e,t)}function lt(r,e,t){var n;if(!r||!e)return;let i=r.parent.childAfter(r.parentOffset);if((!i.node||!i.node.marks.some(f=>f.type===e))&&(i=r.parent.childBefore(r.parentOffset)),!i.node||!i.node.marks.some(f=>f.type===e)||(t=t||((n=i.node.marks[0])==null?void 0:n.attrs),!gn([...i.node.marks],e,t)))return;let o=i.index,l=r.start()+i.offset,a=o+1,c=l+i.node.nodeSize;for(;o>0&&Rt([...r.parent.child(o-1).marks],e,t);)o-=1,l-=r.parent.child(o).nodeSize;for(;a<r.parent.childCount&&Rt([...r.parent.child(a).marks],e,t);)c+=r.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Q(r,e){if(typeof r=="string"){if(!e.marks[r])throw Error(`There is no mark type named '${r}'. Maybe you forgot to add the extension?`);return e.marks[r]}return r}var oi=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const s=Q(r,n.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:f}=l;if(i){const u=lt(a,s,e);if(u&&u.from<=c&&u.to>=f){const d=v.TextSelection.create(o,u.from,u.to);t.setSelection(d)}}return!0},li=r=>e=>{const t=typeof r=="function"?r(e):r;for(let n=0;n<t.length;n+=1)if(t[n](e))return!0;return!1};function at(r){return r instanceof v.TextSelection}function _(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function ai(r,e=null){if(!e)return null;const t=v.Selection.atStart(r),n=v.Selection.atEnd(r);if(e==="start"||e===!0)return t;if(e==="end")return n;const i=t.from,s=n.to;return e==="all"?v.TextSelection.create(r,_(0,i,s),_(r.content.size,i,s)):v.TextSelection.create(r,_(e,i,s),_(e,i,s))}function qe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function de(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function ci(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var fi=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(de()||qe())&&n.dom.focus(),ci()&&!de()&&!qe()&&n.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};try{if(n.hasFocus()&&r===null||r===!1)return!0}catch{return!1}if(s&&r===null&&!at(t.state.selection))return o(),!0;const l=ai(i.doc,r)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},ui=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),di=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e),yn=r=>{const e=r.childNodes;for(let t=e.length-1;t>=0;t-=1){const n=e[t];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?r.removeChild(n):n.nodeType===1&&yn(n)}return r};function xe(r){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${r}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return yn(t)}function he(r,e,t){if(r instanceof D.Node||r instanceof D.Fragment)return r;t={slice:!0,parseOptions:{},...t};const n=typeof r=="object"&&r!==null,i=typeof r=="string";if(n)try{if(Array.isArray(r)&&r.length>0)return D.Fragment.fromArray(r.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(r);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",r,"Error:",s),he("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new D.Schema({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?D.DOMParser.fromSchema(a).parseSlice(xe(r),t.parseOptions):D.DOMParser.fromSchema(a).parse(xe(r),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=D.DOMParser.fromSchema(e);return t.slice?s.parseSlice(xe(r),t.parseOptions).content:s.parse(xe(r),t.parseOptions)}return he("",e,t)}function hi(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof R||i instanceof N))return;const s=r.mapping.maps[n];let o=0;s.forEach((l,a,c,f)=>{o===0&&(o=f)}),r.setSelection(v.Selection.near(r.doc.resolve(o),t))}var pi=r=>!("type"in r),mi=(r,e,t)=>({tr:n,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{he(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=he(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:f,to:u}=typeof r=="number"?{from:r,to:r}:{from:r.from,to:r.to},d=!0,h=!0;if((pi(l)?l:[l]).forEach(g=>{g.check(),d=d?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),f===u&&h){const{parent:g}=n.doc.resolve(f);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(f-=1,u+=1)}let m;if(d){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof D.Fragment){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;n.insertText(m,f,u)}else{m=l;const g=n.doc.resolve(f),y=g.node(),x=g.parentOffset===0,S=y.isText||y.isTextblock,M=y.content.size>0;x&&S&&M&&(f=Math.max(0,f-1)),n.replaceWith(f,u,m)}t.updateSelection&&hi(n,n.steps.length-1,-1),t.applyInputRules&&n.setMeta("applyInputRules",{from:f,text:m}),t.applyPasteRules&&n.setMeta("applyPasteRules",{from:f,text:m})}return!0},gi=()=>({state:r,dispatch:e})=>Tr(r,e),yi=()=>({state:r,dispatch:e})=>Ar(r,e),wi=()=>({state:r,dispatch:e})=>nn(r,e),ki=()=>({state:r,dispatch:e})=>ln(r,e),xi=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Te(r.doc,r.selection.$from.pos,-1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},vi=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Te(r.doc,r.selection.$from.pos,1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},Si=()=>({state:r,dispatch:e})=>Er(r,e),bi=()=>({state:r,dispatch:e})=>Cr(r,e);function wn(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Mi(r){const e=r.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))de()||wn()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return n&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var Ei=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=Mi(r).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const f=c.map(n.mapping);f&&i&&n.maybeStep(f)}),!0};function re(r,e,t={}){const{from:n,to:i,empty:s}=r.selection,o=e?I(e,r.schema):null,l=[];r.doc.nodesBetween(n,i,(u,d)=>{if(u.isText)return;const h=Math.max(n,d),p=Math.min(i,d+u.nodeSize);l.push({node:u,from:h,to:p})});const a=i-n,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>Ce(u.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var Ci=(r,e={})=>({state:t,dispatch:n})=>{const i=I(r,t.schema);return re(t,i,e)?Rr(t,n):!1},Ti=()=>({state:r,dispatch:e})=>un(r,e),Ai=r=>({state:e,dispatch:t})=>{const n=I(r,e.schema);return Jr(n)(e,t)},Ri=()=>({state:r,dispatch:e})=>cn(r,e);function Ie(r,e){return e.nodes[r]?"node":e.marks[r]?"mark":null}function Nt(r,e){const t=typeof e=="string"?[e]:e;return Object.keys(r).reduce((n,i)=>(t.includes(i)||(n[i]=r[i]),n),{})}var Ni=(r,e)=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=Ie(typeof r=="string"?r:r.name,n.schema);if(!l)return!1;l==="node"&&(s=I(r,n.schema)),l==="mark"&&(o=Q(r,n.schema));let a=!1;return t.selection.ranges.forEach(c=>{n.doc.nodesBetween(c.$from.pos,c.$to.pos,(f,u)=>{s&&s===f.type&&(a=!0,i&&t.setNodeMarkup(u,void 0,Nt(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(d=>{o===d.type&&(a=!0,i&&t.addMark(u,u+f.nodeSize,o.create(Nt(d.attrs,e))))})})}),a},Ii=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),zi=()=>({tr:r,dispatch:e})=>{if(e){const t=new v.AllSelection(r.doc);r.setSelection(t)}return!0},Oi=()=>({state:r,dispatch:e})=>sn(r,e),Pi=()=>({state:r,dispatch:e})=>an(r,e),$i=()=>({state:r,dispatch:e})=>Or(r,e),Bi=()=>({state:r,dispatch:e})=>Br(r,e),Di=()=>({state:r,dispatch:e})=>$r(r,e);function Fi(r,e,t={},n={}){return he(r,e,{slice:!1,parseOptions:t,errorOnInvalidContent:n.errorOnInvalidContent})}var Li=(r,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:n={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:a}=s;if(n.preserveWhitespace!=="full"){const c=Fi(r,i.schema,n,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},r,{parseOptions:n,errorOnInvalidContent:e??i.options.enableContentCheck})};function kn(r,e){const t=Q(e,r.schema),{from:n,to:i,empty:s}=r.selection,o=[];s?(r.storedMarks&&o.push(...r.storedMarks),o.push(...r.selection.$head.marks())):r.doc.nodesBetween(n,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function xn(r,e){const t=new Qt(r);return e.forEach(n=>{n.steps.forEach(i=>{t.step(i)})}),t}function Wi(r){for(let e=0;e<r.edgeCount;e+=1){const{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Ji(r,e,t){const n=[];return r.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&n.push({node:i,pos:s})}),n}function vn(r,e){for(let t=r.depth;t>0;t-=1){const n=r.node(t);if(e(n))return{pos:t>0?r.before(t):0,start:r.start(t),depth:t,node:n}}}function pe(r){return e=>vn(e.$from,r)}function ie(r,e,t){return r.config[e]===void 0&&r.parent?ie(r.parent,e,t):typeof r.config[e]=="function"?r.config[e].bind({...t,parent:r.parent?ie(r.parent,e,t):null}):r.config[e]}function ji(r){return typeof r=="function"}function J(r,e=void 0,...t){return ji(r)?e?r.bind(e)(...t):r(...t):r}function Sn(r){const e=r.filter(i=>i.type==="extension"),t=r.filter(i=>i.type==="node"),n=r.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:n}}function Hi(r){const e=[];let t="",n=!1,i=!1,s=0;const o=r.length;for(let l=0;l<o;l+=1){const a=r[l];if(a==="'"&&!i){n=!n,t+=a;continue}if(a==='"'&&!n){i=!i,t+=a;continue}if(!n&&!i){if(a==="("){s+=1,t+=a;continue}if(a===")"&&s>0){s-=1,t+=a;continue}if(a===";"&&s===0){e.push(t),t="";continue}}t+=a}return t&&e.push(t),e}function It(r){const e=[],t=Hi(r||""),n=t.length;for(let i=0;i<n;i+=1){const s=t[i],o=s.indexOf(":");if(o===-1)continue;const l=s.slice(0,o).trim(),a=s.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function bn(...r){return r.filter(e=>!!e).reduce((e,t)=>{const n={...e};return Object.entries(t).forEach(([i,s])=>{if(!n[i]){n[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],a=n[i]?n[i].split(" "):[],c=l.filter(f=>!a.includes(f));n[i]=[...a,...c].join(" ")}else if(i==="style"){const l=new Map([...It(n[i]),...It(s)]);n[i]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else n[i]=s}),n},{})}function _i(r,e){return e.filter(t=>t.type===r.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(r.attrs)||{}:{[t.name]:r.attrs[t.name]}).reduce((t,n)=>bn(t,n),{})}function Mn(r,e,t){const{from:n,to:i}=e,{blockSeparator:s=`
|
|
5
|
+
`).scrollIntoView()),!0)};function it(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Nr=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=it(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,o.createAndFill());a.setSelection(C.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},fn=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof L||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=it(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,l=r.tr.insert(o,s.createAndFill());l.setSelection(P.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},un=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(V(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&se(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function Ir(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof E&&e.selection.node.isBlock)return!n.parentOffset||!V(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let h=n.depth;;h--)if(n.node(h).isBlock){a=n.end(h)==n.pos+(n.depth-h),c=n.start(h)==n.pos-(n.depth-h),l=it(n.node(h-1).contentMatchAt(n.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let f=e.tr;(e.selection instanceof P||e.selection instanceof L)&&f.deleteSelection();let u=f.mapping.map(n.pos),d=V(f.doc,u,s.length,s);if(d||(s[0]=l?{type:l}:null,d=V(f.doc,u,s.length,s)),!d)return!1;if(f.split(u,s.length,s),!a&&c&&n.node(o).type!=l){let h=f.mapping.map(n.before(o)),p=f.doc.resolve(h);l&&n.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&f.setNodeMarkup(f.mapping.map(n.before(o)),l)}return t&&t(f.scrollIntoView()),!0}}const zr=Ir(),Or=(r,e)=>{let{$from:t,to:n}=r.selection,i,s=t.sharedDepth(n);return s==0?!1:(i=t.before(s),e&&e(r.tr.setSelection(E.create(r.doc,i))),!0)};function Pr(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,s=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(s-1,s)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Y(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function dn(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Pr(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=w.empty;for(let y=o.length-1;y>=0;y--)p=w.from(o[y].create(null,p));p=w.from(i.copy(p));let m=r.tr.step(new N(e.pos-1,h,e.pos,h,new k(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Y(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=s.type.spec.isolating||n>0&&a?null:C.findFrom(e,1),u=f&&f.$from.blockRange(f.$to),d=u&&se(u);if(d!=null&&d>=e.depth)return t&&t(r.tr.lift(u,d).scrollIntoView()),!0;if(c&&ne(s,"start",!0)&&ne(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=w.empty;for(let S=p.length-1;S>=0;S--)y=w.from(p[S].copy(y));let x=r.tr.step(new N(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new k(y,p.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function hn(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(P.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}const $r=hn(-1),Br=hn(1);function Dr(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&et(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function At(r,e=null){return function(t,n){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(r,e)))if(a.type==r)i=!0;else{let f=t.doc.resolve(c),u=f.index();i=f.parent.canReplaceWith(u,u+1,r)}})}if(!i)return!1;if(n){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,r,e)}n(s.scrollIntoView())}return!0}}function st(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}st(Ne,nn,sn);st(Ne,ln,an);st(cn,fn,un,zr);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Fr(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=n?t.tr:null;return Lr(l,o,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function Lr(r,e,t,n=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new He(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new He(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=et(s,t,n,e);return l?(r&&Wr(r,e,l,i,t),!0):!1}function Wr(r,e,t,n,i){let s=w.empty;for(let f=t.length-1;f>=0;f--)s=w.from(t[f].type.create(t[f].attrs,s));r.step(new N(e.start-(n?2:0),e.end,e.start,e.end,new k(s,0,0),t.length,!0));let o=0;for(let f=0;f<t.length;f++)t[f].type==i&&(o=f+1);let l=t.length-o,a=e.start+t.length-(n?2:0),c=e.parent;for(let f=e.startIndex,u=e.endIndex,d=!0;f<u;f++,d=!1)!d&&V(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(f).nodeSize;return r}function Jr(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,o=>o.childCount>0&&o.firstChild.type==r);return s?t?n.node(s.depth-1).type==r?jr(e,t,r,s):Hr(e,t,s):!0:!1}}function jr(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);s<o&&(i.step(new N(s-1,o,s,o,new k(w.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new He(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth));const l=se(n);if(l==null)return!1;i.lift(n,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return Y(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Hr(r,e,t){let n=r.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=i.child(p).nodeSize,n.delete(h-1,h+1);let s=n.doc.resolve(t.start),o=s.nodeAfter;if(n.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),f=s.index(-1);if(!c.canReplace(f+(l?0:1),f+1,o.content.append(a?w.empty:w.from(i))))return!1;let u=s.pos,d=u+o.nodeSize;return n.step(new N(u-(l?1:0),d+(a?1:0),u+1,d-1,new k((l?w.empty:w.from(i.copy(w.empty))).append(a?w.empty:w.from(i.copy(w.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function _r(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,c=>c.childCount>0&&c.firstChild.type==r);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=r)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,f=w.from(c?r.create():null),u=new k(w.from(r.create(null,w.from(l.type.create(null,f)))),c?3:1,0),d=s.start,h=s.end;t(e.tr.step(new N(d-(c?3:1),h,d,h,u,1,!0)).scrollIntoView())}return!0}}var Vr=Object.defineProperty,ot=(r,e)=>{for(var t in e)Vr(r,t,{get:e[t],enumerable:!0})};function pn(r){const{state:e,transaction:t}=r;let{selection:n}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return n},get doc(){return i},get tr(){return n=t.selection,i=t.doc,s=t.storedMarks,t}}}var Kr=class{constructor(r){this.editor=r.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=r.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:r,editor:e,state:t}=this,{view:n}=e,{tr:i}=t,s=this.buildProps(i);return Object.fromEntries(Object.entries(r).map(([o,l])=>[o,(...c)=>{const f=l(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&n.dispatch(i),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(r,e=!0){const{rawCommands:t,editor:n,state:i}=this,{view:s}=n,o=[],l=!!r,a=r||i.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(u=>u===!0)),f={...Object.fromEntries(Object.entries(t).map(([u,d])=>[u,(...p)=>{const m=this.buildProps(a,e),g=d(...p)(m);return o.push(g),f}])),run:c};return f}createCan(r){const{rawCommands:e,state:t}=this,n=!1,i=r||t.tr,s=this.buildProps(i,n);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,n)}}buildProps(r,e=!0){const{rawCommands:t,editor:n,state:i}=this,{view:s}=n,o={tr:r,editor:n,view:s,state:pn({state:i,transaction:r}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(r,e),can:()=>this.createCan(r),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},mn={};ot(mn,{blur:()=>qr,clearContent:()=>Ur,clearNodes:()=>Xr,command:()=>Yr,createParagraphNear:()=>Qr,cut:()=>Zr,deleteCurrentNode:()=>Gr,deleteNode:()=>ei,deleteRange:()=>ti,deleteSelection:()=>ni,enter:()=>ri,exitCode:()=>ii,extendMarkRange:()=>oi,first:()=>li,focus:()=>fi,forEach:()=>ui,insertContent:()=>di,insertContentAt:()=>mi,joinBackward:()=>wi,joinDown:()=>yi,joinForward:()=>ki,joinItemBackward:()=>xi,joinItemForward:()=>vi,joinTextblockBackward:()=>Si,joinTextblockForward:()=>bi,joinUp:()=>gi,keyboardShortcut:()=>Ei,lift:()=>Ci,liftEmptyBlock:()=>Ti,liftListItem:()=>Ai,newlineInCode:()=>Ri,resetAttributes:()=>Ni,scrollIntoView:()=>Ii,selectAll:()=>zi,selectNodeBackward:()=>Oi,selectNodeForward:()=>Pi,selectParentNode:()=>$i,selectTextblockEnd:()=>Bi,selectTextblockStart:()=>Di,setContent:()=>Li,setMark:()=>ss,setMeta:()=>ls,setNode:()=>as,setNodeSelection:()=>cs,setTextDirection:()=>fs,setTextSelection:()=>us,sinkListItem:()=>ds,splitBlock:()=>hs,splitListItem:()=>ps,toggleList:()=>ms,toggleMark:()=>gs,toggleNode:()=>ys,toggleWrap:()=>ws,undoInputRule:()=>ks,unsetAllMarks:()=>xs,unsetMark:()=>vs,unsetTextDirection:()=>Ss,updateAttributes:()=>bs,wrapIn:()=>Ms,wrapInList:()=>Es});var qr=()=>({editor:r,view:e})=>(requestAnimationFrame(()=>{var t;r.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())==null||t.removeAllRanges())}),!0),Ur=(r=!0)=>({commands:e})=>e.setContent("",{emitUpdate:r}),Xr=()=>({state:r,tr:e,dispatch:t})=>{const{selection:n}=e,{ranges:i}=n;return t&&i.forEach(({$from:s,$to:o})=>{r.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:f}=e,u=c.resolve(f.map(a)),d=c.resolve(f.map(a+l.nodeSize)),h=u.blockRange(d);if(!h)return;const p=se(h);if(l.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Yr=r=>e=>r(e),Qr=()=>({state:r,dispatch:e})=>fn(r,e),Zr=(r,e)=>({editor:t,tr:n})=>{const{state:i}=t,s=i.doc.slice(r.from,r.to);n.deleteRange(r.from,r.to);const o=n.mapping.map(e);return n.insert(o,s.content),n.setSelection(new v.TextSelection(n.doc.resolve(Math.max(o-1,0)))),!0},Gr=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,n=t.$anchor.node();if(n.content.size>0)return!1;const i=r.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===n.type){if(e){const l=i.before(s),a=i.after(s);r.delete(l,a).scrollIntoView()}return!0}return!1};function I(r,e){if(typeof r=="string"){if(!e.nodes[r])throw Error(`There is no node type named '${r}'. Maybe you forgot to add the extension?`);return e.nodes[r]}return r}var ei=r=>({tr:e,state:t,dispatch:n})=>{const i=I(r,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(n){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},ti=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},ni=()=>({state:r,dispatch:e})=>Ne(r,e),ri=()=>({commands:r})=>r.keyboardShortcut("Enter"),ii=()=>({state:r,dispatch:e})=>Nr(r,e);function si(r){return Object.prototype.toString.call(r)==="[object RegExp]"}function Ce(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:si(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function gn(r,e,t={}){return r.find(n=>n.type===e&&Ce(Object.fromEntries(Object.keys(t).map(i=>[i,n.attrs[i]])),t))}function Rt(r,e,t={}){return!!gn(r,e,t)}function lt(r,e,t){var n;if(!r||!e)return;let i=r.parent.childAfter(r.parentOffset);if((!i.node||!i.node.marks.some(f=>f.type===e))&&(i=r.parent.childBefore(r.parentOffset)),!i.node||!i.node.marks.some(f=>f.type===e)||(t=t||((n=i.node.marks[0])==null?void 0:n.attrs),!gn([...i.node.marks],e,t)))return;let o=i.index,l=r.start()+i.offset,a=o+1,c=l+i.node.nodeSize;for(;o>0&&Rt([...r.parent.child(o-1).marks],e,t);)o-=1,l-=r.parent.child(o).nodeSize;for(;a<r.parent.childCount&&Rt([...r.parent.child(a).marks],e,t);)c+=r.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Q(r,e){if(typeof r=="string"){if(!e.marks[r])throw Error(`There is no mark type named '${r}'. Maybe you forgot to add the extension?`);return e.marks[r]}return r}var oi=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const s=Q(r,n.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:f}=l;if(i){const u=lt(a,s,e);if(u&&u.from<=c&&u.to>=f){const d=v.TextSelection.create(o,u.from,u.to);t.setSelection(d)}}return!0},li=r=>e=>{const t=typeof r=="function"?r(e):r;for(let n=0;n<t.length;n+=1)if(t[n](e))return!0;return!1};function at(r){return r instanceof v.TextSelection}function _(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function ai(r,e=null){if(!e)return null;const t=v.Selection.atStart(r),n=v.Selection.atEnd(r);if(e==="start"||e===!0)return t;if(e==="end")return n;const i=t.from,s=n.to;return e==="all"?v.TextSelection.create(r,_(0,i,s),_(r.content.size,i,s)):v.TextSelection.create(r,_(e,i,s),_(e,i,s))}function qe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function de(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function ci(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var fi=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(de()||qe())&&n.dom.focus(),ci()&&!de()&&!qe()&&n.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};try{if(n.hasFocus()&&r===null||r===!1)return!0}catch{return!1}if(s&&r===null&&!at(t.state.selection))return o(),!0;const l=ai(i.doc,r)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},ui=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),di=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e),yn=r=>{const e=r.childNodes;for(let t=e.length-1;t>=0;t-=1){const n=e[t];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?r.removeChild(n):n.nodeType===1&&yn(n)}return r};function xe(r){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${r}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return yn(t)}function he(r,e,t){if(r instanceof D.Node||r instanceof D.Fragment)return r;t={slice:!0,parseOptions:{},...t};const n=typeof r=="object"&&r!==null,i=typeof r=="string";if(n)try{if(Array.isArray(r)&&r.length>0)return D.Fragment.fromArray(r.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(r);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",r,"Error:",s),he("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new D.Schema({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?D.DOMParser.fromSchema(a).parseSlice(xe(r),t.parseOptions):D.DOMParser.fromSchema(a).parse(xe(r),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=D.DOMParser.fromSchema(e);return t.slice?s.parseSlice(xe(r),t.parseOptions).content:s.parse(xe(r),t.parseOptions)}return he("",e,t)}function hi(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof R||i instanceof N))return;const s=r.mapping.maps[n];let o=0;s.forEach((l,a,c,f)=>{o===0&&(o=f)}),r.setSelection(v.Selection.near(r.doc.resolve(o),t))}var pi=r=>!("type"in r),mi=(r,e,t)=>({tr:n,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{he(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=he(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:f,to:u}=typeof r=="number"?{from:r,to:r}:{from:r.from,to:r.to},d=!0,h=!0;if((pi(l)?l:[l]).forEach(g=>{g.check(),d=d?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),f===u&&h){const{parent:g}=n.doc.resolve(f);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(f-=1,u+=1)}let m;if(d){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof D.Fragment){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;n.insertText(m,f,u)}else{m=l;const g=n.doc.resolve(f),y=g.node(),x=g.parentOffset===0,S=y.isText||y.isTextblock,M=y.content.size>0;x&&S&&M&&(f=Math.max(0,f-1)),n.replaceWith(f,u,m)}t.updateSelection&&hi(n,n.steps.length-1,-1),t.applyInputRules&&n.setMeta("applyInputRules",{from:f,text:m}),t.applyPasteRules&&n.setMeta("applyPasteRules",{from:f,text:m})}return!0},gi=()=>({state:r,dispatch:e})=>Tr(r,e),yi=()=>({state:r,dispatch:e})=>Ar(r,e),wi=()=>({state:r,dispatch:e})=>nn(r,e),ki=()=>({state:r,dispatch:e})=>ln(r,e),xi=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Te(r.doc,r.selection.$from.pos,-1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},vi=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Te(r.doc,r.selection.$from.pos,1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},Si=()=>({state:r,dispatch:e})=>Er(r,e),bi=()=>({state:r,dispatch:e})=>Cr(r,e);function wn(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Mi(r){const e=r.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))de()||wn()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return n&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var Ei=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=Mi(r).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const f=c.map(n.mapping);f&&i&&n.maybeStep(f)}),!0};function re(r,e,t={}){const{from:n,to:i,empty:s}=r.selection,o=e?I(e,r.schema):null,l=[];r.doc.nodesBetween(n,i,(u,d)=>{if(u.isText)return;const h=Math.max(n,d),p=Math.min(i,d+u.nodeSize);l.push({node:u,from:h,to:p})});const a=i-n,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>Ce(u.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var Ci=(r,e={})=>({state:t,dispatch:n})=>{const i=I(r,t.schema);return re(t,i,e)?Rr(t,n):!1},Ti=()=>({state:r,dispatch:e})=>un(r,e),Ai=r=>({state:e,dispatch:t})=>{const n=I(r,e.schema);return Jr(n)(e,t)},Ri=()=>({state:r,dispatch:e})=>cn(r,e);function Ie(r,e){return e.nodes[r]?"node":e.marks[r]?"mark":null}function Nt(r,e){const t=typeof e=="string"?[e]:e;return Object.keys(r).reduce((n,i)=>(t.includes(i)||(n[i]=r[i]),n),{})}var Ni=(r,e)=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=Ie(typeof r=="string"?r:r.name,n.schema);if(!l)return!1;l==="node"&&(s=I(r,n.schema)),l==="mark"&&(o=Q(r,n.schema));let a=!1;return t.selection.ranges.forEach(c=>{n.doc.nodesBetween(c.$from.pos,c.$to.pos,(f,u)=>{s&&s===f.type&&(a=!0,i&&t.setNodeMarkup(u,void 0,Nt(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(d=>{o===d.type&&(a=!0,i&&t.addMark(u,u+f.nodeSize,o.create(Nt(d.attrs,e))))})})}),a},Ii=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),zi=()=>({tr:r,dispatch:e})=>{if(e){const t=new v.AllSelection(r.doc);r.setSelection(t)}return!0},Oi=()=>({state:r,dispatch:e})=>sn(r,e),Pi=()=>({state:r,dispatch:e})=>an(r,e),$i=()=>({state:r,dispatch:e})=>Or(r,e),Bi=()=>({state:r,dispatch:e})=>Br(r,e),Di=()=>({state:r,dispatch:e})=>$r(r,e);function Fi(r,e,t={},n={}){return he(r,e,{slice:!1,parseOptions:t,errorOnInvalidContent:n.errorOnInvalidContent})}var Li=(r,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:n={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:a}=s;if(n.preserveWhitespace!=="full"){const c=Fi(r,i.schema,n,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},r,{parseOptions:n,errorOnInvalidContent:e??i.options.enableContentCheck})};function kn(r,e){const t=Q(e,r.schema),{from:n,to:i,empty:s}=r.selection,o=[];s?(r.storedMarks&&o.push(...r.storedMarks),o.push(...r.selection.$head.marks())):r.doc.nodesBetween(n,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function xn(r,e){const t=new Qt(r);return e.forEach(n=>{n.steps.forEach(i=>{t.step(i)})}),t}function Wi(r){for(let e=0;e<r.edgeCount;e+=1){const{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Ji(r,e){const t=[];return r.descendants((n,i)=>{e(n)&&t.push({node:n,pos:i})}),t}function ji(r,e,t){const n=[];return r.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&n.push({node:i,pos:s})}),n}function vn(r,e){for(let t=r.depth;t>0;t-=1){const n=r.node(t);if(e(n))return{pos:t>0?r.before(t):0,start:r.start(t),depth:t,node:n}}}function pe(r){return e=>vn(e.$from,r)}function ie(r,e,t){return r.config[e]===void 0&&r.parent?ie(r.parent,e,t):typeof r.config[e]=="function"?r.config[e].bind({...t,parent:r.parent?ie(r.parent,e,t):null}):r.config[e]}function Hi(r){return typeof r=="function"}function J(r,e=void 0,...t){return Hi(r)?e?r.bind(e)(...t):r(...t):r}function Sn(r){const e=r.filter(i=>i.type==="extension"),t=r.filter(i=>i.type==="node"),n=r.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:n}}function _i(r){const e=[];let t="",n=!1,i=!1,s=0;const o=r.length;for(let l=0;l<o;l+=1){const a=r[l];if(a==="'"&&!i){n=!n,t+=a;continue}if(a==='"'&&!n){i=!i,t+=a;continue}if(!n&&!i){if(a==="("){s+=1,t+=a;continue}if(a===")"&&s>0){s-=1,t+=a;continue}if(a===";"&&s===0){e.push(t),t="";continue}}t+=a}return t&&e.push(t),e}function It(r){const e=[],t=_i(r||""),n=t.length;for(let i=0;i<n;i+=1){const s=t[i],o=s.indexOf(":");if(o===-1)continue;const l=s.slice(0,o).trim(),a=s.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function bn(...r){return r.filter(e=>!!e).reduce((e,t)=>{const n={...e};return Object.entries(t).forEach(([i,s])=>{if(!n[i]){n[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],a=n[i]?n[i].split(" "):[],c=l.filter(f=>!a.includes(f));n[i]=[...a,...c].join(" ")}else if(i==="style"){const l=new Map([...It(n[i]),...It(s)]);n[i]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else n[i]=s}),n},{})}function Vi(r,e){return e.filter(t=>t.type===r.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(r.attrs)||{}:{[t.name]:r.attrs[t.name]}).reduce((t,n)=>bn(t,n),{})}function Mn(r,e,t){const{from:n,to:i}=e,{blockSeparator:s=`
|
|
6
6
|
|
|
7
|
-
`,textSerializers:o={}}=t||{};let l="";return r.nodesBetween(n,i,(a,c,f,u)=>{var d;a.isBlock&&c>n&&(l+=s);const h=o==null?void 0:o[a.type.name];if(h)return f&&(l+=h({node:a,pos:c,parent:f,index:u,range:e})),!1;a.isText&&(l+=(d=a==null?void 0:a.text)==null?void 0:d.slice(Math.max(n,c)-c,i-c))}),l}function Vi(r,e){const t={from:0,to:r.content.size};return Mn(r,t,e)}function En(r){return Object.fromEntries(Object.entries(r.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Ki(r,e){const t=I(e,r.schema),{from:n,to:i}=r.selection,s=[];r.doc.nodesBetween(n,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function qi(r,e){const t=Ie(typeof e=="string"?e:e.name,r.schema);return t==="node"?Ki(r,e):t==="mark"?kn(r,e):{}}function Ui(r,e=JSON.stringify){const t={};return r.filter(n=>{const i=e(n);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Xi(r){const e=Ui(r);return e.length===1?e:e.filter((t,n)=>!e.filter((s,o)=>o!==n).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function Cn(r){const{mapping:e,steps:t}=r,n=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),f=e.slice(s).map(a),u=e.invert().map(c,-1),d=e.invert().map(f);n.push({oldRange:{from:u,to:d},newRange:{from:c,to:f}})})}),Xi(n)}function ct(r,e,t){const n=[];return r===e?t.resolve(r).marks().forEach(i=>{const s=t.resolve(r),o=lt(s,i.type);o&&n.push({mark:i,...o})}):t.nodesBetween(r,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||n.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),n}var Yi=(r,e,t,n=20)=>{const i=r.doc.resolve(t);let s=n,o=null;for(;s>0&&o===null;){const l=i.node(s);(l==null?void 0:l.type.name)===e?o=l:s-=1}return[o,s]};function Me(r,e,t){return Object.fromEntries(Object.entries(t).filter(([n])=>{const i=r.find(s=>s.type===e&&s.name===n);return i?i.attribute.keepOnSplit:!1}))}function Ue(r,e,t={}){const{empty:n,ranges:i}=r.selection,s=e?Q(e,r.schema):null;if(n)return!!(r.storedMarks||r.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>Ce(u.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:u,$to:d})=>{const h=u.pos,p=d.pos;r.doc.nodesBetween(h,p,(m,g)=>{if(s&&m.inlineContent&&!m.type.allowsMarkType(s))return!1;if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),x=Math.min(p,g+m.nodeSize),S=x-y;o+=S,l.push(...m.marks.map(M=>({mark:M,from:y,to:x})))})}),o===0)return!1;const a=l.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>Ce(u.mark.attrs,t,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>s?u.mark.type!==s&&u.mark.type.excludes(s):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=o}function Qi(r,e,t={}){if(!e)return re(r,null,t)||Ue(r,null,t);const n=Ie(e,r.schema);return n==="node"?re(r,e,t):n==="mark"?Ue(r,e,t):!1}var Zi=(r,e)=>{const{$from:t,$to:n,$anchor:i}=r.selection;if(e){const s=pe(l=>l.type.name===e)(r.selection);if(!s)return!1;const o=r.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(n.parentOffset<n.parent.nodeSize-2||t.pos!==n.pos)},Gi=r=>{const{$from:e,$to:t}=r.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Xe(r,e){const{nodeExtensions:t}=Sn(e),n=t.find(o=>o.name===r);if(!n)return!1;const i={name:n.name,options:n.options,storage:n.storage},s=J(ie(n,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function ft(r,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var n;if(t){if(r.type.name==="hardBreak")return!0;if(r.isText)return/^\s*$/m.test((n=r.text)!=null?n:"")}if(r.isText)return!r.text;if(r.isAtom||r.isLeaf)return!1;if(r.content.childCount===0)return!0;if(e){let i=!0;return r.content.forEach(s=>{i!==!1&&(ft(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function es(r){return r instanceof v.NodeSelection}var Tn=class An{constructor(e){this.position=e}static fromJSON(e){return new An(e.position)}toJSON(){return{position:this.position}}};function ts(r,e){const t=e.mapping.mapResult(r.position);return{position:new Tn(t.pos),mapResult:t}}function ns(r,e,t){const i=r.state.doc.content.size,s=_(e,0,i),o=_(t,0,i),l=r.coordsAtPos(s),a=r.coordsAtPos(o,-1),c=Math.min(l.top,a.top),f=Math.max(l.bottom,a.bottom),u=Math.min(l.left,a.left),d=Math.max(l.right,a.right),h=d-u,p=f-c,y={top:c,bottom:f,left:u,right:d,width:h,height:p,x:u,y:c};return{...y,toJSON:()=>y}}function rs(r,e,t){var n;const{selection:i}=e;let s=null;if(at(i)&&(s=i.$cursor),s){const l=(n=r.storedMarks)!=null?n:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?r.doc.inlineContent&&r.doc.type.allowsMarkType(t):!1;return r.doc.nodesBetween(l.pos,a.pos,(f,u,d)=>{if(c)return!1;if(f.isInline){const h=!d||d.type.allowsMarkType(t),p=!!t.isInSet(f.marks)||!f.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}var is=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Q(r,n.schema);if(i)if(o){const c=kn(n,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const f=c.$from.pos,u=c.$to.pos;n.doc.nodesBetween(f,u,(d,h)=>{const p=Math.max(h,f),m=Math.min(h+d.nodeSize,u);d.marks.find(y=>y.type===a)?d.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return rs(n,t,a)},ss=(r,e)=>({tr:t})=>(t.setMeta(r,e),!0),ls=(r,e={})=>({state:t,dispatch:n,chain:i})=>{const s=I(r,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>At(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>At(s,{...o,...e})(l,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},as=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,i=_(r,0,n.content.size),s=v.NodeSelection.create(n,i);e.setSelection(s)}return!0},cs=(r,e)=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=n;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&t.doc.nodesBetween(o,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:r})}),!0},fs=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,{from:i,to:s}=typeof r=="number"?{from:r,to:r}:r,o=v.TextSelection.atStart(n).from,l=v.TextSelection.atEnd(n).to,a=_(i,o,l),c=_(s,o,l),f=v.TextSelection.create(n,a,c);e.setSelection(f)}return!0},us=r=>({state:e,dispatch:t})=>{const n=I(r,e.schema);return _r(n)(e,t)};function zt(r,e){const t=r.storedMarks||r.selection.$to.parentOffset&&r.selection.$from.marks();if(t){const n=t.filter(i=>e==null?void 0:e.includes(i.type.name));r.tr.ensureMarks(n)}}var ds=({keepMarks:r=!0}={})=>({tr:e,state:t,dispatch:n,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,f=Me(c,l.node().type.name,l.node().attrs);if(s instanceof v.NodeSelection&&s.node.isBlock)return!l.parentOffset||!V(o,l.pos)?!1:(n&&(r&&zt(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,d=l.depth===0?void 0:Wi(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&d?[{type:d,attrs:f}]:void 0,p=V(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&V(e.doc,e.mapping.map(l.pos),1,d?[{type:d}]:void 0)&&(p=!0,h=d?[{type:d,attrs:f}]:void 0),n){if(p&&(s instanceof v.TextSelection&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),d&&!u&&!l.parentOffset&&l.parent.type!==d)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,d)&&e.setNodeMarkup(e.mapping.map(l.before()),d)}r&&zt(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},hs=(r,e={})=>({tr:t,state:n,dispatch:i,editor:s})=>{var o;const l=I(r,n.schema),{$from:a,$to:c}=n.selection,f=n.selection.node;if(f&&f.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const d=s.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let y=D.Fragment.empty;const x=a.index(-1)?1:a.index(-2)?2:3;for(let B=a.depth-x;B>=a.depth-3;B-=1)y=D.Fragment.from(a.node(B).copy(y));const S=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,M={...Me(d,a.node().type.name,a.node().attrs),...e},b=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(M))||void 0;y=y.append(D.Fragment.from(l.createAndFill(null,b)||void 0));const A=a.before(a.depth-(x-1));t.replace(A,a.after(-S),new D.Slice(y,4-x,0));let z=-1;t.doc.nodesBetween(A,t.doc.content.size,(B,K)=>{if(z>-1)return!1;B.isTextblock&&B.content.size===0&&(z=K+1)}),z>-1&&t.setSelection(v.TextSelection.near(t.doc.resolve(z))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Me(d,u.type.name,u.attrs),...e},m={...Me(d,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!V(t.doc,a.pos,2))return!1;if(i){const{selection:y,storedMarks:x}=n,{splittableMarks:S}=s.extensionManager,M=x||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!M||!i)return!0;const b=M.filter(A=>S.includes(A.type.name));t.ensureMarks(b)}return!0},Le=(r,e)=>{const t=pe(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&Y(r.doc,t.pos)&&r.join(t.pos),!0},We=(r,e)=>{const t=pe(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(t.start).after(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&Y(r.doc,n)&&r.join(n),!0},ps=(r,e,t,n={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:f})=>{const{extensions:u,splittableMarks:d}=i.extensionManager,h=I(r,o.schema),p=I(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:x}=m,S=y.blockRange(x),M=g||m.$to.parentOffset&&m.$from.marks();if(!S)return!1;const b=pe(A=>Xe(A.type.name,u))(m);if(S.depth>=1&&b&&S.depth-b.depth<=1){if(b.node.type===h)return c.liftListItem(p);if(Xe(b.node.type.name,u)&&h.validContent(b.node.content)&&l)return a().command(()=>(s.setNodeMarkup(b.pos,h),!0)).command(()=>Le(s,h)).command(()=>We(s,h)).run()}return!t||!M||!l?a().command(()=>f().wrapInList(h,n)?!0:c.clearNodes()).wrapInList(h,n).command(()=>Le(s,h)).command(()=>We(s,h)).run():a().command(()=>{const A=f().wrapInList(h,n),z=M.filter(B=>d.includes(B.type.name));return s.ensureMarks(z),A?!0:c.clearNodes()}).wrapInList(h,n).command(()=>Le(s,h)).command(()=>We(s,h)).run()},ms=(r,e={},t={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Q(r,n.schema);return Ue(n,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},gs=(r,e,t={})=>({state:n,commands:i})=>{const s=I(r,n.schema),o=I(e,n.schema),l=re(n,s,t);let a;return n.selection.$anchor.sameParent(n.selection.$head)&&(a=n.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},ys=(r,e={})=>({state:t,commands:n})=>{const i=I(r,t.schema);return re(t,i,e)?n.lift(i):n.wrapIn(i,e)},ws=()=>({state:r,dispatch:e})=>{const t=r.plugins;for(let n=0;n<t.length;n+=1){const i=t[n];let s;if(i.spec.isInputRules&&(s=i.getState(r))){if(e){const o=r.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,r.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},ks=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,{empty:n,ranges:i}=t;return n||e&&i.forEach(s=>{r.removeMark(s.$from.pos,s.$to.pos)}),!0},xs=(r,e={})=>({tr:t,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Q(r,n.schema),{$from:c,empty:f,ranges:u}=l;if(!i)return!0;if(f&&o){let{from:d,to:h}=l;const p=(s=c.marks().find(g=>g.type===a))==null?void 0:s.attrs,m=lt(c,a,p);m&&(d=m.from,h=m.to),t.removeMark(d,h,a)}else u.forEach(d=>{t.removeMark(d.$from.pos,d.$to.pos,a)});return t.removeStoredMark(a),!0},vs=r=>({tr:e,state:t,dispatch:n})=>{const{selection:i}=t;let s,o;return typeof r=="number"?(s=r,o=r):r&&"from"in r&&"to"in r?(s=r.from,o=r.to):(s=i.from,o=i.to),n&&e.doc.nodesBetween(s,o,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Ss=(r,e={})=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=Ie(typeof r=="string"?r:r.name,n.schema);if(!l)return!1;l==="node"&&(s=I(r,n.schema)),l==="mark"&&(o=Q(r,n.schema));let a=!1;return t.selection.ranges.forEach(c=>{const f=c.$from.pos,u=c.$to.pos;let d,h,p,m;t.selection.empty?n.doc.nodesBetween(f,u,(g,y)=>{s&&s===g.type&&(a=!0,p=Math.max(y,f),m=Math.min(y+g.nodeSize,u),d=y,h=g)}):n.doc.nodesBetween(f,u,(g,y)=>{y<f&&s&&s===g.type&&(a=!0,p=Math.max(y,f),m=Math.min(y+g.nodeSize,u),d=y,h=g),y>=f&&y<=u&&(s&&s===g.type&&(a=!0,i&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(x=>{if(o===x.type&&(a=!0,i)){const S=Math.max(y,f),M=Math.min(y+g.nodeSize,u);t.addMark(S,M,o.create({...x.attrs,...e}))}}))}),h&&(d!==void 0&&i&&t.setNodeMarkup(d,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&i&&t.addMark(p,m,o.create({...g.attrs,...e}))}))}),a},bs=(r,e={})=>({state:t,dispatch:n})=>{const i=I(r,t.schema);return Dr(i,e)(t,n)},Ms=(r,e={})=>({state:t,dispatch:n})=>{const i=I(r,t.schema);return Fr(i,e)(t,n)},me=class{constructor(r){var e;this.find=r.find,this.handler=r.handler,this.undoable=(e=r.undoable)!=null?e:!0}};function Es(r){return Object.prototype.toString.call(r).slice(8,-1)}function ve(r){return Es(r)!=="Object"?!1:r.constructor===Object&&Object.getPrototypeOf(r)===Object.prototype}function Rn(r,e){const t={...r};return ve(r)&&ve(e)&&Object.keys(e).forEach(n=>{ve(e[n])&&ve(r[n])?t[n]=Rn(r[n],e[n]):t[n]=e[n]}),t}var ut=class{constructor(r={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...r},this.name=this.config.name}get options(){return{...J(ie(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...J(ie(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(r={}){const e=this.extend({...this.config,addOptions:()=>Rn(this.options,r)});return e.name=this.name,e.parent=this.parent,e}extend(r={}){const e=new this.constructor({...this.config,...r});return e.parent=this,this.child=e,e.name="name"in r?r.name:e.parent.name,e}},Cs=class Nn extends ut{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new Nn(t)}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&n.removeStoredMark(a),n.insertText(" ",i.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function Ts(r){return typeof r=="number"}var dt=class{constructor(r){this.find=r.find,this.handler=r.handler}},As={};ot(As,{ClipboardTextSerializer:()=>Rs,Commands:()=>Ns,Delete:()=>Is,Drop:()=>zs,Editable:()=>Os,FocusEvents:()=>Ps,Keymap:()=>$s,Paste:()=>Bs,Tabindex:()=>Ds,TextDirection:()=>Fs,focusEventsPluginKey:()=>zn});var j=class In extends ut{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new In(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Rs=j.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:r}=this,{state:e,schema:t}=r,{doc:n,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(f=>f.$from.pos)),l=Math.max(...s.map(f=>f.$to.pos)),a=En(t);return Mn(n,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Ns=j.create({name:"commands",addCommands(){return{...mn}}}),Is=j.create({name:"delete",onUpdate({transaction:r,appendedTransactions:e}){var t,n,i;const s=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,r))!=null?c:r.getMeta("y-sync$"))return;const f=xn(r.before,[r,...e]);Cn(f).forEach(h=>{f.mapping.mapResult(h.oldRange.from).deletedAfter&&f.mapping.mapResult(h.oldRange.to).deletedBefore&&f.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,m)=>{const g=m+p.nodeSize-2,y=h.oldRange.from<=m&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:f.mapping.map(m),newTo:f.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!y,editor:this.editor,transaction:r,combinedTransform:f})})});const d=f.mapping;f.steps.forEach((h,p)=>{var m,g;if(h instanceof W){const y=d.slice(p).map(h.from,-1),x=d.slice(p).map(h.to),S=d.invert().map(y,-1),M=d.invert().map(x),b=(m=f.doc.nodeAt(y-1))==null?void 0:m.marks.some(z=>z.eq(h.mark)),A=(g=f.doc.nodeAt(x))==null?void 0:g.marks.some(z=>z.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:S,to:M},newRange:{from:y,to:x},partial:!!(A||b),editor:this.editor,transaction:r,combinedTransform:f})}})};(i=(n=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:n.async)==null||i?setTimeout(s,0):s()}}),zs=j.create({name:"drop",addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("tiptapDrop"),props:{handleDrop:(r,e,t,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:n})}}})]}}),Os=j.create({name:"editable",addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}}),zn=new v.PluginKey("focusEvents"),Ps=j.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:r}=this;return[new v.Plugin({key:zn,props:{handleDOMEvents:{focus:(e,t)=>{r.isFocused=!0;const n=r.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1},blur:(e,t)=>{r.isFocused=!1;const n=r.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1}}}})]}}),$s=j.create({name:"keymap",addKeyboardShortcuts(){const r=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:f,$anchor:u}=a,{pos:d,parent:h}=u,p=u.parent.isTextblock&&d>0?l.doc.resolve(d-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&p.parent.childCount===1?g===u.pos:v.Selection.atStart(c).from===d;return!f||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:r,"Mod-Backspace":r,"Shift-Backspace":r,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...n},s={...n,"Ctrl-h":r,"Alt-Backspace":r,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return de()||wn()?s:i},addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("clearDocument"),appendTransaction:(r,e,t)=>{if(r.some(m=>m.getMeta("composition")))return;const n=r.some(m=>m.docChanged)&&!e.doc.eq(t.doc),i=r.some(m=>m.getMeta("preventClearDocument"));if(!n||i)return;const{empty:s,from:o,to:l}=e.selection,a=v.Selection.atStart(e.doc).from,c=v.Selection.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!ft(t.doc))return;const d=t.tr,h=pn({state:t,transaction:d}),{commands:p}=new Kr({editor:this.editor,state:h});if(p.clearNodes(),!!d.steps.length)return d}})]}}),Bs=j.create({name:"paste",addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("tiptapPaste"),props:{handlePaste:(r,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Ds=j.create({name:"tabindex",addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Fs=j.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:r}=Sn(this.extensions);return[{types:r.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("textDirection"),props:{attributes:()=>{const r=this.options.direction;return r?{dir:r}:{}}}})]}});function Ls(r){return new me({find:r.find,handler:({state:e,range:t,match:n})=>{const i=J(r.getAttributes,void 0,n);if(i===!1||i===null)return null;const{tr:s}=e,o=n[n.length-1],l=n[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),f=c+o.length;if(ct(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===r.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;f<t.to&&s.delete(f,t.to),c>t.from&&s.delete(t.from+a,c);const d=t.from+a+o.length;s.addMark(t.from+a,d,r.type.create(i||{})),s.removeStoredMark(r.type)}},undoable:r.undoable})}function Ws(r){return new me({find:r.find,handler:({state:e,range:t,match:n})=>{const i=J(r.getAttributes,void 0,n)||{},{tr:s}=e,o=t.from;let l=t.to;const a=r.type.create(i);if(n[1]){const c=n[0].lastIndexOf(n[1]);let f=o+c;f>l?f=l:l=f+n[1].length;const u=n[0][n[0].length-1];s.insertText(u,o+n[0].length-1),s.replaceWith(f,l,a)}else if(n[0]){const c=r.type.isInline?o:o-1;s.insert(c,r.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:r.undoable})}function Js(r){return new me({find:r.find,handler:({state:e,range:t,match:n})=>{const i=e.doc.resolve(t.from),s=J(r.getAttributes,void 0,n)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),r.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,r.type,s)},undoable:r.undoable})}function js(r){return new me({find:r.find,handler:({state:e,range:t,match:n,chain:i})=>{const s=J(r.getAttributes,void 0,n)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&et(a,r.type,s);if(!c)return null;if(o.wrap(a,c),r.keepMarks&&r.editor){const{selection:u,storedMarks:d}=e,{splittableMarks:h}=r.editor.extensionManager,p=d||u.$to.parentOffset&&u.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(r.keepAttributes){const u=r.type.name==="bulletList"||r.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,s).run()}const f=o.doc.resolve(t.from-1).nodeBefore;f&&f.type===r.type&&Y(o.doc,t.from-1)&&(!r.joinPredicate||r.joinPredicate(n,f))&&o.join(t.from-1)},undoable:r.undoable})}var Hs=r=>"touches"in r,_s=class{constructor(r){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.touches[0];if(!a)return;const c=a.clientX-this.startX,f=a.clientY-this.startY;this.handleResize(c,f)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,t,n,i,s,o;this.node=r.node,this.editor=r.editor,this.element=r.element,this.contentElement=r.contentElement,this.getPos=r.getPos,this.onResize=r.onResize,this.onCommit=r.onCommit,this.onUpdate=r.onUpdate,(e=r.options)!=null&&e.min&&(this.minSize={...this.minSize,...r.options.min}),(t=r.options)!=null&&t.max&&(this.maxSize=r.options.max),(n=r==null?void 0:r.options)!=null&&n.directions&&(this.directions=r.options.directions),(i=r.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=r.options.preserveAspectRatio),(s=r.options)!=null&&s.className&&(this.classNames={container:r.options.className.container||"",wrapper:r.options.className.wrapper||"",handle:r.options.className.handle||"",resizing:r.options.className.resizing||""}),(o=r.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=r.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var r;return(r=this.contentElement)!=null?r:null}handleEditorUpdate(){const r=this.editor.isEditable;r!==this.lastEditableState&&(this.lastEditableState=r,r?r&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(r,e,t){return r.type!==this.node.type?!1:(this.node=r,this.onUpdate?this.onUpdate(r,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const r=document.createElement("div");return r.dataset.resizeContainer="",r.dataset.node=this.node.type.name,r.style.display="flex",this.classNames.container&&(r.className=this.classNames.container),r.appendChild(this.wrapper),r}createWrapper(){const r=document.createElement("div");return r.style.position="relative",r.style.display="block",r.dataset.resizeWrapper="",this.classNames.wrapper&&(r.className=this.classNames.wrapper),r.appendChild(this.element),r}createHandle(r){const e=document.createElement("div");return e.dataset.resizeHandle=r,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(r,e){const t=e.includes("top"),n=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");t&&(r.style.top="0"),n&&(r.style.bottom="0"),i&&(r.style.left="0"),s&&(r.style.right="0"),(e==="top"||e==="bottom")&&(r.style.left="0",r.style.right="0"),(e==="left"||e==="right")&&(r.style.top="0",r.style.bottom="0")}attachHandles(){this.directions.forEach(r=>{let e;this.createCustomHandle?e=this.createCustomHandle(r):e=this.createHandle(r),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${r}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(r)),this.createCustomHandle||this.positionHandle(e,r),e.addEventListener("mousedown",t=>this.handleResizeStart(t,r)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,r)),this.handleMap.set(r,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(r=>r.remove()),this.handleMap.clear()}applyInitialSize(){const r=this.node.attrs.width,e=this.node.attrs.height;r?(this.element.style.width=`${r}px`,this.initialWidth=r):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(r,e){r.preventDefault(),r.stopPropagation(),this.isResizing=!0,this.activeHandle=e,Hs(r)?(this.startX=r.touches[0].clientX,this.startY=r.touches[0].clientY):(this.startX=r.clientX,this.startY=r.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(r,e){if(!this.activeHandle)return;const t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:n,height:i}=this.calculateNewDimensions(this.activeHandle,r,e),s=this.applyConstraints(n,i,t);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(r,e,t){let n=this.startWidth,i=this.startHeight;const s=r.includes("right"),o=r.includes("left"),l=r.includes("bottom"),a=r.includes("top");return s?n=this.startWidth+e:o&&(n=this.startWidth-e),l?i=this.startHeight+t:a&&(i=this.startHeight-t),(r==="right"||r==="left")&&(n=this.startWidth+(s?e:-e)),(r==="top"||r==="bottom")&&(i=this.startHeight+(l?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(n,i,r):{width:n,height:i}}applyConstraints(r,e,t){var n,i,s,o;if(!t){let c=Math.max(this.minSize.width,r),f=Math.max(this.minSize.height,e);return(n=this.maxSize)!=null&&n.width&&(c=Math.min(this.maxSize.width,c)),(i=this.maxSize)!=null&&i.height&&(f=Math.min(this.maxSize.height,f)),{width:c,height:f}}let l=r,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(r,e,t){const n=t==="left"||t==="right",i=t==="top"||t==="bottom";return n?{width:r,height:r/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:r,height:r/this.aspectRatio}}};function Vs(r,e){const{selection:t}=r,{$from:n}=t;if(t instanceof v.NodeSelection){const s=n.index();return n.parent.canReplaceWith(s,s+1,e)}let i=n.depth;for(;i>=0;){const s=n.index(i);if(n.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}function Ks(r){return r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function qs(){return typeof navigator<"u"?/Firefox/.test(navigator.userAgent):!1}var Us={};ot(Us,{createAtomBlockMarkdownSpec:()=>Xs,createBlockMarkdownSpec:()=>Ys,createInlineMarkdownSpec:()=>On,parseAttributes:()=>ht,parseIndentedBlocks:()=>Pn,renderNestedMarkdownContent:()=>$n,serializeAttributes:()=>pt});function ht(r){if(!(r!=null&&r.trim()))return{};const e={},t=[],n=r.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),i=n.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const c=i.map(f=>f.trim().slice(1));e.class=c.join(" ")}const s=n.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(n.matchAll(o)).forEach(([,c,f])=>{var u;const d=parseInt(((u=f.match(/__QUOTED_(\d+)__/))==null?void 0:u[1])||"0",10),h=t[d];h&&(e[c]=h.slice(1,-1))});const a=n.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(f=>{f.match(/^[a-zA-Z][\w-]*$/)&&(e[f]=!0)}),e}function pt(r){if(!r||Object.keys(r).length===0)return"";const e=[];return r.class&&String(r.class).split(/\s+/).filter(Boolean).forEach(n=>e.push(`.${n}`)),r.id&&e.push(`#${r.id}`),Object.entries(r).forEach(([t,n])=>{t==="class"||t==="id"||(n===!0?e.push(t):n!==!1&&n!=null&&e.push(`${t}="${String(n)}"`))}),e.join(" ")}function Xs(r){const{nodeName:e,name:t,parseAttributes:n=ht,serializeAttributes:i=pt,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=r,a=t||e,c=f=>{if(!l)return f;const u={};return l.forEach(d=>{d in f&&(u[d]=f[d])}),u};return{parseMarkdown:(f,u)=>{const d={...s,...f.attributes};return u.createNode(e,d,[])},markdownTokenizer:{name:e,level:"block",start(f){var u;const d=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(u=f.match(d))==null?void 0:u.index;return h!==void 0?h:-1},tokenize(f,u,d){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=f.match(h);if(!p)return;const m=p[1]||"",g=n(m);if(!o.find(x=>!(x in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:f=>{const u=c(f.attrs||{}),d=i(u),h=d?` {${d}}`:"";return`:::${a}${h} :::`}}}function Ys(r){const{nodeName:e,name:t,getContent:n,parseAttributes:i=ht,serializeAttributes:s=pt,defaultAttributes:o={},content:l="block",allowedAttributes:a}=r,c=t||e,f=u=>{if(!a)return u;const d={};return a.forEach(h=>{h in u&&(d[h]=u[h])}),d};return{parseMarkdown:(u,d)=>{let h;if(n){const m=n(u);h=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?h=d.parseChildren(u.tokens||[]):h=d.parseInline(u.tokens||[]);const p={...o,...u.attributes};return d.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(u){var d;const h=new RegExp(`^:::${c}`,"m"),p=(d=u.match(h))==null?void 0:d.index;return p!==void 0?p:-1},tokenize(u,d,h){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=u.match(m);if(!g)return;const[y,x=""]=g,S=i(x);let M=1;const b=y.length;let A="";const z=/^:::([\w-]*)(\s.*)?/gm,B=u.slice(b);for(z.lastIndex=0;;){const K=z.exec(B);if(K===null)break;const ge=K.index,Dn=K[1];if(!((p=K[2])!=null&&p.endsWith(":::"))){if(Dn)M+=1;else if(M-=1,M===0){const mt=B.slice(0,ge);A=mt.trim();const Fn=u.slice(0,b+ge+K[0].length);let q=[];if(A)if(l==="block")for(q=h.blockTokens(mt),q.forEach(H=>{H.text&&(!H.tokens||H.tokens.length===0)&&(H.tokens=h.inlineTokens(H.text))});q.length>0;){const H=q[q.length-1];if(H.type==="paragraph"&&(!H.text||H.text.trim()===""))q.pop();else break}else q=h.inlineTokens(A);return{type:e,raw:Fn,attributes:S,content:A,tokens:q}}}}}},renderMarkdown:(u,d)=>{const h=f(u.attrs||{}),p=s(h),m=p?` {${p}}`:"",g=d.renderChildren(u.content||[],`
|
|
7
|
+
`,textSerializers:o={}}=t||{};let l="";return r.nodesBetween(n,i,(a,c,f,u)=>{var d;a.isBlock&&c>n&&(l+=s);const h=o==null?void 0:o[a.type.name];if(h)return f&&(l+=h({node:a,pos:c,parent:f,index:u,range:e})),!1;a.isText&&(l+=(d=a==null?void 0:a.text)==null?void 0:d.slice(Math.max(n,c)-c,i-c))}),l}function Ki(r,e){const t={from:0,to:r.content.size};return Mn(r,t,e)}function En(r){return Object.fromEntries(Object.entries(r.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function qi(r,e){const t=I(e,r.schema),{from:n,to:i}=r.selection,s=[];r.doc.nodesBetween(n,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Ui(r,e){const t=Ie(typeof e=="string"?e:e.name,r.schema);return t==="node"?qi(r,e):t==="mark"?kn(r,e):{}}function Xi(r,e=JSON.stringify){const t={};return r.filter(n=>{const i=e(n);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Yi(r){const e=Xi(r);return e.length===1?e:e.filter((t,n)=>!e.filter((s,o)=>o!==n).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function Cn(r){const{mapping:e,steps:t}=r,n=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),f=e.slice(s).map(a),u=e.invert().map(c,-1),d=e.invert().map(f);n.push({oldRange:{from:u,to:d},newRange:{from:c,to:f}})})}),Yi(n)}function ct(r,e,t){const n=[];return r===e?t.resolve(r).marks().forEach(i=>{const s=t.resolve(r),o=lt(s,i.type);o&&n.push({mark:i,...o})}):t.nodesBetween(r,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||n.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),n}var Qi=(r,e,t,n=20)=>{const i=r.doc.resolve(t);let s=n,o=null;for(;s>0&&o===null;){const l=i.node(s);(l==null?void 0:l.type.name)===e?o=l:s-=1}return[o,s]};function Me(r,e,t){return Object.fromEntries(Object.entries(t).filter(([n])=>{const i=r.find(s=>s.type===e&&s.name===n);return i?i.attribute.keepOnSplit:!1}))}function Ue(r,e,t={}){const{empty:n,ranges:i}=r.selection,s=e?Q(e,r.schema):null;if(n)return!!(r.storedMarks||r.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>Ce(u.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:u,$to:d})=>{const h=u.pos,p=d.pos;r.doc.nodesBetween(h,p,(m,g)=>{if(s&&m.inlineContent&&!m.type.allowsMarkType(s))return!1;if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),x=Math.min(p,g+m.nodeSize),S=x-y;o+=S,l.push(...m.marks.map(M=>({mark:M,from:y,to:x})))})}),o===0)return!1;const a=l.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>Ce(u.mark.attrs,t,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>s?u.mark.type!==s&&u.mark.type.excludes(s):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=o}function Zi(r,e,t={}){if(!e)return re(r,null,t)||Ue(r,null,t);const n=Ie(e,r.schema);return n==="node"?re(r,e,t):n==="mark"?Ue(r,e,t):!1}var Gi=(r,e)=>{const{$from:t,$to:n,$anchor:i}=r.selection;if(e){const s=pe(l=>l.type.name===e)(r.selection);if(!s)return!1;const o=r.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(n.parentOffset<n.parent.nodeSize-2||t.pos!==n.pos)},es=r=>{const{$from:e,$to:t}=r.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Xe(r,e){const{nodeExtensions:t}=Sn(e),n=t.find(o=>o.name===r);if(!n)return!1;const i={name:n.name,options:n.options,storage:n.storage},s=J(ie(n,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function ft(r,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var n;if(t){if(r.type.name==="hardBreak")return!0;if(r.isText)return!/\S/.test((n=r.text)!=null?n:"")}if(r.isText)return!r.text;if(r.isAtom||r.isLeaf)return!1;if(r.content.childCount===0)return!0;if(e){let i=!0;return r.content.forEach(s=>{i!==!1&&(ft(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function ts(r){return r instanceof v.NodeSelection}var Tn=class An{constructor(e){this.position=e}static fromJSON(e){return new An(e.position)}toJSON(){return{position:this.position}}};function ns(r,e){const t=e.mapping.mapResult(r.position);return{position:new Tn(t.pos),mapResult:t}}function rs(r,e,t){const i=r.state.doc.content.size,s=_(e,0,i),o=_(t,0,i),l=r.coordsAtPos(s),a=r.coordsAtPos(o,-1),c=Math.min(l.top,a.top),f=Math.max(l.bottom,a.bottom),u=Math.min(l.left,a.left),d=Math.max(l.right,a.right),h=d-u,p=f-c,y={top:c,bottom:f,left:u,right:d,width:h,height:p,x:u,y:c};return{...y,toJSON:()=>y}}function is(r,e,t){var n;const{selection:i}=e;let s=null;if(at(i)&&(s=i.$cursor),s){const l=(n=r.storedMarks)!=null?n:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?r.doc.inlineContent&&r.doc.type.allowsMarkType(t):!1;return r.doc.nodesBetween(l.pos,a.pos,(f,u,d)=>{if(c)return!1;if(f.isInline){const h=!d||d.type.allowsMarkType(t),p=!!t.isInSet(f.marks)||!f.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}var ss=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Q(r,n.schema);if(i)if(o){const c=kn(n,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const f=c.$from.pos,u=c.$to.pos;n.doc.nodesBetween(f,u,(d,h)=>{const p=Math.max(h,f),m=Math.min(h+d.nodeSize,u);d.marks.find(y=>y.type===a)?d.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return is(n,t,a)},ls=(r,e)=>({tr:t})=>(t.setMeta(r,e),!0),as=(r,e={})=>({state:t,dispatch:n,chain:i})=>{const s=I(r,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>At(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>At(s,{...o,...e})(l,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},cs=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,i=_(r,0,n.content.size),s=v.NodeSelection.create(n,i);e.setSelection(s)}return!0},fs=(r,e)=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=n;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&t.doc.nodesBetween(o,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:r})}),!0},us=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,{from:i,to:s}=typeof r=="number"?{from:r,to:r}:r,o=v.TextSelection.atStart(n).from,l=v.TextSelection.atEnd(n).to,a=_(i,o,l),c=_(s,o,l),f=v.TextSelection.create(n,a,c);e.setSelection(f)}return!0},ds=r=>({state:e,dispatch:t})=>{const n=I(r,e.schema);return _r(n)(e,t)};function zt(r,e){const t=r.storedMarks||r.selection.$to.parentOffset&&r.selection.$from.marks();if(t){const n=t.filter(i=>e==null?void 0:e.includes(i.type.name));r.tr.ensureMarks(n)}}var hs=({keepMarks:r=!0}={})=>({tr:e,state:t,dispatch:n,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,f=Me(c,l.node().type.name,l.node().attrs);if(s instanceof v.NodeSelection&&s.node.isBlock)return!l.parentOffset||!V(o,l.pos)?!1:(n&&(r&&zt(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,d=l.depth===0?void 0:Wi(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&d?[{type:d,attrs:f}]:void 0,p=V(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&V(e.doc,e.mapping.map(l.pos),1,d?[{type:d}]:void 0)&&(p=!0,h=d?[{type:d,attrs:f}]:void 0),n){if(p&&(s instanceof v.TextSelection&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),d&&!u&&!l.parentOffset&&l.parent.type!==d)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,d)&&e.setNodeMarkup(e.mapping.map(l.before()),d)}r&&zt(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},ps=(r,e={})=>({tr:t,state:n,dispatch:i,editor:s})=>{var o;const l=I(r,n.schema),{$from:a,$to:c}=n.selection,f=n.selection.node;if(f&&f.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const d=s.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let y=D.Fragment.empty;const x=a.index(-1)?1:a.index(-2)?2:3;for(let B=a.depth-x;B>=a.depth-3;B-=1)y=D.Fragment.from(a.node(B).copy(y));const S=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,M={...Me(d,a.node().type.name,a.node().attrs),...e},b=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(M))||void 0;y=y.append(D.Fragment.from(l.createAndFill(null,b)||void 0));const A=a.before(a.depth-(x-1));t.replace(A,a.after(-S),new D.Slice(y,4-x,0));let z=-1;t.doc.nodesBetween(A,t.doc.content.size,(B,K)=>{if(z>-1)return!1;B.isTextblock&&B.content.size===0&&(z=K+1)}),z>-1&&t.setSelection(v.TextSelection.near(t.doc.resolve(z))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Me(d,u.type.name,u.attrs),...e},m={...Me(d,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!V(t.doc,a.pos,2))return!1;if(i){const{selection:y,storedMarks:x}=n,{splittableMarks:S}=s.extensionManager,M=x||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!M||!i)return!0;const b=M.filter(A=>S.includes(A.type.name));t.ensureMarks(b)}return!0},Le=(r,e)=>{const t=pe(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&Y(r.doc,t.pos)&&r.join(t.pos),!0},We=(r,e)=>{const t=pe(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(t.start).after(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&Y(r.doc,n)&&r.join(n),!0},ms=(r,e,t,n={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:f})=>{const{extensions:u,splittableMarks:d}=i.extensionManager,h=I(r,o.schema),p=I(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:x}=m,S=y.blockRange(x),M=g||m.$to.parentOffset&&m.$from.marks();if(!S)return!1;const b=pe(A=>Xe(A.type.name,u))(m);if(S.depth>=1&&b&&S.depth-b.depth<=1){if(b.node.type===h)return c.liftListItem(p);if(Xe(b.node.type.name,u)&&h.validContent(b.node.content)&&l)return a().command(()=>(s.setNodeMarkup(b.pos,h),!0)).command(()=>Le(s,h)).command(()=>We(s,h)).run()}return!t||!M||!l?a().command(()=>f().wrapInList(h,n)?!0:c.clearNodes()).wrapInList(h,n).command(()=>Le(s,h)).command(()=>We(s,h)).run():a().command(()=>{const A=f().wrapInList(h,n),z=M.filter(B=>d.includes(B.type.name));return s.ensureMarks(z),A?!0:c.clearNodes()}).wrapInList(h,n).command(()=>Le(s,h)).command(()=>We(s,h)).run()},gs=(r,e={},t={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Q(r,n.schema);return Ue(n,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},ys=(r,e,t={})=>({state:n,commands:i})=>{const s=I(r,n.schema),o=I(e,n.schema),l=re(n,s,t);let a;return n.selection.$anchor.sameParent(n.selection.$head)&&(a=n.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},ws=(r,e={})=>({state:t,commands:n})=>{const i=I(r,t.schema);return re(t,i,e)?n.lift(i):n.wrapIn(i,e)},ks=()=>({state:r,dispatch:e})=>{const t=r.plugins;for(let n=0;n<t.length;n+=1){const i=t[n];let s;if(i.spec.isInputRules&&(s=i.getState(r))){if(e){const o=r.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,r.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},xs=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,{empty:n,ranges:i}=t;return n||e&&i.forEach(s=>{r.removeMark(s.$from.pos,s.$to.pos)}),!0},vs=(r,e={})=>({tr:t,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Q(r,n.schema),{$from:c,empty:f,ranges:u}=l;if(!i)return!0;if(f&&o){let{from:d,to:h}=l;const p=(s=c.marks().find(g=>g.type===a))==null?void 0:s.attrs,m=lt(c,a,p);m&&(d=m.from,h=m.to),t.removeMark(d,h,a)}else u.forEach(d=>{t.removeMark(d.$from.pos,d.$to.pos,a)});return t.removeStoredMark(a),!0},Ss=r=>({tr:e,state:t,dispatch:n})=>{const{selection:i}=t;let s,o;return typeof r=="number"?(s=r,o=r):r&&"from"in r&&"to"in r?(s=r.from,o=r.to):(s=i.from,o=i.to),n&&e.doc.nodesBetween(s,o,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},bs=(r,e={})=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=Ie(typeof r=="string"?r:r.name,n.schema);if(!l)return!1;l==="node"&&(s=I(r,n.schema)),l==="mark"&&(o=Q(r,n.schema));let a=!1;return t.selection.ranges.forEach(c=>{const f=c.$from.pos,u=c.$to.pos;let d,h,p,m;t.selection.empty?n.doc.nodesBetween(f,u,(g,y)=>{s&&s===g.type&&(a=!0,p=Math.max(y,f),m=Math.min(y+g.nodeSize,u),d=y,h=g)}):n.doc.nodesBetween(f,u,(g,y)=>{y<f&&s&&s===g.type&&(a=!0,p=Math.max(y,f),m=Math.min(y+g.nodeSize,u),d=y,h=g),y>=f&&y<=u&&(s&&s===g.type&&(a=!0,i&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(x=>{if(o===x.type&&(a=!0,i)){const S=Math.max(y,f),M=Math.min(y+g.nodeSize,u);t.addMark(S,M,o.create({...x.attrs,...e}))}}))}),h&&(d!==void 0&&i&&t.setNodeMarkup(d,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&i&&t.addMark(p,m,o.create({...g.attrs,...e}))}))}),a},Ms=(r,e={})=>({state:t,dispatch:n})=>{const i=I(r,t.schema);return Dr(i,e)(t,n)},Es=(r,e={})=>({state:t,dispatch:n})=>{const i=I(r,t.schema);return Fr(i,e)(t,n)},me=class{constructor(r){var e;this.find=r.find,this.handler=r.handler,this.undoable=(e=r.undoable)!=null?e:!0}};function Cs(r){return Object.prototype.toString.call(r).slice(8,-1)}function ve(r){return Cs(r)!=="Object"?!1:r.constructor===Object&&Object.getPrototypeOf(r)===Object.prototype}function Rn(r,e){const t={...r};return ve(r)&&ve(e)&&Object.keys(e).forEach(n=>{ve(e[n])&&ve(r[n])?t[n]=Rn(r[n],e[n]):t[n]=e[n]}),t}var ut=class{constructor(r={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...r},this.name=this.config.name}get options(){return{...J(ie(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...J(ie(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(r={}){const e=this.extend({...this.config,addOptions:()=>Rn(this.options,r)});return e.name=this.name,e.parent=this.parent,e}extend(r={}){const e=new this.constructor({...this.config,...r});return e.parent=this,this.child=e,e.name="name"in r?r.name:e.parent.name,e}},Ts=class Nn extends ut{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new Nn(t)}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&n.removeStoredMark(a),n.insertText(" ",i.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function As(r){return typeof r=="number"}var dt=class{constructor(r){this.find=r.find,this.handler=r.handler}},Rs={};ot(Rs,{ClipboardTextSerializer:()=>Ns,Commands:()=>Is,Delete:()=>zs,Drop:()=>Os,Editable:()=>Ps,FocusEvents:()=>$s,Keymap:()=>Bs,Paste:()=>Ds,Tabindex:()=>Fs,TextDirection:()=>Ls,focusEventsPluginKey:()=>zn});var j=class In extends ut{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new In(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Ns=j.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:r}=this,{state:e,schema:t}=r,{doc:n,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(f=>f.$from.pos)),l=Math.max(...s.map(f=>f.$to.pos)),a=En(t);return Mn(n,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Is=j.create({name:"commands",addCommands(){return{...mn}}}),zs=j.create({name:"delete",onUpdate({transaction:r,appendedTransactions:e}){var t,n,i;const s=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,r))!=null?c:r.getMeta("y-sync$"))return;const f=xn(r.before,[r,...e]);Cn(f).forEach(h=>{f.mapping.mapResult(h.oldRange.from).deletedAfter&&f.mapping.mapResult(h.oldRange.to).deletedBefore&&f.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,m)=>{const g=m+p.nodeSize-2,y=h.oldRange.from<=m&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:f.mapping.map(m),newTo:f.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!y,editor:this.editor,transaction:r,combinedTransform:f})})});const d=f.mapping;f.steps.forEach((h,p)=>{var m,g;if(h instanceof W){const y=d.slice(p).map(h.from,-1),x=d.slice(p).map(h.to),S=d.invert().map(y,-1),M=d.invert().map(x),b=(m=f.doc.nodeAt(y-1))==null?void 0:m.marks.some(z=>z.eq(h.mark)),A=(g=f.doc.nodeAt(x))==null?void 0:g.marks.some(z=>z.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:S,to:M},newRange:{from:y,to:x},partial:!!(A||b),editor:this.editor,transaction:r,combinedTransform:f})}})};(i=(n=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:n.async)==null||i?setTimeout(s,0):s()}}),Os=j.create({name:"drop",addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("tiptapDrop"),props:{handleDrop:(r,e,t,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:n})}}})]}}),Ps=j.create({name:"editable",addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}}),zn=new v.PluginKey("focusEvents"),$s=j.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:r}=this;return[new v.Plugin({key:zn,props:{handleDOMEvents:{focus:(e,t)=>{r.isFocused=!0;const n=r.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1},blur:(e,t)=>{r.isFocused=!1;const n=r.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1}}}})]}}),Bs=j.create({name:"keymap",addKeyboardShortcuts(){const r=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:f,$anchor:u}=a,{pos:d,parent:h}=u,p=u.parent.isTextblock&&d>0?l.doc.resolve(d-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&p.parent.childCount===1?g===u.pos:v.Selection.atStart(c).from===d;return!f||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:r,"Mod-Backspace":r,"Shift-Backspace":r,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...n},s={...n,"Ctrl-h":r,"Alt-Backspace":r,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return de()||wn()?s:i},addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("clearDocument"),appendTransaction:(r,e,t)=>{if(r.some(m=>m.getMeta("composition")))return;const n=r.some(m=>m.docChanged)&&!e.doc.eq(t.doc),i=r.some(m=>m.getMeta("preventClearDocument"));if(!n||i)return;const{empty:s,from:o,to:l}=e.selection,a=v.Selection.atStart(e.doc).from,c=v.Selection.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!ft(t.doc))return;const d=t.tr,h=pn({state:t,transaction:d}),{commands:p}=new Kr({editor:this.editor,state:h});if(p.clearNodes(),!!d.steps.length)return d}})]}}),Ds=j.create({name:"paste",addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("tiptapPaste"),props:{handlePaste:(r,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Fs=j.create({name:"tabindex",addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Ls=j.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:r}=Sn(this.extensions);return[{types:r.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("textDirection"),props:{attributes:()=>{const r=this.options.direction;return r?{dir:r}:{}}}})]}});function Ws(r){return new me({find:r.find,handler:({state:e,range:t,match:n})=>{const i=J(r.getAttributes,void 0,n);if(i===!1||i===null)return null;const{tr:s}=e,o=n[n.length-1],l=n[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),f=c+o.length;if(ct(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===r.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;f<t.to&&s.delete(f,t.to),c>t.from&&s.delete(t.from+a,c);const d=t.from+a+o.length;s.addMark(t.from+a,d,r.type.create(i||{})),s.removeStoredMark(r.type)}},undoable:r.undoable})}function Js(r){return new me({find:r.find,handler:({state:e,range:t,match:n})=>{const i=J(r.getAttributes,void 0,n)||{},{tr:s}=e,o=t.from;let l=t.to;const a=r.type.create(i);if(n[1]){const c=n[0].lastIndexOf(n[1]);let f=o+c;f>l?f=l:l=f+n[1].length;const u=n[0][n[0].length-1];s.insertText(u,o+n[0].length-1),s.replaceWith(f,l,a)}else if(n[0]){const c=r.type.isInline?o:o-1;s.insert(c,r.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:r.undoable})}function js(r){return new me({find:r.find,handler:({state:e,range:t,match:n})=>{const i=e.doc.resolve(t.from),s=J(r.getAttributes,void 0,n)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),r.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,r.type,s)},undoable:r.undoable})}function Hs(r){return new me({find:r.find,handler:({state:e,range:t,match:n,chain:i})=>{const s=J(r.getAttributes,void 0,n)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&et(a,r.type,s);if(!c)return null;if(o.wrap(a,c),r.keepMarks&&r.editor){const{selection:u,storedMarks:d}=e,{splittableMarks:h}=r.editor.extensionManager,p=d||u.$to.parentOffset&&u.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(r.keepAttributes){const u=r.type.name==="bulletList"||r.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,s).run()}const f=o.doc.resolve(t.from-1).nodeBefore;f&&f.type===r.type&&Y(o.doc,t.from-1)&&(!r.joinPredicate||r.joinPredicate(n,f))&&o.join(t.from-1)},undoable:r.undoable})}var _s=r=>"touches"in r,Vs=class{constructor(r){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.touches[0];if(!a)return;const c=a.clientX-this.startX,f=a.clientY-this.startY;this.handleResize(c,f)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,t,n,i,s,o;this.node=r.node,this.editor=r.editor,this.element=r.element,this.contentElement=r.contentElement,this.getPos=r.getPos,this.onResize=r.onResize,this.onCommit=r.onCommit,this.onUpdate=r.onUpdate,(e=r.options)!=null&&e.min&&(this.minSize={...this.minSize,...r.options.min}),(t=r.options)!=null&&t.max&&(this.maxSize=r.options.max),(n=r==null?void 0:r.options)!=null&&n.directions&&(this.directions=r.options.directions),(i=r.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=r.options.preserveAspectRatio),(s=r.options)!=null&&s.className&&(this.classNames={container:r.options.className.container||"",wrapper:r.options.className.wrapper||"",handle:r.options.className.handle||"",resizing:r.options.className.resizing||""}),(o=r.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=r.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var r;return(r=this.contentElement)!=null?r:null}handleEditorUpdate(){const r=this.editor.isEditable;r!==this.lastEditableState&&(this.lastEditableState=r,r?r&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(r,e,t){return r.type!==this.node.type?!1:(this.node=r,this.onUpdate?this.onUpdate(r,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const r=document.createElement("div");return r.dataset.resizeContainer="",r.dataset.node=this.node.type.name,r.style.display="flex",this.classNames.container&&(r.className=this.classNames.container),r.appendChild(this.wrapper),r}createWrapper(){const r=document.createElement("div");return r.style.position="relative",r.style.display="block",r.dataset.resizeWrapper="",this.classNames.wrapper&&(r.className=this.classNames.wrapper),r.appendChild(this.element),r}createHandle(r){const e=document.createElement("div");return e.dataset.resizeHandle=r,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(r,e){const t=e.includes("top"),n=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");t&&(r.style.top="0"),n&&(r.style.bottom="0"),i&&(r.style.left="0"),s&&(r.style.right="0"),(e==="top"||e==="bottom")&&(r.style.left="0",r.style.right="0"),(e==="left"||e==="right")&&(r.style.top="0",r.style.bottom="0")}attachHandles(){this.directions.forEach(r=>{let e;this.createCustomHandle?e=this.createCustomHandle(r):e=this.createHandle(r),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${r}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(r)),this.createCustomHandle||this.positionHandle(e,r),e.addEventListener("mousedown",t=>this.handleResizeStart(t,r)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,r)),this.handleMap.set(r,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(r=>r.remove()),this.handleMap.clear()}applyInitialSize(){const r=this.node.attrs.width,e=this.node.attrs.height;r?(this.element.style.width=`${r}px`,this.initialWidth=r):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(r,e){r.preventDefault(),r.stopPropagation(),this.isResizing=!0,this.activeHandle=e,_s(r)?(this.startX=r.touches[0].clientX,this.startY=r.touches[0].clientY):(this.startX=r.clientX,this.startY=r.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(r,e){if(!this.activeHandle)return;const t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:n,height:i}=this.calculateNewDimensions(this.activeHandle,r,e),s=this.applyConstraints(n,i,t);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(r,e,t){let n=this.startWidth,i=this.startHeight;const s=r.includes("right"),o=r.includes("left"),l=r.includes("bottom"),a=r.includes("top");return s?n=this.startWidth+e:o&&(n=this.startWidth-e),l?i=this.startHeight+t:a&&(i=this.startHeight-t),(r==="right"||r==="left")&&(n=this.startWidth+(s?e:-e)),(r==="top"||r==="bottom")&&(i=this.startHeight+(l?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(n,i,r):{width:n,height:i}}applyConstraints(r,e,t){var n,i,s,o;if(!t){let c=Math.max(this.minSize.width,r),f=Math.max(this.minSize.height,e);return(n=this.maxSize)!=null&&n.width&&(c=Math.min(this.maxSize.width,c)),(i=this.maxSize)!=null&&i.height&&(f=Math.min(this.maxSize.height,f)),{width:c,height:f}}let l=r,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(r,e,t){const n=t==="left"||t==="right",i=t==="top"||t==="bottom";return n?{width:r,height:r/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:r,height:r/this.aspectRatio}}};function Ks(r,e){const{selection:t}=r,{$from:n}=t;if(t instanceof v.NodeSelection){const s=n.index();return n.parent.canReplaceWith(s,s+1,e)}let i=n.depth;for(;i>=0;){const s=n.index(i);if(n.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}function qs(r){return r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Us(){return typeof navigator<"u"?/Firefox/.test(navigator.userAgent):!1}var Xs={};ot(Xs,{createAtomBlockMarkdownSpec:()=>Ys,createBlockMarkdownSpec:()=>Qs,createInlineMarkdownSpec:()=>On,parseAttributes:()=>ht,parseIndentedBlocks:()=>Pn,renderNestedMarkdownContent:()=>$n,serializeAttributes:()=>pt});function ht(r){if(!(r!=null&&r.trim()))return{};const e={},t=[],n=r.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),i=n.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const c=i.map(f=>f.trim().slice(1));e.class=c.join(" ")}const s=n.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(n.matchAll(o)).forEach(([,c,f])=>{var u;const d=parseInt(((u=f.match(/__QUOTED_(\d+)__/))==null?void 0:u[1])||"0",10),h=t[d];h&&(e[c]=h.slice(1,-1))});const a=n.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(f=>{f.match(/^[a-zA-Z][\w-]*$/)&&(e[f]=!0)}),e}function pt(r){if(!r||Object.keys(r).length===0)return"";const e=[];return r.class&&String(r.class).split(/\s+/).filter(Boolean).forEach(n=>e.push(`.${n}`)),r.id&&e.push(`#${r.id}`),Object.entries(r).forEach(([t,n])=>{t==="class"||t==="id"||(n===!0?e.push(t):n!==!1&&n!=null&&e.push(`${t}="${String(n)}"`))}),e.join(" ")}function Ys(r){const{nodeName:e,name:t,parseAttributes:n=ht,serializeAttributes:i=pt,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=r,a=t||e,c=f=>{if(!l)return f;const u={};return l.forEach(d=>{d in f&&(u[d]=f[d])}),u};return{parseMarkdown:(f,u)=>{const d={...s,...f.attributes};return u.createNode(e,d,[])},markdownTokenizer:{name:e,level:"block",start(f){var u;const d=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(u=f.match(d))==null?void 0:u.index;return h!==void 0?h:-1},tokenize(f,u,d){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=f.match(h);if(!p)return;const m=p[1]||"",g=n(m);if(!o.find(x=>!(x in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:f=>{const u=c(f.attrs||{}),d=i(u),h=d?` {${d}}`:"";return`:::${a}${h} :::`}}}function Qs(r){const{nodeName:e,name:t,getContent:n,parseAttributes:i=ht,serializeAttributes:s=pt,defaultAttributes:o={},content:l="block",allowedAttributes:a}=r,c=t||e,f=u=>{if(!a)return u;const d={};return a.forEach(h=>{h in u&&(d[h]=u[h])}),d};return{parseMarkdown:(u,d)=>{let h;if(n){const m=n(u);h=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?h=d.parseChildren(u.tokens||[]):h=d.parseInline(u.tokens||[]);const p={...o,...u.attributes};return d.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(u){var d;const h=new RegExp(`^:::${c}`,"m"),p=(d=u.match(h))==null?void 0:d.index;return p!==void 0?p:-1},tokenize(u,d,h){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=u.match(m);if(!g)return;const[y,x=""]=g,S=i(x);let M=1;const b=y.length;let A="";const z=/^:::([\w-]*)(\s.*)?/gm,B=u.slice(b);for(z.lastIndex=0;;){const K=z.exec(B);if(K===null)break;const ge=K.index,Dn=K[1];if(!((p=K[2])!=null&&p.endsWith(":::"))){if(Dn)M+=1;else if(M-=1,M===0){const mt=B.slice(0,ge);A=mt.trim();const Fn=u.slice(0,b+ge+K[0].length);let q=[];if(A)if(l==="block")for(q=h.blockTokens(mt),q.forEach(H=>{H.text&&(!H.tokens||H.tokens.length===0)&&(H.tokens=h.inlineTokens(H.text))});q.length>0;){const H=q[q.length-1];if(H.type==="paragraph"&&(!H.text||H.text.trim()===""))q.pop();else break}else q=h.inlineTokens(A);return{type:e,raw:Fn,attributes:S,content:A,tokens:q}}}}}},renderMarkdown:(u,d)=>{const h=f(u.attrs||{}),p=s(h),m=p?` {${p}}`:"",g=d.renderChildren(u.content||[],`
|
|
8
8
|
|
|
9
9
|
`);return`:::${c}${m}
|
|
10
10
|
|
|
11
11
|
${g}
|
|
12
12
|
|
|
13
|
-
:::`}}}function
|
|
13
|
+
:::`}}}function Zs(r){if(!r.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let n=t.exec(r);for(;n!==null;){const[,i,s,o]=n;e[i]=s||o,n=t.exec(r)}return e}function Gs(r){return Object.entries(r).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function On(r){const{nodeName:e,name:t,getContent:n,parseAttributes:i=Zs,serializeAttributes:s=Gs,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:a}=r,c=t||e,f=d=>{if(!a)return d;const h={};return a.forEach(p=>{const m=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(m in d){const y=d[m];if(g!==void 0&&y===g)return;h[m]=y}}),h},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(d,h)=>{const p={...o,...d.attributes};if(l)return h.createNode(e,p);const m=n?n(d):d.content||"";return m?h.createNode(e,p,[h.createTextNode(m)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(d){const h=l?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),p=d.match(h),m=p==null?void 0:p.index;return m!==void 0?m:-1},tokenize(d,h,p){const m=l?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),g=d.match(m);if(!g)return;let y="",x="";if(l){const[,M]=g;x=M}else{const[,M,b]=g;x=M,y=b||""}const S=i(x.trim());return{type:e,raw:g[0],content:y.trim(),attributes:S}}},renderMarkdown:d=>{let h="";n?h=n(d):d.content&&d.content.length>0&&(h=d.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const p=f(d.attrs||{}),m=s(p),g=m?` ${m}`:"";return l?`[${c}${g}]`:`[${c}${g}]${h}[/${c}]`}}}function Pn(r,e,t){var n,i,s,o;const l=r.split(`
|
|
14
14
|
`),a=[];let c="",f=0;const u=e.baseIndentSize||2;for(;f<l.length;){const d=l[f],h=d.match(e.itemPattern);if(!h){if(a.length>0)break;if(d.trim()===""){f+=1,c=`${c}${d}
|
|
15
15
|
`;continue}else return}const p=e.extractItemData(h),{indentLevel:m,mainContent:g}=p;c=`${c}${d}
|
|
16
16
|
`;const y=[g];for(f+=1;f<l.length;){const b=l[f];if(b.trim()===""){const z=l.slice(f+1).findIndex(ge=>ge.trim()!=="");if(z===-1)break;if((((i=(n=l[f+1+z].match(/^(\s*)/))==null?void 0:n[1])==null?void 0:i.length)||0)>m){y.push(b),c=`${c}${b}
|
|
17
17
|
`,f+=1;continue}else break}if((((o=(s=b.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>m)y.push(b),c=`${c}${b}
|
|
18
18
|
`,f+=1;else break}let x;const S=y.slice(1);if(S.length>0){const b=S.map(A=>A.slice(m+u)).join(`
|
|
19
|
-
`);b.trim()&&(e.customNestedParser?x=e.customNestedParser(b):x=t.blockTokens(b))}const M=e.createToken(p,x);a.push(M)}if(a.length!==0)return{items:a,raw:c}}function $n(r,e,t,n){if(!r||!Array.isArray(r.content))return"";const i=typeof t=="function"?t(n):t,[s,...o]=r.content,l=e.renderChildren([s])
|
|
20
|
-
`).map(
|
|
21
|
-
`);a.
|
|
22
|
-
|
|
19
|
+
`);b.trim()&&(e.customNestedParser?x=e.customNestedParser(b):x=t.blockTokens(b))}const M=e.createToken(p,x);a.push(M)}if(a.length!==0)return{items:a,raw:c}}function $n(r,e,t,n){if(!r||!Array.isArray(r.content))return"";const i=typeof t=="function"?t(n):t,[s,...o]=r.content,l=e.renderChildren([s]);let a=`${i}${l}`;return o&&o.length>0&&o.forEach((c,f)=>{var u,d;const h=(d=(u=e.renderChild)==null?void 0:u.call(e,c,f+1))!=null?d:e.renderChildren([c]);if(h!=null){const p=h.split(`
|
|
20
|
+
`).map(m=>m?e.indent(m):e.indent("")).join(`
|
|
21
|
+
`);a+=c.type==="paragraph"?`
|
|
22
|
+
|
|
23
|
+
${p}`:`
|
|
24
|
+
${p}`}}),a}var eo=class Bn extends ut{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Bn(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},to=class{constructor(r,e,t){this.isDragging=!1,this.component=r,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(r){var e,t,n,i,s,o,l;const{view:a}=this.editor,c=r.target,f=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!f)return;let u=0,d=0;if(this.dom!==f){const x=this.dom.getBoundingClientRect(),S=f.getBoundingClientRect(),M=(i=r.offsetX)!=null?i:(n=r.nativeEvent)==null?void 0:n.offsetX,b=(o=r.offsetY)!=null?o:(s=r.nativeEvent)==null?void 0:s.offsetY;u=S.x-x.x+M,d=S.y-x.y+b}const h=this.dom.cloneNode(!0);try{const x=this.dom.getBoundingClientRect();h.style.width=`${Math.round(x.width)}px`,h.style.height=`${Math.round(x.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(h),document.body.appendChild(p),(l=r.dataTransfer)==null||l.setDragImage(h,u,d)}finally{p&&setTimeout(()=>{try{p==null||p.remove()}catch{}},0)}const m=this.getPos();if(typeof m!="number")return;const g=v.NodeSelection.create(a.state.doc,m),y=a.state.tr.setSelection(g);a.dispatch(y)}stopEvent(r){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:r});const t=r.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const i=r.type.startsWith("drag"),s=r.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!s&&!i)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,f=v.NodeSelection.isSelectable(this.node),u=r.type==="copy",d=r.type==="paste",h=r.type==="cut",p=r.type==="mousedown";if(!c&&f&&i&&r.target===this.dom&&r.preventDefault(),c&&i&&!a&&r.target===this.dom)return r.preventDefault(),!1;if(c&&l&&!a&&p){const m=t.closest("[data-drag-handle]");m&&(this.dom===m||this.dom.contains(m))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||s||u||d||h||p&&f)}ignoreMutation(r){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:r}):this.node.isLeaf||this.node.isAtom?!0:r.type==="selection"||this.dom.contains(r.target)&&r.type==="childList"&&(de()||qe())&&this.editor.isFocused&&[...Array.from(r.addedNodes),...Array.from(r.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===r.target&&r.type==="attributes"?!0:!this.contentDOM.contains(r.target)}updateAttributes(r){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...r}),!0)})}deleteNode(){const r=this.getPos();if(typeof r!="number")return;const e=r+this.node.nodeSize;this.editor.commands.deleteRange({from:r,to:e})}};function no(r){return new dt({find:r.find,handler:({state:e,range:t,match:n,pasteEvent:i})=>{const s=J(r.getAttributes,void 0,n,i);if(s===!1||s===null)return null;const{tr:o}=e,l=n[n.length-1],a=n[0];let c=t.to;if(l){const f=a.search(/\S/),u=t.from+a.indexOf(l),d=u+l.length;if(ct(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===r.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;d<t.to&&o.delete(d,t.to),u>t.from&&o.delete(t.from+f,u),c=t.from+f+l.length,o.addMark(t.from+f,c,r.type.create(s||{})),o.removeStoredMark(r.type)}}})}function ro(r){return new dt({find:r.find,handler({match:e,chain:t,range:n,pasteEvent:i}){const s=J(r.getAttributes,void 0,e,i),o=J(r.getContent,void 0,s);if(s===!1||s===null)return null;const l={type:r.type.name,attrs:s};o&&(l.content=o),e.input&&t().deleteRange(n).insertContentAt(n.from,l)}})}exports.AllSelection=L;exports.DOMParser=Ee;exports.DOMSerializer=Qe;exports.Extension=j;exports.Fragment=w;exports.InputRule=me;exports.MappablePosition=Tn;exports.Mapping=fe;exports.Mark=Ts;exports.Node3=eo;exports.NodeSelection=E;exports.NodeView=to;exports.PasteRule=dt;exports.Plugin=br;exports.PluginKey=Mr;exports.ResizableNodeView=Vs;exports.Selection=C;exports.SelectionRange=Zt;exports.Slice=k;exports.TextSelection=P;exports.Transform=Qt;exports.callOrReturn=J;exports.canInsertNode=Ks;exports.combineTransactionSteps=xn;exports.createInlineMarkdownSpec=On;exports.deleteSelection=Ne;exports.dropPoint=mr;exports.escapeForRegEx=qs;exports.findChildren=Ji;exports.findChildrenInRange=ji;exports.findParentNode=pe;exports.findParentNodeClosestToPos=vn;exports.getAttributes=Ui;exports.getChangedRanges=Cn;exports.getExtensionField=ie;exports.getMarksBetween=ct;exports.getNodeAtPosition=Qi;exports.getNodeType=I;exports.getRenderedAttributes=Vi;exports.getText=Ki;exports.getTextSerializersFromSchema=En;exports.getUpdatedPosition=ns;exports.isActive=Zi;exports.isAtEndOfNode=Gi;exports.isAtStartOfNode=es;exports.isFirefox=Us;exports.isList=Xe;exports.isNodeActive=re;exports.isNodeEmpty=ft;exports.isNodeSelection=ts;exports.isNumber=As;exports.isTextSelection=at;exports.markInputRule=Ws;exports.markPasteRule=no;exports.mergeAttributes=bn;exports.nodeInputRule=Js;exports.nodePasteRule=ro;exports.parseIndentedBlocks=Pn;exports.posToDOMRect=rs;exports.renderNestedMarkdownContent=$n;exports.textblockTypeInputRule=js;exports.wrappingInputRule=Hs;
|