reactjs-tiptap-editor 0.4.2 → 1.0.1
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-BKOg7hkq.js +38 -0
- package/lib/ActionMenuButton-DLQyd_gx.cjs +1 -0
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.d.cts +27 -39
- package/lib/Attachment.d.ts +27 -39
- package/lib/Attachment.js +129 -99
- package/lib/Blockquote.cjs +3 -3
- package/lib/Blockquote.d.cts +27 -39
- package/lib/Blockquote.d.ts +27 -39
- package/lib/Blockquote.js +50 -22
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.d.cts +27 -39
- package/lib/Bold.d.ts +27 -39
- package/lib/Bold.js +48 -20
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.d.cts +27 -39
- package/lib/BulletList.d.ts +27 -39
- package/lib/BulletList.js +38 -9
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.d.cts +27 -39
- package/lib/Clear.d.ts +27 -39
- package/lib/Clear.js +32 -6
- package/lib/Code.cjs +1 -1
- package/lib/Code.d.cts +27 -39
- package/lib/Code.d.ts +27 -39
- package/lib/Code.js +53 -25
- package/lib/CodeBlock.cjs +35 -35
- package/lib/CodeBlock.d.cts +27 -39
- package/lib/CodeBlock.d.ts +27 -39
- package/lib/CodeBlock.js +605 -590
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.d.cts +28 -40
- package/lib/CodeView.d.ts +28 -40
- package/lib/CodeView.js +49 -21
- package/lib/Color.cjs +1 -1
- package/lib/Color.d.cts +31 -39
- package/lib/Color.d.ts +31 -39
- package/lib/Color.js +123 -79
- package/lib/Column.cjs +1 -0
- package/lib/{Document.d.cts → Column.d.cts} +33 -42
- package/lib/{Document.d.ts → Column.d.ts} +33 -42
- package/lib/Column.js +217 -0
- package/lib/{Drawer-CaAfmqNo.js → Drawer-DZ5jvmrX.js} +404 -394
- package/lib/Drawer-SRhwOc6T.cjs +1 -0
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.d.cts +27 -39
- package/lib/Drawer.d.ts +27 -39
- package/lib/Drawer.js +6 -5
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.d.cts +27 -44
- package/lib/Emoji.d.ts +27 -44
- package/lib/Emoji.js +377 -392
- package/lib/Excalidraw-DwBRXEtC.js +345 -0
- package/lib/Excalidraw-ZN3DQvDC.cjs +1 -0
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.d.cts +27 -39
- package/lib/Excalidraw.d.ts +27 -39
- package/lib/Excalidraw.js +6 -4
- package/lib/ExportPdf.cjs +5 -5
- package/lib/ExportPdf.d.cts +27 -39
- package/lib/ExportPdf.d.ts +27 -39
- package/lib/ExportPdf.js +60 -32
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.d.cts +28 -40
- package/lib/ExportWord.d.ts +28 -40
- package/lib/ExportWord.js +84 -21
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.d.cts +41 -42
- package/lib/FontFamily.d.ts +41 -42
- package/lib/FontFamily.js +72 -74
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.d.cts +38 -42
- package/lib/FontSize.d.ts +38 -42
- package/lib/FontSize.js +72 -64
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.d.cts +41 -39
- package/lib/Heading.d.ts +41 -39
- package/lib/Heading.js +91 -73
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.d.cts +31 -39
- package/lib/Highlight.d.ts +31 -39
- package/lib/Highlight.js +150 -19
- package/lib/History.cjs +1 -1
- package/lib/History.d.cts +29 -39
- package/lib/History.d.ts +29 -39
- package/lib/History.js +976 -53
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.d.cts +27 -39
- package/lib/HorizontalRule.d.ts +27 -39
- package/lib/HorizontalRule.js +97 -17
- package/lib/Icon-DUpv2cI6.cjs +1 -0
- package/lib/Icon-jKs8Hr6p.js +11 -0
- package/lib/Iframe-CmXkEqOd.js +431 -0
- package/lib/Iframe-Cvca2G7X.cjs +1 -0
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.d.cts +26 -45
- package/lib/Iframe.d.ts +26 -45
- package/lib/Iframe.js +6 -4
- package/lib/Image.cjs +1 -1
- package/lib/Image.d.cts +27 -40
- package/lib/Image.d.ts +27 -40
- package/lib/Image.js +848 -5
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.d.cts +28 -42
- package/lib/ImageGif.d.ts +28 -42
- package/lib/ImageGif.js +424 -5
- package/lib/ImportWord.cjs +48 -48
- package/lib/ImportWord.d.cts +28 -40
- package/lib/ImportWord.d.ts +28 -40
- package/lib/ImportWord.js +2759 -2751
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.d.cts +27 -39
- package/lib/Indent.d.ts +27 -39
- package/lib/Indent.js +97 -27
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.d.cts +27 -39
- package/lib/Italic.d.ts +27 -39
- package/lib/Italic.js +47 -19
- package/lib/Katex-DsYXsjSS.js +2740 -0
- package/lib/Katex-XfrNne6U.cjs +4 -0
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.d.cts +27 -39
- package/lib/Katex.d.ts +27 -39
- package/lib/Katex.js +5 -196
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.d.cts +29 -45
- package/lib/LineHeight.d.ts +29 -45
- package/lib/LineHeight.js +71 -112
- package/lib/Link.cjs +1 -1
- package/lib/Link.d.cts +28 -42
- package/lib/Link.d.ts +28 -42
- package/lib/Link.js +3 -3
- package/lib/LinkEditBlock-BZenZq-Z.cjs +5 -0
- package/lib/LinkEditBlock-CB8yIffE.js +1241 -0
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.d.cts +24 -39
- package/lib/Mention.d.ts +24 -39
- package/lib/Mention.js +112 -124
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.d.cts +27 -39
- package/lib/Mermaid.d.ts +27 -39
- package/lib/Mermaid.js +177 -165
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.d.cts +42 -41
- package/lib/MoreMark.d.ts +42 -41
- package/lib/MoreMark.js +125 -55
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.d.cts +27 -39
- package/lib/OrderedList.d.ts +27 -39
- package/lib/OrderedList.js +37 -9
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.d.cts +27 -42
- package/lib/SearchAndReplace.d.ts +27 -42
- package/lib/SearchAndReplace.js +221 -197
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.d.cts +39 -46
- package/lib/SlashCommand.d.ts +39 -46
- package/lib/SlashCommand.js +235 -249
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.d.cts +27 -39
- package/lib/Strike.d.ts +27 -39
- package/lib/Strike.js +39 -11
- package/lib/Table-B1j1Ebmh.cjs +9 -0
- package/lib/Table-Db8TcQX8.js +1984 -0
- package/lib/Table.cjs +1 -9
- package/lib/Table.d.cts +28 -42
- package/lib/Table.d.ts +28 -42
- package/lib/Table.js +3 -558
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.d.cts +27 -39
- package/lib/TaskList.d.ts +27 -39
- package/lib/TaskList.js +38 -10
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.d.cts +40 -39
- package/lib/TextAlign.d.ts +40 -39
- package/lib/TextAlign.js +108 -101
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.d.cts +56 -39
- package/lib/TextDirection.d.ts +56 -39
- package/lib/TextDirection.js +105 -112
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.d.cts +27 -39
- package/lib/TextUnderline.d.ts +27 -39
- package/lib/TextUnderline.js +46 -18
- package/lib/{Twitter-BFULyqdR.js → Twitter-CXmmjz9R.js} +536 -498
- package/lib/Twitter-CtVTIWJW.cjs +1 -0
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.d.cts +27 -39
- package/lib/Twitter.d.ts +27 -39
- package/lib/Twitter.js +5 -4
- package/lib/Video.cjs +1 -1
- package/lib/Video.d.cts +27 -39
- package/lib/Video.d.ts +27 -39
- package/lib/Video.js +261 -4
- package/lib/_commonjsHelpers-BItOPCY9.js +28 -0
- package/lib/_commonjsHelpers-BTDuMlIz.cjs +1 -0
- package/lib/bubble.cjs +2 -0
- package/lib/{bubble-extra.d.cts → bubble.d.cts} +53 -54
- package/lib/{bubble-extra.d.ts → bubble.d.ts} +53 -54
- package/lib/bubble.js +1925 -0
- package/lib/button-B12K7BJ4.cjs +1 -0
- package/lib/button-DXMsXUEn.js +43 -0
- package/lib/clsx-C11secjj.cjs +1 -0
- package/lib/clsx-OuTLNxxd.js +16 -0
- package/lib/delete-node-CosiBes5.cjs +1 -0
- package/lib/delete-node-IyVmiRbI.js +22 -0
- package/lib/dialog-CaCS-W5S.cjs +1 -0
- package/lib/dialog-PtQivpHS.js +100 -0
- package/lib/dom-dataset-BqoJhJXt.cjs +1 -0
- package/lib/dom-dataset-CIEeltF6.js +47 -0
- package/lib/dropdown-menu-BPp2Z_U-.js +136 -0
- package/lib/dropdown-menu-CdSm4emp.cjs +1 -0
- package/lib/file-BLas99n7.js +43 -0
- package/lib/file-i7e4nQY2.cjs +1 -0
- package/lib/floating-ui.dom-U1vPFQ5f.js +1151 -0
- package/lib/floating-ui.dom-VCrc58uF.cjs +1 -0
- package/lib/icons-Cllpys39.js +362 -0
- package/lib/icons-CqHjeW5T.cjs +1 -0
- package/lib/index-BH4bc3jN.cjs +33 -0
- package/lib/index-BPfVXs5_.js +2380 -0
- package/lib/index-Bnmd0WvY.js +1631 -0
- package/lib/{index-Ch6dBBad.js → index-CBce_TWY.js} +40 -42
- package/lib/{index-5iBZLua9.cjs → index-D-5U8dY8.cjs} +8 -8
- package/lib/{index-ByurDDMv.js → index-D2TUfKkC.js} +2 -2
- package/lib/index-DV5kbgRU.cjs +1 -0
- package/lib/{index-LmrOdnen.js → index-DYkucCoF.js} +396 -495
- package/lib/index-Dfmm6FTT.cjs +1 -0
- package/lib/index-DnWWK9F_.js +6374 -0
- package/lib/index-DzcKxutn.js +632 -0
- package/lib/index-DzvuNTxo.cjs +4 -0
- package/lib/{index-BeCTd5v2.cjs → index-N--9MohJ.cjs} +1 -1
- package/lib/index-RfTlOzIr.cjs +22 -0
- package/lib/index.cjs +132 -1
- package/lib/index.d.cts +29 -280
- package/lib/index.d.ts +29 -280
- package/lib/index.js +243 -2
- package/lib/input-_ECRfn3Y.cjs +1 -0
- package/lib/input-wJ9PDEzZ.js +21 -0
- package/lib/isNumber-ClPupm7P.cjs +1 -0
- package/lib/isNumber-fpLGS0AZ.js +15 -0
- package/lib/label-BkgAe7IY.cjs +1 -0
- package/lib/label-CGdLYWv7.js +19 -0
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.d.cts +5405 -57
- package/lib/locale-bundle.d.ts +5405 -57
- package/lib/locale-bundle.js +9 -7
- package/lib/popover-BgmUNMHj.cjs +1 -0
- package/lib/popover-CAuEW0Mr.js +23 -0
- package/lib/separator-CuBW_w98.js +328 -0
- package/lib/separator-DRIrVZ2N.cjs +1 -0
- package/lib/store-DX599H5W.js +10 -0
- package/lib/store-WStcMOiW.cjs +1 -0
- package/lib/style.css +1 -1
- package/lib/switch-CnLJ7Y-b.cjs +1 -0
- package/lib/switch-Coix_FA1.js +27 -0
- package/lib/tabs-B5mVSN1I.js +46 -0
- package/lib/tabs-BoLCMcCI.cjs +1 -0
- package/lib/textarea-B-6zTKQz.cjs +1 -0
- package/lib/{textarea-aPtytkDx.js → textarea-DUUM1jZd.js} +1 -1
- package/lib/theme-B7aAsK_T.js +15 -0
- package/lib/theme-D8_cxGqB.cjs +1 -0
- package/lib/throttle-CdwDrFpn.js +249 -0
- package/lib/throttle-qX7Yjtsg.cjs +1 -0
- package/lib/toggle-Cdp4IT2U.js +85 -0
- package/lib/toggle-D41PzQLJ.cjs +1 -0
- package/lib/tooltip-BuEiE96N.cjs +1 -0
- package/lib/tooltip-CopwsU8q.js +23 -0
- package/lib/updatePosition-8Sdem5jb.cjs +1 -0
- package/lib/updatePosition-BPmcE0YD.js +215 -0
- package/lib/use-toast-Bz3QCOtE.cjs +1 -0
- package/lib/use-toast-Crf7-q5H.js +98 -0
- package/lib/useButtonProps-BsEd4zYM.js +141 -0
- package/lib/useButtonProps-C6Vpn190.cjs +1 -0
- package/package.json +22 -105
- package/lib/ActionMenuButton-CYdM1xx5.cjs +0 -1
- package/lib/ActionMenuButton-DKRF6oa0.js +0 -33
- package/lib/BaseKit.cjs +0 -3
- package/lib/BaseKit.d.cts +0 -481
- package/lib/BaseKit.d.ts +0 -481
- package/lib/BaseKit.js +0 -132
- package/lib/Document.cjs +0 -1
- package/lib/Document.js +0 -9
- package/lib/Drawer-CdvCMSzN.cjs +0 -1
- package/lib/Excalidraw-BbMQhNvs.cjs +0 -1
- package/lib/Excalidraw-CVWz2Vyn.js +0 -290
- package/lib/FormatPainter.cjs +0 -1
- package/lib/FormatPainter.d.cts +0 -372
- package/lib/FormatPainter.d.ts +0 -372
- package/lib/FormatPainter.js +0 -76
- package/lib/ListItem.cjs +0 -1
- package/lib/ListItem.d.cts +0 -290
- package/lib/ListItem.d.ts +0 -290
- package/lib/ListItem.js +0 -7
- package/lib/MultiColumn.cjs +0 -1
- package/lib/MultiColumn.d.cts +0 -294
- package/lib/MultiColumn.d.ts +0 -294
- package/lib/MultiColumn.js +0 -8
- package/lib/RichTextEditor-CxvwGvQG.cjs +0 -142
- package/lib/RichTextEditor-DGcKEUGr.js +0 -22166
- package/lib/Selection.cjs +0 -1
- package/lib/Selection.d.cts +0 -289
- package/lib/Selection.d.ts +0 -289
- package/lib/Selection.js +0 -25
- package/lib/SubAndSuperScript.cjs +0 -1
- package/lib/SubAndSuperScript.d.cts +0 -377
- package/lib/SubAndSuperScript.d.ts +0 -377
- package/lib/SubAndSuperScript.js +0 -43
- package/lib/TableOfContent.cjs +0 -1
- package/lib/TableOfContent.d.cts +0 -291
- package/lib/TableOfContent.d.ts +0 -291
- package/lib/TableOfContent.js +0 -185
- package/lib/TextBubble.cjs +0 -1
- package/lib/TextBubble.d.cts +0 -362
- package/lib/TextBubble.d.ts +0 -362
- package/lib/TextBubble.js +0 -133
- package/lib/TrailingNode.cjs +0 -1
- package/lib/TrailingNode.d.cts +0 -297
- package/lib/TrailingNode.d.ts +0 -297
- package/lib/TrailingNode.js +0 -41
- package/lib/Twitter-Cutpkh3h.cjs +0 -1
- package/lib/bubble-extra.cjs +0 -2
- package/lib/bubble-extra.js +0 -631
- package/lib/dom-dataset-_6-diIRQ.cjs +0 -33
- package/lib/dom-dataset-lYeH6gfI.js +0 -2361
- package/lib/index-6D1J-A-o.cjs +0 -1
- package/lib/index-B96Cclrj.cjs +0 -3
- package/lib/index-BBz7Nmv9.js +0 -55
- package/lib/index-CUogRI7j.cjs +0 -1
- package/lib/index-DF2Lp4HZ.cjs +0 -100
- package/lib/index-D_L6n8O8.js +0 -76
- package/lib/index-Dbvi-Bvh.cjs +0 -1
- package/lib/index-DpCrt7xs.cjs +0 -1
- package/lib/index-DsAX1Vq8.cjs +0 -1
- package/lib/index-Dy4DlW9o.js +0 -12
- package/lib/index-J3jHHZ4d.js +0 -200
- package/lib/index-VvXaaKe3.js +0 -898
- package/lib/index-kbO3iWqL.js +0 -13432
- package/lib/textarea-DFo_aXnj.cjs +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";const u=require("./index-RfTlOzIr.cjs");var P={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},J={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},lt=typeof navigator<"u"&&/Mac/.test(navigator.platform),st=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var y=0;y<10;y++)P[48+y]=P[96+y]=String(y);for(var y=1;y<=24;y++)P[y+111]="F"+y;for(var y=65;y<=90;y++)P[y]=String.fromCharCode(y+32),J[y]=String.fromCharCode(y);for(var te in P)J.hasOwnProperty(te)||(J[te]=P[te]);function it(e){var n=lt&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||st&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",t=!n&&e.key||(e.shiftKey?J:P)[e.keyCode]||e.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const at=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ct=typeof navigator<"u"&&/Win/.test(navigator.platform);function ft(e){let n=e.split(/-(?!$)/),t=n[n.length-1];t=="Space"&&(t=" ");let r,o,l,s;for(let i=0;i<n.length-1;i++){let a=n[i];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))l=!0;else if(/^mod$/i.test(a))at?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),s&&(t="Meta-"+t),l&&(t="Shift-"+t),t}function dt(e){let n=Object.create(null);for(let t in e)n[ft(t)]=e[t];return n}function ne(e,n,t=!0){return n.altKey&&(e="Alt-"+e),n.ctrlKey&&(e="Ctrl-"+e),n.metaKey&&(e="Meta-"+e),t&&n.shiftKey&&(e="Shift-"+e),e}function ut(e){let n=dt(e);return function(t,r){let o=it(r),l,s=n[ne(o,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let i=n[ne(o,r,!1)];if(i&&i(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(ct&&r.ctrlKey&&r.altKey)&&(l=P[r.keyCode])&&l!=o){let i=n[ne(l,r)];if(i&&i(t.state,t.dispatch,t))return!0}}return!1}}const z=function(e){for(var n=0;;n++)if(e=e.previousSibling,!e)return n},Le=function(e,n,t,r){return t&&(Ne(e,n,t,r,-1)||Ne(e,n,t,r,1))},pt=/^(img|br|input|textarea|hr)$/i;function Ne(e,n,t,r,o){for(var l;;){if(e==t&&n==r)return!0;if(n==(o<0?0:G(e))){let s=e.parentNode;if(!s||s.nodeType!=1||ue(e)||pt.test(e.nodeName)||e.contentEditable=="false")return!1;n=z(e)+(o<0?0:1),e=s}else if(e.nodeType==1){let s=e.childNodes[n+(o<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((l=s.pmViewDesc)===null||l===void 0)&&l.ignoreForSelection)n+=o;else return!1;else e=s,n=o<0?G(e):0}else return!1}}function G(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function ht(e,n,t){for(let r=n==0,o=n==G(e);r||o;){if(e==t)return!0;let l=z(e);if(e=e.parentNode,!e)return!1;r=r&&l==0,o=o&&l==G(e)}}function ue(e){let n;for(let t=e;t&&!(n=t.pmViewDesc);t=t.parentNode);return n&&n.node&&n.node.isBlock&&(n.dom==e||n.contentDOM==e)}const ze=function(e){return e.focusNode&&Le(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Ve(e,n){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=e,t.key=t.code=n,t}const x=typeof navigator<"u"?navigator:null,De=typeof document<"u"?document:null,$=x&&x.userAgent||"",le=/Edge\/(\d+)/.exec($),Fe=/MSIE \d/.exec($),se=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec($),j=!!(Fe||se||le),Be=Fe?document.documentMode:se?+se[1]:le?+le[1]:0,v=!j&&/gecko\/(\d+)/i.test($);v&&+(/Firefox\/(\d+)/.exec($)||[0,0])[1];const ie=!j&&/Chrome\/(\d+)/.exec($),K=!!ie,qe=ie?+ie[1]:0,V=!j&&!!x&&/Apple Computer/.test(x.vendor),pe=V&&(/Mobile\/\w+/.test($)||!!x&&x.maxTouchPoints>2),C=pe||(x?/Mac/.test(x.platform):!1),mt=x?/Win/.test(x.platform):!1,X=/Android \d/.test($),he=!!De&&"webkitFontSmoothing"in De.documentElement.style,gt=he?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function yt(e,n=null){let t=e.domSelectionRange(),r=e.state.doc;if(!t.focusNode)return null;let o=e.docView.nearestDesc(t.focusNode),l=o&&o.size==0,s=e.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let i=r.resolve(s),a,c;if(ze(t)){for(a=s;o&&!o.node;)o=o.parent;let d=o.node;if(o&&d.isAtom&&u.NodeSelection.isSelectable(d)&&o.parent&&!(d.isInline&&ht(t.focusNode,t.focusOffset,o.dom))){let p=o.posBefore;c=new u.NodeSelection(s==p?i:r.resolve(p))}}else{if(t instanceof e.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=s,p=s;for(let h=0;h<t.rangeCount;h++){let m=t.getRangeAt(h);d=Math.min(d,e.docView.posFromDOM(m.startContainer,m.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[a,s]=p==e.state.selection.anchor?[p,d]:[d,p],i=r.resolve(s)}else a=e.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let f=r.resolve(a);if(!c){let d=n=="pointer"||e.state.selection.head<i.pos&&!l?1:-1;c=We(e,f,i,d)}return c}function He(e){return e.editable?e.hasFocus():Nt(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function me(e,n=!1){let t=e.state.selection;if(Ct(e,t),!!He(e)){if(!n&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&K){let r=e.domSelectionRange(),o=e.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Le(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)St(e);else{let{anchor:r,head:o}=t,l,s;ke&&!(t instanceof u.TextSelection)&&(t.$from.parent.inlineContent||(l=Te(e,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=Te(e,t.to))),e.docView.setSelection(r,o,e,n),ke&&(l&&xe(l),s&&xe(s)),t.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&bt(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const ke=V||K&&qe<63;function Te(e,n){let{node:t,offset:r}=e.docView.domFromPos(n,0),o=r<t.childNodes.length?t.childNodes[r]:null,l=r?t.childNodes[r-1]:null;if(V&&o&&o.contentEditable=="false")return re(o);if((!o||o.contentEditable=="false")&&(!l||l.contentEditable=="false")){if(o)return re(o);if(l)return re(l)}}function re(e){return e.contentEditable="true",V&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function xe(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function bt(e){let n=e.dom.ownerDocument;n.removeEventListener("selectionchange",e.input.hideSelectionGuard);let t=e.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;n.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(n.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!He(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function St(e){let n=e.domSelection();if(!n)return;let t=e.cursorWrapper.dom,r=t.nodeName=="IMG";r?n.collapse(t.parentNode,z(t)+1):n.collapse(t,0),!r&&!e.state.selection.visible&&j&&Be<=11&&(t.disabled=!0,t.disabled=!1)}function Ct(e,n){if(n instanceof u.NodeSelection){let t=e.docView.descAt(n.from);t!=e.lastSelectedViewDesc&&(Ee(e),t&&t.selectNode(),e.lastSelectedViewDesc=t)}else Ee(e)}function Ee(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function We(e,n,t,r){return e.someProp("createSelectionBetween",o=>o(e,n,t))||u.TextSelection.between(n,t,r)}function Nt(e){let n=e.domSelectionRange();if(!n.anchorNode)return!1;try{return e.dom.contains(n.anchorNode.nodeType==3?n.anchorNode.parentNode:n.anchorNode)&&(e.editable||e.dom.contains(n.focusNode.nodeType==3?n.focusNode.parentNode:n.focusNode))}catch{return!1}}function ae(e,n){let{$anchor:t,$head:r}=e.selection,o=n>0?t.max(r):t.min(r),l=o.parent.inlineContent?o.depth?e.doc.resolve(n>0?o.after():o.before()):null:o;return l&&u.Selection.findFrom(l,n)}function O(e,n){return e.dispatch(e.state.tr.setSelection(n).scrollIntoView()),!0}function Oe(e,n,t){let r=e.state.selection;if(r instanceof u.TextSelection)if(t.indexOf("s")>-1){let{$head:o}=r,l=o.textOffset?null:n<0?o.nodeBefore:o.nodeAfter;if(!l||l.isText||!l.isLeaf)return!1;let s=e.state.doc.resolve(o.pos+l.nodeSize*(n<0?-1:1));return O(e,new u.TextSelection(r.$anchor,s))}else if(r.empty){if(e.endOfTextblock(n>0?"forward":"backward")){let o=ae(e.state,n);return o&&o instanceof u.NodeSelection?O(e,o):!1}else if(!(C&&t.indexOf("m")>-1)){let o=r.$head,l=o.textOffset?null:n<0?o.nodeBefore:o.nodeAfter,s;if(!l||l.isText)return!1;let i=n<0?o.pos-l.nodeSize:o.pos;return l.isAtom||(s=e.docView.descAt(i))&&!s.contentDOM?u.NodeSelection.isSelectable(l)?O(e,new u.NodeSelection(n<0?e.state.doc.resolve(o.pos-l.nodeSize):o)):he?O(e,new u.TextSelection(e.state.doc.resolve(n<0?i:i+l.nodeSize))):!1:!1}}else return!1;else{if(r instanceof u.NodeSelection&&r.node.isInline)return O(e,new u.TextSelection(n>0?r.$to:r.$from));{let o=ae(e.state,n);return o?O(e,o):!1}}}function Q(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function H(e,n){let t=e.pmViewDesc;return t&&t.size==0&&(n<0||e.nextSibling||e.nodeName!="BR")}function F(e,n){return n<0?Dt(e):kt(e)}function Dt(e){let n=e.domSelectionRange(),t=n.focusNode,r=n.focusOffset;if(!t)return;let o,l,s=!1;for(v&&t.nodeType==1&&r<Q(t)&&H(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(t.nodeType!=1)break;{let i=t.childNodes[r-1];if(H(i,-1))o=t,l=--r;else if(i.nodeType==3)t=i,r=t.nodeValue.length;else break}}else{if(Ue(t))break;{let i=t.previousSibling;for(;i&&H(i,-1);)o=t.parentNode,l=z(i),i=i.previousSibling;if(i)t=i,r=Q(t);else{if(t=t.parentNode,t==e.dom)break;r=0}}}s?ce(e,t,r):o&&ce(e,o,l)}function kt(e){let n=e.domSelectionRange(),t=n.focusNode,r=n.focusOffset;if(!t)return;let o=Q(t),l,s;for(;;)if(r<o){if(t.nodeType!=1)break;let i=t.childNodes[r];if(H(i,1))l=t,s=++r;else break}else{if(Ue(t))break;{let i=t.nextSibling;for(;i&&H(i,1);)l=i.parentNode,s=z(i)+1,i=i.nextSibling;if(i)t=i,r=0,o=Q(t);else{if(t=t.parentNode,t==e.dom)break;r=o=0}}}l&&ce(e,l,s)}function Ue(e){let n=e.pmViewDesc;return n&&n.node&&n.node.isBlock}function Tt(e,n){for(;e&&n==e.childNodes.length&&!ue(e);)n=z(e)+1,e=e.parentNode;for(;e&&n<e.childNodes.length;){let t=e.childNodes[n];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;e=t,n=0}}function xt(e,n){for(;e&&!n&&!ue(e);)n=z(e),e=e.parentNode;for(;e&&n;){let t=e.childNodes[n-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;e=t,n=e.childNodes.length}}function ce(e,n,t){if(n.nodeType!=3){let l,s;(s=Tt(n,t))?(n=s,t=0):(l=xt(n,t))&&(n=l,t=l.nodeValue.length)}let r=e.domSelection();if(!r)return;if(ze(r)){let l=document.createRange();l.setEnd(n,t),l.setStart(n,t),r.removeAllRanges(),r.addRange(l)}else r.extend&&r.extend(n,t);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&me(e)},50)}function Ae(e,n){let t=e.state.doc.resolve(n);if(!(K||mt)&&t.parent.inlineContent){let o=e.coordsAtPos(n);if(n>t.start()){let l=e.coordsAtPos(n-1),s=(l.top+l.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(l.left-o.left)>1)return l.left<o.left?"ltr":"rtl"}if(n<t.end()){let l=e.coordsAtPos(n+1),s=(l.top+l.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(l.left-o.left)>1)return l.left>o.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function Me(e,n,t){let r=e.state.selection;if(r instanceof u.TextSelection&&!r.empty||t.indexOf("s")>-1||C&&t.indexOf("m")>-1)return!1;let{$from:o,$to:l}=r;if(!o.parent.inlineContent||e.endOfTextblock(n<0?"up":"down")){let s=ae(e.state,n);if(s&&s instanceof u.NodeSelection)return O(e,s)}if(!o.parent.inlineContent){let s=n<0?o:l,i=r instanceof u.AllSelection?u.Selection.near(s,n):u.Selection.findFrom(s,n);return i?O(e,i):!1}return!1}function Pe(e,n){if(!(e.state.selection instanceof u.TextSelection))return!0;let{$head:t,$anchor:r,empty:o}=e.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(n>0?"forward":"backward"))return!0;let l=!t.textOffset&&(n<0?t.nodeBefore:t.nodeAfter);if(l&&!l.isText){let s=e.state.tr;return n<0?s.delete(t.pos-l.nodeSize,t.pos):s.delete(t.pos,t.pos+l.nodeSize),e.dispatch(s),!0}return!1}function $e(e,n,t){e.domObserver.stop(),n.contentEditable=t,e.domObserver.start()}function Et(e){if(!V||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:n,focusOffset:t}=e.domSelectionRange();if(n&&n.nodeType==1&&t==0&&n.firstChild&&n.firstChild.contentEditable=="false"){let r=n.firstChild;$e(e,r,"true"),setTimeout(()=>$e(e,r,"false"),20)}return!1}function Ot(e){let n="";return e.ctrlKey&&(n+="c"),e.metaKey&&(n+="m"),e.altKey&&(n+="a"),e.shiftKey&&(n+="s"),n}function At(e,n){let t=n.keyCode,r=Ot(n);if(t==8||C&&t==72&&r=="c")return Pe(e,-1)||F(e,-1);if(t==46&&!n.shiftKey||C&&t==68&&r=="c")return Pe(e,1)||F(e,1);if(t==13||t==27)return!0;if(t==37||C&&t==66&&r=="c"){let o=t==37?Ae(e,e.state.selection.from)=="ltr"?-1:1:-1;return Oe(e,o,r)||F(e,o)}else if(t==39||C&&t==70&&r=="c"){let o=t==39?Ae(e,e.state.selection.from)=="ltr"?1:-1:1;return Oe(e,o,r)||F(e,o)}else{if(t==38||C&&t==80&&r=="c")return Me(e,-1,r)||F(e,-1);if(t==40||C&&t==78&&r=="c")return Et(e)||Me(e,1,r)||F(e,1);if(r==(C?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function je(e,n){e.someProp("transformCopied",h=>{n=h(n,e)});let t=[],{content:r,openStart:o,openEnd:l}=n;for(;o>1&&l>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,l--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=e.someProp("clipboardSerializer")||u.DOMSerializer.fromSchema(e.state.schema),i=Ze(),a=i.createElement("div");a.appendChild(s.serializeFragment(r,{document:i}));let c=a.firstChild,f,d=0;for(;c&&c.nodeType==1&&(f=Qe[c.nodeName.toLowerCase()]);){for(let h=f.length-1;h>=0;h--){let m=i.createElement(f[h]);for(;a.firstChild;)m.appendChild(a.firstChild);a.appendChild(m),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${l}${d?` -${d}`:""} ${JSON.stringify(t)}`);let p=e.someProp("clipboardTextSerializer",h=>h(n,e))||n.content.textBetween(0,n.content.size,`
|
|
2
|
+
|
|
3
|
+
`);return{dom:a,text:p,slice:n}}function Xe(e,n,t,r,o){let l=o.parent.type.spec.code,s,i;if(!t&&!n)return null;let a=!!n&&(r||l||!t);if(a){if(e.someProp("transformPastedText",p=>{n=p(n,l||r,e)}),l)return i=new u.Slice(u.Fragment.from(e.state.schema.text(n.replace(/\r\n?/g,`
|
|
4
|
+
`))),0,0),e.someProp("transformPasted",p=>{i=p(i,e,!0)}),i;let d=e.someProp("clipboardTextParser",p=>p(n,o,r,e));if(d)i=d;else{let p=o.marks(),{schema:h}=e.state,m=u.DOMSerializer.fromSchema(h);s=document.createElement("div"),n.split(/(?:\r\n?|\n)+/).forEach(E=>{let N=s.appendChild(document.createElement("p"));E&&N.appendChild(m.serializeNode(h.text(E,p)))})}}else e.someProp("transformPastedHTML",d=>{t=d(t,e)}),s=Kt(t),he&&It(s);let c=s&&s.querySelector("[data-pm-slice]"),f=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let d=+f[3];d>0;d--){let p=s.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;s=p}if(i||(i=(e.someProp("clipboardParser")||e.someProp("domParser")||u.DOMParser.fromSchema(e.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||f),context:o,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Mt.test(p.parentNode.nodeName)?{ignore:!0}:null}})),f)i=Rt(Ke(i,+f[1],+f[2]),f[4]);else if(i=u.Slice.maxOpen(Pt(i.content,o),!0),i.openStart||i.openEnd){let d=0,p=0;for(let h=i.content.firstChild;d<i.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=i.content.lastChild;p<i.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);i=Ke(i,d,p)}return e.someProp("transformPasted",d=>{i=d(i,e,a)}),i}const Mt=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Pt(e,n){if(e.childCount<2)return e;for(let t=n.depth;t>=0;t--){let o=n.node(t).contentMatchAt(n.index(t)),l,s=[];if(e.forEach(i=>{if(!s)return;let a=o.findWrapping(i.type),c;if(!a)return s=null;if(c=s.length&&l.length&&Je(a,l,i,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Ge(s[s.length-1],l.length));let f=Ye(i,a);s.push(f),o=o.matchType(f.type),l=a}}),s)return u.Fragment.from(s)}return e}function Ye(e,n,t=0){for(let r=n.length-1;r>=t;r--)e=n[r].create(null,u.Fragment.from(e));return e}function Je(e,n,t,r,o){if(o<e.length&&o<n.length&&e[o]==n[o]){let l=Je(e,n,t,r.lastChild,o+1);if(l)return r.copy(r.content.replaceChild(r.childCount-1,l));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?t.type:e[o+1]))return r.copy(r.content.append(u.Fragment.from(Ye(t,e,o+1))))}}function Ge(e,n){if(n==0)return e;let t=e.content.replaceChild(e.childCount-1,Ge(e.lastChild,n-1)),r=e.contentMatchAt(e.childCount).fillBefore(u.Fragment.empty,!0);return e.copy(t.append(r))}function fe(e,n,t,r,o,l){let s=n<0?e.firstChild:e.lastChild,i=s.content;return e.childCount>1&&(l=0),o<r-1&&(i=fe(i,n,t,r,o+1,l)),o>=t&&(i=n<0?s.contentMatchAt(0).fillBefore(i,l<=o).append(i):i.append(s.contentMatchAt(s.childCount).fillBefore(u.Fragment.empty,!0))),e.replaceChild(n<0?0:e.childCount-1,s.copy(i))}function Ke(e,n,t){return n<e.openStart&&(e=new u.Slice(fe(e.content,-1,n,e.openStart,0,e.openEnd),n,e.openEnd)),t<e.openEnd&&(e=new u.Slice(fe(e.content,1,t,e.openEnd,0,0),e.openStart,t)),e}const Qe={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ie=null;function Ze(){return Ie||(Ie=document.implementation.createHTMLDocument("title"))}let oe=null;function $t(e){let n=window.trustedTypes;return n?(oe||(oe=n.defaultPolicy||n.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),oe.createHTML(e)):e}function Kt(e){let n=/^(\s*<meta [^>]*>)*/.exec(e);n&&(e=e.slice(n[0].length));let t=Ze().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e),o;if((o=r&&Qe[r[1].toLowerCase()])&&(e=o.map(l=>"<"+l+">").join("")+e+o.map(l=>"</"+l+">").reverse().join("")),t.innerHTML=$t(e),o)for(let l=0;l<o.length;l++)t=t.querySelector(o[l])||t;return t}function It(e){let n=e.querySelectorAll(K?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<n.length;t++){let r=n[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function Rt(e,n){if(!e.size)return e;let t=e.content.firstChild.type.schema,r;try{r=JSON.parse(n)}catch{return e}let{content:o,openStart:l,openEnd:s}=e;for(let i=r.length-2;i>=0;i-=2){let a=t.nodes[r[i]];if(!a||a.hasRequiredAttrs())break;o=u.Fragment.from(a.create(r[i+1],o)),l++,s++}return new u.Slice(o,l,s)}const k={},S={};function A(e,n){e.input.lastSelectionOrigin=n,e.input.lastSelectionTime=Date.now()}S.keydown=(e,n)=>{let t=n;if(e.input.shiftKey=t.keyCode==16||t.shiftKey,!we(e,t)&&(e.input.lastKeyCode=t.keyCode,e.input.lastKeyCodeTime=Date.now(),!(X&&K&&t.keyCode==13)))if(t.keyCode!=229&&e.domObserver.forceFlush(),pe&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",o=>o(e,Ve(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,t))||At(e,t)?t.preventDefault():A(e,"key")};S.keyup=(e,n)=>{n.keyCode==16&&(e.input.shiftKey=!1)};S.keypress=(e,n)=>{let t=n;if(we(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||C&&t.metaKey)return;if(e.someProp("handleKeyPress",o=>o(e,t))){t.preventDefault();return}let r=e.state.selection;if(!(r instanceof u.TextSelection)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode),l=()=>e.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!e.someProp("handleTextInput",s=>s(e,r.$from.pos,r.$to.pos,o,l))&&e.dispatch(l()),t.preventDefault()}};function ee(e){return{left:e.clientX,top:e.clientY}}function Lt(e,n){let t=n.x-e.clientX,r=n.y-e.clientY;return t*t+r*r<100}function ge(e,n,t,r,o){if(r==-1)return!1;let l=e.state.doc.resolve(r);for(let s=l.depth+1;s>0;s--)if(e.someProp(n,i=>s>l.depth?i(e,t,l.nodeAfter,l.before(s),o,!0):i(e,t,l.node(s),l.before(s),o,!1)))return!0;return!1}function q(e,n,t){if(e.focused||e.focus(),e.state.selection.eq(n))return;let r=e.state.tr.setSelection(n);r.setMeta("pointer",!0),e.dispatch(r)}function zt(e,n){if(n==-1)return!1;let t=e.state.doc.resolve(n),r=t.nodeAfter;return r&&r.isAtom&&u.NodeSelection.isSelectable(r)?(q(e,new u.NodeSelection(t)),!0):!1}function Vt(e,n){if(n==-1)return!1;let t=e.state.selection,r,o;t instanceof u.NodeSelection&&(r=t.node);let l=e.state.doc.resolve(n);for(let s=l.depth+1;s>0;s--){let i=s>l.depth?l.nodeAfter:l.node(s);if(u.NodeSelection.isSelectable(i)){r&&t.$from.depth>0&&s>=t.$from.depth&&l.before(t.$from.depth+1)==t.$from.pos?o=l.before(t.$from.depth):o=l.before(s);break}}return o!=null?(q(e,u.NodeSelection.create(e.state.doc,o)),!0):!1}function Ft(e,n,t,r,o){return ge(e,"handleClickOn",n,t,r)||e.someProp("handleClick",l=>l(e,n,r))||(o?Vt(e,t):zt(e,t))}function Bt(e,n,t,r){return ge(e,"handleDoubleClickOn",n,t,r)||e.someProp("handleDoubleClick",o=>o(e,n,r))}function qt(e,n,t,r){return ge(e,"handleTripleClickOn",n,t,r)||e.someProp("handleTripleClick",o=>o(e,n,r))||Ht(e,t,r)}function Ht(e,n,t){if(t.button!=0)return!1;let r=e.state.doc;if(n==-1)return r.inlineContent?(q(e,u.TextSelection.create(r,0,r.content.size)),!0):!1;let o=r.resolve(n);for(let l=o.depth+1;l>0;l--){let s=l>o.depth?o.nodeAfter:o.node(l),i=o.before(l);if(s.inlineContent)q(e,u.TextSelection.create(r,i+1,i+1+s.content.size));else if(u.NodeSelection.isSelectable(s))q(e,u.NodeSelection.create(r,i));else continue;return!0}}function ye(e){return Z(e)}const _e=C?"metaKey":"ctrlKey";k.mousedown=(e,n)=>{let t=n;e.input.shiftKey=t.shiftKey;let r=ye(e),o=Date.now(),l="singleClick";o-e.input.lastClick.time<500&&Lt(t,e.input.lastClick)&&!t[_e]&&e.input.lastClick.button==t.button&&(e.input.lastClick.type=="singleClick"?l="doubleClick":e.input.lastClick.type=="doubleClick"&&(l="tripleClick")),e.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:l,button:t.button};let s=e.posAtCoords(ee(t));s&&(l=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Wt(e,s,t,!!r)):(l=="doubleClick"?Bt:qt)(e,s.pos,s.inside,t)?t.preventDefault():A(e,"pointer"))};class Wt{constructor(n,t,r,o){this.view=n,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=n.state.doc,this.selectNode=!!r[_e],this.allowDefault=r.shiftKey;let l,s;if(t.inside>-1)l=n.state.doc.nodeAt(t.inside),s=t.inside;else{let f=n.state.doc.resolve(t.pos);l=f.parent,s=f.depth?f.before():0}const i=o?null:r.target,a=i?n.docView.nearestDesc(i,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=n.state;(r.button==0&&l.type.spec.draggable&&l.type.spec.selectable!==!1||c instanceof u.NodeSelection&&c.from<=s&&c.to>s)&&(this.mightDrag={node:l,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&v&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),n.root.addEventListener("mouseup",this.up=this.up.bind(this)),n.root.addEventListener("mousemove",this.move=this.move.bind(this)),A(n,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>me(this.view)),this.view.input.mouseDown=null}up(n){if(this.done(),!this.view.dom.contains(n.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ee(n))),this.updateAllowDefault(n),this.allowDefault||!t?A(this.view,"pointer"):Ft(this.view,t.pos,t.inside,n,this.selectNode)?n.preventDefault():n.button==0&&(this.flushed||V&&this.mightDrag&&!this.mightDrag.node.isAtom||K&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(q(this.view,u.Selection.near(this.view.state.doc.resolve(t.pos))),n.preventDefault()):A(this.view,"pointer")}move(n){this.updateAllowDefault(n),A(this.view,"pointer"),n.buttons==0&&this.done()}updateAllowDefault(n){!this.allowDefault&&(Math.abs(this.event.x-n.clientX)>4||Math.abs(this.event.y-n.clientY)>4)&&(this.allowDefault=!0)}}k.touchstart=e=>{e.input.lastTouch=Date.now(),ye(e),A(e,"pointer")};k.touchmove=e=>{e.input.lastTouch=Date.now(),A(e,"pointer")};k.contextmenu=e=>ye(e);function we(e,n){return e.composing?!0:V&&Math.abs(n.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const Ut=X?5e3:-1;S.compositionstart=S.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:n}=e,t=n.selection.$to;if(n.selection instanceof u.TextSelection&&(n.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))e.markCursor=e.state.storedMarks||t.marks(),Z(e,!0),e.markCursor=null;else if(Z(e,!n.selection.empty),v&&n.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=e.domSelectionRange();for(let o=r.focusNode,l=r.focusOffset;o&&o.nodeType==1&&l!=0;){let s=l<0?o.lastChild:o.childNodes[l-1];if(!s)break;if(s.nodeType==3){let i=e.domSelection();i&&i.collapse(s,s.nodeValue.length);break}else o=s,l=-1}}e.input.composing=!0}ve(e,Ut)};S.compositionend=(e,n)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=n.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,ve(e,20))};function ve(e,n){clearTimeout(e.input.composingTimeout),n>-1&&(e.input.composingTimeout=setTimeout(()=>Z(e),n))}function jt(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Xt());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Xt(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function Z(e,n=!1){if(!(X&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),jt(e),n||e.docView&&e.docView.dirty){let t=yt(e),r=e.state.selection;return t&&!t.eq(r)?e.dispatch(e.state.tr.setSelection(t)):(e.markCursor||n)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Yt(e,n){if(!e.dom.parentNode)return;let t=e.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(n),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(n),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),e.focus()},50)}const W=j&&Be<15||pe&><604;k.copy=S.cut=(e,n)=>{let t=n,r=e.state.selection,o=t.type=="cut";if(r.empty)return;let l=W?null:t.clipboardData,s=r.content(),{dom:i,text:a}=je(e,s);l?(t.preventDefault(),l.clearData(),l.setData("text/html",i.innerHTML),l.setData("text/plain",a)):Yt(e,i),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Jt(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Gt(e,n){if(!e.dom.parentNode)return;let t=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),t?de(e,r.value,null,o,n):de(e,r.textContent,r.innerHTML,o,n)},50)}function de(e,n,t,r,o){let l=Xe(e,n,t,r,e.state.selection.$from);if(e.someProp("handlePaste",a=>a(e,o,l||u.Slice.empty)))return!0;if(!l)return!1;let s=Jt(l),i=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(l);return e.dispatch(i.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function et(e){let n=e.getData("text/plain")||e.getData("Text");if(n)return n;let t=e.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}S.paste=(e,n)=>{let t=n;if(e.composing&&!X)return;let r=W?null:t.clipboardData,o=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&de(e,et(r),r.getData("text/html"),o,t)?t.preventDefault():Gt(e,t)};class Qt{constructor(n,t,r){this.slice=n,this.move=t,this.node=r}}const Zt=C?"altKey":"ctrlKey";function tt(e,n){let t=e.someProp("dragCopies",r=>!r(n));return t??!n[Zt]}k.dragstart=(e,n)=>{let t=n,r=e.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=e.state.selection,l=o.empty?null:e.posAtCoords(ee(t)),s;if(!(l&&l.pos>=o.from&&l.pos<=(o instanceof u.NodeSelection?o.to-1:o.to))){if(r&&r.mightDrag)s=u.NodeSelection.create(e.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=e.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=e.docView&&(s=u.NodeSelection.create(e.state.doc,d.posBefore))}}let i=(s||e.state.selection).content(),{dom:a,text:c,slice:f}=je(e,i);(!t.dataTransfer.files.length||!K||qe>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(W?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",W||t.dataTransfer.setData("text/plain",c),e.dragging=new Qt(f,tt(e,t),s)};k.dragend=e=>{let n=e.dragging;window.setTimeout(()=>{e.dragging==n&&(e.dragging=null)},50)};S.dragover=S.dragenter=(e,n)=>n.preventDefault();S.drop=(e,n)=>{let t=n,r=e.dragging;if(e.dragging=null,!t.dataTransfer)return;let o=e.posAtCoords(ee(t));if(!o)return;let l=e.state.doc.resolve(o.pos),s=r&&r.slice;s?e.someProp("transformPasted",m=>{s=m(s,e,!1)}):s=Xe(e,et(t.dataTransfer),W?null:t.dataTransfer.getData("text/html"),!1,l);let i=!!(r&&tt(e,t));if(e.someProp("handleDrop",m=>m(e,t,s||u.Slice.empty,i))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?u.dropPoint(e.state.doc,l.pos,s):l.pos;a==null&&(a=l.pos);let c=e.state.tr;if(i){let{node:m}=r;m?m.replace(c):c.deleteSelection()}let f=c.mapping.map(a),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,p=c.doc;if(d?c.replaceRangeWith(f,f,s.content.firstChild):c.replaceRange(f,f,s),c.doc.eq(p))return;let h=c.doc.resolve(f);if(d&&u.NodeSelection.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new u.NodeSelection(h));else{let m=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((E,N,D,Y)=>m=Y),c.setSelection(We(e,h,c.doc.resolve(m)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))};k.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&me(e)},20))};k.blur=(e,n)=>{let t=n;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),t.relatedTarget&&e.dom.contains(t.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};k.beforeinput=(e,n)=>{if(K&&X&&n.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",l=>l(e,Ve(8,"Backspace")))))return;let{$cursor:o}=e.state.selection;o&&o.pos>0&&e.dispatch(e.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let e in S)k[e]=S[e];function U(e,n){if(e==n)return!0;for(let t in e)if(e[t]!==n[t])return!1;for(let t in n)if(!(t in e))return!1;return!0}class _{constructor(n,t){this.toDOM=n,this.spec=t||R,this.side=this.spec.side||0}map(n,t,r,o){let{pos:l,deleted:s}=n.mapResult(t.from+o,this.side<0?-1:1);return s?null:new T(l-r,l-r,this)}valid(){return!0}eq(n){return this==n||n instanceof _&&(this.spec.key&&this.spec.key==n.spec.key||this.toDOM==n.toDOM&&U(this.spec,n.spec))}destroy(n){this.spec.destroy&&this.spec.destroy(n)}}class M{constructor(n,t){this.attrs=n,this.spec=t||R}map(n,t,r,o){let l=n.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,s=n.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return l>=s?null:new T(l,s,this)}valid(n,t){return t.from<t.to}eq(n){return this==n||n instanceof M&&U(this.attrs,n.attrs)&&U(this.spec,n.spec)}static is(n){return n.type instanceof M}destroy(){}}class be{constructor(n,t){this.attrs=n,this.spec=t||R}map(n,t,r,o){let l=n.mapResult(t.from+o,1);if(l.deleted)return null;let s=n.mapResult(t.to+o,-1);return s.deleted||s.pos<=l.pos?null:new T(l.pos-r,s.pos-r,this)}valid(n,t){let{index:r,offset:o}=n.content.findIndex(t.from),l;return o==t.from&&!(l=n.child(r)).isText&&o+l.nodeSize==t.to}eq(n){return this==n||n instanceof be&&U(this.attrs,n.attrs)&&U(this.spec,n.spec)}destroy(){}}class T{constructor(n,t,r){this.from=n,this.to=t,this.type=r}copy(n,t){return new T(n,t,this.type)}eq(n,t=0){return this.type.eq(n.type)&&this.from+t==n.from&&this.to+t==n.to}map(n,t,r){return this.type.map(n,this,t,r)}static widget(n,t,r){return new T(n,n,new _(t,r))}static inline(n,t,r,o){return new T(n,t,new M(r,o))}static node(n,t,r,o){return new T(n,t,new be(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof M}get widget(){return this.type instanceof _}}const B=[],R={};class g{constructor(n,t){this.local=n.length?n:B,this.children=t.length?t:B}static create(n,t){return t.length?w(t,n,0,R):b}find(n,t,r){let o=[];return this.findInner(n??0,t??1e9,o,0,r),o}findInner(n,t,r,o,l){for(let s=0;s<this.local.length;s++){let i=this.local[s];i.from<=t&&i.to>=n&&(!l||l(i.spec))&&r.push(i.copy(i.from+o,i.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>n){let i=this.children[s]+1;this.children[s+2].findInner(n-i,t-i,r,o+i,l)}}map(n,t,r){return this==b||n.maps.length==0?this:this.mapInner(n,t,0,0,r||R)}mapInner(n,t,r,o,l){let s;for(let i=0;i<this.local.length;i++){let a=this.local[i].map(n,r,o);a&&a.type.valid(t,a)?(s||(s=[])).push(a):l.onRemove&&l.onRemove(this.local[i].spec)}return this.children.length?_t(this.children,s||[],n,t,r,o,l):s?new g(s.sort(L),B):b}add(n,t){return t.length?this==b?g.create(n,t):this.addInner(n,t,0):this}addInner(n,t,r){let o,l=0;n.forEach((i,a)=>{let c=a+r,f;if(f=rt(t,i,c)){for(o||(o=this.children.slice());l<o.length&&o[l]<a;)l+=3;o[l]==a?o[l+2]=o[l+2].addInner(i,f,c+1):o.splice(l,0,a,a+i.nodeSize,w(f,i,c+1,R)),l+=3}});let s=nt(l?ot(t):t,-r);for(let i=0;i<s.length;i++)s[i].type.valid(n,s[i])||s.splice(i--,1);return new g(s.length?this.local.concat(s).sort(L):this.local,o||this.children)}remove(n){return n.length==0||this==b?this:this.removeInner(n,0)}removeInner(n,t){let r=this.children,o=this.local;for(let l=0;l<r.length;l+=3){let s,i=r[l]+t,a=r[l+1]+t;for(let f=0,d;f<n.length;f++)(d=n[f])&&d.from>i&&d.to<a&&(n[f]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[l+2].removeInner(s,i+1);c!=b?r[l+2]=c:(r.splice(l,3),l-=3)}if(o.length){for(let l=0,s;l<n.length;l++)if(s=n[l])for(let i=0;i<o.length;i++)o[i].eq(s,t)&&(o==this.local&&(o=this.local.slice()),o.splice(i--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new g(o,r):b}forChild(n,t){if(this==b)return this;if(t.isLeaf)return g.empty;let r,o;for(let i=0;i<this.children.length;i+=3)if(this.children[i]>=n){this.children[i]==n&&(r=this.children[i+2]);break}let l=n+1,s=l+t.content.size;for(let i=0;i<this.local.length;i++){let a=this.local[i];if(a.from<s&&a.to>l&&a.type instanceof M){let c=Math.max(l,a.from)-l,f=Math.min(s,a.to)-l;c<f&&(o||(o=[])).push(a.copy(c,f))}}if(o){let i=new g(o.sort(L),B);return r?new I([i,r]):i}return r||b}eq(n){if(this==n)return!0;if(!(n instanceof g)||this.local.length!=n.local.length||this.children.length!=n.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(n.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=n.children[t]||this.children[t+1]!=n.children[t+1]||!this.children[t+2].eq(n.children[t+2]))return!1;return!0}locals(n){return Se(this.localsInner(n))}localsInner(n){if(this==b)return B;if(n.inlineContent||!this.local.some(M.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof M||t.push(this.local[r]);return t}forEachSet(n){n(this)}}g.empty=new g([],[]);g.removeOverlap=Se;const b=g.empty;class I{constructor(n){this.members=n}map(n,t){const r=this.members.map(o=>o.map(n,t,R));return I.from(r)}forChild(n,t){if(t.isLeaf)return g.empty;let r=[];for(let o=0;o<this.members.length;o++){let l=this.members[o].forChild(n,t);l!=b&&(l instanceof I?r=r.concat(l.members):r.push(l))}return I.from(r)}eq(n){if(!(n instanceof I)||n.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(n.members[t]))return!1;return!0}locals(n){let t,r=!0;for(let o=0;o<this.members.length;o++){let l=this.members[o].localsInner(n);if(l.length)if(!t)t=l;else{r&&(t=t.slice(),r=!1);for(let s=0;s<l.length;s++)t.push(l[s])}}return t?Se(r?t:t.sort(L)):B}static from(n){switch(n.length){case 0:return b;case 1:return n[0];default:return new I(n.every(t=>t instanceof g)?n:n.reduce((t,r)=>t.concat(r instanceof g?r:r.members),[]))}}forEachSet(n){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(n)}}function _t(e,n,t,r,o,l,s){let i=e.slice();for(let c=0,f=l;c<t.maps.length;c++){let d=0;t.maps[c].forEach((p,h,m,E)=>{let N=E-m-(h-p);for(let D=0;D<i.length;D+=3){let Y=i[D+1];if(Y<0||p>Y+f-d)continue;let Ce=i[D]+f-d;h>=Ce?i[D+1]=p<=Ce?-2:-1:p>=f&&N&&(i[D]+=N,i[D+1]+=N)}d+=N}),f=t.maps[c].map(f,-1)}let a=!1;for(let c=0;c<i.length;c+=3)if(i[c+1]<0){if(i[c+1]==-2){a=!0,i[c+1]=-1;continue}let f=t.map(e[c]+l),d=f-o;if(d<0||d>=r.content.size){a=!0;continue}let p=t.map(e[c+1]+l,-1),h=p-o,{index:m,offset:E}=r.content.findIndex(d),N=r.maybeChild(m);if(N&&E==d&&E+N.nodeSize==h){let D=i[c+2].mapInner(t,N,f+1,e[c]+l+1,s);D!=b?(i[c]=d,i[c+1]=h,i[c+2]=D):(i[c+1]=-2,a=!0)}else a=!0}if(a){let c=wt(i,e,n,t,o,l,s),f=w(c,r,0,s);n=f.local;for(let d=0;d<i.length;d+=3)i[d+1]<0&&(i.splice(d,3),d-=3);for(let d=0,p=0;d<f.children.length;d+=3){let h=f.children[d];for(;p<i.length&&i[p]<h;)p+=3;i.splice(p,0,f.children[d],f.children[d+1],f.children[d+2])}}return new g(n.sort(L),i)}function nt(e,n){if(!n||!e.length)return e;let t=[];for(let r=0;r<e.length;r++){let o=e[r];t.push(new T(o.from+n,o.to+n,o.type))}return t}function wt(e,n,t,r,o,l,s){function i(a,c){for(let f=0;f<a.local.length;f++){let d=a.local[f].map(r,o,c);d?t.push(d):s.onRemove&&s.onRemove(a.local[f].spec)}for(let f=0;f<a.children.length;f+=3)i(a.children[f+2],a.children[f]+c+1)}for(let a=0;a<e.length;a+=3)e[a+1]==-1&&i(e[a+2],n[a]+l+1);return t}function rt(e,n,t){if(n.isLeaf)return null;let r=t+n.nodeSize,o=null;for(let l=0,s;l<e.length;l++)(s=e[l])&&s.from>t&&s.to<r&&((o||(o=[])).push(s),e[l]=null);return o}function ot(e){let n=[];for(let t=0;t<e.length;t++)e[t]!=null&&n.push(e[t]);return n}function w(e,n,t,r){let o=[],l=!1;n.forEach((i,a)=>{let c=rt(e,i,a+t);if(c){l=!0;let f=w(c,i,t+a+1,r);f!=b&&o.push(a,a+i.nodeSize,f)}});let s=nt(l?ot(e):e,-t).sort(L);for(let i=0;i<s.length;i++)s[i].type.valid(n,s[i])||(r.onRemove&&r.onRemove(s[i].spec),s.splice(i--,1));return s.length||o.length?new g(s,o):b}function L(e,n){return e.from-n.from||e.to-n.to}function Se(e){let n=e;for(let t=0;t<n.length-1;t++){let r=n[t];if(r.from!=r.to)for(let o=t+1;o<n.length;o++){let l=n[o];if(l.from==r.from){l.to!=r.to&&(n==e&&(n=e.slice()),n[o]=l.copy(l.from,r.to),Re(n,o+1,l.copy(r.to,l.to)));continue}else{l.from<r.to&&(n==e&&(n=e.slice()),n[t]=r.copy(r.from,l.from),Re(n,o,r.copy(l.from,r.to)));break}}}return n}function Re(e,n,t){for(;n<e.length&&L(t,e[n])>0;)n++;e.splice(n,0,t)}exports.Decoration=T;exports.DecorationSet=g;exports.keydownHandler=ut;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const i=require("./index-RfTlOzIr.cjs");var c=20,u=(t,e=0)=>{const r=[];return!t.children.length||e>c||Array.from(t.children).forEach(o=>{o.tagName==="SPAN"?r.push(o):o.children.length&&r.push(...u(o,e+1))}),r},f=t=>{if(!t.children.length)return;const e=u(t);e&&e.forEach(r=>{var o,n;const s=r.getAttribute("style"),l=(n=(o=r.parentElement)==null?void 0:o.closest("span"))==null?void 0:n.getAttribute("style");r.setAttribute("style",`${l};${s}`)})},m=i.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&f(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",i.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(r,o)=>{if(r.isTextblock)return!0;r.marks.filter(n=>n.type===this.type).some(n=>Object.values(n.attrs).some(s=>!!s))||t.removeMark(o,o+r.nodeSize,this.type)}),!0}}}}),g=i.Extension.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const r=t.getAttribute("style");if(r){const o=r.split(";").map(n=>n.trim()).filter(Boolean);for(let n=o.length-1;n>=0;n-=1){const s=o[n].split(":");if(s.length>=2){const l=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(l==="background-color")return a.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),y=i.Extension.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const r=t.getAttribute("style");if(r){const o=r.split(";").map(n=>n.trim()).filter(Boolean);for(let n=o.length-1;n>=0;n-=1){const s=o[n].split(":");if(s.length>=2){const l=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(l==="color")return a.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),p=i.Extension.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),h=i.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),d=i.Extension.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});i.Extension.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(g.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(y.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(p.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(h.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(d.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(m.configure(this.options.textStyle)),t}});exports.Color=y;exports.FontFamily=p;exports.LineHeight=d;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";const v=require("@tiptap/pm/state"),D=require("@tiptap/pm/model");require("@tiptap/pm/view");function It(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let i=r.child(n),s=e.child(n);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=It(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function zt(r,e,t,n){for(let i=r.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:n};let o=r.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,n-=a;continue}if(!o.sameMarkup(l))return{a:t,b:n};if(o.isText&&o.text!=l.text){let c=0,f=Math.min(o.text.length,l.text.length);for(;c<f&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,n--;return{a:t,b:n}}if(o.content.size||l.content.size){let c=zt(o.content,l.content,t-1,n-1);if(c)return c}t-=a,n-=a}}class w{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&n(a,i+l,s||null,o)!==!1&&a.content.size){let f=l+1;a.nodesBetween(Math.max(0,e-f),Math.min(a.content.size,t-f),n,i+f)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&n&&(o?o=!1:s+=n),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new w(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),n.push(l),i+=l.nodeSize),o=a}return new w(n,i)}cutByIndex(e,t){return e==t?w.empty:e==0&&t==this.content.length?this:new w(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new w(i,s)}addToStart(e){return new w([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new w(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return It(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return zt(this,e,t,n)}findIndex(e){if(e==0)return ge(0,e);if(e==this.size)return ge(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let i=this.child(t),s=n+i.nodeSize;if(s>=e)return s==e?ge(t+1,s):ge(t,n);n=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return w.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new w(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return w.empty;let t,n=0;for(let i=0;i<e.length;i++){let s=e[i];n+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new w(t||e,n)}static from(e){if(!e)return w.empty;if(e instanceof w)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new w([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}w.empty=new w([],0);const ze={index:0,offset:0};function ge(r,e){return ze.index=r,ze.offset=e,ze}function Je(r,e){if(r===e)return!0;if(!(r&&typeof r=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(r);if(Array.isArray(e)!=t)return!1;if(t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!Je(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!Je(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}let F=class je{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(s)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Je(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=n.create(t.attrs);return n.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return je.none;if(e instanceof je)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}};F.none=[];class Bn extends Error{}class k{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Pt(this.content,e+this.openStart,t);return n&&new k(n,this.openStart,this.openEnd)}removeBetween(e,t){return new k(Ot(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return k.empty;let n=t.openStart||0,i=t.openEnd||0;if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new k(w.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new k(e,n,i)}}k.empty=new k(w.empty,0,0);function Ot(r,e,t){let{index:n,offset:i}=r.findIndex(e),s=r.maybeChild(n),{index:o,offset:l}=r.findIndex(t);if(i==e||s.isText){if(l!=t&&!r.child(o).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=o)throw new RangeError("Removing non-flat range");return r.replaceChild(n,s.copy(Ot(s.content,e-i-1,t-i-1)))}function Pt(r,e,t,n){let{index:i,offset:s}=r.findIndex(e),o=r.maybeChild(i);if(s==e||o.isText)return n&&!n.canReplace(i,i,t)?null:r.cut(0,e).append(t).append(r.cut(e));let l=Pt(o.content,e-s-1,t,o);return l&&r.replaceChild(i,o.copy(l))}class He{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}function Dn(r){let e=Object.create(null);for(let t in r){let n=r[t];if(!n.hasDefault)return null;e[t]=n.default}return e}function Fn(r,e){let t=Object.create(null);for(let n in r){let i=e&&e[n];if(i===void 0){let s=r[n];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+n)}t[n]=i}return t}function Ln(r,e,t,n){for(let i in e)if(!(i in r))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in r){let s=r[i];s.validate&&s.validate(e[i])}}function Wn(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new jn(r,n,e[n]);return t}function Jn(r,e,t){let n=t.split("|");return i=>{let s=i===null?"null":typeof i;if(n.indexOf(s)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${r}, got ${s}`)}}class jn{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Jn(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Xe{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=Wn(e,i.attrs),this.excluded=null;let s=Dn(this.attrs);this.instance=s?new F(this,s):null}create(e=null){return!e&&this.instance?this.instance:new F(this,Fn(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((s,o)=>n[s]=new Xe(s,i++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Ln(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}function Hn(r){return r.tag!=null}function Vn(r){return r.style!=null}class Me{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(i=>{if(Hn(i))this.tags.push(i);else if(Vn(i)){let s=/[^=]*/.exec(i.style)[0];n.indexOf(s)<0&&n.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let n=new gt(this,t,!1);return n.addAll(e,F.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new gt(this,t,!0);return n.addAll(e,F.none,t.from,t.to),k.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(qn(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,n,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!n.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function n(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{n(o=yt(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{n(o=yt(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Me(e,Me.schemaRules(e)))}}const $t={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},_n={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Bt={ol:!0,ul:!0},ce=1,Ve=2,ae=4;function mt(r,e,t){return e!=null?(e?ce:0)|(e==="full"?Ve:0):r&&r.whitespace=="pre"?ce|Ve:t&~ae}class ye{constructor(e,t,n,i,s,o){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=o,this.content=[],this.activeMarks=F.none,this.match=s||(o&ae?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(w.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,i;return(i=n.findWrapping(e.type))?(this.match=n,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ce)){let n=this.content[this.content.length-1],i;if(n&&n.isText&&(i=/[ \t\r\n\u000c]+$/.exec(n.text))){let s=n;n.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=w.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(w.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!$t.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class gt{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=mt(null,t.preserveWhitespace,0)|(n?ae:0);i?s=new ye(i.type,i.attrs,F.none,!0,t.topMatch||i.type.contentMatch,o):n?s=new ye(null,null,F.none,!0,null,o):s=new ye(e.schema.topNodeType,null,F.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,i=this.top,s=i.options&Ve?"full":this.localPreserveWS||(i.options&ce)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)if(s==="full")n=n.replace(/\r\n?/g,`
|
|
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;Bt.hasOwnProperty(o)&&this.parser.normalizeLists&&Kn(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:_n.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($t.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
|
+
`),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):wt(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=mt(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):wt(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new ye(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 Kn(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Bt.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function qn(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function yt(r){let e={};for(let t in r)e[t]=r[t];return e}function wt(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 Ye{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}=ve(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&&ve(Oe(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return ve(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ye(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=kt(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return kt(e.marks)}}function kt(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 xt=new WeakMap;function Un(r){let e=xt.get(r);return e===void 0&&xt.set(r,e=Xn(r)),e}function Xn(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 ve(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=Un(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}=ve(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 Dt=65535,Ft=Math.pow(2,16);function Yn(r,e){return r+e*Ft}function vt(r){return r&Dt}function Zn(r){return(r-(r&Dt))/Ft}const Lt=1,Wt=2,Se=4,Jt=8;class _e{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Jt)>0}get deletedBefore(){return(this.delInfo&(Lt|Se))>0}get deletedAfter(){return(this.delInfo&(Wt|Se))>0}get deletedAcross(){return(this.delInfo&Se)>0}}class ${constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&$.empty)return $.empty}recover(e){let t=0,n=vt(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+Zn(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:Yn(l/3,e-a),m=e==a?Wt:e==u?Lt:Se;return(t<0?e!=a:e!=u)&&(m|=Jt),new _e(h,m,p)}i+=f-c}return n?e+i:new _e(e+i,0,null)}touches(e,t){let n=0,i=vt(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 _e(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 Bn)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 Q(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 Q 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 Q(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 Q(t.pos,e.markFromJSON(t.mark))}}O.jsonID("removeNodeMark",Q);class N 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 N(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 N(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof N)||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 N(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 N(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 N(t.from,t.to,k.fromJSON(e,t.slice),!!t.structure)}}O.jsonID("replace",N);class R 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 R(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 R(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 R(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}}O.jsonID("replaceAround",R);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 Qn(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 Gn(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 Xe){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 Qe(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 N(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 N(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 er(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||!er(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function tr(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 R(a,c,o,l,new k(f.append(d),u,h),f.size-u,!0))}function Ge(r,e,t=null,n=r){let i=nr(r,e),s=i&&rr(n,e);return s?i.map(St).concat({type:e,attrs:t}).concat(s.map(St)):null}function St(r){return{type:r,attrs:null}}function nr(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 rr(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 ir(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 R(i,s,i,s,new k(n,0,0),t.length,!0))}function sr(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)&&or(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&&Ht(r,o,l,s),Qe(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 R(u,d,u+1,d-1,new k(w.from(n.create(a,null,o.marks)),0,0),1,!0)),c===!0&&jt(r,o,l,s),!1}})}function jt(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 Ht(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
|
+
`))}})}function or(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function lr(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 R(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new k(w.from(o),0,0),1,!0))}function _(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 ar(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 N(e,e,new k(s.append(o),t,t),!0))}function Y(r,e){let t=r.resolve(e),n=t.index();return Vt(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function cr(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 Vt(r,e){return!!(r&&e&&!r.isLeaf&&cr(r,e))}function Ce(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&&Vt(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 fr(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);Ht(r,f.node(),f.before(),l)}o.inlineContent&&Qe(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 N(c,a.map(e+t,-1),k.empty,!0)),n===!0){let f=r.doc.resolve(c);jt(r,f.node(),f.before(),r.steps.length)}return r}function ur(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 dr(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 Te(r,e,t=e,n=k.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),s=r.resolve(t);return _t(i,s,n)?new N(e,t,n):new hr(i,s,n).fit()}function _t(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class hr{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 R(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new N(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(Kt(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 Kt(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,Kt(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&&!pr(t,s.content,o)?l:null}function pr(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function mr(r){return r.spec.defining||r.spec.definingForContent}function gr(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),s=r.doc.resolve(t);if(_t(i,s,n))return r.step(new N(e,t,n));let o=Ut(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=mr(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(qt(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 qt(r,e,t,n,i){if(e<t){let s=r.firstChild;r=r.replaceChild(0,s.copy(qt(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 yr(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=ur(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new k(w.from(n),0,0))}function wr(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t),s=Ut(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 Ut(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 Xt{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}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=Te(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 gr(this,e,t,n),this}replaceRangeWith(e,t,n){return yr(this,e,t,n),this}deleteRange(e,t){return wr(this,e,t),this}lift(e,t){return tr(this,e,t),this}join(e,t=1){return fr(this,e,t),this}wrap(e,t){return ir(this,e,t),this}setBlockType(e,t=e,n,i=null){return sr(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return lr(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 Q(e,t));else{let i=n.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new Q(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 ar(this,e,t,n),this}addMark(e,t,n){return Qn(this,e,t,n),this}removeMark(e,t,n){return Gn(this,e,t,n),this}clearIncompatible(e,t,n){return Qe(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 Yt(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&&Et(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),Et(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 Yt{constructor(e,t){this.$from=e,this.$to=t}}let bt=!1;function Mt(r){!bt&&!r.parent.inlineContent&&(bt=!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){Mt(e),Mt(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 Ae(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 Ae{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ae(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 et(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 et{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Ae(n,n):new et(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 kr}}C.jsonID("all",L);const kr={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 Et(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof N||i instanceof R))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 Ct(r,e){return!e||!r?r:r.bind(e)}class we{constructor(e,t,n){this.name=e,this.init=Ct(t.init,n),this.apply=Ct(t.apply,n)}}new we("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new we("selection",{init(r,e){return r.selection||C.atStart(e.doc)},apply(r){return r.selection}}),new we("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new we("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}});function Zt(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=Zt(i,e,{})),t[n]=i}return t}class xr{constructor(e){this.spec=e,this.props={},e.props&&Zt(e.props,this,this.props),this.key=e.key?e.key.key:Qt("plugin")}getState(e){return e[this.key]}}const Fe=Object.create(null);function Qt(r){return r in Fe?r+"$"+ ++Fe[r]:(Fe[r]=0,r+"$")}class vr{constructor(e="key"){this.key=Qt(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 Gt(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const en=(r,e,t)=>{let n=Gt(r,t);if(!n)return!1;let i=tt(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(fn(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=Te(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},Sr=(r,e,t)=>{let n=Gt(r,t);if(!n)return!1;let i=tt(n);return i?tn(r,i,e):!1},br=(r,e,t)=>{let n=rn(r,t);if(!n)return!1;let i=nt(n);return i?tn(r,i,e):!1};function tn(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=Te(r.doc,s,a,k.empty);if(!c||c.from!=s||c instanceof N&&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 nn=(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=tt(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 tt(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 rn(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const sn=(r,e,t)=>{let n=rn(r,t);if(!n)return!1;let i=nt(n);if(!i)return!1;let s=i.nodeAfter;if(fn(r,i,e,1))return!0;if(n.parent.content.size==0&&(ne(s,"start")||E.isSelectable(s))){let o=Te(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},on=(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=nt(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 nt(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 Mr=(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=Ce(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},Er=(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=Ce(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},Cr=(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)},ln=(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 rt(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 Tr=(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=rt(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},an=(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=rt(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},cn=(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(_(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 Ar(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof E&&e.selection.node.isBlock)return!n.parentOffset||!_(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=rt(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=_(f.doc,u,s.length,s);if(d||(s[0]=l?{type:l}:null,d=_(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 Nr=Ar(),Rr=(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 Ir(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 fn(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Ir(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 R(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 R(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 un(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 zr=un(-1),Or=un(1);function Pr(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Ge(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Tt(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 it(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}it(Ne,en,nn);it(Ne,sn,on);it(ln,an,cn,Nr);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function $r(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 Br(l,o,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function Br(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=Ge(s,t,n,e);return l?(r&&Dr(r,e,l,i,t),!0):!1}function Dr(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 R(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&&_(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(f).nodeSize;return r}function Fr(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?Lr(e,t,r,s):Wr(e,t,s):!0:!1}}function Lr(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);s<o&&(i.step(new R(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 Wr(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 R(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 Jr(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 R(d-(c?3:1),h,d,h,u,1,!0)).scrollIntoView())}return!0}}var jr=Object.defineProperty,st=(r,e)=>{for(var t in e)jr(r,t,{get:e[t],enumerable:!0})};function dn(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 Hr=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:dn({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}},hn={};st(hn,{blur:()=>Vr,clearContent:()=>_r,clearNodes:()=>Kr,command:()=>qr,createParagraphNear:()=>Ur,cut:()=>Xr,deleteCurrentNode:()=>Yr,deleteNode:()=>Zr,deleteRange:()=>Qr,deleteSelection:()=>Gr,enter:()=>ei,exitCode:()=>ti,extendMarkRange:()=>ri,first:()=>ii,focus:()=>oi,forEach:()=>li,insertContent:()=>ai,insertContentAt:()=>ui,joinBackward:()=>pi,joinDown:()=>hi,joinForward:()=>mi,joinItemBackward:()=>gi,joinItemForward:()=>yi,joinTextblockBackward:()=>wi,joinTextblockForward:()=>ki,joinUp:()=>di,keyboardShortcut:()=>vi,lift:()=>Si,liftEmptyBlock:()=>bi,liftListItem:()=>Mi,newlineInCode:()=>Ei,resetAttributes:()=>Ci,scrollIntoView:()=>Ti,selectAll:()=>Ai,selectNodeBackward:()=>Ni,selectNodeForward:()=>Ri,selectParentNode:()=>Ii,selectTextblockEnd:()=>zi,selectTextblockStart:()=>Oi,setContent:()=>$i,setMark:()=>Qi,setMeta:()=>Gi,setNode:()=>es,setNodeSelection:()=>ts,setTextDirection:()=>ns,setTextSelection:()=>rs,sinkListItem:()=>is,splitBlock:()=>ss,splitListItem:()=>ls,toggleList:()=>as,toggleMark:()=>cs,toggleNode:()=>fs,toggleWrap:()=>us,undoInputRule:()=>ds,unsetAllMarks:()=>hs,unsetMark:()=>ps,unsetTextDirection:()=>ms,updateAttributes:()=>gs,wrapIn:()=>ys,wrapInList:()=>ws});var Vr=()=>({editor:r,view:e})=>(requestAnimationFrame(()=>{var t;r.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())==null||t.removeAllRanges())}),!0),_r=(r=!0)=>({commands:e})=>e.setContent("",{emitUpdate:r}),Kr=()=>({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},qr=r=>e=>r(e),Ur=()=>({state:r,dispatch:e})=>an(r,e),Xr=(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},Yr=()=>({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 Zr=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},Qr=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},Gr=()=>({state:r,dispatch:e})=>Ne(r,e),ei=()=>({commands:r})=>r.keyboardShortcut("Enter"),ti=()=>({state:r,dispatch:e})=>Tr(r,e);function ni(r){return Object.prototype.toString.call(r)==="[object RegExp]"}function Ee(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:ni(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function pn(r,e,t={}){return r.find(n=>n.type===e&&Ee(Object.fromEntries(Object.keys(t).map(i=>[i,n.attrs[i]])),t))}function At(r,e,t={}){return!!pn(r,e,t)}function ot(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),!pn([...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&&At([...r.parent.child(o-1).marks],e,t);)o-=1,l-=r.parent.child(o).nodeSize;for(;a<r.parent.childCount&&At([...r.parent.child(a).marks],e,t);)c+=r.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Z(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 ri=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const s=Z(r,n.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:f}=l;if(i){const u=ot(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},ii=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 lt(r){return r instanceof v.TextSelection}function V(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function si(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,V(0,i,s),V(r.content.size,i,s)):v.TextSelection.create(r,V(e,i,s),V(e,i,s))}function mn(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Re(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var oi=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(Re()||mn())&&n.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(n.hasFocus()&&r===null||r===!1)return!0;if(s&&r===null&&!lt(t.state.selection))return o(),!0;const l=si(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},li=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),ai=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e),gn=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&&gn(n)}return r};function ke(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 gn(t)}function de(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),de("",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(ke(r),t.parseOptions):D.DOMParser.fromSchema(a).parse(ke(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(ke(r),t.parseOptions).content:s.parse(ke(r),t.parseOptions)}return de("",e,t)}function ci(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof N||i instanceof R))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 fi=r=>!("type"in r),ui=(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{de(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=de(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((fi(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&&ci(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},di=()=>({state:r,dispatch:e})=>Mr(r,e),hi=()=>({state:r,dispatch:e})=>Er(r,e),pi=()=>({state:r,dispatch:e})=>en(r,e),mi=()=>({state:r,dispatch:e})=>sn(r,e),gi=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Ce(r.doc,r.selection.$from.pos,-1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},yi=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Ce(r.doc,r.selection.$from.pos,1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},wi=()=>({state:r,dispatch:e})=>Sr(r,e),ki=()=>({state:r,dispatch:e})=>br(r,e);function yn(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function xi(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))Re()||yn()?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 vi=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=xi(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=>Ee(u.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var Si=(r,e={})=>({state:t,dispatch:n})=>{const i=I(r,t.schema);return re(t,i,e)?Cr(t,n):!1},bi=()=>({state:r,dispatch:e})=>cn(r,e),Mi=r=>({state:e,dispatch:t})=>{const n=I(r,e.schema);return Fr(n)(e,t)},Ei=()=>({state:r,dispatch:e})=>ln(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 Ci=(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=Z(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},Ti=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),Ai=()=>({tr:r,dispatch:e})=>{if(e){const t=new v.AllSelection(r.doc);r.setSelection(t)}return!0},Ni=()=>({state:r,dispatch:e})=>nn(r,e),Ri=()=>({state:r,dispatch:e})=>on(r,e),Ii=()=>({state:r,dispatch:e})=>Rr(r,e),zi=()=>({state:r,dispatch:e})=>Or(r,e),Oi=()=>({state:r,dispatch:e})=>zr(r,e);function Pi(r,e,t={},n={}){return de(r,e,{slice:!1,parseOptions:t,errorOnInvalidContent:n.errorOnInvalidContent})}var $i=(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=Pi(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 wn(r,e){const t=Z(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 kn(r,e){const t=new Xt(r);return e.forEach(n=>{n.steps.forEach(i=>{t.step(i)})}),t}function Bi(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 Di(r,e,t){const n=[];return r.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&n.push({node:i,pos:s})}),n}function xn(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 he(r){return e=>xn(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 Fi(r){return typeof r=="function"}function J(r,e=void 0,...t){return Fi(r)?e?r.bind(e)(...t):r(...t):r}function vn(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 Sn(...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=s?s.split(";").map(f=>f.trim()).filter(Boolean):[],a=n[i]?n[i].split(";").map(f=>f.trim()).filter(Boolean):[],c=new Map;a.forEach(f=>{const[u,d]=f.split(":").map(h=>h.trim());c.set(u,d)}),l.forEach(f=>{const[u,d]=f.split(":").map(h=>h.trim());c.set(u,d)}),n[i]=Array.from(c.entries()).map(([f,u])=>`${f}: ${u}`).join("; ")}else n[i]=s}),n},{})}function Li(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)=>Sn(t,n),{})}function bn(r,e,t){const{from:n,to:i}=e,{blockSeparator:s=`
|
|
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 Wi(r,e){const t={from:0,to:r.content.size};return bn(r,t,e)}function Mn(r){return Object.fromEntries(Object.entries(r.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Ji(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 ji(r,e){const t=Ie(typeof e=="string"?e:e.name,r.schema);return t==="node"?Ji(r,e):t==="mark"?wn(r,e):{}}function Hi(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 Vi(r){const e=Hi(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 En(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}})})}),Vi(n)}function at(r,e,t){const n=[];return r===e?t.resolve(r).marks().forEach(i=>{const s=t.resolve(r),o=ot(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 _i=(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 be(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 qe(r,e,t={}){const{empty:n,ranges:i}=r.selection,s=e?Z(e,r.schema):null;if(n)return!!(r.storedMarks||r.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>Ee(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(!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=>Ee(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 Ki(r,e,t={}){if(!e)return re(r,null,t)||qe(r,null,t);const n=Ie(e,r.schema);return n==="node"?re(r,e,t):n==="mark"?qe(r,e,t):!1}var qi=(r,e)=>{const{$from:t,$to:n,$anchor:i}=r.selection;if(e){const s=he(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)},Ui=r=>{const{$from:e,$to:t}=r.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Ue(r,e){const{nodeExtensions:t}=vn(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 ct(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&&(ct(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function Xi(r){return r instanceof v.NodeSelection}function Yi(r,e,t){const i=r.state.doc.content.size,s=V(e,0,i),o=V(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 Zi(r,e,t){var n;const{selection:i}=e;let s=null;if(lt(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 Qi=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Z(r,n.schema);if(i)if(o){const c=wn(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 Zi(n,t,a)},Gi=(r,e)=>({tr:t})=>(t.setMeta(r,e),!0),es=(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})=>Tt(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Tt(s,{...o,...e})(l,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ts=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,i=V(r,0,n.content.size),s=v.NodeSelection.create(n,i);e.setSelection(s)}return!0},ns=(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},rs=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=V(i,o,l),c=V(s,o,l),f=v.TextSelection.create(n,a,c);e.setSelection(f)}return!0},is=r=>({state:e,dispatch:t})=>{const n=I(r,e.schema);return Jr(n)(e,t)};function Rt(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 ss=({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=be(c,l.node().type.name,l.node().attrs);if(s instanceof v.NodeSelection&&s.node.isBlock)return!l.parentOffset||!_(o,l.pos)?!1:(n&&(r&&Rt(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:Bi(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&d?[{type:d,attrs:f}]:void 0,p=_(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&_(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&&Rt(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},ls=(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={...be(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={...be(d,u.type.name,u.attrs),...e},m={...be(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(!_(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=he(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=he(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},as=(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=he(A=>Ue(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(Ue(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()},cs=(r,e={},t={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Z(r,n.schema);return qe(n,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},fs=(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})},us=(r,e={})=>({state:t,commands:n})=>{const i=I(r,t.schema);return re(t,i,e)?n.lift(i):n.wrapIn(i,e)},ds=()=>({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},hs=()=>({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},ps=(r,e={})=>({tr:t,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Z(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=ot(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},ms=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},gs=(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=Z(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},ys=(r,e={})=>({state:t,dispatch:n})=>{const i=I(r,t.schema);return Pr(i,e)(t,n)},ws=(r,e={})=>({state:t,dispatch:n})=>{const i=I(r,t.schema);return $r(i,e)(t,n)},pe=class{constructor(r){var e;this.find=r.find,this.handler=r.handler,this.undoable=(e=r.undoable)!=null?e:!0}};function ks(r){return Object.prototype.toString.call(r).slice(8,-1)}function xe(r){return ks(r)!=="Object"?!1:r.constructor===Object&&Object.getPrototypeOf(r)===Object.prototype}function Cn(r,e){const t={...r};return xe(r)&&xe(e)&&Object.keys(e).forEach(n=>{xe(e[n])&&xe(r[n])?t[n]=Cn(r[n],e[n]):t[n]=e[n]}),t}var ft=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:()=>Cn(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}},xs=class Tn extends ft{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new Tn(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 vs(r){return typeof r=="number"}var ut=class{constructor(r){this.find=r.find,this.handler=r.handler}},Ss={};st(Ss,{ClipboardTextSerializer:()=>bs,Commands:()=>Ms,Delete:()=>Es,Drop:()=>Cs,Editable:()=>Ts,FocusEvents:()=>As,Keymap:()=>Ns,Paste:()=>Rs,Tabindex:()=>Is,TextDirection:()=>zs,focusEventsPluginKey:()=>Nn});var j=class An extends ft{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new An(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},bs=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=Mn(t);return bn(n,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Ms=j.create({name:"commands",addCommands(){return{...hn}}}),Es=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=kn(r.before,[r,...e]);En(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()}}),Cs=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})}}})]}}),Ts=j.create({name:"editable",addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Nn=new v.PluginKey("focusEvents"),As=j.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:r}=this;return[new v.Plugin({key:Nn,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}}}})]}}),Ns=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 Re()||yn()?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)||!ct(t.doc))return;const d=t.tr,h=dn({state:t,transaction:d}),{commands:p}=new Hr({editor:this.editor,state:h});if(p.clearNodes(),!!d.steps.length)return d}})]}}),Rs=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})}}})]}}),Is=j.create({name:"tabindex",addProseMirrorPlugins(){return[new v.Plugin({key:new v.PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),zs=j.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:r}=vn(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 Os(r){return new pe({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(at(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 Ps(r){return new pe({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 $s(r){return new pe({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 Bs(r){return new pe({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&&Ge(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 Ds=r=>"touches"in r,Fs=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(){return this.contentElement}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,Ds(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 Ls(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 Ws(r){return r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Js={};st(Js,{createAtomBlockMarkdownSpec:()=>js,createBlockMarkdownSpec:()=>Hs,createInlineMarkdownSpec:()=>Rn,parseAttributes:()=>dt,parseIndentedBlocks:()=>In,renderNestedMarkdownContent:()=>zn,serializeAttributes:()=>ht});function dt(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 ht(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 js(r){const{nodeName:e,name:t,parseAttributes:n=dt,serializeAttributes:i=ht,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 Hs(r){const{nodeName:e,name:t,getContent:n,parseAttributes:i=dt,serializeAttributes:s=ht,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 me=K.index,Pn=K[1];if(!((p=K[2])!=null&&p.endsWith(":::"))){if(Pn)M+=1;else if(M-=1,M===0){const pt=B.slice(0,me);A=pt.trim();const $n=u.slice(0,b+me+K[0].length);let q=[];if(A)if(l==="block")for(q=h.blockTokens(pt),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:$n,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
|
+
|
|
9
|
+
`);return`:::${c}${m}
|
|
10
|
+
|
|
11
|
+
${g}
|
|
12
|
+
|
|
13
|
+
:::`}}}function Vs(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 _s(r){return Object.entries(r).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function Rn(r){const{nodeName:e,name:t,getContent:n,parseAttributes:i=Vs,serializeAttributes:s=_s,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 In(r,e,t){var n,i,s,o;const l=r.split(`
|
|
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
|
+
`;continue}else return}const p=e.extractItemData(h),{indentLevel:m,mainContent:g}=p;c=`${c}${d}
|
|
16
|
+
`;const y=[g];for(f+=1;f<l.length;){const b=l[f];if(b.trim()===""){const z=l.slice(f+1).findIndex(me=>me.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
|
+
`,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
|
+
`,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 zn(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]),a=[`${i}${l}`];return o&&o.length>0&&o.forEach(c=>{const f=e.renderChildren([c]);if(f){const u=f.split(`
|
|
20
|
+
`).map(d=>d?e.indent(d):"").join(`
|
|
21
|
+
`);a.push(u)}}),a.join(`
|
|
22
|
+
`)}var Ks=class On extends ft{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new On(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},qs=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"&&(Re()||mn())&&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 Us(r){return new ut({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(at(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 Xs(r){return new ut({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=Me;exports.DOMSerializer=Ye;exports.Extension=j;exports.Fragment=w;exports.InputRule=pe;exports.Mapping=fe;exports.Mark=xs;exports.Node3=Ks;exports.NodeSelection=E;exports.NodeView=qs;exports.PasteRule=ut;exports.Plugin=xr;exports.PluginKey=vr;exports.ResizableNodeView=Fs;exports.Selection=C;exports.SelectionRange=Yt;exports.Slice=k;exports.TextSelection=P;exports.Transform=Xt;exports.callOrReturn=J;exports.canInsertNode=Ls;exports.combineTransactionSteps=kn;exports.createInlineMarkdownSpec=Rn;exports.deleteSelection=Ne;exports.dropPoint=dr;exports.escapeForRegEx=Ws;exports.findChildrenInRange=Di;exports.findParentNode=he;exports.findParentNodeClosestToPos=xn;exports.getAttributes=ji;exports.getChangedRanges=En;exports.getExtensionField=ie;exports.getMarksBetween=at;exports.getNodeAtPosition=_i;exports.getNodeType=I;exports.getRenderedAttributes=Li;exports.getText=Wi;exports.getTextSerializersFromSchema=Mn;exports.isActive=Ki;exports.isAtEndOfNode=qi;exports.isAtStartOfNode=Ui;exports.isList=Ue;exports.isNodeActive=re;exports.isNodeEmpty=ct;exports.isNodeSelection=Xi;exports.isNumber=vs;exports.isTextSelection=lt;exports.markInputRule=Os;exports.markPasteRule=Us;exports.mergeAttributes=Sn;exports.nodeInputRule=Ps;exports.nodePasteRule=Xs;exports.parseIndentedBlocks=In;exports.posToDOMRect=Yi;exports.renderNestedMarkdownContent=zn;exports.textblockTypeInputRule=$s;exports.wrappingInputRule=Bs;
|