@alxgrn/prose-editor 0.0.51 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/prose-editor.umd.js +13 -13
- package/package.json +2 -2
package/dist/prose-editor.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(_,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("react-dom"),require("@alxgrn/telefrag-ui")):typeof define=="function"&&define.amd?define(["exports","react","react-dom","@alxgrn/telefrag-ui"],m):(_=typeof globalThis<"u"?globalThis:_||self,m(_.ProseEditor={},_.React,_.ReactDOM,_["@alxgrn/telefrag-ui"]))})(this,function(_,m,Re,v){"use strict";var sg=Object.defineProperty;var og=(_,m,Re)=>m in _?sg(_,m,{enumerable:!0,configurable:!0,writable:!0,value:Re}):_[m]=Re;var B=(_,m,Re)=>og(_,typeof m!="symbol"?m+"":m,Re);var qs=document.createElement("style");qs.textContent=`placeholder.ProseMirror-widget{display:flex;align-items:center;justify-content:center;margin:var(--alxgrn-unit) auto;border-radius:var(--alxgrn-unit-small);width:100%;height:200px;background-color:var(--alxgrn-logo-color-beige);font-style:normal;font-weight:400;font-size:var(--alxgrn-font-size)}placeholder.ProseMirror-widget:after{content:"Загрузка..."}div.carousel div.carousel-list span{display:block;scroll-snap-align:start;flex:0 0 auto;width:100%;margin:0}div.carousel placeholder.ProseMirror-widget{height:unset;aspect-ratio:16 / 9;margin:0}.MenuItem{display:flex;align-items:center;justify-content:center;cursor:pointer;padding:var(--alxgrn-unit-smallest)}.MenuItem.active{background:var(--alxgrn-bg-accent);border-radius:var(--alxgrn-unit-smallest)}.MenuItem.disabled{cursor:default;opacity:.3}.MenuBlock{flex:0 0 auto;display:flex;align-items:center;gap:var(--alxgrn-unit-small);border-right:1px solid var(--alxgrn-border);padding-right:var(--alxgrn-unit-small)}.MenuBlock:last-child{border-right:none;padding-right:0;flex:1 1 auto;justify-content:flex-end}.SimpleMenuBar{display:flex;align-items:center;gap:var(--alxgrn-unit-small);flex-wrap:wrap;padding:var(--alxgrn-unit-small)}.ProseMirror{position:relative;outline:none;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0}.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{-webkit-user-select:text;user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf;border-radius:var(--alxgrn-unit-half)}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:calc(-2px - var(--alxgrn-unit-double));right:-2px;top:-2px;bottom:-2px;border:2px solid #8cf;pointer-events:none;border-radius:var(--alxgrn-unit-half)}.ProseMirror-gapcursor{display:none;pointer-events:none;position:absolute}.ProseMirror-gapcursor:after{content:"";display:block;position:absolute;top:-2px;width:20px;border-top:1px solid black;animation:ProseMirror-cursor-blink 1.1s steps(2,start) infinite}@keyframes ProseMirror-cursor-blink{to{visibility:hidden}}.ProseMirror-focused .ProseMirror-gapcursor{display:block}:root{--prose-button-bg: rgba(136, 136, 136, .9);--prose-button-color: #fff;--prose-button-bg-hover: rgba(136, 136, 136, 1);--prose-button-color-hover: #fff;--prose-button-accent-bg: rgba(70, 130, 180, .9);--prose-button-accent-color: #fff;--prose-button-accent-bg-hover: rgba(70, 130, 180, 1);--prose-button-accent-color-hover: #fff}.ProseViewer{display:block}.ProseViewer .unknown_node_type{display:block;color:red}.ProseNotes p,.ProseEditor p,.ProseViewer p{margin:var(--alxgrn-unit) 0;padding:0}.ProseNotes p:first-child,.ProseEditor p:first-child,.ProseViewer p:first-child{margin-top:0}.ProseNotes p:last-child,.ProseEditor p:last-child,.ProseViewer p:last-child{margin-bottom:0}.ProseNotes ul,.ProseEditor ul,.ProseViewer ul,.ProseNotes ol,.ProseEditor ol,.ProseViewer ol{margin:var(--alxgrn-unit) 0;padding:0}.ProseNotes ul ul,.ProseEditor ul ul,.ProseViewer ul ul,.ProseNotes ul ol,.ProseEditor ul ol,.ProseViewer ul ol,.ProseNotes ol ul,.ProseEditor ol ul,.ProseViewer ol ul,.ProseNotes ol ol,.ProseEditor ol ol,.ProseViewer ol ol,.ProseNotes ul p,.ProseEditor ul p,.ProseViewer ul p,.ProseNotes ol p,.ProseEditor ol p,.ProseViewer ol p{margin:0}.ProseNotes li,.ProseEditor li,.ProseViewer li{padding:0;margin:0;margin-left:var(--alxgrn-unit-double)}.ProseNotes blockquote,.ProseEditor blockquote,.ProseViewer blockquote{display:block;margin:0;border-left:var(--alxgrn-unit-small) solid var(--alxgrn-color-accent);margin:var(--alxgrn-unit) 0;padding:var(--alxgrn-unit-half);border-radius:var(--alxgrn-unit-small);background-color:var(--alxgrn-bg-accent)}.ProseNotes div.image,.ProseEditor div.image,.ProseViewer div.image,.ProseNotes div.video,.ProseEditor div.video,.ProseViewer div.video{display:block;margin:var(--alxgrn-unit) auto;text-align:center;position:relative}.ProseViewer div.video .video-switcher,.ProseEditor div.video .video-switcher,.ProseNotes div.video .video-switcher{position:absolute;display:flex;gap:var(--alxgrn-unit-small);margin:var(--alxgrn-unit-small);z-index:10}.ProseViewer div.video .video-switcher div,.ProseEditor div.video .video-switcher div,.ProseNotes div.video .video-switcher div{padding:0 var(--alxgrn-unit);font-style:normal;font-size:var(--alxgrn-font-size-small);color:var(--prose-button-color);background-color:var(--prose-button-bg);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);display:flex;align-items:center;justify-content:center}.ProseViewer div.video .video-switcher div:hover,.ProseEditor div.video .video-switcher div:hover,.ProseNotes div.video .video-switcher div:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}.ProseViewer div.video .video-switcher div.active,.ProseEditor div.video .video-switcher div.active,.ProseNotes div.video .video-switcher div.active{color:var(--prose-button-accent-color);background-color:var(--prose-button-accent-bg)}.ProseViewer div.video .video-switcher div.active:hover,.ProseEditor div.video .video-switcher div.active:hover,.ProseNotes div.video .video-switcher div.active:hover{color:var(--prose-button-accent-color-hover);background-color:var(--prose-button-accent-bg-hover)}.ProseViewer div.video .video-title,.ProseEditor div.video .video-title,.ProseNotes div.video .video-title{font-style:italic;display:block;width:80%;margin:0 auto}.ProseNotes div.image img,.ProseEditor div.image img,.ProseViewer div.image img,.ProseNotes div.video img,.ProseEditor div.video img,.ProseViewer div.video img{display:block;border-radius:var(--alxgrn-unit-half);max-width:100%;max-height:75vh;margin:0 auto}.ProseViewer div.image .image-title,.ProseEditor div.image .image-title,.ProseNotes div.image .image-title{font-style:italic;display:block;width:80%;margin:0 auto}.ProseViewer div.image img{cursor:pointer}.ProseViewer div.image:fullscreen{background-color:#000;border-radius:0;display:flex;justify-content:center;align-items:center}.ProseViewer div.image:fullscreen .image-title{display:none}.ProseViewer div.image:fullscreen img{border-radius:0;max-width:100%;max-height:100%}.ProseEditor div.image div.image-buttons{position:absolute;gap:var(--alxgrn-unit-small);top:0;right:0;width:auto;margin:var(--alxgrn-unit-small);display:flex;align-items:stretch;justify-content:stretch}.ProseEditor div.carousel div.carousel-buttons{z-index:10;position:absolute;gap:var(--alxgrn-unit-small);top:0;left:0;width:auto;margin:var(--alxgrn-unit-small);display:flex;align-items:stretch;justify-content:stretch}.ProseViewer div.image div.image-full,.ProseEditor div.image div.image-buttons div,.ProseEditor div.carousel div.carousel-buttons div{display:flex;align-items:center;justify-content:center;color:var(--prose-button-color);background-color:var(--prose-button-bg);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);padding:0;z-index:10}.ProseViewer div.image div.image-full{position:absolute;top:var(--alxgrn-unit-half);right:var(--alxgrn-unit-half)}.ProseViewer div.image div.image-full:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}.ProseEditor div.image div.image-buttons div.text-button,.ProseEditor div.carousel div.carousel-buttons div.text-button{width:unset;padding:0 var(--alxgrn-unit);font-style:normal;font-size:var(--alxgrn-font-size-small)}.ProseEditor div.image div.image-buttons div:hover,.ProseEditor div.carousel div.carousel-buttons div:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}.ProseNotes div.image div.image-buttons{display:none}.ProseNotes div.video iframe,.ProseEditor div.video iframe,.ProseViewer div.video iframe{display:block;border-radius:var(--alxgrn-unit-half);width:100%;aspect-ratio:16 / 9;border:none;margin:0 auto;background-color:var(--alxgrn-border)}.ProseNotes pre,.ProseEditor pre,.ProseViewer pre{white-space:pre-wrap;background-color:var(--alxgrn-bg-light);border-radius:var(--alxgrn-unit-small);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseViewer hr,.ProseEditor hr{display:block;border:none;border-top:1px solid var(--alxgrn-border);margin:var(--alxgrn-unit) 0}.ProseViewer table{width:100%;margin:var(--alxgrn-unit) 0;border-spacing:0}.ProseViewer th,.ProseViewer td{text-align:left;vertical-align:top;min-width:var(--alxgrn-unit);border-right:1px solid var(--alxgrn-border);border-bottom:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseViewer th{font-weight:700;text-align:center;vertical-align:middle;background-color:var(--alxgrn-bg-light)}.ProseViewer th:first-child,.ProseViewer td:first-child{border-left:1px solid var(--alxgrn-border)}.ProseViewer tr:first-child>th,.ProseViewer tr:first-child>td{border-top:1px solid var(--alxgrn-border)}.ProseViewer tr:first-child>th:first-child,.ProseViewer tr:first-child>td:first-child{border-top-left-radius:var(--alxgrn-unit-small)}.ProseViewer tr:first-child>th:last-child,.ProseViewer tr:first-child>td:last-child{border-top-right-radius:var(--alxgrn-unit-small)}.ProseViewer tr:last-child>th:first-child,.ProseViewer tr:last-child>td:first-child{border-bottom-left-radius:var(--alxgrn-unit-small)}.ProseViewer tr:last-child>th:last-child,.ProseViewer tr:last-child>td:last-child{border-bottom-right-radius:var(--alxgrn-unit-small)}.ProseNotes{display:flex;gap:var(--alxgrn-unit-half);flex-direction:column}.ProseNotesContent{border:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small);border-radius:var(--alxgrn-unit-small)}.ProseNotesTitle,.ProseNotesTitle:focus{width:100%;color:var(--alxgrn-color-text);border:1px solid var(--alxgrn-border);border-radius:var(--alxgrn-unit-small);background-color:transparent;outline:none;padding:var(--alxgrn-unit-half);font-size:var(--alxgrn-font-size)}.ProseNotesTitle::placeholder{color:var(--alxgrn-color-text);opacity:.5;font-style:italic}.ProseNotes .ProseMirror{overflow:auto;min-height:20vh;max-height:45vh;padding:var(--alxgrn-unit-small);padding-right:var(--alxgrn-unit-half);margin-top:var(--alxgrn-unit-small)}.ProseNotesButtons{display:flex;gap:var(--alxgrn-unit);align-items:center;justify-content:flex-end}.ProseNotes .ProseMirror::-webkit-scrollbar{width:var(--alxgrn-unit-small);height:var(--alxgrn-unit-small)}.ProseNotes .ProseMirror::-webkit-scrollbar-track{background-color:transparent;border-radius:var(--alxgrn-unit-small)}.ProseNotes .ProseMirror::-webkit-scrollbar-thumb{background-color:var(--alxgrn-color-scroll);border-radius:var(--alxgrn-unit-small);cursor:default}.ProseNotes .ProseMirror::-webkit-scrollbar-corner{background-color:transparent}.MenuBar{display:flex;align-items:center;gap:var(--alxgrn-unit-small);flex-wrap:wrap;border:none;border-bottom:2px solid var(--alxgrn-color-text)!important;position:sticky;top:var(--alxgrn-layout-header-height);background-color:var(--alxgrn-bg-panel);z-index:100;padding:var(--alxgrn-unit-half) 0;margin-bottom:var(--alxgrn-unit)}.ProseMirror .tableWrapper,.ProseMirror .table-wrapper{overflow:hidden;margin:var(--alxgrn-unit) 0}.ProseMirror .table-resizer{height:var(--alxgrn-unit);position:relative;margin-left:var(--alxgrn-unit)}.ProseMirror .table-resizer div{top:0;height:100%;width:7px;position:absolute;background-color:transparent;cursor:ew-resize;cursor:col-resize;z-index:100}.ProseMirror .table-resizer div:last-child{display:none}.ProseMirror table{position:relative;border-collapse:collapse;table-layout:fixed;width:calc(100% - var(--alxgrn-unit));margin-left:var(--alxgrn-unit)}.ProseMirror td,.ProseMirror th{text-align:left;vertical-align:top;box-sizing:border-box;position:relative;min-width:1em;border:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseMirror th{font-weight:700;text-align:center;vertical-align:middle;background-color:var(--alxgrn-bg-light)}.ProseMirror td:not([data-colwidth]):not(.column-resize-dragging),.ProseMirror th:not([data-colwidth]):not(.column-resize-dragging){min-width:var(--default-cell-min-width)}.ProseMirror .column-resize-handle{position:absolute;right:-2px;top:0;bottom:0;width:4px;z-index:20;background-color:#adf;pointer-events:none}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror .selectedCell{background-color:#adf}.ProseMirror table caption{position:absolute;top:calc(-1 * var(--alxgrn-unit));left:calc(-1 * var(--alxgrn-unit));display:flex;align-items:center;justify-content:center;padding:0;border:none;width:var(--alxgrn-unit);height:var(--alxgrn-unit);font-size:var(--alxgrn-font-size-small);cursor:pointer;color:var(--alxgrn-color-light);background-color:transparent}.ProseMirror table caption:hover{color:var(--alxgrn-color-accent)}.ProseMirror table tbody tr th:first-child:after,.ProseMirror table tbody tr td:first-child:after{content:" ";display:block;background-color:var(--alxgrn-border);position:absolute;top:0;bottom:0;right:100%;width:var(--alxgrn-unit);border-top-left-radius:var(--alxgrn-unit-small);border-bottom-left-radius:var(--alxgrn-unit-small);cursor:pointer}.ProseMirror table tbody tr:last-child th:first-child:after,.ProseMirror table tbody tr:last-child td:first-child:after{bottom:-1px}.ProseMirror table tbody tr:first-child th:before,.ProseMirror table tbody tr:first-child td:before{content:" ";display:block;background-color:var(--alxgrn-border);position:absolute;left:0;right:0;bottom:100%;height:var(--alxgrn-unit);border-top-left-radius:var(--alxgrn-unit-small);border-top-right-radius:var(--alxgrn-unit-small);cursor:pointer}.ProseMirror table tbody tr:first-child th:first-child:before,.ProseMirror table tbody tr:first-child td:first-child:before{left:0}.ProseMirror table tbody tr:first-child th:last-child:before,.ProseMirror table tbody tr:first-child td:last-child:before{right:-1px}.ProseMirror table tr .col-menu:hover,.ProseMirror table tr .row-menu:hover{background-color:var(--alxgrn-color-text)}div.carousel{width:100%;position:relative;text-align:center;margin:var(--alxgrn-unit) 0;border-radius:var(--alxgrn-unit-half);overflow:hidden;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.carousel:fullscreen{display:flex;border-radius:0;background-color:#000;justify-content:center;align-items:center}div.carousel div.carousel-numb,div.carousel div.carousel-full,div.carousel div.carousel-prev,div.carousel div.carousel-next{position:absolute;top:calc(50% - var(--alxgrn-unit));left:var(--alxgrn-unit-small);height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);color:var(--prose-button-color);background-color:var(--prose-button-bg);cursor:pointer;border-radius:var(--alxgrn-unit-small);display:flex;justify-content:center;align-items:center}div.carousel div.carousel-next{left:unset;right:var(--alxgrn-unit-small)}div.carousel div.carousel-numb{top:var(--alxgrn-unit-small);font-size:var(--alxgrn-font-size-small);font-style:normal;padding:0 var(--alxgrn-unit-half);width:unset}div.carousel div.carousel-full{top:var(--alxgrn-unit-small);left:unset;right:var(--alxgrn-unit-small)}div.carousel:hover div.carousel-numb:hover,div.carousel:hover div.carousel-full:hover,div.carousel:hover div.carousel-prev:hover,div.carousel:hover div.carousel-next:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}div.carousel div.carousel-list{display:flex;align-items:center;overflow-x:auto;scroll-snap-type:x mandatory;scroll-behavior:smooth;-webkit-overflow-scrolling:touch}div.carousel div.carousel-list div.image{scroll-snap-align:start;flex:0 0 auto;width:100%;margin:0}div.carousel:fullscreen div.carousel-list div.image .image-title{display:none}div.carousel:fullscreen div.carousel-list div.image img{border-radius:0;max-width:100%;max-height:100%}div.carousel div.carousel-list::-webkit-scrollbar{width:0;height:0}div.carousel div.carousel-list::-webkit-scrollbar-thumb{border:none;background:transparent}div.carousel div.carousel-list::-webkit-scrollbar-track{border:none;background:transparent}.ProseEditor .ProseMirror{min-height:100vh}
|
|
1
|
+
(function(_,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("react-dom"),require("@alxgrn/telefrag-ui")):typeof define=="function"&&define.amd?define(["exports","react","react-dom","@alxgrn/telefrag-ui"],m):(_=typeof globalThis<"u"?globalThis:_||self,m(_.ProseEditor={},_.React,_.ReactDOM,_["@alxgrn/telefrag-ui"]))})(this,function(_,m,Re,v){"use strict";var sg=Object.defineProperty;var og=(_,m,Re)=>m in _?sg(_,m,{enumerable:!0,configurable:!0,writable:!0,value:Re}):_[m]=Re;var B=(_,m,Re)=>og(_,typeof m!="symbol"?m+"":m,Re);var qs=document.createElement("style");qs.textContent=`placeholder.ProseMirror-widget{display:flex;align-items:center;justify-content:center;margin:var(--alxgrn-unit) auto;border-radius:var(--alxgrn-unit-small);width:100%;height:200px;background-color:var(--alxgrn-logo-color-beige);font-style:normal;font-weight:400;font-size:var(--alxgrn-font-size)}placeholder.ProseMirror-widget:after{content:"Загрузка..."}div.carousel div.carousel-list span{display:block;scroll-snap-align:start;flex:0 0 auto;width:100%;margin:0}div.carousel placeholder.ProseMirror-widget{height:unset;aspect-ratio:16 / 9;margin:0}.MenuItem{display:flex;align-items:center;justify-content:center;cursor:pointer;padding:var(--alxgrn-unit-smallest)}.MenuItem.active{background:var(--alxgrn-bg-accent);border-radius:var(--alxgrn-unit-smallest)}.MenuItem.disabled{cursor:default;opacity:.3}.MenuBlock{flex:0 0 auto;display:flex;align-items:center;gap:var(--alxgrn-unit-small);border-right:1px solid var(--alxgrn-border);padding-right:var(--alxgrn-unit-small)}.MenuBlock:last-child{border-right:none;padding-right:0;flex:1 1 auto;justify-content:flex-end}.SimpleMenuBar{display:flex;align-items:center;gap:var(--alxgrn-unit-small);flex-wrap:wrap;padding:var(--alxgrn-unit-small)}.ProseMirror{position:relative;outline:none;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0}.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{-webkit-user-select:text;user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf;border-radius:var(--alxgrn-unit-half)}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:calc(-2px - var(--alxgrn-unit-double));right:-2px;top:-2px;bottom:-2px;border:2px solid #8cf;pointer-events:none;border-radius:var(--alxgrn-unit-half)}.ProseMirror-gapcursor{display:none;pointer-events:none;position:absolute}.ProseMirror-gapcursor:after{content:"";display:block;position:absolute;top:-2px;width:20px;border-top:1px solid black;animation:ProseMirror-cursor-blink 1.1s steps(2,start) infinite}@keyframes ProseMirror-cursor-blink{to{visibility:hidden}}.ProseMirror-focused .ProseMirror-gapcursor{display:block}:root{--prose-button-bg: rgba(136, 136, 136, .9);--prose-button-color: #fff;--prose-button-bg-hover: rgba(136, 136, 136, 1);--prose-button-color-hover: #fff;--prose-button-accent-bg: rgba(70, 130, 180, .9);--prose-button-accent-color: #fff;--prose-button-accent-bg-hover: rgba(70, 130, 180, 1);--prose-button-accent-color-hover: #fff}.ProseViewer{display:block}.ProseViewer .unknown_node_type{display:block;color:red}.ProseNotes p,.ProseEditor p,.ProseViewer p{margin:var(--alxgrn-unit) 0;padding:0}.ProseNotes p:first-child,.ProseEditor p:first-child,.ProseViewer p:first-child{margin-top:0}.ProseNotes p:last-child,.ProseEditor p:last-child,.ProseViewer p:last-child{margin-bottom:0}.ProseNotes ul,.ProseEditor ul,.ProseViewer ul,.ProseNotes ol,.ProseEditor ol,.ProseViewer ol{margin:var(--alxgrn-unit) 0;padding:0}.ProseNotes ul ul,.ProseEditor ul ul,.ProseViewer ul ul,.ProseNotes ul ol,.ProseEditor ul ol,.ProseViewer ul ol,.ProseNotes ol ul,.ProseEditor ol ul,.ProseViewer ol ul,.ProseNotes ol ol,.ProseEditor ol ol,.ProseViewer ol ol,.ProseNotes ul p,.ProseEditor ul p,.ProseViewer ul p,.ProseNotes ol p,.ProseEditor ol p,.ProseViewer ol p{margin:0}.ProseNotes li,.ProseEditor li,.ProseViewer li{padding:0;margin:0;margin-left:var(--alxgrn-unit-double)}.ProseNotes blockquote,.ProseEditor blockquote,.ProseViewer blockquote{display:block;margin:0;border-left:var(--alxgrn-unit-small) solid var(--alxgrn-color-accent);margin:var(--alxgrn-unit) 0;padding:var(--alxgrn-unit-half);border-radius:var(--alxgrn-unit-small);background-color:var(--alxgrn-bg-accent)}.ProseNotes div.image,.ProseEditor div.image,.ProseViewer div.image,.ProseNotes div.video,.ProseEditor div.video,.ProseViewer div.video{display:block;margin:var(--alxgrn-unit) auto;text-align:center;position:relative}.ProseNotes div.image:first-child,.ProseEditor div.image:first-child,.ProseViewer div.image:first-child,.ProseNotes div.video:first-child,.ProseEditor div.video:first-child,.ProseViewer div.video:first-child{margin-top:0}.ProseNotes div.image:last-child,.ProseEditor div.image:last-child,.ProseViewer div.image:last-child,.ProseNotes div.video:last-child,.ProseEditor div.video:last-child,.ProseViewer div.video:last-child{margin-bottom:0}.ProseViewer div.video .video-switcher,.ProseEditor div.video .video-switcher,.ProseNotes div.video .video-switcher{position:absolute;display:flex;gap:var(--alxgrn-unit-small);margin:var(--alxgrn-unit-small);z-index:10}.ProseViewer div.video .video-switcher div,.ProseEditor div.video .video-switcher div,.ProseNotes div.video .video-switcher div{padding:0 var(--alxgrn-unit);font-style:normal;font-size:var(--alxgrn-font-size-small);color:var(--prose-button-color);background-color:var(--prose-button-bg);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);display:flex;align-items:center;justify-content:center}.ProseViewer div.video .video-switcher div:hover,.ProseEditor div.video .video-switcher div:hover,.ProseNotes div.video .video-switcher div:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}.ProseViewer div.video .video-switcher div.active,.ProseEditor div.video .video-switcher div.active,.ProseNotes div.video .video-switcher div.active{color:var(--prose-button-accent-color);background-color:var(--prose-button-accent-bg)}.ProseViewer div.video .video-switcher div.active:hover,.ProseEditor div.video .video-switcher div.active:hover,.ProseNotes div.video .video-switcher div.active:hover{color:var(--prose-button-accent-color-hover);background-color:var(--prose-button-accent-bg-hover)}.ProseViewer div.video .video-title,.ProseEditor div.video .video-title,.ProseNotes div.video .video-title{font-style:italic;display:block;width:80%;margin:0 auto}.ProseNotes div.image img,.ProseEditor div.image img,.ProseViewer div.image img,.ProseNotes div.video img,.ProseEditor div.video img,.ProseViewer div.video img{display:block;border-radius:var(--alxgrn-unit-half);max-width:100%;max-height:75vh;margin:0 auto}.ProseViewer div.image .image-title,.ProseEditor div.image .image-title,.ProseNotes div.image .image-title{font-style:italic;display:block;width:80%;margin:0 auto}.ProseViewer div.image img{cursor:pointer}.ProseViewer div.image:fullscreen{background-color:#000;border-radius:0;display:flex;justify-content:center;align-items:center}.ProseViewer div.image:fullscreen .image-title{display:none}.ProseViewer div.image:fullscreen img{border-radius:0;max-width:100%;max-height:100%}.ProseEditor div.image div.image-buttons{position:absolute;gap:var(--alxgrn-unit-small);top:0;right:0;width:auto;margin:var(--alxgrn-unit-small);display:flex;align-items:stretch;justify-content:stretch}.ProseEditor div.carousel div.carousel-buttons{z-index:10;position:absolute;gap:var(--alxgrn-unit-small);top:0;left:0;width:auto;margin:var(--alxgrn-unit-small);display:flex;align-items:stretch;justify-content:stretch}.ProseViewer div.image div.image-full,.ProseEditor div.image div.image-buttons div,.ProseEditor div.carousel div.carousel-buttons div{display:flex;align-items:center;justify-content:center;color:var(--prose-button-color);background-color:var(--prose-button-bg);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);padding:0;z-index:10}.ProseViewer div.image div.image-full{display:none;position:absolute;top:var(--alxgrn-unit-half);right:var(--alxgrn-unit-half)}.ProseViewer div.image:hover div.image-full{display:flex}.ProseViewer div.image div.image-full:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}.ProseEditor div.image div.image-buttons div.text-button,.ProseEditor div.carousel div.carousel-buttons div.text-button{width:unset;padding:0 var(--alxgrn-unit);font-style:normal;font-size:var(--alxgrn-font-size-small)}.ProseEditor div.image div.image-buttons div:hover,.ProseEditor div.carousel div.carousel-buttons div:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}.ProseNotes div.image div.image-buttons{display:none}.ProseNotes div.video iframe,.ProseEditor div.video iframe,.ProseViewer div.video iframe{display:block;border-radius:var(--alxgrn-unit-half);width:100%;aspect-ratio:16 / 9;border:none;margin:0 auto;background-color:var(--alxgrn-border)}.ProseNotes pre,.ProseEditor pre,.ProseViewer pre{white-space:pre-wrap;background-color:var(--alxgrn-bg-light);border-radius:var(--alxgrn-unit-small);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseViewer hr,.ProseEditor hr{display:block;border:none;border-top:1px solid var(--alxgrn-border);margin:var(--alxgrn-unit) 0}.ProseViewer table{width:100%;margin:var(--alxgrn-unit) 0;border-spacing:0}.ProseViewer th,.ProseViewer td{text-align:left;vertical-align:top;min-width:var(--alxgrn-unit);border-right:1px solid var(--alxgrn-border);border-bottom:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseViewer th{font-weight:700;text-align:center;vertical-align:middle;background-color:var(--alxgrn-bg-light)}.ProseViewer th:first-child,.ProseViewer td:first-child{border-left:1px solid var(--alxgrn-border)}.ProseViewer tr:first-child>th,.ProseViewer tr:first-child>td{border-top:1px solid var(--alxgrn-border)}.ProseViewer tr:first-child>th:first-child,.ProseViewer tr:first-child>td:first-child{border-top-left-radius:var(--alxgrn-unit-small)}.ProseViewer tr:first-child>th:last-child,.ProseViewer tr:first-child>td:last-child{border-top-right-radius:var(--alxgrn-unit-small)}.ProseViewer tr:last-child>th:first-child,.ProseViewer tr:last-child>td:first-child{border-bottom-left-radius:var(--alxgrn-unit-small)}.ProseViewer tr:last-child>th:last-child,.ProseViewer tr:last-child>td:last-child{border-bottom-right-radius:var(--alxgrn-unit-small)}.ProseNotes{display:flex;gap:var(--alxgrn-unit-half);flex-direction:column}.ProseNotesContent{border:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small);border-radius:var(--alxgrn-unit-small)}.ProseNotesTitle,.ProseNotesTitle:focus{width:100%;color:var(--alxgrn-color-text);border:1px solid var(--alxgrn-border);border-radius:var(--alxgrn-unit-small);background-color:transparent;outline:none;padding:var(--alxgrn-unit-half);font-size:var(--alxgrn-font-size)}.ProseNotesTitle::placeholder{color:var(--alxgrn-color-text);opacity:.5;font-style:italic}.ProseNotes .ProseMirror{overflow:auto;min-height:20vh;max-height:45vh;padding:var(--alxgrn-unit-small);padding-right:var(--alxgrn-unit-half);margin-top:var(--alxgrn-unit-small)}.ProseNotesButtons{display:flex;gap:var(--alxgrn-unit);align-items:center;justify-content:flex-end}.ProseNotes .ProseMirror::-webkit-scrollbar{width:var(--alxgrn-unit-small);height:var(--alxgrn-unit-small)}.ProseNotes .ProseMirror::-webkit-scrollbar-track{background-color:transparent;border-radius:var(--alxgrn-unit-small)}.ProseNotes .ProseMirror::-webkit-scrollbar-thumb{background-color:var(--alxgrn-color-scroll);border-radius:var(--alxgrn-unit-small);cursor:default}.ProseNotes .ProseMirror::-webkit-scrollbar-corner{background-color:transparent}.MenuBar{display:flex;align-items:center;gap:var(--alxgrn-unit-small);flex-wrap:wrap;border:none;border-bottom:2px solid var(--alxgrn-color-text)!important;position:sticky;top:var(--alxgrn-layout-header-height);background-color:var(--alxgrn-bg-panel);z-index:100;padding:var(--alxgrn-unit-half) 0;margin-bottom:var(--alxgrn-unit)}.ProseMirror .tableWrapper,.ProseMirror .table-wrapper{overflow:hidden;margin:var(--alxgrn-unit) 0}.ProseMirror .table-resizer{height:var(--alxgrn-unit);position:relative;margin-left:var(--alxgrn-unit)}.ProseMirror .table-resizer div{top:0;height:100%;width:7px;position:absolute;background-color:transparent;cursor:ew-resize;cursor:col-resize;z-index:100}.ProseMirror .table-resizer div:last-child{display:none}.ProseMirror table{position:relative;border-collapse:collapse;table-layout:fixed;width:calc(100% - var(--alxgrn-unit));margin-left:var(--alxgrn-unit)}.ProseMirror td,.ProseMirror th{text-align:left;vertical-align:top;box-sizing:border-box;position:relative;min-width:1em;border:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseMirror th{font-weight:700;text-align:center;vertical-align:middle;background-color:var(--alxgrn-bg-light)}.ProseMirror td:not([data-colwidth]):not(.column-resize-dragging),.ProseMirror th:not([data-colwidth]):not(.column-resize-dragging){min-width:var(--default-cell-min-width)}.ProseMirror .column-resize-handle{position:absolute;right:-2px;top:0;bottom:0;width:4px;z-index:20;background-color:#adf;pointer-events:none}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror .selectedCell{background-color:#adf}.ProseMirror table caption{position:absolute;top:calc(-1 * var(--alxgrn-unit));left:calc(-1 * var(--alxgrn-unit));display:flex;align-items:center;justify-content:center;padding:0;border:none;width:var(--alxgrn-unit);height:var(--alxgrn-unit);font-size:var(--alxgrn-font-size-small);cursor:pointer;color:var(--alxgrn-color-light);background-color:transparent}.ProseMirror table caption:hover{color:var(--alxgrn-color-accent)}.ProseMirror table tbody tr th:first-child:after,.ProseMirror table tbody tr td:first-child:after{content:" ";display:block;background-color:var(--alxgrn-border);position:absolute;top:0;bottom:0;right:100%;width:var(--alxgrn-unit);border-top-left-radius:var(--alxgrn-unit-small);border-bottom-left-radius:var(--alxgrn-unit-small);cursor:pointer}.ProseMirror table tbody tr:last-child th:first-child:after,.ProseMirror table tbody tr:last-child td:first-child:after{bottom:-1px}.ProseMirror table tbody tr:first-child th:before,.ProseMirror table tbody tr:first-child td:before{content:" ";display:block;background-color:var(--alxgrn-border);position:absolute;left:0;right:0;bottom:100%;height:var(--alxgrn-unit);border-top-left-radius:var(--alxgrn-unit-small);border-top-right-radius:var(--alxgrn-unit-small);cursor:pointer}.ProseMirror table tbody tr:first-child th:first-child:before,.ProseMirror table tbody tr:first-child td:first-child:before{left:0}.ProseMirror table tbody tr:first-child th:last-child:before,.ProseMirror table tbody tr:first-child td:last-child:before{right:-1px}.ProseMirror table tr .col-menu:hover,.ProseMirror table tr .row-menu:hover{background-color:var(--alxgrn-color-text)}div.carousel{width:100%;position:relative;text-align:center;margin:var(--alxgrn-unit) 0;border-radius:var(--alxgrn-unit-half);overflow:hidden;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.carousel:fullscreen{display:flex;border-radius:0;background-color:#000;justify-content:center;align-items:center}div.carousel div.carousel-numb,div.carousel div.carousel-full,div.carousel div.carousel-prev,div.carousel div.carousel-next{position:absolute;top:calc(50% - var(--alxgrn-unit));left:var(--alxgrn-unit-small);height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);color:var(--prose-button-color);background-color:var(--prose-button-bg);cursor:pointer;border-radius:var(--alxgrn-unit-small);display:flex;justify-content:center;align-items:center}div.carousel div.carousel-next{left:unset;right:var(--alxgrn-unit-small)}div.carousel div.carousel-numb{top:var(--alxgrn-unit-small);font-size:var(--alxgrn-font-size-small);font-style:normal;padding:0 var(--alxgrn-unit-half);width:unset}div.carousel div.carousel-full{top:var(--alxgrn-unit-small);left:unset;right:var(--alxgrn-unit-small)}div.carousel:hover div.carousel-numb:hover,div.carousel:hover div.carousel-full:hover,div.carousel:hover div.carousel-prev:hover,div.carousel:hover div.carousel-next:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}div.carousel div.carousel-full,div.carousel div.carousel-prev,div.carousel div.carousel-next{display:none}div.carousel:hover div.carousel-full,div.carousel:hover div.carousel-prev,div.carousel:hover div.carousel-next{display:flex}div.carousel div.carousel-list{display:flex;align-items:center;overflow-x:auto;scroll-snap-type:x mandatory;scroll-behavior:smooth;-webkit-overflow-scrolling:touch}div.carousel div.carousel-list div.image{scroll-snap-align:start;flex:0 0 auto;width:100%;margin:0}div.carousel:fullscreen div.carousel-list div.image .image-title{display:none}div.carousel:fullscreen div.carousel-list div.image img{border-radius:0;max-width:100%;max-height:100%}div.carousel div.carousel-list::-webkit-scrollbar{width:0;height:0}div.carousel div.carousel-list::-webkit-scrollbar-thumb{border:none;background:transparent}div.carousel div.carousel-list::-webkit-scrollbar-track{border:none;background:transparent}.ProseEditor .ProseMirror{min-height:100vh}
|
|
2
2
|
/*$vite$:1*/`,document.head.appendChild(qs);function Xa(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ur={exports:{}},Kt={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -15,26 +15,26 @@
|
|
|
15
15
|
*
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var Hs;function Ua(){return Hs||(Hs=1,process.env.NODE_ENV!=="production"&&function(){function r(C){if(C==null)return null;if(typeof C=="function")return C.$$typeof===F?null:C.displayName||C.name||null;if(typeof C=="string")return C;switch(C){case y:return"Fragment";case k:return"Profiler";case x:return"StrictMode";case M:return"Suspense";case T:return"SuspenseList";case X:return"Activity"}if(typeof C=="object")switch(typeof C.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),C.$$typeof){case b:return"Portal";case N:return C.displayName||"Context";case w:return(C._context.displayName||"Context")+".Consumer";case
|
|
18
|
+
*/var Hs;function Ua(){return Hs||(Hs=1,process.env.NODE_ENV!=="production"&&function(){function r(C){if(C==null)return null;if(typeof C=="function")return C.$$typeof===F?null:C.displayName||C.name||null;if(typeof C=="string")return C;switch(C){case y:return"Fragment";case k:return"Profiler";case x:return"StrictMode";case M:return"Suspense";case T:return"SuspenseList";case X:return"Activity"}if(typeof C=="object")switch(typeof C.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),C.$$typeof){case b:return"Portal";case N:return C.displayName||"Context";case w:return(C._context.displayName||"Context")+".Consumer";case O:var R=C.render;return C=C.displayName,C||(C=R.displayName||R.name||"",C=C!==""?"ForwardRef("+C+")":"ForwardRef"),C;case I:return R=C.displayName||null,R!==null?R:r(C.type)||"Memo";case D:R=C._payload,C=C._init;try{return r(C(R))}catch{}}return null}function e(C){return""+C}function t(C){try{e(C);var R=!1}catch{R=!0}if(R){R=console;var W=R.error,H=typeof Symbol=="function"&&Symbol.toStringTag&&C[Symbol.toStringTag]||C.constructor.name||"Object";return W.call(R,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",H),e(C)}}function n(C){if(C===y)return"<>";if(typeof C=="object"&&C!==null&&C.$$typeof===D)return"<...>";try{var R=r(C);return R?"<"+R+">":"<...>"}catch{return"<...>"}}function s(){var C=ae.A;return C===null?null:C.getOwner()}function o(){return Error("react-stack-top-frame")}function i(C){if(ar.call(C,"key")){var R=Object.getOwnPropertyDescriptor(C,"key").get;if(R&&R.isReactWarning)return!1}return C.key!==void 0}function l(C,R){function W(){$a||($a=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",R))}W.isReactWarning=!0,Object.defineProperty(C,"key",{get:W,configurable:!0})}function a(){var C=r(this.type);return Wa[C]||(Wa[C]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),C=this.props.ref,C!==void 0?C:null}function c(C,R,W,H,cr,Ls){var K=W.ref;return C={$$typeof:p,type:C,key:R,props:W,_owner:H},(K!==void 0?K:null)!==null?Object.defineProperty(C,"ref",{enumerable:!1,get:a}):Object.defineProperty(C,"ref",{enumerable:!1,value:null}),C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(C,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(C,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:cr}),Object.defineProperty(C,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ls}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C}function u(C,R,W,H,cr,Ls){var K=R.children;if(K!==void 0)if(H)if(ng(K)){for(H=0;H<K.length;H++)d(K[H]);Object.freeze&&Object.freeze(K)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else d(K);if(ar.call(R,"key")){K=r(C);var qt=Object.keys(R).filter(function(rg){return rg!=="key"});H=0<qt.length?"{key: someKey, "+qt.join(": ..., ")+": ...}":"{key: someKey}",Ja[K+H]||(qt=0<qt.length?"{"+qt.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
19
19
|
let props = %s;
|
|
20
20
|
<%s {...props} />
|
|
21
21
|
React keys must be passed directly to JSX without using spread:
|
|
22
22
|
let props = %s;
|
|
23
|
-
<%s key={someKey} {...props} />`,H,K,qt,K),Ja[K+H]=!0)}if(K=null,W!==void 0&&(t(W),K=""+W),i(R)&&(t(R.key),K=""+R.key),"key"in R){W={};for(var $s in R)$s!=="key"&&(W[$s]=R[$s])}else W=R;return K&&l(W,typeof C=="function"?C.displayName||C.name||"Unknown":C),c(C,K,W,s(),cr,Ls)}function d(C){f(C)?C._store&&(C._store.validated=1):typeof C=="object"&&C!==null&&C.$$typeof===D&&(C._payload.status==="fulfilled"?f(C._payload.value)&&C._payload.value._store&&(C._payload.value._store.validated=1):C._store&&(C._store.validated=1))}function f(C){return typeof C=="object"&&C!==null&&C.$$typeof===p}var h=m,p=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),N=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),F=Symbol.for("react.client.reference"),ae=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ar=Object.prototype.hasOwnProperty,ng=Array.isArray,Fs=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(C){return C()}};var $a,Wa={},_a=h.react_stack_bottom_frame.bind(h,o)(),qa=Fs(n(o)),Ja={};Yt.Fragment=y,Yt.jsx=function(C,R,W){var H=1e4>ae.recentlyCreatedOwnerStacks++;return u(C,R,W,!1,H?Error("react-stack-top-frame"):_a,H?Fs(n(C)):qa)},Yt.jsxs=function(C,R,W){var H=1e4>ae.recentlyCreatedOwnerStacks++;return u(C,R,W,!0,H?Error("react-stack-top-frame"):_a,H?Fs(n(C)):qa)}}()),Yt}process.env.NODE_ENV==="production"?ur.exports=Qa():ur.exports=Ua();var g=ur.exports;function Q(r){this.content=r}Q.prototype={constructor:Q,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return e==-1?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,s=n.find(r),o=n.content.slice();return s==-1?o.push(t||r,e):(o[s+1]=e,t&&(o[s]=t)),new Q(o)},remove:function(r){var e=this.find(r);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Q(t)},addToStart:function(r,e){return new Q([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new Q(t)},addBefore:function(r,e,t){var n=this.remove(e),s=n.content.slice(),o=n.find(r);return s.splice(o==-1?s.length:o,0,e,t),new Q(s)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return r=Q.from(r),r.size?new Q(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=Q.from(r),r.size?new Q(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=Q.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},toObject:function(){var r={};return this.forEach(function(e,t){r[e]=t}),r},get size(){return this.content.length>>1}},Q.from=function(r){if(r instanceof Q)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new Q(e)};function Ks(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let s=r.child(n),o=e.child(n);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=Ks(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function Ys(r,e,t,n){for(let s=r.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:n};let i=r.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,n-=a;continue}if(!i.sameMarkup(l))return{a:t,b:n};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,n--;return{a:t,b:n}}if(i.content.size||l.content.size){let c=Ys(i.content,l.content,t-1,n-1);if(c)return c}t-=a,n-=a}}class S{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,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&n(a,s+l,o||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),n,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&n&&(i?i=!1:o+=n),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(s[s.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new S(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),n.push(l),s+=l.nodeSize),i=a}return new S(n,s)}cutByIndex(e,t){return e==t?S.empty:e==0&&t==this.content.length?this:new S(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return s[e]=t,new S(s,o)}addToStart(e){return new S([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new S(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 s=this.content[t];e(s,n,t),n+=s.nodeSize}}findDiffStart(e,t=0){return Ks(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Ys(this,e,t,n)}findIndex(e,t=-1){if(e==0)return vn(0,e);if(e==this.size)return vn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,s=0;;n++){let o=this.child(n),i=s+o.nodeSize;if(i>=e)return i==e||t>0?vn(n+1,i):vn(n,s);s=i}}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 S.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new S(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return S.empty;let t,n=0;for(let s=0;s<e.length;s++){let o=e[s];n+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new S(t||e,n)}static from(e){if(!e)return S.empty;if(e instanceof S)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new S([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}S.empty=new S([],0);const dr={index:0,offset:0};function vn(r,e){return dr.index=r,dr.offset=e,dr}function Nn(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(!Nn(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!Nn(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}class z{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),n=!0),t&&t.push(o)}}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&&Nn(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 s=n.create(t.attrs);return n.checkAttrs(s.attrs),s}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 z.none;if(e instanceof z)return[e];let t=e.slice();return t.sort((n,s)=>n.type.rank-s.type.rank),t}}z.none=[];class On extends Error{}class O{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=Xs(this.content,e+this.openStart,t);return n&&new O(n,this.openStart,this.openEnd)}removeBetween(e,t){return new O(Gs(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 O.empty;let n=t.openStart||0,s=t.openEnd||0;if(typeof n!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new O(S.fromJSON(e,t.content),n,s)}static maxOpen(e,t=!0){let n=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new O(e,n,s)}}O.empty=new O(S.empty,0,0);function Gs(r,e,t){let{index:n,offset:s}=r.findIndex(e),o=r.maybeChild(n),{index:i,offset:l}=r.findIndex(t);if(s==e||o.isText){if(l!=t&&!r.child(i).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=i)throw new RangeError("Removing non-flat range");return r.replaceChild(n,o.copy(Gs(o.content,e-s-1,t-s-1)))}function Xs(r,e,t,n){let{index:s,offset:o}=r.findIndex(e),i=r.maybeChild(s);if(o==e||i.isText)return r.cut(0,e).append(t).append(r.cut(e));let l=Xs(i.content,e-o-1,t);return l&&r.replaceChild(s,i.copy(l))}function Za(r,e,t){if(t.openStart>r.depth)throw new On("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new On("Inconsistent open depths");return Qs(r,e,t,0)}function Qs(r,e,t,n){let s=r.index(n),o=r.node(n);if(s==e.index(n)&&n<r.depth-t.openStart){let i=Qs(r,e,t,n+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&r.depth==n&&e.depth==n){let i=r.parent,l=i.content;return at(i,l.cut(0,r.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=ec(t,r);return at(o,Zs(r,i,l,e,n))}else return at(o,En(r,e,n))}function Us(r,e){if(!e.type.compatibleContent(r.type))throw new On("Cannot join "+e.type.name+" onto "+r.type.name)}function fr(r,e,t){let n=r.node(t);return Us(n,e.node(t)),n}function lt(r,e){let t=e.length-1;t>=0&&r.isText&&r.sameMarkup(e[t])?e[t]=r.withText(e[t].text+r.text):e.push(r)}function Gt(r,e,t,n){let s=(e||r).node(t),o=0,i=e?e.index(t):s.childCount;r&&(o=r.index(t),r.depth>t?o++:r.textOffset&&(lt(r.nodeAfter,n),o++));for(let l=o;l<i;l++)lt(s.child(l),n);e&&e.depth==t&&e.textOffset&<(e.nodeBefore,n)}function at(r,e){return r.type.checkContent(e),r.copy(e)}function Zs(r,e,t,n,s){let o=r.depth>s&&fr(r,e,s+1),i=n.depth>s&&fr(t,n,s+1),l=[];return Gt(null,r,s,l),o&&i&&e.index(s)==t.index(s)?(Us(o,i),lt(at(o,Zs(r,e,t,n,s+1)),l)):(o&<(at(o,En(r,e,s+1)),l),Gt(e,t,s,l),i&<(at(i,En(t,n,s+1)),l)),Gt(n,null,s,l),new S(l)}function En(r,e,t){let n=[];if(Gt(null,r,t,n),r.depth>t){let s=fr(r,e,t+1);lt(at(s,En(r,e,t+1)),n)}return Gt(e,null,t,n),new S(n)}function ec(r,e){let t=e.depth-r.openStart,s=e.node(t).copy(r.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(S.from(s));return{start:s.resolveNoCache(r.openStart+t),end:s.resolveNoCache(s.content.size-r.openEnd-t)}}class Xt{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],s=e.child(t);return n?e.child(t).cut(n):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=n.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return z.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),s=e.maybeChild(t);if(!n){let l=n;n=s,s=l}let o=n.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)n[o].type.spec.inclusive===!1&&(!s||!n[o].isInSet(s.marks))&&(n=n[o--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Dn(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(n.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new Xt(t,n,o)}static resolveCached(e,t){let n=eo.get(e);if(n)for(let o=0;o<n.elts.length;o++){let i=n.elts[o];if(i.pos==t)return i}else eo.set(e,n=new tc);let s=n.elts[n.i]=Xt.resolve(e,t);return n.i=(n.i+1)%nc,s}}class tc{constructor(){this.elts=[],this.i=0}}const nc=12,eo=new WeakMap;class Dn{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)}}const rc=Object.create(null);class pe{constructor(e,t,n,s=z.none){this.type=e,this.attrs=t,this.marks=s,this.content=n||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,s=0){this.content.nodesBetween(e,t,n,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,s){return this.content.textBetween(e,t,n,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Nn(this.attrs,t||e.defaultAttrs||rc)&&z.sameSet(this.marks,n||z.none)}copy(e=null){return e==this.content?this:new pe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new pe(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return O.empty;let s=this.resolve(e),o=this.resolve(t),i=n?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new O(c,s.depth-i,o.depth-i)}replace(e,t,n){return Za(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let s=this.content.child(t-1);return{node:s,index:t-1,offset:n-s.nodeSize}}resolve(e){return Xt.resolveCached(this,e)}resolveNoCache(e){return Xt.resolve(this,e)}rangeHasMark(e,t,n){let s=!1;return t>e&&this.nodesBetween(e,t,o=>(n.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),to(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=S.empty,s=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=z.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!z.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let s=S.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,n);return o.type.checkAttrs(o.attrs),o}}pe.prototype.text=void 0;class Tn extends pe{constructor(e,t,n,s){if(super(e,t,null,s),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):to(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Tn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Tn(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function to(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}class ct{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new sc(e,t);if(n.next==null)return ct.empty;let s=no(n);n.next&&n.err("Unexpected trailing text");let o=dc(uc(s));return fc(o,n),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let s=this;for(let o=t;s&&o<n;o++)s=s.matchType(e.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let s=[this];function o(i,l){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return S.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=o(d,l.concat(u));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let s=n.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(n.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let s=0;s<n.next.length;s++)e.indexOf(n.next[s].next)==-1&&t(n.next[s].next)}return t(this),e.map((n,s)=>{let o=s+(n.validEnd?"*":" ")+" ";for(let i=0;i<n.next.length;i++)o+=(i?", ":"")+n.next[i].type.name+"->"+e.indexOf(n.next[i].next);return o}).join(`
|
|
24
|
-
`)}}ct.empty=new ct(!0);class sc{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function no(r){let e=[];do e.push(oc(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function oc(r){let e=[];do e.push(ic(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ic(r){let e=cc(r);for(;;)if(r.eat("+"))e={type:"plus",expr:e};else if(r.eat("*"))e={type:"star",expr:e};else if(r.eat("?"))e={type:"opt",expr:e};else if(r.eat("{"))e=lc(r,e);else break;return e}function ro(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function lc(r,e){let t=ro(r),n=t;return r.eat(",")&&(r.next!="}"?n=ro(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function ac(r,e){let t=r.nodeTypes,n=t[e];if(n)return[n];let s=[];for(let o in t){let i=t[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&r.err("No node type or group '"+e+"' found"),s}function cc(r){if(r.eat("(")){let e=no(r);return r.eat(")")||r.err("Missing closing paren"),e}else if(/\W/.test(r.next))r.err("Unexpected token '"+r.next+"'");else{let e=ac(r,r.next).map(t=>(r.inline==null?r.inline=t.isInline:r.inline!=t.isInline&&r.err("Mixing inline and block content"),{type:"name",value:t}));return r.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function uc(r){let e=[[]];return s(o(r,0),t()),e;function t(){return e.push([])-1}function n(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function o(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=o(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return n(l,a),s(o(i.expr,a),a),[n(a)]}else if(i.type=="plus"){let a=t();return s(o(i.expr,l),a),s(o(i.expr,a),a),[n(a)]}else{if(i.type=="opt")return[n(l)].concat(o(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=t();s(o(i.expr,a),u),a=u}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();n(a,u),s(o(i.expr,a),u),a=u}return[n(a)]}else{if(i.type=="name")return[n(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function so(r,e){return e-r}function oo(r,e){let t=[];return n(e),t.sort(so);function n(s){let o=r[s];if(o.length==1&&!o[0].term)return n(o[0].to);t.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&t.indexOf(a)==-1&&n(a)}}}function dc(r){let e=Object.create(null);return t(oo(r,0));function t(n){let s=[];n.forEach(i=>{r[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);oo(r,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[n.join(",")]=new ct(n.indexOf(r.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(so);o.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return o}}function fc(r,e){for(let t=0,n=[r];t<n.length;t++){let s=n[t],o=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),n.indexOf(c)==-1&&n.push(c)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function io(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 lo(r,e){let t=Object.create(null);for(let n in r){let s=e&&e[n];if(s===void 0){let o=r[n];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+n)}t[n]=s}return t}function ao(r,e,t,n){for(let s in e)if(!(s in r))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in r){let o=r[s];o.validate&&o.validate(e[s])}}function co(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new pc(r,n,e[n]);return t}let uo=class Ha{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=co(e,n.attrs),this.defaultAttrs=io(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ct.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:lo(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new pe(this,this.computeAttrs(e),S.from(t),z.setFrom(n))}createChecked(e=null,t,n){return t=S.from(t),this.checkContent(t),new pe(this,this.computeAttrs(e),t,z.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=S.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),o=s&&s.fillBefore(S.empty,!0);return o?new pe(this,e,t.append(o),z.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){ao(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:z.none:e}static compile(e,t){let n=Object.create(null);e.forEach((o,i)=>n[o]=new Ha(o,t,i));let s=t.spec.topNode||"doc";if(!n[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function hc(r,e,t){let n=t.split("|");return s=>{let o=s===null?"null":typeof s;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${r}, got ${o}`)}}class pc{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?hc(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class An{constructor(e,t,n,s){this.name=e,this.rank=t,this.schema=n,this.spec=s,this.attrs=co(e,s.attrs),this.excluded=null;let o=io(this.attrs);this.instance=o?new z(this,o):null}create(e=null){return!e&&this.instance?this.instance:new z(this,lo(this.attrs,e))}static compile(e,t){let n=Object.create(null),s=0;return e.forEach((o,i)=>n[o]=new An(o,s++,t,i)),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){ao(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Pn{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=Q.from(e.nodes),t.marks=Q.from(e.marks||{}),this.nodes=uo.compile(this.spec.nodes,this),this.marks=An.compile(this.spec.marks,this);let n=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=n[i]||(n[i]=ct.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?fo(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:fo(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof uo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,n,s)}text(e,t){let n=this.nodes.text;return new Tn(n,n.defaultAttrs,e,z.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return pe.fromJSON(this,e)}markFromJSON(e){return z.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function fo(r,e){let t=[];for(let n=0;n<e.length;n++){let s=e[n],o=r.marks[s],i=o;if(o)t.push(o);else for(let l in r.marks){let a=r.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}function mc(r){return r.tag!=null}function gc(r){return r.style!=null}let In=class Ws{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(s=>{if(mc(s))this.tags.push(s);else if(gc(s)){let o=/[^=]*/.exec(s.style)[0];n.indexOf(o)<0&&n.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let n=new go(this,t,!1);return n.addAll(e,z.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new go(this,t,!0);return n.addAll(e,z.none,t.from,t.to),O.maxOpen(n.finish())}matchTag(e,t,n){for(let s=n?this.tags.indexOf(n)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(xc(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,t,n,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!n.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function n(s){let o=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<o)break}t.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{n(i=yo(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let o=e.nodes[s].spec.parseDOM;o&&o.forEach(i=>{n(i=yo(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ws(e,Ws.schemaRules(e)))}};const ho={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},yc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},po={ol:!0,ul:!0},Qt=1,hr=2,Vn=4;function mo(r,e,t){return e!=null?(e?Qt:0)|(e==="full"?hr:0):r&&r.whitespace=="pre"?Qt|hr:t&-5}class Rn{constructor(e,t,n,s,o,i){this.type=e,this.attrs=t,this.marks=n,this.solid=s,this.options=i,this.content=[],this.activeMarks=z.none,this.match=o||(i&Vn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,s;return(s=n.findWrapping(e.type))?(this.match=n,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Qt)){let n=this.content[this.content.length-1],s;if(n&&n.isText&&(s=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.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&&!ho.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class go{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let s=t.topNode,o,i=mo(null,t.preserveWhitespace,0)|(n?Vn:0);s?o=new Rn(s.type,s.attrs,z.none,!0,t.topMatch||s.type.contentMatch,i):n?o=new Rn(null,null,z.none,!0,null,i):o=new Rn(e.schema.topNodeType,null,z.none,!0,null,i),this.nodes=[o],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,s=this.top,o=s.options&hr?"full":this.localPreserveWS||(s.options&Qt)>0;if(o==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)o!=="full"?n=n.replace(/\r?\n|\r/g," "):n=n.replace(/\r\n?/g,`
|
|
23
|
+
<%s key={someKey} {...props} />`,H,K,qt,K),Ja[K+H]=!0)}if(K=null,W!==void 0&&(t(W),K=""+W),i(R)&&(t(R.key),K=""+R.key),"key"in R){W={};for(var $s in R)$s!=="key"&&(W[$s]=R[$s])}else W=R;return K&&l(W,typeof C=="function"?C.displayName||C.name||"Unknown":C),c(C,K,W,s(),cr,Ls)}function d(C){f(C)?C._store&&(C._store.validated=1):typeof C=="object"&&C!==null&&C.$$typeof===D&&(C._payload.status==="fulfilled"?f(C._payload.value)&&C._payload.value._store&&(C._payload.value._store.validated=1):C._store&&(C._store.validated=1))}function f(C){return typeof C=="object"&&C!==null&&C.$$typeof===p}var h=m,p=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),N=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),F=Symbol.for("react.client.reference"),ae=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ar=Object.prototype.hasOwnProperty,ng=Array.isArray,Fs=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(C){return C()}};var $a,Wa={},_a=h.react_stack_bottom_frame.bind(h,o)(),qa=Fs(n(o)),Ja={};Yt.Fragment=y,Yt.jsx=function(C,R,W){var H=1e4>ae.recentlyCreatedOwnerStacks++;return u(C,R,W,!1,H?Error("react-stack-top-frame"):_a,H?Fs(n(C)):qa)},Yt.jsxs=function(C,R,W){var H=1e4>ae.recentlyCreatedOwnerStacks++;return u(C,R,W,!0,H?Error("react-stack-top-frame"):_a,H?Fs(n(C)):qa)}}()),Yt}process.env.NODE_ENV==="production"?ur.exports=Qa():ur.exports=Ua();var g=ur.exports;function Q(r){this.content=r}Q.prototype={constructor:Q,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return e==-1?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,s=n.find(r),o=n.content.slice();return s==-1?o.push(t||r,e):(o[s+1]=e,t&&(o[s]=t)),new Q(o)},remove:function(r){var e=this.find(r);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Q(t)},addToStart:function(r,e){return new Q([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new Q(t)},addBefore:function(r,e,t){var n=this.remove(e),s=n.content.slice(),o=n.find(r);return s.splice(o==-1?s.length:o,0,e,t),new Q(s)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return r=Q.from(r),r.size?new Q(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=Q.from(r),r.size?new Q(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=Q.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},toObject:function(){var r={};return this.forEach(function(e,t){r[e]=t}),r},get size(){return this.content.length>>1}},Q.from=function(r){if(r instanceof Q)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new Q(e)};function Ks(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let s=r.child(n),o=e.child(n);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=Ks(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function Ys(r,e,t,n){for(let s=r.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:n};let i=r.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,n-=a;continue}if(!i.sameMarkup(l))return{a:t,b:n};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,n--;return{a:t,b:n}}if(i.content.size||l.content.size){let c=Ys(i.content,l.content,t-1,n-1);if(c)return c}t-=a,n-=a}}class S{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,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&n(a,s+l,o||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),n,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&n&&(i?i=!1:o+=n),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(s[s.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new S(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),n.push(l),s+=l.nodeSize),i=a}return new S(n,s)}cutByIndex(e,t){return e==t?S.empty:e==0&&t==this.content.length?this:new S(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return s[e]=t,new S(s,o)}addToStart(e){return new S([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new S(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 s=this.content[t];e(s,n,t),n+=s.nodeSize}}findDiffStart(e,t=0){return Ks(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Ys(this,e,t,n)}findIndex(e,t=-1){if(e==0)return vn(0,e);if(e==this.size)return vn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,s=0;;n++){let o=this.child(n),i=s+o.nodeSize;if(i>=e)return i==e||t>0?vn(n+1,i):vn(n,s);s=i}}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 S.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new S(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return S.empty;let t,n=0;for(let s=0;s<e.length;s++){let o=e[s];n+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new S(t||e,n)}static from(e){if(!e)return S.empty;if(e instanceof S)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new S([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}S.empty=new S([],0);const dr={index:0,offset:0};function vn(r,e){return dr.index=r,dr.offset=e,dr}function Nn(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(!Nn(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!Nn(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}class z{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),n=!0),t&&t.push(o)}}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&&Nn(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 s=n.create(t.attrs);return n.checkAttrs(s.attrs),s}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 z.none;if(e instanceof z)return[e];let t=e.slice();return t.sort((n,s)=>n.type.rank-s.type.rank),t}}z.none=[];class En extends Error{}class E{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=Xs(this.content,e+this.openStart,t);return n&&new E(n,this.openStart,this.openEnd)}removeBetween(e,t){return new E(Gs(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 E.empty;let n=t.openStart||0,s=t.openEnd||0;if(typeof n!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new E(S.fromJSON(e,t.content),n,s)}static maxOpen(e,t=!0){let n=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new E(e,n,s)}}E.empty=new E(S.empty,0,0);function Gs(r,e,t){let{index:n,offset:s}=r.findIndex(e),o=r.maybeChild(n),{index:i,offset:l}=r.findIndex(t);if(s==e||o.isText){if(l!=t&&!r.child(i).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=i)throw new RangeError("Removing non-flat range");return r.replaceChild(n,o.copy(Gs(o.content,e-s-1,t-s-1)))}function Xs(r,e,t,n){let{index:s,offset:o}=r.findIndex(e),i=r.maybeChild(s);if(o==e||i.isText)return r.cut(0,e).append(t).append(r.cut(e));let l=Xs(i.content,e-o-1,t);return l&&r.replaceChild(s,i.copy(l))}function Za(r,e,t){if(t.openStart>r.depth)throw new En("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new En("Inconsistent open depths");return Qs(r,e,t,0)}function Qs(r,e,t,n){let s=r.index(n),o=r.node(n);if(s==e.index(n)&&n<r.depth-t.openStart){let i=Qs(r,e,t,n+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&r.depth==n&&e.depth==n){let i=r.parent,l=i.content;return at(i,l.cut(0,r.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=ec(t,r);return at(o,Zs(r,i,l,e,n))}else return at(o,On(r,e,n))}function Us(r,e){if(!e.type.compatibleContent(r.type))throw new En("Cannot join "+e.type.name+" onto "+r.type.name)}function fr(r,e,t){let n=r.node(t);return Us(n,e.node(t)),n}function lt(r,e){let t=e.length-1;t>=0&&r.isText&&r.sameMarkup(e[t])?e[t]=r.withText(e[t].text+r.text):e.push(r)}function Gt(r,e,t,n){let s=(e||r).node(t),o=0,i=e?e.index(t):s.childCount;r&&(o=r.index(t),r.depth>t?o++:r.textOffset&&(lt(r.nodeAfter,n),o++));for(let l=o;l<i;l++)lt(s.child(l),n);e&&e.depth==t&&e.textOffset&<(e.nodeBefore,n)}function at(r,e){return r.type.checkContent(e),r.copy(e)}function Zs(r,e,t,n,s){let o=r.depth>s&&fr(r,e,s+1),i=n.depth>s&&fr(t,n,s+1),l=[];return Gt(null,r,s,l),o&&i&&e.index(s)==t.index(s)?(Us(o,i),lt(at(o,Zs(r,e,t,n,s+1)),l)):(o&<(at(o,On(r,e,s+1)),l),Gt(e,t,s,l),i&<(at(i,On(t,n,s+1)),l)),Gt(n,null,s,l),new S(l)}function On(r,e,t){let n=[];if(Gt(null,r,t,n),r.depth>t){let s=fr(r,e,t+1);lt(at(s,On(r,e,t+1)),n)}return Gt(e,null,t,n),new S(n)}function ec(r,e){let t=e.depth-r.openStart,s=e.node(t).copy(r.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(S.from(s));return{start:s.resolveNoCache(r.openStart+t),end:s.resolveNoCache(s.content.size-r.openEnd-t)}}class Xt{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],s=e.child(t);return n?e.child(t).cut(n):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=n.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return z.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),s=e.maybeChild(t);if(!n){let l=n;n=s,s=l}let o=n.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)n[o].type.spec.inclusive===!1&&(!s||!n[o].isInSet(s.marks))&&(n=n[o--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Dn(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(n.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new Xt(t,n,o)}static resolveCached(e,t){let n=eo.get(e);if(n)for(let o=0;o<n.elts.length;o++){let i=n.elts[o];if(i.pos==t)return i}else eo.set(e,n=new tc);let s=n.elts[n.i]=Xt.resolve(e,t);return n.i=(n.i+1)%nc,s}}class tc{constructor(){this.elts=[],this.i=0}}const nc=12,eo=new WeakMap;class Dn{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)}}const rc=Object.create(null);class pe{constructor(e,t,n,s=z.none){this.type=e,this.attrs=t,this.marks=s,this.content=n||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,s=0){this.content.nodesBetween(e,t,n,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,s){return this.content.textBetween(e,t,n,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Nn(this.attrs,t||e.defaultAttrs||rc)&&z.sameSet(this.marks,n||z.none)}copy(e=null){return e==this.content?this:new pe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new pe(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return E.empty;let s=this.resolve(e),o=this.resolve(t),i=n?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new E(c,s.depth-i,o.depth-i)}replace(e,t,n){return Za(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let s=this.content.child(t-1);return{node:s,index:t-1,offset:n-s.nodeSize}}resolve(e){return Xt.resolveCached(this,e)}resolveNoCache(e){return Xt.resolve(this,e)}rangeHasMark(e,t,n){let s=!1;return t>e&&this.nodesBetween(e,t,o=>(n.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),to(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=S.empty,s=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=z.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!z.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let s=S.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,n);return o.type.checkAttrs(o.attrs),o}}pe.prototype.text=void 0;class Tn extends pe{constructor(e,t,n,s){if(super(e,t,null,s),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):to(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Tn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Tn(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function to(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}class ct{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new sc(e,t);if(n.next==null)return ct.empty;let s=no(n);n.next&&n.err("Unexpected trailing text");let o=dc(uc(s));return fc(o,n),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let s=this;for(let o=t;s&&o<n;o++)s=s.matchType(e.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let s=[this];function o(i,l){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return S.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=o(d,l.concat(u));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let s=n.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(n.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let s=0;s<n.next.length;s++)e.indexOf(n.next[s].next)==-1&&t(n.next[s].next)}return t(this),e.map((n,s)=>{let o=s+(n.validEnd?"*":" ")+" ";for(let i=0;i<n.next.length;i++)o+=(i?", ":"")+n.next[i].type.name+"->"+e.indexOf(n.next[i].next);return o}).join(`
|
|
24
|
+
`)}}ct.empty=new ct(!0);class sc{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function no(r){let e=[];do e.push(oc(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function oc(r){let e=[];do e.push(ic(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ic(r){let e=cc(r);for(;;)if(r.eat("+"))e={type:"plus",expr:e};else if(r.eat("*"))e={type:"star",expr:e};else if(r.eat("?"))e={type:"opt",expr:e};else if(r.eat("{"))e=lc(r,e);else break;return e}function ro(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function lc(r,e){let t=ro(r),n=t;return r.eat(",")&&(r.next!="}"?n=ro(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function ac(r,e){let t=r.nodeTypes,n=t[e];if(n)return[n];let s=[];for(let o in t){let i=t[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&r.err("No node type or group '"+e+"' found"),s}function cc(r){if(r.eat("(")){let e=no(r);return r.eat(")")||r.err("Missing closing paren"),e}else if(/\W/.test(r.next))r.err("Unexpected token '"+r.next+"'");else{let e=ac(r,r.next).map(t=>(r.inline==null?r.inline=t.isInline:r.inline!=t.isInline&&r.err("Mixing inline and block content"),{type:"name",value:t}));return r.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function uc(r){let e=[[]];return s(o(r,0),t()),e;function t(){return e.push([])-1}function n(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function o(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=o(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return n(l,a),s(o(i.expr,a),a),[n(a)]}else if(i.type=="plus"){let a=t();return s(o(i.expr,l),a),s(o(i.expr,a),a),[n(a)]}else{if(i.type=="opt")return[n(l)].concat(o(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=t();s(o(i.expr,a),u),a=u}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();n(a,u),s(o(i.expr,a),u),a=u}return[n(a)]}else{if(i.type=="name")return[n(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function so(r,e){return e-r}function oo(r,e){let t=[];return n(e),t.sort(so);function n(s){let o=r[s];if(o.length==1&&!o[0].term)return n(o[0].to);t.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&t.indexOf(a)==-1&&n(a)}}}function dc(r){let e=Object.create(null);return t(oo(r,0));function t(n){let s=[];n.forEach(i=>{r[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);oo(r,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[n.join(",")]=new ct(n.indexOf(r.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(so);o.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return o}}function fc(r,e){for(let t=0,n=[r];t<n.length;t++){let s=n[t],o=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),n.indexOf(c)==-1&&n.push(c)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function io(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 lo(r,e){let t=Object.create(null);for(let n in r){let s=e&&e[n];if(s===void 0){let o=r[n];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+n)}t[n]=s}return t}function ao(r,e,t,n){for(let s in e)if(!(s in r))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in r){let o=r[s];o.validate&&o.validate(e[s])}}function co(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new pc(r,n,e[n]);return t}let uo=class Ha{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=co(e,n.attrs),this.defaultAttrs=io(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ct.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:lo(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new pe(this,this.computeAttrs(e),S.from(t),z.setFrom(n))}createChecked(e=null,t,n){return t=S.from(t),this.checkContent(t),new pe(this,this.computeAttrs(e),t,z.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=S.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),o=s&&s.fillBefore(S.empty,!0);return o?new pe(this,e,t.append(o),z.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){ao(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:z.none:e}static compile(e,t){let n=Object.create(null);e.forEach((o,i)=>n[o]=new Ha(o,t,i));let s=t.spec.topNode||"doc";if(!n[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function hc(r,e,t){let n=t.split("|");return s=>{let o=s===null?"null":typeof s;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${r}, got ${o}`)}}class pc{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?hc(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class An{constructor(e,t,n,s){this.name=e,this.rank=t,this.schema=n,this.spec=s,this.attrs=co(e,s.attrs),this.excluded=null;let o=io(this.attrs);this.instance=o?new z(this,o):null}create(e=null){return!e&&this.instance?this.instance:new z(this,lo(this.attrs,e))}static compile(e,t){let n=Object.create(null),s=0;return e.forEach((o,i)=>n[o]=new An(o,s++,t,i)),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){ao(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Pn{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=Q.from(e.nodes),t.marks=Q.from(e.marks||{}),this.nodes=uo.compile(this.spec.nodes,this),this.marks=An.compile(this.spec.marks,this);let n=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=n[i]||(n[i]=ct.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?fo(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:fo(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof uo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,n,s)}text(e,t){let n=this.nodes.text;return new Tn(n,n.defaultAttrs,e,z.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return pe.fromJSON(this,e)}markFromJSON(e){return z.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function fo(r,e){let t=[];for(let n=0;n<e.length;n++){let s=e[n],o=r.marks[s],i=o;if(o)t.push(o);else for(let l in r.marks){let a=r.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}function mc(r){return r.tag!=null}function gc(r){return r.style!=null}let In=class Ws{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(s=>{if(mc(s))this.tags.push(s);else if(gc(s)){let o=/[^=]*/.exec(s.style)[0];n.indexOf(o)<0&&n.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let n=new go(this,t,!1);return n.addAll(e,z.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new go(this,t,!0);return n.addAll(e,z.none,t.from,t.to),E.maxOpen(n.finish())}matchTag(e,t,n){for(let s=n?this.tags.indexOf(n)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(xc(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,t,n,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!n.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function n(s){let o=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<o)break}t.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{n(i=yo(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let o=e.nodes[s].spec.parseDOM;o&&o.forEach(i=>{n(i=yo(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ws(e,Ws.schemaRules(e)))}};const ho={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},yc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},po={ol:!0,ul:!0},Qt=1,hr=2,Vn=4;function mo(r,e,t){return e!=null?(e?Qt:0)|(e==="full"?hr:0):r&&r.whitespace=="pre"?Qt|hr:t&-5}class Rn{constructor(e,t,n,s,o,i){this.type=e,this.attrs=t,this.marks=n,this.solid=s,this.options=i,this.content=[],this.activeMarks=z.none,this.match=o||(i&Vn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,s;return(s=n.findWrapping(e.type))?(this.match=n,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Qt)){let n=this.content[this.content.length-1],s;if(n&&n.isText&&(s=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.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&&!ho.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class go{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let s=t.topNode,o,i=mo(null,t.preserveWhitespace,0)|(n?Vn:0);s?o=new Rn(s.type,s.attrs,z.none,!0,t.topMatch||s.type.contentMatch,i):n?o=new Rn(null,null,z.none,!0,null,i):o=new Rn(e.schema.topNodeType,null,z.none,!0,null,i),this.nodes=[o],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,s=this.top,o=s.options&hr?"full":this.localPreserveWS||(s.options&Qt)>0;if(o==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)o!=="full"?n=n.replace(/\r?\n|\r/g," "):n=n.replace(/\r\n?/g,`
|
|
25
25
|
`);else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let i=s.content[s.content.length-1],l=e.previousSibling;(!i||l&&l.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let s=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;po.hasOwnProperty(i)&&this.parser.normalizeLists&&bc(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:yc.hasOwnProperty(i))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,u=this.needsBlock;if(ho.hasOwnProperty(i))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
26
|
-
`),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 s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=n.getPropertyValue(o);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(o,i,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,s){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(i,t.attrs||null,n,t.preserveWhitespace);a&&(o=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,n,s);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)}o&&this.sync(l)&&this.open--}addAll(e,t,n,s){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,n){let s,o;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,o=a,!c.length))break;if(a.solid){if(n)break;l+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t,n);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=z.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):bo(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,n,s){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,s)),o}enterInner(e,t,n,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=mo(e,o,i.options);i.options&Vn&&i.content.length==0&&(l|=Vn);let a=z.none;return n=n.filter(c=>(i.type?i.type.allowsMarkType(c.type):bo(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Rn(e,t,a,s,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|=Qt)}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 s=n.length-1;s>=0;s--)e+=n[s].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 s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(n?2:4)&&(this.find[s].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,s=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:n&&a>=o?n.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(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 bc(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&po.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function xc(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function yo(r){let e={};for(let t in r)e[t]=r[t];return e}function bo(r,e){let t=e.schema.nodes;for(let n in t){let s=t[n];if(!s.allowsMarkType(r))continue;let o=[],i=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&i(u))return!0}};if(i(s.contentMatch))return!0}}class ze{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=pr(t).createDocumentFragment());let s=n,o=[];return e.forEach(i=>{if(o.length||i.marks.length){let l=0,a=0;for(;l<o.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)s=o.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(o.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:s}=zn(pr(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let s=this.marks[e.type.name];return s&&zn(pr(n),s(e,t),null,e.attrs)}static renderSpec(e,t,n=null,s){return zn(e,t,n,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ze(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=xo(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return xo(e.marks)}}function xo(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function pr(r){return r.document||window.document}const ko=new WeakMap;function kc(r){let e=ko.get(r);return e===void 0&&ko.set(r,e=wc(r)),e}function wc(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 s=0;s<n.length;s++)t(n[s]);else for(let s in n)t(n[s])}return t(r),e}function zn(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 s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(o=kc(n))&&o.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 i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?r.createElementNS(t,s):r.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)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}=zn(r,f,t,n);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const wo=65535,So=Math.pow(2,16);function Sc(r,e){return r+e*So}function Co(r){return r&wo}function Cc(r){return(r-(r&wo))/So}const Mo=1,vo=2,jn=4,No=8;class mr{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&No)>0}get deletedBefore(){return(this.delInfo&(Mo|jn))>0}get deletedAfter(){return(this.delInfo&(vo|jn))>0}get deletedAcross(){return(this.delInfo&jn)>0}}class me{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&me.empty)return me.empty}recover(e){let t=0,n=Co(e);if(!this.inverted)for(let s=0;s<n;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[n*3]+t+Cc(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 s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+i],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+s+(f<0?0:u);if(n)return h;let p=e==(t<0?a:d)?null:Sc(l/3,e-a),b=e==a?vo:e==d?Mo:jn;return(t<0?e!=a:e!=d)&&(b|=No),new mr(h,b,p)}s+=u-c}return n?e+s:new mr(e+s,0,null)}touches(e,t){let n=0,s=Co(t),o=this.inverted?2:1,i=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+o],u=a+c;if(e<=u&&l==s*3)return!0;n+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[s+t],u=this.ranges[s+n];e(l,l+c,a,a+u),o+=u-c}}invert(){return new me(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?me.empty:new me(e<0?[0,-e,0]:[0,0,e])}}me.empty=new me([]);class Ut{constructor(e,t,n=0,s=e?e.length:0){this.mirror=t,this.from=n,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Ut(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 s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?n+s: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 s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?n-s-1:void 0)}}invert(){let e=new Ut;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 s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return n?e:new mr(e,s,null)}}const gr=Object.create(null);class se{getMap(){return me.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=gr[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 gr)throw new RangeError("Duplicate use of step JSON ID "+e);return gr[e]=t,t.prototype.jsonID=e,t}}class q{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new q(e,null)}static fail(e){return new q(null,e)}static fromReplace(e,t,n,s){try{return q.ok(e.replace(t,n,s))}catch(o){if(o instanceof On)return q.fail(o.message);throw o}}}function yr(r,e,t){let n=[];for(let s=0;s<r.childCount;s++){let o=r.child(s);o.content.size&&(o=o.copy(yr(o.content,e,o))),o.isInline&&(o=e(o,t,s)),n.push(o)}return S.fromArray(n)}class Je extends se{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),s=n.node(n.sharedDepth(this.to)),o=new O(yr(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,o)}invert(){return new Oe(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 Je(t.pos,n.pos,this.mark)}merge(e){return e instanceof Je&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Je(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 Je(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("addMark",Je);class Oe extends se{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 O(yr(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,n)}invert(){return new Je(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 Oe(t.pos,n.pos,this.mark)}merge(e){return e instanceof Oe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Oe(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 Oe(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("removeMark",Oe);class He extends se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new O(S.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 s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(n))return new He(this.pos,t.marks[s]);return new He(this.pos,this.mark)}}return new ut(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new He(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 He(t.pos,e.markFromJSON(t.mark))}}se.jsonID("addNodeMark",He);class ut extends se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new O(S.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new He(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ut(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 ut(t.pos,e.markFromJSON(t.mark))}}se.jsonID("removeNodeMark",ut);class oe extends se{constructor(e,t,n,s=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=s}apply(e){return this.structure&&br(e,this.from,this.to)?q.fail("Structure replace would overwrite content"):q.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new me([this.from,this.to-this.from,this.slice.size])}invert(e){return new oe(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 oe(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof oe)||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?O.empty:new O(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new oe(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?O.empty:new O(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new oe(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 oe(t.from,t.to,O.fromJSON(e,t.slice),!!t.structure)}}se.jsonID("replace",oe);class U extends se{constructor(e,t,n,s,o,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(br(e,this.from,this.gapFrom)||br(e,this.gapTo,this.to)))return q.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return q.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?q.fromReplace(e,this.from,this.to,n):q.fail("Content does not fit in gap")}getMap(){return new me([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 U(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),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||s<t.pos||o>n.pos?null:new U(t.pos,n.pos,s,o,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 U(t.from,t.to,t.gapFrom,t.gapTo,O.fromJSON(e,t.slice),t.insert,!!t.structure)}}se.jsonID("replaceAround",U);function br(r,e,t){let n=r.resolve(e),s=t-e,o=n.depth;for(;s>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,s--;if(s>0){let i=n.node(o).maybeChild(n.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function Mc(r,e,t,n){let s=[],o=[],i,l;r.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!n.isInSet(d)&&u.type.allowsMarkType(n.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=n.addToSet(d);for(let b=0;b<d.length;b++)d[b].isInSet(p)||(i&&i.to==f&&i.mark.eq(d[b])?i.to=h:s.push(i=new Oe(f,h,d[b])));l&&l.to==f?l.to=h:o.push(l=new Je(f,h,n))}}),s.forEach(a=>r.step(a)),o.forEach(a=>r.step(a))}function vc(r,e,t,n){let s=[],o=0;r.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(n instanceof An){let c=i.marks,u;for(;u=n.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else n?n.isInSet(i.marks)&&(a=[n]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==o-1&&d.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=o):s.push({style:d,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>r.step(new Oe(i.from,i.to,i.style)))}function xr(r,e,t,n=t.contentMatch,s=!0){let o=r.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,d=n.matchType(c.type);if(!d)i.push(new oe(l,u,O.empty));else{n=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||r.step(new Oe(l,u,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new O(S.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new oe(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!n.validEnd){let a=n.fillBefore(S.empty,!0);r.replace(l,l,new O(a,0,0))}for(let a=i.length-1;a>=0;a--)r.step(i[a])}function Nc(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function Zt(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth;;--n){let s=r.$from.node(n),o=r.$from.index(n),i=r.$to.indexAfter(n);if(n<r.depth&&s.canReplace(o,i,t))return n;if(n==0||s.type.spec.isolating||!Nc(s,o,i))break}return null}function Oc(r,e,t){let{$from:n,$to:s,depth:o}=e,i=n.before(o+1),l=s.after(o+1),a=i,c=l,u=S.empty,d=0;for(let p=o,b=!1;p>t;p--)b||n.index(p)>0?(b=!0,u=S.from(n.node(p).copy(u)),d++):a--;let f=S.empty,h=0;for(let p=o,b=!1;p>t;p--)b||s.after(p+1)<s.end(p)?(b=!0,f=S.from(s.node(p).copy(f)),h++):c++;r.step(new U(a,c,i,l,new O(u.append(f),d,h),u.size-d,!0))}function kr(r,e,t=null,n=r){let s=Ec(r,e),o=s&&Dc(n,e);return o?s.map(Oo).concat({type:e,attrs:t}).concat(o.map(Oo)):null}function Oo(r){return{type:r,attrs:null}}function Ec(r,e){let{parent:t,startIndex:n,endIndex:s}=r,o=t.contentMatchAt(n).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return t.canReplaceWith(n,s,i)?o:null}function Dc(r,e){let{parent:t,startIndex:n,endIndex:s}=r,o=t.child(n),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=n;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Tc(r,e,t){let n=S.empty;for(let i=t.length-1;i>=0;i--){if(n.size){let l=t[i].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=S.from(t[i].type.create(t[i].attrs,n))}let s=e.start,o=e.end;r.step(new U(s,o,s,o,new O(n,0,0),t.length,!0))}function Ac(r,e,t,n,s){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=r.steps.length;r.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(n,a)&&Pc(r.doc,r.mapping.slice(o).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&&Do(r,i,l,o),xr(r,r.mapping.slice(o).map(l,1),n,void 0,c===null);let u=r.mapping.slice(o),d=u.map(l,1),f=u.map(l+i.nodeSize,1);return r.step(new U(d,f,d+1,f-1,new O(S.from(n.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Eo(r,i,l,o),!1}})}function Eo(r,e,t,n){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=r.mapping.slice(n).map(t+1+o+i.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Do(r,e,t,n){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=r.mapping.slice(n).map(t+1+o);r.replaceWith(i,i+1,e.type.schema.text(`
|
|
27
|
-
`))}})}function Pc(r,e,t){let n=r.resolve(e),s=n.index();return n.parent.canReplaceWith(s,s+1,t)}function Ic(r,e,t,n,s){let o=r.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let i=t.create(n,null,s||o.marks);if(o.isLeaf)return r.replaceWith(e,e+o.nodeSize,i);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new U(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new O(S.from(i),0,0),1,!0))}function vt(r,e,t=1,n){let s=r.resolve(e),o=s.depth-t,i=n&&n[n.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=t-2;c>o;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=n&&n[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let b=n&&n[u]||d;if(!d.canReplace(f+1,d.childCount)||!b.type.validContent(h))return!1}let l=s.indexAfter(o),a=n&&n[0];return s.node(o).canReplaceWith(l,l,a?a.type:s.node(o+1).type)}function Vc(r,e,t=1,n){let s=r.doc.resolve(e),o=S.empty,i=S.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){o=S.from(s.node(l).copy(o));let u=n&&n[c];i=S.from(u?u.type.create(u.attrs,i):s.node(l).copy(i))}r.step(new oe(e,e,new O(o.append(i),t,t),!0))}function Nt(r,e){let t=r.resolve(e),n=t.index();return To(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function Rc(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let s=0;s<e.childCount;s++){let o=e.child(s),i=o.type==n?r.type.schema.nodes.text:o.type;if(t=t.matchType(i),!t||!r.type.allowsMarks(o.marks))return!1}return t.validEnd}function To(r,e){return!!(r&&e&&!r.isLeaf&&Rc(r,e))}function Ao(r,e,t=-1){let n=r.resolve(e);for(let s=n.depth;;s--){let o,i,l=n.index(s);if(s==n.depth?(o=n.nodeBefore,i=n.nodeAfter):t>0?(o=n.node(s+1),l++,i=n.node(s).maybeChild(l)):(o=n.node(s).maybeChild(l-1),i=n.node(s+1)),o&&!o.isTextblock&&To(o,i)&&n.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?n.before(s):n.after(s)}}function zc(r,e,t){let n=null,{linebreakReplacement:s}=r.doc.type.schema,o=r.doc.resolve(e-t),i=o.node().type;if(s&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(s);u&&!d?n=!1:!u&&d&&(n=!0)}let l=r.steps.length;if(n===!1){let u=r.doc.resolve(e+t);Do(r,u.node(),u.before(),l)}i.inlineContent&&xr(r,e+t-1,i,o.node().contentMatchAt(o.index()),n==null);let a=r.mapping.slice(l),c=a.map(e-t);if(r.step(new oe(c,a.map(e+t,-1),O.empty,!0)),n===!0){let u=r.doc.resolve(c);Eo(r,u.node(),u.before(),r.steps.length)}return r}function jc(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 s=n.depth-1;s>=0;s--){let o=n.index(s);if(n.node(s).canReplaceWith(o,o,t))return n.before(s+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let s=n.depth-1;s>=0;s--){let o=n.indexAfter(s);if(n.node(s).canReplaceWith(o,o,t))return n.after(s+1);if(o<n.node(s).childCount)return null}return null}function Po(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let s=t.content;for(let o=0;o<t.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let i=n.depth;i>=0;i--){let l=i==n.depth?0:n.pos<=(n.start(i+1)+n.end(i+1))/2?-1:1,a=n.index(i)+(l>0?1:0),c=n.node(i),u=!1;if(o==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?n.pos:l<0?n.before(i+1):n.after(i+1)}return null}function wr(r,e,t=e,n=O.empty){if(e==t&&!n.size)return null;let s=r.resolve(e),o=r.resolve(t);return Io(s,o,n)?new oe(e,t,n):new Bc(s,o,n).fit()}function Io(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class Bc{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=S.empty;for(let s=0;s<=e.depth;s++){let o=e.node(s);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=S.from(e.node(s).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,s=this.close(e<0?this.$to:n.doc.resolve(e));if(!s)return null;let o=this.placed,i=n.depth,l=s.depth;for(;i&&l&&o.childCount==1;)o=o.firstChild.content,i--,l--;let a=new O(o,i,l);return e>-1?new U(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new oe(n.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,s=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(s=0),o.type.spec.isolating&&s<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let s,o=null;n?(o=Sr(this.unplaced.content,n-1).firstChild,s=o.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(i?c.matchType(i.type)||(d=c.fillBefore(S.from(i),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:l,parent:o,inject:d};if(t==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,s=Sr(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new O(e,t+1,Math.max(n,s.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,s=Sr(e,t);if(s.childCount<=1&&t>0){let o=e.size-t<=t+s.size;this.unplaced=new O(en(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new O(en(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:s,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let b=0;b<o.length;b++)this.openFrontierNode(o[b]);let i=this.unplaced,l=n?n.content:i.content,a=i.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(s){for(let b=0;b<s.childCount;b++)u.push(s.child(b));d=d.matchFragment(s)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let b=l.child(c),y=d.matchType(b.type);if(!y)break;c++,(c>1||a==0||b.content.size)&&(d=y,u.push(Vo(b.mark(f.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=tn(this.placed,t,S.from(u)),this.frontier[t].match=d,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,y=l;b<h;b++){let x=y.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),y=x.content}this.unplaced=p?e==0?O.empty:new O(en(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new O(en(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Cr(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,s=this.$to.after(n);for(;n>1&&s==this.$to.end(--n);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:s}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Cr(e,t,s,n,o);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Cr(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:o?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=tn(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let s=e.node(n),o=s.type.contentMatch.fillBefore(s.content,!0,e.index(n));this.openFrontierNode(s.type,s.attrs,o)}return e}openFrontierNode(e,t=null,n){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=tn(this.placed,this.depth,S.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=tn(this.placed,this.frontier.length,t))}}function en(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(en(r.firstChild.content,e-1,t)))}function tn(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(tn(r.lastChild.content,e-1,t)))}function Sr(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function Vo(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,Vo(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(S.empty,!0)))),r.copy(n)}function Cr(r,e,t,n,s){let o=r.node(e),i=s?r.indexAfter(e):r.index(e);if(i==o.childCount&&!t.compatibleContent(o.type))return null;let l=n.fillBefore(o.content,!0,i);return l&&!Fc(t,o.content,i)?l:null}function Fc(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function Lc(r){return r.spec.defining||r.spec.definingForContent}function $c(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let s=r.doc.resolve(e),o=r.doc.resolve(t);if(Io(s,o,n))return r.step(new oe(e,t,n));let i=zo(s,r.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(f)>-1?l=f:s.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],u=n.openStart;for(let f=n.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==n.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=Lc(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=n.openStart;f>=0;f--){let h=(f+u+1)%(n.openStart+1),p=c[h];if(p)for(let b=0;b<i.length;b++){let y=i[(b+a)%i.length],x=!0;y<0&&(x=!1,y=-y);let k=s.node(y-1),w=s.index(y-1);if(k.canReplaceWith(w,w,p.type,p.marks))return r.replace(s.before(y),x?o.after(y):t,new O(Ro(n.content,0,n.openStart,h),h,n.openEnd))}}let d=r.steps.length;for(let f=i.length-1;f>=0&&(r.replace(e,t,n),!(r.steps.length>d));f--){let h=i[f];h<0||(e=s.before(h),t=o.after(h))}}function Ro(r,e,t,n,s){if(e<t){let o=r.firstChild;r=r.replaceChild(0,o.copy(Ro(o.content,e+1,t,n,o)))}if(e>n){let o=s.contentMatchAt(0),i=o.fillBefore(r).append(r);r=i.append(o.matchFragment(i).fillBefore(S.empty,!0))}return r}function Wc(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let s=jc(r.doc,e,n.type);s!=null&&(e=t=s)}r.replaceRange(e,t,new O(S.from(n),0,0))}function _c(r,e,t){let n=r.doc.resolve(e),s=r.doc.resolve(t),o=zo(n,s);for(let i=0;i<o.length;i++){let l=o[i],a=i==o.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),s.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),s.indexAfter(l-1))))return r.delete(n.before(l),s.after(l))}for(let i=1;i<=n.depth&&i<=s.depth;i++)if(e-n.start(i)==n.depth-i&&t>n.end(i)&&s.end(i)-t!=s.depth-i&&n.start(i-1)==s.start(i-1)&&n.node(i-1).canReplace(n.index(i-1),s.index(i-1)))return r.delete(n.before(i),t);r.delete(e,t)}function zo(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let s=n;s>=0;s--){let o=r.start(s);if(o<r.pos-(r.depth-s)||e.end(s)>e.pos+(e.depth-s)||r.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==r.depth&&s==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&t.push(s)}return t}class Ot extends se{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 q.fail("No node at attribute step's position");let n=Object.create(null);for(let o in t.attrs)n[o]=t.attrs[o];n[this.attr]=this.value;let s=t.type.create(n,null,t.marks);return q.fromReplace(e,this.pos,this.pos+1,new O(S.from(s),0,t.isLeaf?0:1))}getMap(){return me.empty}invert(e){return new Ot(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 Ot(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 Ot(t.pos,t.attr,t.value)}}se.jsonID("attr",Ot);class nn extends se{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return q.ok(n)}getMap(){return me.empty}invert(e){return new nn(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 nn(t.attr,t.value)}}se.jsonID("docAttr",nn);let Et=class extends Error{};Et=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t},Et.prototype=Object.create(Error.prototype),Et.prototype.constructor=Et,Et.prototype.name="TransformError";class jo{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ut}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Et(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=O.empty){let s=wr(this.doc,e,t,n);return s&&this.step(s),this}replaceWith(e,t,n){return this.replace(e,t,new O(S.from(n),0,0))}delete(e,t){return this.replace(e,t,O.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return $c(this,e,t,n),this}replaceRangeWith(e,t,n){return Wc(this,e,t,n),this}deleteRange(e,t){return _c(this,e,t),this}lift(e,t){return Oc(this,e,t),this}join(e,t=1){return zc(this,e,t),this}wrap(e,t){return Tc(this,e,t),this}setBlockType(e,t=e,n,s=null){return Ac(this,e,t,n,s),this}setNodeMarkup(e,t,n=null,s){return Ic(this,e,t,n,s),this}setNodeAttribute(e,t,n){return this.step(new Ot(e,t,n)),this}setDocAttribute(e,t){return this.step(new nn(e,t)),this}addNodeMark(e,t){return this.step(new He(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 z)t.isInSet(n.marks)&&this.step(new ut(e,t));else{let s=n.marks,o,i=[];for(;o=t.isInSet(s);)i.push(new ut(e,o)),s=o.removeFromSet(s);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,n){return Vc(this,e,t,n),this}addMark(e,t,n){return Mc(this,e,t,n),this}removeMark(e,t,n){return vc(this,e,t,n),this}clearIncompatible(e,t,n){return xr(this,e,t,n),this}}const Mr=Object.create(null);class P{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Bo(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=O.empty){let n=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=n,n=n.lastChild;let o=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?O.empty:t),l==0&&$o(e,o,(n?n.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:l}=s[o],a=e.mapping.slice(n),c=a.map(i.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),$o(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let s=e.parent.inlineContent?new V(e):Dt(e.node(0),e.parent,e.pos,e.index(),t,n);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=t<0?Dt(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):Dt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ge(e.node(0))}static atStart(e){return Dt(e,e,0,0,1)||new ge(e)}static atEnd(e){return Dt(e,e,e.content.size,e.childCount,-1)||new ge(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Mr[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 Mr)throw new RangeError("Duplicate use of selection JSON ID "+e);return Mr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return V.between(this.$anchor,this.$head).getBookmark()}}P.prototype.visible=!0;class Bo{constructor(e,t){this.$from=e,this.$to=t}}let Fo=!1;function Lo(r){!Fo&&!r.parent.inlineContent&&(Fo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class V extends P{constructor(e,t=e){Lo(e),Lo(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 P.near(n);let s=e.resolve(t.map(this.anchor));return new V(s.parent.inlineContent?s:n,n)}replace(e,t=O.empty){if(super.replace(e,t),t==O.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof V&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Bn(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 V(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let s=e.resolve(t);return new this(s,n==t?s:e.resolve(n))}static between(e,t,n){let s=e.pos-t.pos;if((!n||s)&&(n=s>=0?1:-1),!t.parent.inlineContent){let o=P.findFrom(t,n,!0)||P.findFrom(t,-n,!0);if(o)t=o.$head;else return P.near(t,n)}return e.parent.inlineContent||(s==0?e=t:(e=(P.findFrom(e,-n,!0)||P.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new V(e,t)}}P.jsonID("text",V);class Bn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Bn(e.map(this.anchor),e.map(this.head))}resolve(e){return V.between(e.resolve(this.anchor),e.resolve(this.head))}}class A extends P{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:s}=t.mapResult(this.anchor),o=e.resolve(s);return n?P.near(o):new A(o)}content(){return new O(S.from(this.node),0,0)}eq(e){return e instanceof A&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new vr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new A(e.resolve(t.anchor))}static create(e,t){return new A(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}A.prototype.visible=!1,P.jsonID("node",A);class vr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Bn(n,n):new vr(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&A.isSelectable(n)?new A(t):P.near(t)}}class ge extends P{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=O.empty){if(t==O.empty){e.delete(0,e.doc.content.size);let n=P.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ge(e)}map(e){return new ge(e)}eq(e){return e instanceof ge}getBookmark(){return qc}}P.jsonID("all",ge);const qc={map(){return this},resolve(r){return new ge(r)}};function Dt(r,e,t,n,s,o=!1){if(e.inlineContent)return V.create(r,t);for(let i=n-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!o&&A.isSelectable(l))return A.create(r,t-(s<0?l.nodeSize:0))}else{let a=Dt(r,l,t+s,s<0?l.childCount:0,s,o);if(a)return a}t+=l.nodeSize*s}return null}function $o(r,e,t){let n=r.steps.length-1;if(n<e)return;let s=r.steps[n];if(!(s instanceof oe||s instanceof U))return;let o=r.mapping.maps[n],i;o.forEach((l,a,c,u)=>{i==null&&(i=u)}),r.setSelection(P.near(r.doc.resolve(i),t))}const Wo=1,_o=2,qo=4;class Jc extends jo{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Wo)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Wo)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=_o,this}ensureMarks(e){return z.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&_o)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||z.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),n=n??t,!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let i=this.doc.resolve(t);o=n==t?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,s.text(e,o)),this.selection.empty||this.setSelection(P.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=qo,this}get scrolledIntoView(){return(this.updated&qo)>0}}function Jo(r,e){return!e||!r?r:r.bind(e)}class rn{constructor(e,t,n){this.name=e,this.init=Jo(t.init,n),this.apply=Jo(t.apply,n)}}const Hc=[new rn("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new rn("selection",{init(r,e){return r.selection||P.atStart(e.doc)},apply(r){return r.selection}}),new rn("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new rn("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class Nr{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Hc.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new rn(n.key,n.spec.state,n))})}}class Ke{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let s=this.config.plugins[n];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),s=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,n);if(u&&n.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<i?{state:n,n:t.length}:{state:this,n:0})}t.push(u),n=n.applyInner(u),o=!0}s&&(s[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ke(this.config),n=this.config.fields;for(let s=0;s<n.length;s++){let o=n[s];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Jc(this)}static create(e){let t=new Nr(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new Ke(t);for(let s=0;s<t.fields.length;s++)n[t.fields[s].name]=t.fields[s].init(e,n);return n}reconfigure(e){let t=new Nr(this.schema,e.plugins),n=t.fields,s=new Ke(t);for(let o=0;o<n.length;o++){let i=n[o].name;s[i]=this.hasOwnProperty(i)?this[i]:n[o].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[n],o=s.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Nr(e.schema,e.plugins),o=new Ke(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=pe.fromJSON(e.schema,t.doc);else if(i.name=="selection")o.selection=P.fromJSON(o.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[i.name]=c.fromJSON.call(a,e,t[l],o);return}}o[i.name]=i.init(e,o)}}),o}}function Ho(r,e,t){for(let n in r){let s=r[n];s instanceof Function?s=s.bind(e):n=="handleDOMEvents"&&(s=Ho(s,e,{})),t[n]=s}return t}class Ee{constructor(e){this.spec=e,this.props={},e.props&&Ho(e.props,this,this.props),this.key=e.key?e.key.key:Ko("plugin")}getState(e){return e[this.key]}}const Or=Object.create(null);function Ko(r){return r in Or?r+"$"+ ++Or[r]:(Or[r]=0,r+"$")}class Ye{constructor(e="key"){this.key=Ko(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}for(var Ge={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:"'"},Fn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Kc=typeof navigator<"u"&&/Mac/.test(navigator.platform),Yc=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Z=0;Z<10;Z++)Ge[48+Z]=Ge[96+Z]=String(Z);for(var Z=1;Z<=24;Z++)Ge[Z+111]="F"+Z;for(var Z=65;Z<=90;Z++)Ge[Z]=String.fromCharCode(Z+32),Fn[Z]=String.fromCharCode(Z);for(var Er in Ge)Fn.hasOwnProperty(Er)||(Fn[Er]=Ge[Er]);function Gc(r){var e=Kc&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||Yc&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Fn:Ge)[r.keyCode]||r.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 Xc=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Qc(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,s,o,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))Xc?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function Uc(r){let e=Object.create(null);for(let t in r)e[Qc(t)]=r[t];return e}function Dr(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function Tr(r){return new Ee({props:{handleKeyDown:Ar(r)}})}function Ar(r){let e=Uc(r);return function(t,n){let s=Gc(n),o,i=e[Dr(s,n)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(n.shiftKey){let l=e[Dr(s,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.shiftKey||n.altKey||n.metaKey||s.charCodeAt(0)>127)&&(o=Ge[n.keyCode])&&o!=s){let l=e[Dr(o,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Ln=200,Y=function(){};Y.prototype.append=function(e){return e.length?(e=Y.from(e),!this.length&&e||e.length<Ln&&this.leafAppend(e)||this.length<Ln&&e.leafPrepend(this)||this.appendInner(e)):this},Y.prototype.prepend=function(e){return e.length?Y.from(e).append(this):this},Y.prototype.appendInner=function(e){return new Zc(this,e)},Y.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Y.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Y.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Y.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Y.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,n),s},Y.from=function(e){return e instanceof Y?e:e&&e.length?new Yo(e):Y.empty};var Yo=function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Ln)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Ln)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(Y);Y.empty=new Yo([]);var Zc=function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(n,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(n,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(n,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(n,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(n,s){if(n==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(n,s):n>=o?this.right.slice(n-o,s-o):this.left.slice(n,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(n){var s=this.right.leafAppend(n);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(n){var s=this.left.leafPrepend(n);if(s)return new e(s,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e}(Y);const eu=500;class Me{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let s,o;t&&(s=this.remapping(n,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(n,f+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new De(d.map));let h=d.step.map(s.slice(o)),p;h&&i.maybeStep(h).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new De(p,void 0,void 0,c.length+u.length))),o--,p&&s.appendMap(p,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new Me(this.items.slice(0,n).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,n,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new De(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-n.depth;return c>nu&&(l=tu(l,c),i-=c),new Me(l.append(o),i)}remapping(e,t){let n=new Ut;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?n.maps.length-s.mirrorOffset:void 0;n.appendMap(s.map,i)},e,t),n}addMaps(e){return this.eventCount==0?this:new Me(this.items.append(e.map(t=>new De(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let p=o.maps[h];if(f.step){let b=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(o.slice(a+1,h));y&&l++,n.push(new De(p,b,y))}else n.push(new De(p))},s);let c=[];for(let f=t;f<i;f++)c.push(new De(o.maps[f]));let u=this.items.slice(0,s).append(c).append(n),d=new Me(u,l);return d.emptyItemCount()>eu&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(n)),c=a&&a.getMap();if(n--,c&&t.appendMap(c,n),a){let u=i.selection&&i.selection.map(t.slice(n));u&&o++;let d=new De(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else i.map&&n--},this.items.length,0),new Me(Y.from(s.reverse()),o)}}Me.empty=new Me(Y.empty,0);function tu(r,e){let t;return r.forEach((n,s)=>{if(n.selection&&e--==0)return t=s,!1}),r.slice(t)}class De{constructor(e,t,n,s){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new De(t.getMap().invert(),t,this.selection)}}}class Xe{constructor(e,t,n,s,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=s,this.prevComposition=o}}const nu=20;function ru(r,e,t,n){let s=t.getMeta(dt),o;if(s)return s.historyState;t.getMeta(iu)&&(r=new Xe(r.done,r.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(i&&i.getMeta(dt))return i.getMeta(dt).redo?new Xe(r.done.addTransform(t,void 0,n,$n(e)),r.undone,Go(t.mapping.maps),r.prevTime,r.prevComposition):new Xe(r.done,r.undone.addTransform(t,void 0,n,$n(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!i&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!su(t,r.prevRanges)),c=i?Pr(r.prevRanges,t.mapping):Go(t.mapping.maps);return new Xe(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,$n(e)),Me.empty,c,t.time,l??r.prevComposition)}else return(o=t.getMeta("rebased"))?new Xe(r.done.rebased(t,o),r.undone.rebased(t,o),Pr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new Xe(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),Pr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function su(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,s)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function Go(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,s,o,i)=>e.push(o,i));return e}function Pr(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let s=e.map(r[n],1),o=e.map(r[n+1],-1);s<=o&&t.push(s,o)}return t}function ou(r,e,t){let n=$n(e),s=dt.get(e).spec.config,o=(t?r.undone:r.done).popEvent(e,n);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?r.done:r.undone).addTransform(o.transform,e.selection.getBookmark(),s,n),a=new Xe(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(dt,{redo:t,historyState:a})}let Ir=!1,Xo=null;function $n(r){let e=r.plugins;if(Xo!=e){Ir=!1,Xo=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ir=!0;break}}return Ir}const dt=new Ye("history"),iu=new Ye("closeHistory");function lu(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new Ee({key:dt,state:{init(){return new Xe(Me.empty,Me.empty,null,0,-1)},apply(e,t,n){return ru(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,s=n=="historyUndo"?Vr:n=="historyRedo"?Wn:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function Qo(r,e){return(t,n)=>{let s=dt.getState(t);if(!s||(r?s.undone:s.done).eventCount==0)return!1;if(n){let o=ou(s,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const Vr=Qo(!1,!0),Wn=Qo(!0,!0),Uo=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function au(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const cu=(r,e,t)=>{let n=au(r,t);if(!n)return!1;let s=Zo(n);if(!s){let i=n.blockRange(),l=i&&Zt(i);return l==null?!1:(e&&e(r.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(ri(r,s,e,-1))return!0;if(n.parent.content.size==0&&(Tt(o,"end")||A.isSelectable(o)))for(let i=n.depth;;i--){let l=wr(r.doc,n.before(i),n.after(i),O.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(Tt(o,"end")?P.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):A.create(a.doc,s.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||n.node(i-1).childCount>1)break}return o.isAtom&&s.depth==n.depth-1?(e&&e(r.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1};function Tt(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 uu=(r,e,t)=>{let{$head:n,empty:s}=r.selection,o=n;if(!s)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;o=Zo(n)}let i=o&&o.nodeBefore;return!i||!A.isSelectable(i)?!1:(e&&e(r.tr.setSelection(A.create(r.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function Zo(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 du(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const fu=(r,e,t)=>{let n=du(r,t);if(!n)return!1;let s=ei(n);if(!s)return!1;let o=s.nodeAfter;if(ri(r,s,e,1))return!0;if(n.parent.content.size==0&&(Tt(o,"start")||A.isSelectable(o))){let i=wr(r.doc,n.before(),n.after(),O.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=r.tr.step(i);l.setSelection(Tt(o,"start")?P.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):A.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&s.depth==n.depth-1?(e&&e(r.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},hu=(r,e,t)=>{let{$head:n,empty:s}=r.selection,o=n;if(!s)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;o=ei(n)}let i=o&&o.nodeAfter;return!i||!A.isSelectable(i)?!1:(e&&e(r.tr.setSelection(A.create(r.doc,o.pos)).scrollIntoView()),!0)};function ei(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 ti=(r,e)=>{let t=r.selection,n=t instanceof A,s;if(n){if(t.node.isTextblock||!Nt(r.doc,t.from))return!1;s=t.from}else if(s=Ao(r.doc,t.from,-1),s==null)return!1;if(e){let o=r.tr.join(s);n&&o.setSelection(A.create(o.doc,s-r.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},pu=(r,e)=>{let t=r.selection,n;if(t instanceof A){if(t.node.isTextblock||!Nt(r.doc,t.to))return!1;n=t.to}else if(n=Ao(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},Rr=(r,e)=>{let{$from:t,$to:n}=r.selection,s=t.blockRange(n),o=s&&Zt(s);return o==null?!1:(e&&e(r.tr.lift(s,o).scrollIntoView()),!0)},mu=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
28
|
-
`).scrollIntoView()),!0)};function zr(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 ni=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let s=t.node(-1),o=t.indexAfter(-1),i=zr(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,i.createAndFill());a.setSelection(P.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},gu=(r,e)=>{let t=r.selection,{$from:n,$to:s}=t;if(t instanceof ge||n.parent.inlineContent||s.parent.inlineContent)return!1;let o=zr(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let i=(!n.parentOffset&&s.index()<s.parent.childCount?n:s).pos,l=r.tr.insert(i,o.createAndFill());l.setSelection(V.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},yu=(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 o=t.before();if(vt(r.doc,o))return e&&e(r.tr.split(o).scrollIntoView()),!0}let n=t.blockRange(),s=n&&Zt(n);return s==null?!1:(e&&e(r.tr.lift(n,s).scrollIntoView()),!0)};function bu(r){return(e,t)=>{let{$from:n,$to:s}=e.selection;if(e.selection instanceof A&&e.selection.node.isBlock)return!n.parentOffset||!vt(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],i,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=zr(n.node(h-1).contentMatchAt(n.indexAfter(h-1))),o.unshift(a&&l?{type:l}:null),i=h;break}else{if(h==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof V||e.selection instanceof ge)&&u.deleteSelection();let d=u.mapping.map(n.pos),f=vt(u.doc,d,o.length,o);if(f||(o[0]=l?{type:l}:null,f=vt(u.doc,d,o.length,o)),!f)return!1;if(u.split(d,o.length,o),!a&&c&&n.node(i).type!=l){let h=u.mapping.map(n.before(i)),p=u.doc.resolve(h);l&&n.node(i-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(n.before(i)),l)}return t&&t(u.scrollIntoView()),!0}}const xu=bu(),jr=(r,e)=>{let{$from:t,to:n}=r.selection,s,o=t.sharedDepth(n);return o==0?!1:(s=t.before(o),e&&e(r.tr.setSelection(A.create(r.doc,s))),!0)},ku=(r,e)=>(e&&e(r.tr.setSelection(new ge(r.doc))),!0);function wu(r,e,t){let n=e.nodeBefore,s=e.nodeAfter,o=e.index();return!n||!s||!n.type.compatibleContent(s.type)?!1:!n.content.size&&e.parent.canReplace(o-1,o)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||Nt(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function ri(r,e,t,n){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&wu(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&l.matchType(i[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,p=S.empty;for(let x=i.length-1;x>=0;x--)p=S.from(i[x].create(null,p));p=S.from(s.copy(p));let b=r.tr.step(new U(e.pos-1,h,e.pos,h,new O(p,1,0),i.length,!0)),y=b.doc.resolve(h+2*i.length);y.nodeAfter&&y.nodeAfter.type==s.type&&Nt(b.doc,y.pos)&&b.join(y.pos),t(b.scrollIntoView())}return!0}let u=o.type.spec.isolating||n>0&&a?null:P.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Zt(d);if(f!=null&&f>=e.depth)return t&&t(r.tr.lift(d,f).scrollIntoView()),!0;if(c&&Tt(o,"start",!0)&&Tt(s,"end")){let h=s,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let b=o,y=1;for(;!b.isTextblock;b=b.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,b.content)){if(t){let x=S.empty;for(let w=p.length-1;w>=0;w--)x=S.from(p[w].copy(x));let k=r.tr.step(new U(e.pos-p.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new O(x,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function si(r){return function(e,t){let n=e.selection,s=r<0?n.$from:n.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(t&&t(e.tr.setSelection(V.create(e.doc,r<0?s.start(o):s.end(o)))),!0):!1}}const Su=si(-1),Cu=si(1);function oi(r,e=null){return function(t,n){let{$from:s,$to:o}=t.selection,i=s.blockRange(o),l=i&&kr(i,r,e);return l?(n&&n(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function At(r,e=null){return function(t,n){let s=!1;for(let o=0;o<t.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(r,e)))if(a.type==r)s=!0;else{let u=t.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,r)}})}if(!s)return!1;if(n){let o=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];o.setBlockType(l,a,r,e)}n(o.scrollIntoView())}return!0}}function Mu(r,e,t,n){for(let s=0;s<e.length;s++){let{$from:o,$to:i}=e[s],l=o.depth==0?r.inlineContent&&r.type.allowsMarkType(t):!1;if(r.nodesBetween(o.pos,i.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function ye(r,e=null,t){return function(n,s){let{empty:o,$cursor:i,ranges:l}=n.selection;if(o&&!i||!Mu(n.doc,l,r))return!1;if(s)if(i)r.isInSet(n.storedMarks||i.marks())?s(n.tr.removeStoredMark(r)):s(n.tr.addStoredMark(r.create(e)));else{let a,c=n.tr;a=!l.some(u=>n.doc.rangeHasMark(u.$from.pos,u.$to.pos,r));for(let u=0;u<l.length;u++){let{$from:d,$to:f}=l[u];if(!a)c.removeMark(d.pos,f.pos,r);else{let h=d.pos,p=f.pos,b=d.nodeAfter,y=f.nodeBefore,x=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,k=y&&y.isText?/\s*$/.exec(y.text)[0].length:0;h+x<p&&(h+=x,p-=k),c.addMark(h,p,r.create(e))}}s(c.scrollIntoView())}return!0}}function _n(...r){return function(e,t,n){for(let s=0;s<r.length;s++)if(r[s](e,t,n))return!0;return!1}}let Br=_n(Uo,cu,uu),ii=_n(Uo,fu,hu);const je={Enter:_n(mu,gu,yu,xu),"Mod-Enter":ni,Backspace:Br,"Mod-Backspace":Br,"Shift-Backspace":Br,Delete:ii,"Mod-Delete":ii,"Mod-a":ku},li={"Ctrl-h":je.Backspace,"Alt-Backspace":je["Mod-Backspace"],"Ctrl-d":je.Delete,"Ctrl-Alt-Backspace":je["Mod-Delete"],"Alt-Delete":je["Mod-Delete"],"Alt-d":je["Mod-Delete"],"Ctrl-a":Su,"Ctrl-e":Cu};for(let r in je)li[r]=je[r];const vu=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?li:je;function Nu(r={}){return new Ee({view(e){return new Ou(e,r)}})}class Ou{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),b=d?p.bottom:p.top;d&&f&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;n={left:p.left,right:p.right,top:b-y,bottom:b+y}}}}if(!n){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;n={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(n.left-c)/i+"px",this.element.style.top=(n.top-u)/l+"px",this.element.style.width=(n.right-n.left)/i+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=n&&n.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Po(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const ee=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},Pt=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let Fr=null;const Be=function(r,e,t){let n=Fr||(Fr=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},Eu=function(){Fr=null},ft=function(r,e,t,n){return t&&(ai(r,e,t,n,-1)||ai(r,e,t,n,1))},Du=/^(img|br|input|textarea|hr)$/i;function ai(r,e,t,n,s){for(;;){if(r==t&&e==n)return!0;if(e==(s<0?0:be(r))){let o=r.parentNode;if(!o||o.nodeType!=1||sn(r)||Du.test(r.nodeName)||r.contentEditable=="false")return!1;e=ee(r)+(s<0?0:1),r=o}else if(r.nodeType==1){if(r=r.childNodes[e+(s<0?-1:0)],r.contentEditable=="false")return!1;e=s<0?be(r):0}else return!1}}function be(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Tu(r,e){for(;;){if(r.nodeType==3&&e)return r;if(r.nodeType==1&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=be(r)}else if(r.parentNode&&!sn(r))e=ee(r),r=r.parentNode;else return null}}function Au(r,e){for(;;){if(r.nodeType==3&&e<r.nodeValue.length)return r;if(r.nodeType==1&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!sn(r))e=ee(r)+1,r=r.parentNode;else return null}}function Pu(r,e,t){for(let n=e==0,s=e==be(r);n||s;){if(r==t)return!0;let o=ee(r);if(r=r.parentNode,!r)return!1;n=n&&o==0,s=s&&o==be(r)}}function sn(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const qn=function(r){return r.focusNode&&ft(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function ht(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function Iu(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Vu(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(be(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(be(n.startContainer),n.startOffset)}}}const Te=typeof navigator<"u"?navigator:null,ci=typeof document<"u"?document:null,Qe=Te&&Te.userAgent||"",Lr=/Edge\/(\d+)/.exec(Qe),ui=/MSIE \d/.exec(Qe),$r=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Qe),he=!!(ui||$r||Lr),Ue=ui?document.documentMode:$r?+$r[1]:Lr?+Lr[1]:0,ve=!he&&/gecko\/(\d+)/i.test(Qe);ve&&+(/Firefox\/(\d+)/.exec(Qe)||[0,0])[1];const Wr=!he&&/Chrome\/(\d+)/.exec(Qe),ie=!!Wr,di=Wr?+Wr[1]:0,ce=!he&&!!Te&&/Apple Computer/.test(Te.vendor),It=ce&&(/Mobile\/\w+/.test(Qe)||!!Te&&Te.maxTouchPoints>2),xe=It||(Te?/Mac/.test(Te.platform):!1),Ru=Te?/Win/.test(Te.platform):!1,Fe=/Android \d/.test(Qe),on=!!ci&&"webkitFontSmoothing"in ci.documentElement.style,zu=on?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ju(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function Le(r,e){return typeof r=="number"?r:r[e]}function Bu(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function fi(r,e,t){let n=r.someProp("scrollThreshold")||0,s=r.someProp("scrollMargin")||5,o=r.dom.ownerDocument;for(let i=t||r.dom;i;){if(i.nodeType!=1){i=Pt(i);continue}let l=i,a=l==o.body,c=a?ju(o):Bu(l),u=0,d=0;if(e.top<c.top+Le(n,"top")?d=-(c.top-e.top+Le(s,"top")):e.bottom>c.bottom-Le(n,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Le(s,"top")-c.top:e.bottom-c.bottom+Le(s,"bottom")),e.left<c.left+Le(n,"left")?u=-(c.left-e.left+Le(s,"left")):e.right>c.right-Le(n,"right")&&(u=e.right-c.right+Le(s,"right")),u||d)if(a)o.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let b=l.scrollLeft-h,y=l.scrollTop-p;e={left:e.left-b,top:e.top-y,right:e.right-b,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:Pt(i)}}function Fu(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,s;for(let o=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=r.root.elementFromPoint(o,i);if(!l||l==r.dom||!r.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,s=a.top;break}}return{refDOM:n,refTop:s,stack:hi(r.dom)}}function hi(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=Pt(n));return e}function Lu({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;pi(t,n==0?0:n-e)}function pi(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:s,left:o}=r[t];n.scrollTop!=s+e&&(n.scrollTop=s+e),n.scrollLeft!=o&&(n.scrollLeft=o)}}let Vt=null;function $u(r){if(r.setActive)return r.setActive();if(Vt)return r.focus(Vt);let e=hi(r);r.focus(Vt==null?{get preventScroll(){return Vt={preventScroll:!0},!0}}:void 0),Vt||(Vt=!1,pi(e,0))}function mi(r,e){let t,n=2e8,s,o=0,i=e.top,l=e.top,a,c;for(let u=r.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=Be(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=i&&p.bottom>=l){i=Math.max(p.bottom,i),l=Math.min(p.top,l);let b=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(b<n){t=u,n=b,s=b&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&b&&(o=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=d+1)}}return!t&&a&&(t=a,s=c,n=0),t&&t.nodeType==3?Wu(t,s):!t||n&&t.nodeType==1?{node:r,offset:o}:mi(t,s)}function Wu(r,e){let t=r.nodeValue.length,n=document.createRange();for(let s=0;s<t;s++){n.setEnd(r,s+1),n.setStart(r,s);let o=Ze(n,1);if(o.top!=o.bottom&&_r(e,o))return{node:r,offset:s+(e.left>=(o.left+o.right)/2?1:0)}}return{node:r,offset:0}}function _r(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function _u(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function qu(r,e,t){let{node:n,offset:s}=mi(e,t),o=-1;if(n.nodeType==1&&!n.firstChild){let i=n.getBoundingClientRect();o=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return r.docView.posFromDOM(n,s,o)}function Ju(r,e,t,n){let s=-1;for(let o=e,i=!1;o!=r.dom;){let l=r.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!i&&a.left>n.left||a.top>n.top?s=l.posBefore:(!i&&a.right<n.left||a.bottom<n.top)&&(s=l.posAfter),i=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return s>-1?s:r.docView.posFromDOM(e,t,-1)}function gi(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let s=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),o=s;;){let i=r.childNodes[o];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(_r(e,c))return gi(i,e,c)}}if((o=(o+1)%n)==s)break}return r}function Hu(r,e){let t=r.dom.ownerDocument,n,s=0,o=Vu(t,e.left,e.top);o&&({node:n,offset:s}=o);let i=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),l;if(!i||!r.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=r.dom.getBoundingClientRect();if(!_r(e,c)||(i=gi(r.dom,e,c),!i))return null}if(ce)for(let c=i;n&&c;c=Pt(c))c.draggable&&(n=void 0);if(i=_u(i,e),n){if(ve&&n.nodeType==1&&(s=Math.min(s,n.childNodes.length),s<n.childNodes.length)){let u=n.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;on&&s&&n.nodeType==1&&(c=n.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,n==r.dom&&s==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?l=r.state.doc.content.size:(s==0||n.nodeType!=1||n.childNodes[s-1].nodeName!="BR")&&(l=Ju(r,n,s,e))}l==null&&(l=qu(r,i,e));let a=r.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function yi(r){return r.top<r.bottom||r.left<r.right}function Ze(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(yi(n))return n}return Array.prototype.find.call(t,yi)||r.getBoundingClientRect()}const Ku=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function bi(r,e,t){let{node:n,offset:s,atom:o}=r.docView.domFromPos(e,t<0?-1:1),i=on||ve;if(n.nodeType==3)if(i&&(Ku.test(n.nodeValue)||(t<0?!s:s==n.nodeValue.length))){let a=Ze(Be(n,s,s),t);if(ve&&s&&/\s/.test(n.nodeValue[s-1])&&s<n.nodeValue.length){let c=Ze(Be(n,s-1,s-1),-1);if(c.top==a.top){let u=Ze(Be(n,s,s+1),-1);if(u.top!=a.top)return ln(u,u.left<c.left)}}return a}else{let a=s,c=s,u=t<0?1:-1;return t<0&&!s?(c++,u=-1):t>=0&&s==n.nodeValue.length?(a--,u=1):t<0?a--:c++,ln(Ze(Be(n,a,c),u),u<0)}if(!r.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(t<0||s==be(n))){let a=n.childNodes[s-1];if(a.nodeType==1)return qr(a.getBoundingClientRect(),!1)}if(o==null&&s<be(n)){let a=n.childNodes[s];if(a.nodeType==1)return qr(a.getBoundingClientRect(),!0)}return qr(n.getBoundingClientRect(),t>=0)}if(o==null&&s&&(t<0||s==be(n))){let a=n.childNodes[s-1],c=a.nodeType==3?Be(a,be(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return ln(Ze(c,1),!1)}if(o==null&&s<be(n)){let a=n.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Be(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return ln(Ze(c,-1),!0)}return ln(Ze(n.nodeType==3?Be(n):n,-t),t>=0)}function ln(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function qr(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function xi(r,e,t){let n=r.state,s=r.root.activeElement;n!=e&&r.updateState(e),s!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),s!=r.dom&&s&&s.focus()}}function Yu(r,e,t){let n=e.selection,s=t=="up"?n.$from:n.$to;return xi(r,e,()=>{let{node:o}=r.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=r.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let i=bi(r,s.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Be(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const Gu=/[\u0590-\u08ac]/;function Xu(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let s=n.parentOffset,o=!s,i=s==n.parent.content.size,l=r.domSelection();return l?!Gu.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:i:xi(r,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=r.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:p,focusOffset:b}=r.domSelectionRange(),y=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==b;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):n.pos==n.start()||n.pos==n.end()}let ki=null,wi=null,Si=!1;function Qu(r,e,t){return ki==e&&wi==t?Si:(ki=e,wi=t,Si=t=="up"||t=="down"?Yu(r,e,t):Xu(r,e,t))}const ke=0,Ci=1,pt=2,Ae=3;let an=class{constructor(e,t,n,s){this.parent=e,this.children=t,this.dom=n,this.contentDOM=s,this.dirty=ke,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let s=this.children[t];if(s==e)return n;n+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let o,i;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ee(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!t||o.node))if(n&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))n=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let s=this.children[t],o=n+s.size;if(n==e&&o!=n){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){let l=s.children[i];if(l.size){s=l;break}}return s}if(e<o)return s.descAt(e-n-s.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,s=0;for(let o=0;n<this.children.length;n++){let i=this.children[n],l=o+i.size;if(l>e||i instanceof Oi){s=e-o;break}o=l}if(s)return this.children[n].domFromPos(s-this.children[n].border,t);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof Mi&&o.side>=0;n--);if(t<=0){let o,i=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,i=!1);return o&&t&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?ee(o.dom)+1:0}}else{let o,i=!0;for(;o=n<this.children.length?this.children[n]:null,!(!o||o.dom.parentNode==this.contentDOM);n++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?ee(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=n,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=ee(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=ee(d.dom);break}t+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,s=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let b=this.children[h],y=p+b.size;if(o>p&&i<y)return b.setSelection(e-p-b.border,t-p-b.border,n,s);p=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),u=n.domSelectionRange(),d=!1;if((ve||ce)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==`
|
|
29
|
-
`),d&&p==h.nodeValue.length)for(let b=h,y;b;b=b.parentNode){if(y=b.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:ee(y)+1});break}let x=b.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let b=h.childNodes[p-1];d=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(ve&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||d&&ce)&&ft(l.node,l.offset,u.anchorNode,u.anchorOffset)&&ft(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!d){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,s=0;s<this.children.length;s++){let o=this.children[s],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let l=n+o.border,a=i-o.border;if(e>=l&&t<=a){this.dirty=e==n||t==i?pt:Ci,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Ae:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?pt:Ae}n=i}this.dirty=pt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?pt:Ci;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}},Mi=class extends an{constructor(e,t,n,s){let o,i=t.type.toDOM;if(typeof i=="function"&&(i=i(n,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==ke&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},Uu=class extends an{constructor(e,t,n,s){super(e,[],t,null),this.textDOM=n,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Jn=class _s extends an{constructor(e,t,n,s,o){super(e,[],n,s),this.mark=t,this.spec=o}static create(e,t,n,s){let o=s.nodeViews[t.type.name],i=o&&o(t,s,n);return(!i||!i.dom)&&(i=ze.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new _s(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Ae||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ae&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ke){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=ke}}slice(e,t,n){let s=_s.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=Hr(o,t,i,n)),e>0&&(o=Hr(o,0,e,n));for(let l=0;l<o.length;l++)o[l].parent=s;return s.children=o,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Rt=class Ka extends an{constructor(e,t,n,s,o,i,l,a,c){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=s,this.nodeDOM=l}static create(e,t,n,s,o,i){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},n,s),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=ze.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Ti(u,n,t),c?a=new Zu(e,t,n,s,u,d||null,f,c,o,i+1):t.isText?new Ni(e,t,n,s,u,f,o):new Ka(e,t,n,s,u,d||null,f,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,t,n){return this.dirty==ke&&e.eq(this.node)&&Hn(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,s=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new td(this,i&&i.node,e);sd(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,n,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?z.none:this.node.child(u).marks,n,e),a.placeWidget(c,e,s)},(c,u,d,f)=>{a.syncToMarks(c.marks,n,e);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,s)||a.addNode(c,u,d,e,s),s+=c.nodeSize}),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==pt)&&(i&&this.protectLocalComposition(e,i),Ei(this.contentDOM,this.children,e),It&&od(this.dom))}localCompositionInfo(e,t){let{from:n,to:s}=e.state.selection;if(!(e.state.selection instanceof V)||n<t||s>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,l=id(this.node.content,i,n-t,s-t);return l<0?null:{node:o,pos:l,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:s}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new Uu(this,o,t,s);e.input.compositionNodes.push(i),this.children=Hr(this.children,n,n+s.length,e,i)}update(e,t,n,s){return this.dirty==Ae||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,s),!0)}updateInner(e,t,n,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=ke}updateOuterDeco(e){if(Hn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Di(this.dom,this.nodeDOM,Jr(this.outerDeco,this.node,t),Jr(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function vi(r,e,t,n,s){Ti(n,e,r);let o=new Rt(void 0,r,e,t,n,n,n,s,0);return o.contentDOM&&o.updateChildren(s,0),o}let Ni=class Ya extends Rt{constructor(e,t,n,s,o,i,l){super(e,t,n,s,o,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,s){return this.dirty==Ae||this.dirty!=ke&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ke||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=ke,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let s=this.node.cut(e,t),o=document.createTextNode(s.text);return new Ya(this.parent,s,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ae)}get domAtom(){return!1}isText(e){return this.node.text==e}},Oi=class extends an{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ke&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Zu=class extends Rt{constructor(e,t,n,s,o,i,l,a,c,u){super(e,t,n,s,o,i,l,c,u),this.spec=a}update(e,t,n,s){if(this.dirty==Ae)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,s){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Ei(r,e,t){let n=r.firstChild,s=!1;for(let o=0;o<e.length;o++){let i=e[o],l=i.dom;if(l.parentNode==r){for(;l!=n;)n=Ai(n),s=!0;n=n.nextSibling}else s=!0,r.insertBefore(l,n);if(i instanceof Jn){let a=n?n.previousSibling:r.lastChild;Ei(i.contentDOM,i.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=Ai(n),s=!0;s&&t.trackWrites==r&&(t.trackWrites=null)}const cn=function(r){r&&(this.nodeName=r)};cn.prototype=Object.create(null);const mt=[new cn];function Jr(r,e,t){if(r.length==0)return mt;let n=t?mt[0]:new cn,s=[n];for(let o=0;o<r.length;o++){let i=r[o].type.attrs;if(i){i.nodeName&&s.push(n=new cn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(n=new cn(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return s}function Di(r,e,t,n){if(t==mt&&n==mt)return e;let s=e;for(let o=0;o<n.length;o++){let i=n[o],l=t[o];if(o){let a;l&&l.nodeName==i.nodeName&&s!=r&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=mt[0]),s=a}ed(s,l||mt[0],i)}return s}function ed(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<n.length;o++)s.indexOf(n[o])==-1&&r.classList.remove(n[o]);for(let o=0;o<s.length;o++)n.indexOf(s[o])==-1&&r.classList.add(s[o]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=n.exec(e.style);)r.style.removeProperty(s[1])}t.style&&(r.style.cssText+=t.style)}}function Ti(r,e,t){return Di(r,r,mt,Jr(e,t,r.nodeType!=1))}function Hn(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function Ai(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class td{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=nd(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let s=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;s<i&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=ke,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[o])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Jn.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,n))o=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,s,o){let i=this.top.children[s];return i.dirty==Ae&&i.dom==i.contentDOM&&(i.dirty=pt),i.update(e,t,n,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==n)return s}return-1}e=t}}updateNextNode(e,t,n,s,o,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Rt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ae&&Hn(t,a.outerDeco));if(!f&&a.update(e,t,n,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,n,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=pt,d.updateChildren(s,i+1),d.dirty=ke),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,s,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Hn(n,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=Rt.create(this.top,t,n,s,o,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,n,s,o){let i=Rt.create(this.top,e,t,n,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let o=new Mi(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Jn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ni)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ce||ie)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let s=new Oi(this.top,[],n,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function nd(r,e){let t=e,n=t.children.length,s=r.childCount,o=new Map,i=[];e:for(;s>0;){let l;for(;;)if(n){let c=t.children[n-1];if(c instanceof Jn)t=c,n=c.children.length;else{l=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=r.child(s-1))break;--s,o.set(l,s),i.push(l)}}return{index:s,matched:o,matches:i.reverse()}}function rd(r,e){return r.type.side-e.type.side}function sd(r,e,t,n){let s=e.locals(r),o=0;if(s.length==0){for(let c=0;c<r.childCount;c++){let u=r.child(c);n(u,s,e.forChild(o,u),c),o+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,d;for(;i<s.length&&s[i].to==o;){let y=s[i++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(rd);for(let y=0;y<d.length;y++)t(d[y],c,!!a)}else t(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<r.childCount)h=c,f=r.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=o&&l.splice(y--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)l.push(s[i++]);let p=o+f.nodeSize;if(f.isText){let y=p;i<s.length&&s[i].from<y&&(y=s[i].from);for(let x=0;x<l.length;x++)l[x].to<y&&(y=l[x].to);y<p&&(a=f.cut(y-o),f=f.cut(0,y-o),p=y,h=-1)}else for(;i<s.length&&s[i].to<p;)i++;let b=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();n(f,b,e.forChild(o,f),h),o=p}}function od(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function id(r,e,t,n){for(let s=0,o=0;s<r.childCount&&o<=n;){let i=r.child(s++),l=o;if(o+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<r.childCount;){let c=r.child(s++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;let c=l<n?a.lastIndexOf(e,n-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function Hr(r,e,t,n,s){let o=[];for(let i=0,l=0;i<r.length;i++){let a=r[i],c=l,u=l+=a.size;c>=t||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,n)),s&&(o.push(s),s=void 0),u>t&&o.push(a.slice(t-c,a.size,n)))}return o}function Kr(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let s=r.docView.nearestDesc(t.focusNode),o=s&&s.size==0,i=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=n.resolve(i),a,c;if(qn(t)){for(a=i;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&A.isSelectable(d)&&s.parent&&!(d.isInline&&Pu(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new A(i==f?l:n.resolve(f))}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=i,f=i;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);d=Math.min(d,r.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,r.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,i]=f==r.state.selection.anchor?[f,d]:[d,f],l=n.resolve(i)}else a=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=n.resolve(a);if(!c){let d=e=="pointer"||r.state.selection.head<l.pos&&!o?1:-1;c=Gr(r,u,l,d)}return c}function Pi(r){return r.editable?r.hasFocus():Fi(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function $e(r,e=!1){let t=r.state.selection;if(zi(r,t),!!Pi(r)){if(!e&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&ie){let n=r.domSelectionRange(),s=r.domObserver.currentSelection;if(n.anchorNode&&s.anchorNode&&ft(n.anchorNode,n.anchorOffset,s.anchorNode,s.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)ad(r);else{let{anchor:n,head:s}=t,o,i;Ii&&!(t instanceof V)&&(t.$from.parent.inlineContent||(o=Vi(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Vi(r,t.to))),r.docView.setSelection(n,s,r,e),Ii&&(o&&Ri(o),i&&Ri(i)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ld(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const Ii=ce||ie&&di<63;function Vi(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),s=n<t.childNodes.length?t.childNodes[n]:null,o=n?t.childNodes[n-1]:null;if(ce&&s&&s.contentEditable=="false")return Yr(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return Yr(s);if(o)return Yr(o)}}function Yr(r){return r.contentEditable="true",ce&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function Ri(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function ld(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!Pi(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function ad(r){let e=r.domSelection(),t=document.createRange();if(!e)return;let n=r.cursorWrapper.dom,s=n.nodeName=="IMG";s?t.setStart(n.parentNode,ee(n)+1):t.setStart(n,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!r.state.selection.visible&&he&&Ue<=11&&(n.disabled=!0,n.disabled=!1)}function zi(r,e){if(e instanceof A){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(ji(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else ji(r)}function ji(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function Gr(r,e,t,n){return r.someProp("createSelectionBetween",s=>s(r,e,t))||V.between(e,t,n)}function Bi(r){return r.editable&&!r.hasFocus()?!1:Fi(r)}function Fi(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function cd(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return ft(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Xr(r,e){let{$anchor:t,$head:n}=r.selection,s=e>0?t.max(n):t.min(n),o=s.parent.inlineContent?s.depth?r.doc.resolve(e>0?s.after():s.before()):null:s;return o&&P.findFrom(o,e)}function et(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function Li(r,e,t){let n=r.state.selection;if(n instanceof V)if(t.indexOf("s")>-1){let{$head:s}=n,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=r.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return et(r,new V(n.$anchor,i))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let s=Xr(r.state,e);return s&&s instanceof A?et(r,s):!1}else if(!(xe&&t.indexOf("m")>-1)){let s=n.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let l=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=r.docView.descAt(l))&&!i.contentDOM?A.isSelectable(o)?et(r,new A(e<0?r.state.doc.resolve(s.pos-o.nodeSize):s)):on?et(r,new V(r.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof A&&n.node.isInline)return et(r,new V(e>0?n.$to:n.$from));{let s=Xr(r.state,e);return s?et(r,s):!1}}}function Kn(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function un(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function zt(r,e){return e<0?ud(r):dd(r)}function ud(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let s,o,i=!1;for(ve&&t.nodeType==1&&n<Kn(t)&&un(t.childNodes[n],-1)&&(i=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(un(l,-1))s=t,o=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if($i(t))break;{let l=t.previousSibling;for(;l&&un(l,-1);)s=t.parentNode,o=ee(l),l=l.previousSibling;if(l)t=l,n=Kn(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}i?Qr(r,t,n):s&&Qr(r,s,o)}function dd(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let s=Kn(t),o,i;for(;;)if(n<s){if(t.nodeType!=1)break;let l=t.childNodes[n];if(un(l,1))o=t,i=++n;else break}else{if($i(t))break;{let l=t.nextSibling;for(;l&&un(l,1);)o=l.parentNode,i=ee(l)+1,l=l.nextSibling;if(l)t=l,n=0,s=Kn(t);else{if(t=t.parentNode,t==r.dom)break;n=s=0}}}o&&Qr(r,o,i)}function $i(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function fd(r,e){for(;r&&e==r.childNodes.length&&!sn(r);)e=ee(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=0}}function hd(r,e){for(;r&&!e&&!sn(r);)e=ee(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function Qr(r,e,t){if(e.nodeType!=3){let o,i;(i=fd(e,t))?(e=i,t=0):(o=hd(e,t))&&(e=o,t=o.nodeValue.length)}let n=r.domSelection();if(!n)return;if(qn(n)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),n.removeAllRanges(),n.addRange(o)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:s}=r;setTimeout(()=>{r.state==s&&$e(r)},50)}function Wi(r,e){let t=r.state.doc.resolve(e);if(!(ie||Ru)&&t.parent.inlineContent){let s=r.coordsAtPos(e);if(e>t.start()){let o=r.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<t.end()){let o=r.coordsAtPos(e+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function _i(r,e,t){let n=r.state.selection;if(n instanceof V&&!n.empty||t.indexOf("s")>-1||xe&&t.indexOf("m")>-1)return!1;let{$from:s,$to:o}=n;if(!s.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let i=Xr(r.state,e);if(i&&i instanceof A)return et(r,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=n instanceof ge?P.near(i,e):P.findFrom(i,e);return l?et(r,l):!1}return!1}function qi(r,e){if(!(r.state.selection instanceof V))return!0;let{$head:t,$anchor:n,empty:s}=r.state.selection;if(!t.sameParent(n))return!0;if(!s)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let i=r.state.tr;return e<0?i.delete(t.pos-o.nodeSize,t.pos):i.delete(t.pos,t.pos+o.nodeSize),r.dispatch(i),!0}return!1}function Ji(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function pd(r){if(!ce||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;Ji(r,n,"true"),setTimeout(()=>Ji(r,n,"false"),20)}return!1}function md(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function gd(r,e){let t=e.keyCode,n=md(e);if(t==8||xe&&t==72&&n=="c")return qi(r,-1)||zt(r,-1);if(t==46&&!e.shiftKey||xe&&t==68&&n=="c")return qi(r,1)||zt(r,1);if(t==13||t==27)return!0;if(t==37||xe&&t==66&&n=="c"){let s=t==37?Wi(r,r.state.selection.from)=="ltr"?-1:1:-1;return Li(r,s,n)||zt(r,s)}else if(t==39||xe&&t==70&&n=="c"){let s=t==39?Wi(r,r.state.selection.from)=="ltr"?1:-1:1;return Li(r,s,n)||zt(r,s)}else{if(t==38||xe&&t==80&&n=="c")return _i(r,-1,n)||zt(r,-1);if(t==40||xe&&t==78&&n=="c")return pd(r)||_i(r,1,n)||zt(r,1);if(n==(xe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ur(r,e){r.someProp("transformCopied",h=>{e=h(e,r)});let t=[],{content:n,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){s--,o--;let h=n.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),n=h.content}let i=r.someProp("clipboardSerializer")||ze.fromSchema(r.state.schema),l=Zi(),a=l.createElement("div");a.appendChild(i.serializeFragment(n,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Qi[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${o}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=r.someProp("clipboardTextSerializer",h=>h(e,r))||e.content.textBetween(0,e.content.size,`
|
|
26
|
+
`),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 s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=n.getPropertyValue(o);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(o,i,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,s){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(i,t.attrs||null,n,t.preserveWhitespace);a&&(o=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,n,s);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)}o&&this.sync(l)&&this.open--}addAll(e,t,n,s){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,n){let s,o;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,o=a,!c.length))break;if(a.solid){if(n)break;l+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t,n);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=z.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):bo(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,n,s){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,s)),o}enterInner(e,t,n,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=mo(e,o,i.options);i.options&Vn&&i.content.length==0&&(l|=Vn);let a=z.none;return n=n.filter(c=>(i.type?i.type.allowsMarkType(c.type):bo(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Rn(e,t,a,s,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|=Qt)}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 s=n.length-1;s>=0;s--)e+=n[s].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 s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(n?2:4)&&(this.find[s].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,s=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:n&&a>=o?n.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(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 bc(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&po.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function xc(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function yo(r){let e={};for(let t in r)e[t]=r[t];return e}function bo(r,e){let t=e.schema.nodes;for(let n in t){let s=t[n];if(!s.allowsMarkType(r))continue;let o=[],i=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&i(u))return!0}};if(i(s.contentMatch))return!0}}class ze{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=pr(t).createDocumentFragment());let s=n,o=[];return e.forEach(i=>{if(o.length||i.marks.length){let l=0,a=0;for(;l<o.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)s=o.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(o.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:s}=zn(pr(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let s=this.marks[e.type.name];return s&&zn(pr(n),s(e,t),null,e.attrs)}static renderSpec(e,t,n=null,s){return zn(e,t,n,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ze(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=xo(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return xo(e.marks)}}function xo(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function pr(r){return r.document||window.document}const ko=new WeakMap;function kc(r){let e=ko.get(r);return e===void 0&&ko.set(r,e=wc(r)),e}function wc(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 s=0;s<n.length;s++)t(n[s]);else for(let s in n)t(n[s])}return t(r),e}function zn(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 s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(o=kc(n))&&o.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 i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?r.createElementNS(t,s):r.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)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}=zn(r,f,t,n);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const wo=65535,So=Math.pow(2,16);function Sc(r,e){return r+e*So}function Co(r){return r&wo}function Cc(r){return(r-(r&wo))/So}const Mo=1,vo=2,jn=4,No=8;class mr{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&No)>0}get deletedBefore(){return(this.delInfo&(Mo|jn))>0}get deletedAfter(){return(this.delInfo&(vo|jn))>0}get deletedAcross(){return(this.delInfo&jn)>0}}class me{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&me.empty)return me.empty}recover(e){let t=0,n=Co(e);if(!this.inverted)for(let s=0;s<n;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[n*3]+t+Cc(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 s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+i],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+s+(f<0?0:u);if(n)return h;let p=e==(t<0?a:d)?null:Sc(l/3,e-a),b=e==a?vo:e==d?Mo:jn;return(t<0?e!=a:e!=d)&&(b|=No),new mr(h,b,p)}s+=u-c}return n?e+s:new mr(e+s,0,null)}touches(e,t){let n=0,s=Co(t),o=this.inverted?2:1,i=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+o],u=a+c;if(e<=u&&l==s*3)return!0;n+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[s+t],u=this.ranges[s+n];e(l,l+c,a,a+u),o+=u-c}}invert(){return new me(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?me.empty:new me(e<0?[0,-e,0]:[0,0,e])}}me.empty=new me([]);class Ut{constructor(e,t,n=0,s=e?e.length:0){this.mirror=t,this.from=n,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Ut(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 s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?n+s: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 s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?n-s-1:void 0)}}invert(){let e=new Ut;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 s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return n?e:new mr(e,s,null)}}const gr=Object.create(null);class se{getMap(){return me.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=gr[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 gr)throw new RangeError("Duplicate use of step JSON ID "+e);return gr[e]=t,t.prototype.jsonID=e,t}}class q{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new q(e,null)}static fail(e){return new q(null,e)}static fromReplace(e,t,n,s){try{return q.ok(e.replace(t,n,s))}catch(o){if(o instanceof En)return q.fail(o.message);throw o}}}function yr(r,e,t){let n=[];for(let s=0;s<r.childCount;s++){let o=r.child(s);o.content.size&&(o=o.copy(yr(o.content,e,o))),o.isInline&&(o=e(o,t,s)),n.push(o)}return S.fromArray(n)}class Je extends se{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),s=n.node(n.sharedDepth(this.to)),o=new E(yr(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,o)}invert(){return new Ee(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 Je(t.pos,n.pos,this.mark)}merge(e){return e instanceof Je&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Je(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 Je(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("addMark",Je);class Ee extends se{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 E(yr(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,n)}invert(){return new Je(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 Ee(t.pos,n.pos,this.mark)}merge(e){return e instanceof Ee&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ee(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 Ee(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("removeMark",Ee);class He extends se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new E(S.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 s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(n))return new He(this.pos,t.marks[s]);return new He(this.pos,this.mark)}}return new ut(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new He(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 He(t.pos,e.markFromJSON(t.mark))}}se.jsonID("addNodeMark",He);class ut extends se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new E(S.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new He(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ut(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 ut(t.pos,e.markFromJSON(t.mark))}}se.jsonID("removeNodeMark",ut);class oe extends se{constructor(e,t,n,s=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=s}apply(e){return this.structure&&br(e,this.from,this.to)?q.fail("Structure replace would overwrite content"):q.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new me([this.from,this.to-this.from,this.slice.size])}invert(e){return new oe(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 oe(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof oe)||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?E.empty:new E(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new oe(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?E.empty:new E(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new oe(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 oe(t.from,t.to,E.fromJSON(e,t.slice),!!t.structure)}}se.jsonID("replace",oe);class U extends se{constructor(e,t,n,s,o,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(br(e,this.from,this.gapFrom)||br(e,this.gapTo,this.to)))return q.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return q.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?q.fromReplace(e,this.from,this.to,n):q.fail("Content does not fit in gap")}getMap(){return new me([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 U(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),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||s<t.pos||o>n.pos?null:new U(t.pos,n.pos,s,o,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 U(t.from,t.to,t.gapFrom,t.gapTo,E.fromJSON(e,t.slice),t.insert,!!t.structure)}}se.jsonID("replaceAround",U);function br(r,e,t){let n=r.resolve(e),s=t-e,o=n.depth;for(;s>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,s--;if(s>0){let i=n.node(o).maybeChild(n.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function Mc(r,e,t,n){let s=[],o=[],i,l;r.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!n.isInSet(d)&&u.type.allowsMarkType(n.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=n.addToSet(d);for(let b=0;b<d.length;b++)d[b].isInSet(p)||(i&&i.to==f&&i.mark.eq(d[b])?i.to=h:s.push(i=new Ee(f,h,d[b])));l&&l.to==f?l.to=h:o.push(l=new Je(f,h,n))}}),s.forEach(a=>r.step(a)),o.forEach(a=>r.step(a))}function vc(r,e,t,n){let s=[],o=0;r.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(n instanceof An){let c=i.marks,u;for(;u=n.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else n?n.isInSet(i.marks)&&(a=[n]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==o-1&&d.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=o):s.push({style:d,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>r.step(new Ee(i.from,i.to,i.style)))}function xr(r,e,t,n=t.contentMatch,s=!0){let o=r.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,d=n.matchType(c.type);if(!d)i.push(new oe(l,u,E.empty));else{n=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||r.step(new Ee(l,u,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new E(S.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new oe(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!n.validEnd){let a=n.fillBefore(S.empty,!0);r.replace(l,l,new E(a,0,0))}for(let a=i.length-1;a>=0;a--)r.step(i[a])}function Nc(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function Zt(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth;;--n){let s=r.$from.node(n),o=r.$from.index(n),i=r.$to.indexAfter(n);if(n<r.depth&&s.canReplace(o,i,t))return n;if(n==0||s.type.spec.isolating||!Nc(s,o,i))break}return null}function Ec(r,e,t){let{$from:n,$to:s,depth:o}=e,i=n.before(o+1),l=s.after(o+1),a=i,c=l,u=S.empty,d=0;for(let p=o,b=!1;p>t;p--)b||n.index(p)>0?(b=!0,u=S.from(n.node(p).copy(u)),d++):a--;let f=S.empty,h=0;for(let p=o,b=!1;p>t;p--)b||s.after(p+1)<s.end(p)?(b=!0,f=S.from(s.node(p).copy(f)),h++):c++;r.step(new U(a,c,i,l,new E(u.append(f),d,h),u.size-d,!0))}function kr(r,e,t=null,n=r){let s=Oc(r,e),o=s&&Dc(n,e);return o?s.map(Eo).concat({type:e,attrs:t}).concat(o.map(Eo)):null}function Eo(r){return{type:r,attrs:null}}function Oc(r,e){let{parent:t,startIndex:n,endIndex:s}=r,o=t.contentMatchAt(n).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return t.canReplaceWith(n,s,i)?o:null}function Dc(r,e){let{parent:t,startIndex:n,endIndex:s}=r,o=t.child(n),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=n;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Tc(r,e,t){let n=S.empty;for(let i=t.length-1;i>=0;i--){if(n.size){let l=t[i].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=S.from(t[i].type.create(t[i].attrs,n))}let s=e.start,o=e.end;r.step(new U(s,o,s,o,new E(n,0,0),t.length,!0))}function Ac(r,e,t,n,s){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=r.steps.length;r.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(n,a)&&Pc(r.doc,r.mapping.slice(o).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&&Do(r,i,l,o),xr(r,r.mapping.slice(o).map(l,1),n,void 0,c===null);let u=r.mapping.slice(o),d=u.map(l,1),f=u.map(l+i.nodeSize,1);return r.step(new U(d,f,d+1,f-1,new E(S.from(n.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Oo(r,i,l,o),!1}})}function Oo(r,e,t,n){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=r.mapping.slice(n).map(t+1+o+i.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Do(r,e,t,n){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=r.mapping.slice(n).map(t+1+o);r.replaceWith(i,i+1,e.type.schema.text(`
|
|
27
|
+
`))}})}function Pc(r,e,t){let n=r.resolve(e),s=n.index();return n.parent.canReplaceWith(s,s+1,t)}function Ic(r,e,t,n,s){let o=r.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let i=t.create(n,null,s||o.marks);if(o.isLeaf)return r.replaceWith(e,e+o.nodeSize,i);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new U(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new E(S.from(i),0,0),1,!0))}function vt(r,e,t=1,n){let s=r.resolve(e),o=s.depth-t,i=n&&n[n.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=t-2;c>o;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=n&&n[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let b=n&&n[u]||d;if(!d.canReplace(f+1,d.childCount)||!b.type.validContent(h))return!1}let l=s.indexAfter(o),a=n&&n[0];return s.node(o).canReplaceWith(l,l,a?a.type:s.node(o+1).type)}function Vc(r,e,t=1,n){let s=r.doc.resolve(e),o=S.empty,i=S.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){o=S.from(s.node(l).copy(o));let u=n&&n[c];i=S.from(u?u.type.create(u.attrs,i):s.node(l).copy(i))}r.step(new oe(e,e,new E(o.append(i),t,t),!0))}function Nt(r,e){let t=r.resolve(e),n=t.index();return To(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function Rc(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let s=0;s<e.childCount;s++){let o=e.child(s),i=o.type==n?r.type.schema.nodes.text:o.type;if(t=t.matchType(i),!t||!r.type.allowsMarks(o.marks))return!1}return t.validEnd}function To(r,e){return!!(r&&e&&!r.isLeaf&&Rc(r,e))}function Ao(r,e,t=-1){let n=r.resolve(e);for(let s=n.depth;;s--){let o,i,l=n.index(s);if(s==n.depth?(o=n.nodeBefore,i=n.nodeAfter):t>0?(o=n.node(s+1),l++,i=n.node(s).maybeChild(l)):(o=n.node(s).maybeChild(l-1),i=n.node(s+1)),o&&!o.isTextblock&&To(o,i)&&n.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?n.before(s):n.after(s)}}function zc(r,e,t){let n=null,{linebreakReplacement:s}=r.doc.type.schema,o=r.doc.resolve(e-t),i=o.node().type;if(s&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(s);u&&!d?n=!1:!u&&d&&(n=!0)}let l=r.steps.length;if(n===!1){let u=r.doc.resolve(e+t);Do(r,u.node(),u.before(),l)}i.inlineContent&&xr(r,e+t-1,i,o.node().contentMatchAt(o.index()),n==null);let a=r.mapping.slice(l),c=a.map(e-t);if(r.step(new oe(c,a.map(e+t,-1),E.empty,!0)),n===!0){let u=r.doc.resolve(c);Oo(r,u.node(),u.before(),r.steps.length)}return r}function jc(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 s=n.depth-1;s>=0;s--){let o=n.index(s);if(n.node(s).canReplaceWith(o,o,t))return n.before(s+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let s=n.depth-1;s>=0;s--){let o=n.indexAfter(s);if(n.node(s).canReplaceWith(o,o,t))return n.after(s+1);if(o<n.node(s).childCount)return null}return null}function Po(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let s=t.content;for(let o=0;o<t.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let i=n.depth;i>=0;i--){let l=i==n.depth?0:n.pos<=(n.start(i+1)+n.end(i+1))/2?-1:1,a=n.index(i)+(l>0?1:0),c=n.node(i),u=!1;if(o==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?n.pos:l<0?n.before(i+1):n.after(i+1)}return null}function wr(r,e,t=e,n=E.empty){if(e==t&&!n.size)return null;let s=r.resolve(e),o=r.resolve(t);return Io(s,o,n)?new oe(e,t,n):new Bc(s,o,n).fit()}function Io(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class Bc{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=S.empty;for(let s=0;s<=e.depth;s++){let o=e.node(s);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=S.from(e.node(s).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,s=this.close(e<0?this.$to:n.doc.resolve(e));if(!s)return null;let o=this.placed,i=n.depth,l=s.depth;for(;i&&l&&o.childCount==1;)o=o.firstChild.content,i--,l--;let a=new E(o,i,l);return e>-1?new U(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new oe(n.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,s=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(s=0),o.type.spec.isolating&&s<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let s,o=null;n?(o=Sr(this.unplaced.content,n-1).firstChild,s=o.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(i?c.matchType(i.type)||(d=c.fillBefore(S.from(i),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:l,parent:o,inject:d};if(t==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,s=Sr(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new E(e,t+1,Math.max(n,s.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,s=Sr(e,t);if(s.childCount<=1&&t>0){let o=e.size-t<=t+s.size;this.unplaced=new E(en(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new E(en(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:s,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let b=0;b<o.length;b++)this.openFrontierNode(o[b]);let i=this.unplaced,l=n?n.content:i.content,a=i.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(s){for(let b=0;b<s.childCount;b++)u.push(s.child(b));d=d.matchFragment(s)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let b=l.child(c),y=d.matchType(b.type);if(!y)break;c++,(c>1||a==0||b.content.size)&&(d=y,u.push(Vo(b.mark(f.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=tn(this.placed,t,S.from(u)),this.frontier[t].match=d,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,y=l;b<h;b++){let x=y.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),y=x.content}this.unplaced=p?e==0?E.empty:new E(en(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new E(en(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Cr(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,s=this.$to.after(n);for(;n>1&&s==this.$to.end(--n);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:s}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Cr(e,t,s,n,o);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Cr(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:o?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=tn(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let s=e.node(n),o=s.type.contentMatch.fillBefore(s.content,!0,e.index(n));this.openFrontierNode(s.type,s.attrs,o)}return e}openFrontierNode(e,t=null,n){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=tn(this.placed,this.depth,S.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=tn(this.placed,this.frontier.length,t))}}function en(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(en(r.firstChild.content,e-1,t)))}function tn(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(tn(r.lastChild.content,e-1,t)))}function Sr(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function Vo(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,Vo(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(S.empty,!0)))),r.copy(n)}function Cr(r,e,t,n,s){let o=r.node(e),i=s?r.indexAfter(e):r.index(e);if(i==o.childCount&&!t.compatibleContent(o.type))return null;let l=n.fillBefore(o.content,!0,i);return l&&!Fc(t,o.content,i)?l:null}function Fc(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function Lc(r){return r.spec.defining||r.spec.definingForContent}function $c(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let s=r.doc.resolve(e),o=r.doc.resolve(t);if(Io(s,o,n))return r.step(new oe(e,t,n));let i=zo(s,r.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(f)>-1?l=f:s.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],u=n.openStart;for(let f=n.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==n.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=Lc(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=n.openStart;f>=0;f--){let h=(f+u+1)%(n.openStart+1),p=c[h];if(p)for(let b=0;b<i.length;b++){let y=i[(b+a)%i.length],x=!0;y<0&&(x=!1,y=-y);let k=s.node(y-1),w=s.index(y-1);if(k.canReplaceWith(w,w,p.type,p.marks))return r.replace(s.before(y),x?o.after(y):t,new E(Ro(n.content,0,n.openStart,h),h,n.openEnd))}}let d=r.steps.length;for(let f=i.length-1;f>=0&&(r.replace(e,t,n),!(r.steps.length>d));f--){let h=i[f];h<0||(e=s.before(h),t=o.after(h))}}function Ro(r,e,t,n,s){if(e<t){let o=r.firstChild;r=r.replaceChild(0,o.copy(Ro(o.content,e+1,t,n,o)))}if(e>n){let o=s.contentMatchAt(0),i=o.fillBefore(r).append(r);r=i.append(o.matchFragment(i).fillBefore(S.empty,!0))}return r}function Wc(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let s=jc(r.doc,e,n.type);s!=null&&(e=t=s)}r.replaceRange(e,t,new E(S.from(n),0,0))}function _c(r,e,t){let n=r.doc.resolve(e),s=r.doc.resolve(t),o=zo(n,s);for(let i=0;i<o.length;i++){let l=o[i],a=i==o.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),s.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),s.indexAfter(l-1))))return r.delete(n.before(l),s.after(l))}for(let i=1;i<=n.depth&&i<=s.depth;i++)if(e-n.start(i)==n.depth-i&&t>n.end(i)&&s.end(i)-t!=s.depth-i&&n.start(i-1)==s.start(i-1)&&n.node(i-1).canReplace(n.index(i-1),s.index(i-1)))return r.delete(n.before(i),t);r.delete(e,t)}function zo(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let s=n;s>=0;s--){let o=r.start(s);if(o<r.pos-(r.depth-s)||e.end(s)>e.pos+(e.depth-s)||r.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==r.depth&&s==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&t.push(s)}return t}class Et extends se{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 q.fail("No node at attribute step's position");let n=Object.create(null);for(let o in t.attrs)n[o]=t.attrs[o];n[this.attr]=this.value;let s=t.type.create(n,null,t.marks);return q.fromReplace(e,this.pos,this.pos+1,new E(S.from(s),0,t.isLeaf?0:1))}getMap(){return me.empty}invert(e){return new Et(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 Et(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 Et(t.pos,t.attr,t.value)}}se.jsonID("attr",Et);class nn extends se{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return q.ok(n)}getMap(){return me.empty}invert(e){return new nn(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 nn(t.attr,t.value)}}se.jsonID("docAttr",nn);let Ot=class extends Error{};Ot=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t},Ot.prototype=Object.create(Error.prototype),Ot.prototype.constructor=Ot,Ot.prototype.name="TransformError";class jo{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ut}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ot(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=E.empty){let s=wr(this.doc,e,t,n);return s&&this.step(s),this}replaceWith(e,t,n){return this.replace(e,t,new E(S.from(n),0,0))}delete(e,t){return this.replace(e,t,E.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return $c(this,e,t,n),this}replaceRangeWith(e,t,n){return Wc(this,e,t,n),this}deleteRange(e,t){return _c(this,e,t),this}lift(e,t){return Ec(this,e,t),this}join(e,t=1){return zc(this,e,t),this}wrap(e,t){return Tc(this,e,t),this}setBlockType(e,t=e,n,s=null){return Ac(this,e,t,n,s),this}setNodeMarkup(e,t,n=null,s){return Ic(this,e,t,n,s),this}setNodeAttribute(e,t,n){return this.step(new Et(e,t,n)),this}setDocAttribute(e,t){return this.step(new nn(e,t)),this}addNodeMark(e,t){return this.step(new He(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 z)t.isInSet(n.marks)&&this.step(new ut(e,t));else{let s=n.marks,o,i=[];for(;o=t.isInSet(s);)i.push(new ut(e,o)),s=o.removeFromSet(s);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,n){return Vc(this,e,t,n),this}addMark(e,t,n){return Mc(this,e,t,n),this}removeMark(e,t,n){return vc(this,e,t,n),this}clearIncompatible(e,t,n){return xr(this,e,t,n),this}}const Mr=Object.create(null);class P{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Bo(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=E.empty){let n=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=n,n=n.lastChild;let o=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?E.empty:t),l==0&&$o(e,o,(n?n.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:l}=s[o],a=e.mapping.slice(n),c=a.map(i.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),$o(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let s=e.parent.inlineContent?new V(e):Dt(e.node(0),e.parent,e.pos,e.index(),t,n);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=t<0?Dt(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):Dt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ge(e.node(0))}static atStart(e){return Dt(e,e,0,0,1)||new ge(e)}static atEnd(e){return Dt(e,e,e.content.size,e.childCount,-1)||new ge(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Mr[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 Mr)throw new RangeError("Duplicate use of selection JSON ID "+e);return Mr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return V.between(this.$anchor,this.$head).getBookmark()}}P.prototype.visible=!0;class Bo{constructor(e,t){this.$from=e,this.$to=t}}let Fo=!1;function Lo(r){!Fo&&!r.parent.inlineContent&&(Fo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class V extends P{constructor(e,t=e){Lo(e),Lo(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 P.near(n);let s=e.resolve(t.map(this.anchor));return new V(s.parent.inlineContent?s:n,n)}replace(e,t=E.empty){if(super.replace(e,t),t==E.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof V&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Bn(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 V(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let s=e.resolve(t);return new this(s,n==t?s:e.resolve(n))}static between(e,t,n){let s=e.pos-t.pos;if((!n||s)&&(n=s>=0?1:-1),!t.parent.inlineContent){let o=P.findFrom(t,n,!0)||P.findFrom(t,-n,!0);if(o)t=o.$head;else return P.near(t,n)}return e.parent.inlineContent||(s==0?e=t:(e=(P.findFrom(e,-n,!0)||P.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new V(e,t)}}P.jsonID("text",V);class Bn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Bn(e.map(this.anchor),e.map(this.head))}resolve(e){return V.between(e.resolve(this.anchor),e.resolve(this.head))}}class A extends P{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:s}=t.mapResult(this.anchor),o=e.resolve(s);return n?P.near(o):new A(o)}content(){return new E(S.from(this.node),0,0)}eq(e){return e instanceof A&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new vr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new A(e.resolve(t.anchor))}static create(e,t){return new A(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}A.prototype.visible=!1,P.jsonID("node",A);class vr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Bn(n,n):new vr(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&A.isSelectable(n)?new A(t):P.near(t)}}class ge extends P{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=E.empty){if(t==E.empty){e.delete(0,e.doc.content.size);let n=P.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ge(e)}map(e){return new ge(e)}eq(e){return e instanceof ge}getBookmark(){return qc}}P.jsonID("all",ge);const qc={map(){return this},resolve(r){return new ge(r)}};function Dt(r,e,t,n,s,o=!1){if(e.inlineContent)return V.create(r,t);for(let i=n-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!o&&A.isSelectable(l))return A.create(r,t-(s<0?l.nodeSize:0))}else{let a=Dt(r,l,t+s,s<0?l.childCount:0,s,o);if(a)return a}t+=l.nodeSize*s}return null}function $o(r,e,t){let n=r.steps.length-1;if(n<e)return;let s=r.steps[n];if(!(s instanceof oe||s instanceof U))return;let o=r.mapping.maps[n],i;o.forEach((l,a,c,u)=>{i==null&&(i=u)}),r.setSelection(P.near(r.doc.resolve(i),t))}const Wo=1,_o=2,qo=4;class Jc extends jo{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Wo)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Wo)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=_o,this}ensureMarks(e){return z.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&_o)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||z.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),n=n??t,!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let i=this.doc.resolve(t);o=n==t?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,s.text(e,o)),this.selection.empty||this.setSelection(P.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=qo,this}get scrolledIntoView(){return(this.updated&qo)>0}}function Jo(r,e){return!e||!r?r:r.bind(e)}class rn{constructor(e,t,n){this.name=e,this.init=Jo(t.init,n),this.apply=Jo(t.apply,n)}}const Hc=[new rn("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new rn("selection",{init(r,e){return r.selection||P.atStart(e.doc)},apply(r){return r.selection}}),new rn("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new rn("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class Nr{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Hc.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new rn(n.key,n.spec.state,n))})}}class Ke{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let s=this.config.plugins[n];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),s=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,n);if(u&&n.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<i?{state:n,n:t.length}:{state:this,n:0})}t.push(u),n=n.applyInner(u),o=!0}s&&(s[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ke(this.config),n=this.config.fields;for(let s=0;s<n.length;s++){let o=n[s];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Jc(this)}static create(e){let t=new Nr(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new Ke(t);for(let s=0;s<t.fields.length;s++)n[t.fields[s].name]=t.fields[s].init(e,n);return n}reconfigure(e){let t=new Nr(this.schema,e.plugins),n=t.fields,s=new Ke(t);for(let o=0;o<n.length;o++){let i=n[o].name;s[i]=this.hasOwnProperty(i)?this[i]:n[o].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[n],o=s.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Nr(e.schema,e.plugins),o=new Ke(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=pe.fromJSON(e.schema,t.doc);else if(i.name=="selection")o.selection=P.fromJSON(o.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[i.name]=c.fromJSON.call(a,e,t[l],o);return}}o[i.name]=i.init(e,o)}}),o}}function Ho(r,e,t){for(let n in r){let s=r[n];s instanceof Function?s=s.bind(e):n=="handleDOMEvents"&&(s=Ho(s,e,{})),t[n]=s}return t}class Oe{constructor(e){this.spec=e,this.props={},e.props&&Ho(e.props,this,this.props),this.key=e.key?e.key.key:Ko("plugin")}getState(e){return e[this.key]}}const Er=Object.create(null);function Ko(r){return r in Er?r+"$"+ ++Er[r]:(Er[r]=0,r+"$")}class Ye{constructor(e="key"){this.key=Ko(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}for(var Ge={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:"'"},Fn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Kc=typeof navigator<"u"&&/Mac/.test(navigator.platform),Yc=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Z=0;Z<10;Z++)Ge[48+Z]=Ge[96+Z]=String(Z);for(var Z=1;Z<=24;Z++)Ge[Z+111]="F"+Z;for(var Z=65;Z<=90;Z++)Ge[Z]=String.fromCharCode(Z+32),Fn[Z]=String.fromCharCode(Z);for(var Or in Ge)Fn.hasOwnProperty(Or)||(Fn[Or]=Ge[Or]);function Gc(r){var e=Kc&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||Yc&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Fn:Ge)[r.keyCode]||r.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 Xc=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Qc(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,s,o,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))Xc?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function Uc(r){let e=Object.create(null);for(let t in r)e[Qc(t)]=r[t];return e}function Dr(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function Tr(r){return new Oe({props:{handleKeyDown:Ar(r)}})}function Ar(r){let e=Uc(r);return function(t,n){let s=Gc(n),o,i=e[Dr(s,n)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(n.shiftKey){let l=e[Dr(s,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.shiftKey||n.altKey||n.metaKey||s.charCodeAt(0)>127)&&(o=Ge[n.keyCode])&&o!=s){let l=e[Dr(o,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Ln=200,Y=function(){};Y.prototype.append=function(e){return e.length?(e=Y.from(e),!this.length&&e||e.length<Ln&&this.leafAppend(e)||this.length<Ln&&e.leafPrepend(this)||this.appendInner(e)):this},Y.prototype.prepend=function(e){return e.length?Y.from(e).append(this):this},Y.prototype.appendInner=function(e){return new Zc(this,e)},Y.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Y.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Y.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Y.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Y.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,n),s},Y.from=function(e){return e instanceof Y?e:e&&e.length?new Yo(e):Y.empty};var Yo=function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Ln)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Ln)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(Y);Y.empty=new Yo([]);var Zc=function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(n,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(n,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(n,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(n,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(n,s){if(n==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(n,s):n>=o?this.right.slice(n-o,s-o):this.left.slice(n,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(n){var s=this.right.leafAppend(n);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(n){var s=this.left.leafPrepend(n);if(s)return new e(s,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e}(Y);const eu=500;class Me{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let s,o;t&&(s=this.remapping(n,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(n,f+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new De(d.map));let h=d.step.map(s.slice(o)),p;h&&i.maybeStep(h).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new De(p,void 0,void 0,c.length+u.length))),o--,p&&s.appendMap(p,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new Me(this.items.slice(0,n).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,n,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new De(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-n.depth;return c>nu&&(l=tu(l,c),i-=c),new Me(l.append(o),i)}remapping(e,t){let n=new Ut;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?n.maps.length-s.mirrorOffset:void 0;n.appendMap(s.map,i)},e,t),n}addMaps(e){return this.eventCount==0?this:new Me(this.items.append(e.map(t=>new De(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let p=o.maps[h];if(f.step){let b=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(o.slice(a+1,h));y&&l++,n.push(new De(p,b,y))}else n.push(new De(p))},s);let c=[];for(let f=t;f<i;f++)c.push(new De(o.maps[f]));let u=this.items.slice(0,s).append(c).append(n),d=new Me(u,l);return d.emptyItemCount()>eu&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(n)),c=a&&a.getMap();if(n--,c&&t.appendMap(c,n),a){let u=i.selection&&i.selection.map(t.slice(n));u&&o++;let d=new De(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else i.map&&n--},this.items.length,0),new Me(Y.from(s.reverse()),o)}}Me.empty=new Me(Y.empty,0);function tu(r,e){let t;return r.forEach((n,s)=>{if(n.selection&&e--==0)return t=s,!1}),r.slice(t)}class De{constructor(e,t,n,s){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new De(t.getMap().invert(),t,this.selection)}}}class Xe{constructor(e,t,n,s,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=s,this.prevComposition=o}}const nu=20;function ru(r,e,t,n){let s=t.getMeta(dt),o;if(s)return s.historyState;t.getMeta(iu)&&(r=new Xe(r.done,r.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(i&&i.getMeta(dt))return i.getMeta(dt).redo?new Xe(r.done.addTransform(t,void 0,n,$n(e)),r.undone,Go(t.mapping.maps),r.prevTime,r.prevComposition):new Xe(r.done,r.undone.addTransform(t,void 0,n,$n(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!i&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!su(t,r.prevRanges)),c=i?Pr(r.prevRanges,t.mapping):Go(t.mapping.maps);return new Xe(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,$n(e)),Me.empty,c,t.time,l??r.prevComposition)}else return(o=t.getMeta("rebased"))?new Xe(r.done.rebased(t,o),r.undone.rebased(t,o),Pr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new Xe(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),Pr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function su(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,s)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function Go(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,s,o,i)=>e.push(o,i));return e}function Pr(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let s=e.map(r[n],1),o=e.map(r[n+1],-1);s<=o&&t.push(s,o)}return t}function ou(r,e,t){let n=$n(e),s=dt.get(e).spec.config,o=(t?r.undone:r.done).popEvent(e,n);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?r.done:r.undone).addTransform(o.transform,e.selection.getBookmark(),s,n),a=new Xe(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(dt,{redo:t,historyState:a})}let Ir=!1,Xo=null;function $n(r){let e=r.plugins;if(Xo!=e){Ir=!1,Xo=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ir=!0;break}}return Ir}const dt=new Ye("history"),iu=new Ye("closeHistory");function lu(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new Oe({key:dt,state:{init(){return new Xe(Me.empty,Me.empty,null,0,-1)},apply(e,t,n){return ru(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,s=n=="historyUndo"?Vr:n=="historyRedo"?Wn:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function Qo(r,e){return(t,n)=>{let s=dt.getState(t);if(!s||(r?s.undone:s.done).eventCount==0)return!1;if(n){let o=ou(s,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const Vr=Qo(!1,!0),Wn=Qo(!0,!0),Uo=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function au(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const cu=(r,e,t)=>{let n=au(r,t);if(!n)return!1;let s=Zo(n);if(!s){let i=n.blockRange(),l=i&&Zt(i);return l==null?!1:(e&&e(r.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(ri(r,s,e,-1))return!0;if(n.parent.content.size==0&&(Tt(o,"end")||A.isSelectable(o)))for(let i=n.depth;;i--){let l=wr(r.doc,n.before(i),n.after(i),E.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(Tt(o,"end")?P.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):A.create(a.doc,s.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||n.node(i-1).childCount>1)break}return o.isAtom&&s.depth==n.depth-1?(e&&e(r.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1};function Tt(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 uu=(r,e,t)=>{let{$head:n,empty:s}=r.selection,o=n;if(!s)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;o=Zo(n)}let i=o&&o.nodeBefore;return!i||!A.isSelectable(i)?!1:(e&&e(r.tr.setSelection(A.create(r.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function Zo(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 du(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const fu=(r,e,t)=>{let n=du(r,t);if(!n)return!1;let s=ei(n);if(!s)return!1;let o=s.nodeAfter;if(ri(r,s,e,1))return!0;if(n.parent.content.size==0&&(Tt(o,"start")||A.isSelectable(o))){let i=wr(r.doc,n.before(),n.after(),E.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=r.tr.step(i);l.setSelection(Tt(o,"start")?P.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):A.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&s.depth==n.depth-1?(e&&e(r.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},hu=(r,e,t)=>{let{$head:n,empty:s}=r.selection,o=n;if(!s)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;o=ei(n)}let i=o&&o.nodeAfter;return!i||!A.isSelectable(i)?!1:(e&&e(r.tr.setSelection(A.create(r.doc,o.pos)).scrollIntoView()),!0)};function ei(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 ti=(r,e)=>{let t=r.selection,n=t instanceof A,s;if(n){if(t.node.isTextblock||!Nt(r.doc,t.from))return!1;s=t.from}else if(s=Ao(r.doc,t.from,-1),s==null)return!1;if(e){let o=r.tr.join(s);n&&o.setSelection(A.create(o.doc,s-r.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},pu=(r,e)=>{let t=r.selection,n;if(t instanceof A){if(t.node.isTextblock||!Nt(r.doc,t.to))return!1;n=t.to}else if(n=Ao(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},Rr=(r,e)=>{let{$from:t,$to:n}=r.selection,s=t.blockRange(n),o=s&&Zt(s);return o==null?!1:(e&&e(r.tr.lift(s,o).scrollIntoView()),!0)},mu=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
28
|
+
`).scrollIntoView()),!0)};function zr(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 ni=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let s=t.node(-1),o=t.indexAfter(-1),i=zr(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,i.createAndFill());a.setSelection(P.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},gu=(r,e)=>{let t=r.selection,{$from:n,$to:s}=t;if(t instanceof ge||n.parent.inlineContent||s.parent.inlineContent)return!1;let o=zr(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let i=(!n.parentOffset&&s.index()<s.parent.childCount?n:s).pos,l=r.tr.insert(i,o.createAndFill());l.setSelection(V.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},yu=(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 o=t.before();if(vt(r.doc,o))return e&&e(r.tr.split(o).scrollIntoView()),!0}let n=t.blockRange(),s=n&&Zt(n);return s==null?!1:(e&&e(r.tr.lift(n,s).scrollIntoView()),!0)};function bu(r){return(e,t)=>{let{$from:n,$to:s}=e.selection;if(e.selection instanceof A&&e.selection.node.isBlock)return!n.parentOffset||!vt(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],i,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=zr(n.node(h-1).contentMatchAt(n.indexAfter(h-1))),o.unshift(a&&l?{type:l}:null),i=h;break}else{if(h==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof V||e.selection instanceof ge)&&u.deleteSelection();let d=u.mapping.map(n.pos),f=vt(u.doc,d,o.length,o);if(f||(o[0]=l?{type:l}:null,f=vt(u.doc,d,o.length,o)),!f)return!1;if(u.split(d,o.length,o),!a&&c&&n.node(i).type!=l){let h=u.mapping.map(n.before(i)),p=u.doc.resolve(h);l&&n.node(i-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(n.before(i)),l)}return t&&t(u.scrollIntoView()),!0}}const xu=bu(),jr=(r,e)=>{let{$from:t,to:n}=r.selection,s,o=t.sharedDepth(n);return o==0?!1:(s=t.before(o),e&&e(r.tr.setSelection(A.create(r.doc,s))),!0)},ku=(r,e)=>(e&&e(r.tr.setSelection(new ge(r.doc))),!0);function wu(r,e,t){let n=e.nodeBefore,s=e.nodeAfter,o=e.index();return!n||!s||!n.type.compatibleContent(s.type)?!1:!n.content.size&&e.parent.canReplace(o-1,o)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||Nt(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function ri(r,e,t,n){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&wu(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&l.matchType(i[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,p=S.empty;for(let x=i.length-1;x>=0;x--)p=S.from(i[x].create(null,p));p=S.from(s.copy(p));let b=r.tr.step(new U(e.pos-1,h,e.pos,h,new E(p,1,0),i.length,!0)),y=b.doc.resolve(h+2*i.length);y.nodeAfter&&y.nodeAfter.type==s.type&&Nt(b.doc,y.pos)&&b.join(y.pos),t(b.scrollIntoView())}return!0}let u=o.type.spec.isolating||n>0&&a?null:P.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Zt(d);if(f!=null&&f>=e.depth)return t&&t(r.tr.lift(d,f).scrollIntoView()),!0;if(c&&Tt(o,"start",!0)&&Tt(s,"end")){let h=s,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let b=o,y=1;for(;!b.isTextblock;b=b.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,b.content)){if(t){let x=S.empty;for(let w=p.length-1;w>=0;w--)x=S.from(p[w].copy(x));let k=r.tr.step(new U(e.pos-p.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new E(x,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function si(r){return function(e,t){let n=e.selection,s=r<0?n.$from:n.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(t&&t(e.tr.setSelection(V.create(e.doc,r<0?s.start(o):s.end(o)))),!0):!1}}const Su=si(-1),Cu=si(1);function oi(r,e=null){return function(t,n){let{$from:s,$to:o}=t.selection,i=s.blockRange(o),l=i&&kr(i,r,e);return l?(n&&n(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function At(r,e=null){return function(t,n){let s=!1;for(let o=0;o<t.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(r,e)))if(a.type==r)s=!0;else{let u=t.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,r)}})}if(!s)return!1;if(n){let o=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];o.setBlockType(l,a,r,e)}n(o.scrollIntoView())}return!0}}function Mu(r,e,t,n){for(let s=0;s<e.length;s++){let{$from:o,$to:i}=e[s],l=o.depth==0?r.inlineContent&&r.type.allowsMarkType(t):!1;if(r.nodesBetween(o.pos,i.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function ye(r,e=null,t){return function(n,s){let{empty:o,$cursor:i,ranges:l}=n.selection;if(o&&!i||!Mu(n.doc,l,r))return!1;if(s)if(i)r.isInSet(n.storedMarks||i.marks())?s(n.tr.removeStoredMark(r)):s(n.tr.addStoredMark(r.create(e)));else{let a,c=n.tr;a=!l.some(u=>n.doc.rangeHasMark(u.$from.pos,u.$to.pos,r));for(let u=0;u<l.length;u++){let{$from:d,$to:f}=l[u];if(!a)c.removeMark(d.pos,f.pos,r);else{let h=d.pos,p=f.pos,b=d.nodeAfter,y=f.nodeBefore,x=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,k=y&&y.isText?/\s*$/.exec(y.text)[0].length:0;h+x<p&&(h+=x,p-=k),c.addMark(h,p,r.create(e))}}s(c.scrollIntoView())}return!0}}function _n(...r){return function(e,t,n){for(let s=0;s<r.length;s++)if(r[s](e,t,n))return!0;return!1}}let Br=_n(Uo,cu,uu),ii=_n(Uo,fu,hu);const je={Enter:_n(mu,gu,yu,xu),"Mod-Enter":ni,Backspace:Br,"Mod-Backspace":Br,"Shift-Backspace":Br,Delete:ii,"Mod-Delete":ii,"Mod-a":ku},li={"Ctrl-h":je.Backspace,"Alt-Backspace":je["Mod-Backspace"],"Ctrl-d":je.Delete,"Ctrl-Alt-Backspace":je["Mod-Delete"],"Alt-Delete":je["Mod-Delete"],"Alt-d":je["Mod-Delete"],"Ctrl-a":Su,"Ctrl-e":Cu};for(let r in je)li[r]=je[r];const vu=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?li:je;function Nu(r={}){return new Oe({view(e){return new Eu(e,r)}})}class Eu{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),b=d?p.bottom:p.top;d&&f&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;n={left:p.left,right:p.right,top:b-y,bottom:b+y}}}}if(!n){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;n={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(n.left-c)/i+"px",this.element.style.top=(n.top-u)/l+"px",this.element.style.width=(n.right-n.left)/i+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=n&&n.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Po(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const ee=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},Pt=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let Fr=null;const Be=function(r,e,t){let n=Fr||(Fr=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},Ou=function(){Fr=null},ft=function(r,e,t,n){return t&&(ai(r,e,t,n,-1)||ai(r,e,t,n,1))},Du=/^(img|br|input|textarea|hr)$/i;function ai(r,e,t,n,s){for(;;){if(r==t&&e==n)return!0;if(e==(s<0?0:be(r))){let o=r.parentNode;if(!o||o.nodeType!=1||sn(r)||Du.test(r.nodeName)||r.contentEditable=="false")return!1;e=ee(r)+(s<0?0:1),r=o}else if(r.nodeType==1){if(r=r.childNodes[e+(s<0?-1:0)],r.contentEditable=="false")return!1;e=s<0?be(r):0}else return!1}}function be(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Tu(r,e){for(;;){if(r.nodeType==3&&e)return r;if(r.nodeType==1&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=be(r)}else if(r.parentNode&&!sn(r))e=ee(r),r=r.parentNode;else return null}}function Au(r,e){for(;;){if(r.nodeType==3&&e<r.nodeValue.length)return r;if(r.nodeType==1&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!sn(r))e=ee(r)+1,r=r.parentNode;else return null}}function Pu(r,e,t){for(let n=e==0,s=e==be(r);n||s;){if(r==t)return!0;let o=ee(r);if(r=r.parentNode,!r)return!1;n=n&&o==0,s=s&&o==be(r)}}function sn(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const qn=function(r){return r.focusNode&&ft(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function ht(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function Iu(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Vu(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(be(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(be(n.startContainer),n.startOffset)}}}const Te=typeof navigator<"u"?navigator:null,ci=typeof document<"u"?document:null,Qe=Te&&Te.userAgent||"",Lr=/Edge\/(\d+)/.exec(Qe),ui=/MSIE \d/.exec(Qe),$r=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Qe),he=!!(ui||$r||Lr),Ue=ui?document.documentMode:$r?+$r[1]:Lr?+Lr[1]:0,ve=!he&&/gecko\/(\d+)/i.test(Qe);ve&&+(/Firefox\/(\d+)/.exec(Qe)||[0,0])[1];const Wr=!he&&/Chrome\/(\d+)/.exec(Qe),ie=!!Wr,di=Wr?+Wr[1]:0,ce=!he&&!!Te&&/Apple Computer/.test(Te.vendor),It=ce&&(/Mobile\/\w+/.test(Qe)||!!Te&&Te.maxTouchPoints>2),xe=It||(Te?/Mac/.test(Te.platform):!1),Ru=Te?/Win/.test(Te.platform):!1,Fe=/Android \d/.test(Qe),on=!!ci&&"webkitFontSmoothing"in ci.documentElement.style,zu=on?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ju(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function Le(r,e){return typeof r=="number"?r:r[e]}function Bu(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function fi(r,e,t){let n=r.someProp("scrollThreshold")||0,s=r.someProp("scrollMargin")||5,o=r.dom.ownerDocument;for(let i=t||r.dom;i;){if(i.nodeType!=1){i=Pt(i);continue}let l=i,a=l==o.body,c=a?ju(o):Bu(l),u=0,d=0;if(e.top<c.top+Le(n,"top")?d=-(c.top-e.top+Le(s,"top")):e.bottom>c.bottom-Le(n,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Le(s,"top")-c.top:e.bottom-c.bottom+Le(s,"bottom")),e.left<c.left+Le(n,"left")?u=-(c.left-e.left+Le(s,"left")):e.right>c.right-Le(n,"right")&&(u=e.right-c.right+Le(s,"right")),u||d)if(a)o.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let b=l.scrollLeft-h,y=l.scrollTop-p;e={left:e.left-b,top:e.top-y,right:e.right-b,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:Pt(i)}}function Fu(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,s;for(let o=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=r.root.elementFromPoint(o,i);if(!l||l==r.dom||!r.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,s=a.top;break}}return{refDOM:n,refTop:s,stack:hi(r.dom)}}function hi(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=Pt(n));return e}function Lu({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;pi(t,n==0?0:n-e)}function pi(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:s,left:o}=r[t];n.scrollTop!=s+e&&(n.scrollTop=s+e),n.scrollLeft!=o&&(n.scrollLeft=o)}}let Vt=null;function $u(r){if(r.setActive)return r.setActive();if(Vt)return r.focus(Vt);let e=hi(r);r.focus(Vt==null?{get preventScroll(){return Vt={preventScroll:!0},!0}}:void 0),Vt||(Vt=!1,pi(e,0))}function mi(r,e){let t,n=2e8,s,o=0,i=e.top,l=e.top,a,c;for(let u=r.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=Be(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=i&&p.bottom>=l){i=Math.max(p.bottom,i),l=Math.min(p.top,l);let b=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(b<n){t=u,n=b,s=b&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&b&&(o=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=d+1)}}return!t&&a&&(t=a,s=c,n=0),t&&t.nodeType==3?Wu(t,s):!t||n&&t.nodeType==1?{node:r,offset:o}:mi(t,s)}function Wu(r,e){let t=r.nodeValue.length,n=document.createRange();for(let s=0;s<t;s++){n.setEnd(r,s+1),n.setStart(r,s);let o=Ze(n,1);if(o.top!=o.bottom&&_r(e,o))return{node:r,offset:s+(e.left>=(o.left+o.right)/2?1:0)}}return{node:r,offset:0}}function _r(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function _u(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function qu(r,e,t){let{node:n,offset:s}=mi(e,t),o=-1;if(n.nodeType==1&&!n.firstChild){let i=n.getBoundingClientRect();o=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return r.docView.posFromDOM(n,s,o)}function Ju(r,e,t,n){let s=-1;for(let o=e,i=!1;o!=r.dom;){let l=r.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!i&&a.left>n.left||a.top>n.top?s=l.posBefore:(!i&&a.right<n.left||a.bottom<n.top)&&(s=l.posAfter),i=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return s>-1?s:r.docView.posFromDOM(e,t,-1)}function gi(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let s=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),o=s;;){let i=r.childNodes[o];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(_r(e,c))return gi(i,e,c)}}if((o=(o+1)%n)==s)break}return r}function Hu(r,e){let t=r.dom.ownerDocument,n,s=0,o=Vu(t,e.left,e.top);o&&({node:n,offset:s}=o);let i=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),l;if(!i||!r.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=r.dom.getBoundingClientRect();if(!_r(e,c)||(i=gi(r.dom,e,c),!i))return null}if(ce)for(let c=i;n&&c;c=Pt(c))c.draggable&&(n=void 0);if(i=_u(i,e),n){if(ve&&n.nodeType==1&&(s=Math.min(s,n.childNodes.length),s<n.childNodes.length)){let u=n.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;on&&s&&n.nodeType==1&&(c=n.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,n==r.dom&&s==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?l=r.state.doc.content.size:(s==0||n.nodeType!=1||n.childNodes[s-1].nodeName!="BR")&&(l=Ju(r,n,s,e))}l==null&&(l=qu(r,i,e));let a=r.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function yi(r){return r.top<r.bottom||r.left<r.right}function Ze(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(yi(n))return n}return Array.prototype.find.call(t,yi)||r.getBoundingClientRect()}const Ku=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function bi(r,e,t){let{node:n,offset:s,atom:o}=r.docView.domFromPos(e,t<0?-1:1),i=on||ve;if(n.nodeType==3)if(i&&(Ku.test(n.nodeValue)||(t<0?!s:s==n.nodeValue.length))){let a=Ze(Be(n,s,s),t);if(ve&&s&&/\s/.test(n.nodeValue[s-1])&&s<n.nodeValue.length){let c=Ze(Be(n,s-1,s-1),-1);if(c.top==a.top){let u=Ze(Be(n,s,s+1),-1);if(u.top!=a.top)return ln(u,u.left<c.left)}}return a}else{let a=s,c=s,u=t<0?1:-1;return t<0&&!s?(c++,u=-1):t>=0&&s==n.nodeValue.length?(a--,u=1):t<0?a--:c++,ln(Ze(Be(n,a,c),u),u<0)}if(!r.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(t<0||s==be(n))){let a=n.childNodes[s-1];if(a.nodeType==1)return qr(a.getBoundingClientRect(),!1)}if(o==null&&s<be(n)){let a=n.childNodes[s];if(a.nodeType==1)return qr(a.getBoundingClientRect(),!0)}return qr(n.getBoundingClientRect(),t>=0)}if(o==null&&s&&(t<0||s==be(n))){let a=n.childNodes[s-1],c=a.nodeType==3?Be(a,be(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return ln(Ze(c,1),!1)}if(o==null&&s<be(n)){let a=n.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Be(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return ln(Ze(c,-1),!0)}return ln(Ze(n.nodeType==3?Be(n):n,-t),t>=0)}function ln(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function qr(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function xi(r,e,t){let n=r.state,s=r.root.activeElement;n!=e&&r.updateState(e),s!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),s!=r.dom&&s&&s.focus()}}function Yu(r,e,t){let n=e.selection,s=t=="up"?n.$from:n.$to;return xi(r,e,()=>{let{node:o}=r.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=r.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let i=bi(r,s.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Be(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const Gu=/[\u0590-\u08ac]/;function Xu(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let s=n.parentOffset,o=!s,i=s==n.parent.content.size,l=r.domSelection();return l?!Gu.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:i:xi(r,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=r.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:p,focusOffset:b}=r.domSelectionRange(),y=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==b;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):n.pos==n.start()||n.pos==n.end()}let ki=null,wi=null,Si=!1;function Qu(r,e,t){return ki==e&&wi==t?Si:(ki=e,wi=t,Si=t=="up"||t=="down"?Yu(r,e,t):Xu(r,e,t))}const ke=0,Ci=1,pt=2,Ae=3;let an=class{constructor(e,t,n,s){this.parent=e,this.children=t,this.dom=n,this.contentDOM=s,this.dirty=ke,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let s=this.children[t];if(s==e)return n;n+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let o,i;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ee(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!t||o.node))if(n&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))n=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let s=this.children[t],o=n+s.size;if(n==e&&o!=n){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){let l=s.children[i];if(l.size){s=l;break}}return s}if(e<o)return s.descAt(e-n-s.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,s=0;for(let o=0;n<this.children.length;n++){let i=this.children[n],l=o+i.size;if(l>e||i instanceof Ei){s=e-o;break}o=l}if(s)return this.children[n].domFromPos(s-this.children[n].border,t);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof Mi&&o.side>=0;n--);if(t<=0){let o,i=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,i=!1);return o&&t&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?ee(o.dom)+1:0}}else{let o,i=!0;for(;o=n<this.children.length?this.children[n]:null,!(!o||o.dom.parentNode==this.contentDOM);n++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?ee(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=n,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=ee(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=ee(d.dom);break}t+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,s=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let b=this.children[h],y=p+b.size;if(o>p&&i<y)return b.setSelection(e-p-b.border,t-p-b.border,n,s);p=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),u=n.domSelectionRange(),d=!1;if((ve||ce)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==`
|
|
29
|
+
`),d&&p==h.nodeValue.length)for(let b=h,y;b;b=b.parentNode){if(y=b.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:ee(y)+1});break}let x=b.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let b=h.childNodes[p-1];d=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(ve&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||d&&ce)&&ft(l.node,l.offset,u.anchorNode,u.anchorOffset)&&ft(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!d){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,s=0;s<this.children.length;s++){let o=this.children[s],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let l=n+o.border,a=i-o.border;if(e>=l&&t<=a){this.dirty=e==n||t==i?pt:Ci,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Ae:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?pt:Ae}n=i}this.dirty=pt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?pt:Ci;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}},Mi=class extends an{constructor(e,t,n,s){let o,i=t.type.toDOM;if(typeof i=="function"&&(i=i(n,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==ke&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},Uu=class extends an{constructor(e,t,n,s){super(e,[],t,null),this.textDOM=n,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Jn=class _s extends an{constructor(e,t,n,s,o){super(e,[],n,s),this.mark=t,this.spec=o}static create(e,t,n,s){let o=s.nodeViews[t.type.name],i=o&&o(t,s,n);return(!i||!i.dom)&&(i=ze.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new _s(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Ae||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ae&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ke){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=ke}}slice(e,t,n){let s=_s.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=Hr(o,t,i,n)),e>0&&(o=Hr(o,0,e,n));for(let l=0;l<o.length;l++)o[l].parent=s;return s.children=o,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Rt=class Ka extends an{constructor(e,t,n,s,o,i,l,a,c){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=s,this.nodeDOM=l}static create(e,t,n,s,o,i){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},n,s),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=ze.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Ti(u,n,t),c?a=new Zu(e,t,n,s,u,d||null,f,c,o,i+1):t.isText?new Ni(e,t,n,s,u,f,o):new Ka(e,t,n,s,u,d||null,f,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,t,n){return this.dirty==ke&&e.eq(this.node)&&Hn(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,s=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new td(this,i&&i.node,e);sd(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,n,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?z.none:this.node.child(u).marks,n,e),a.placeWidget(c,e,s)},(c,u,d,f)=>{a.syncToMarks(c.marks,n,e);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,s)||a.addNode(c,u,d,e,s),s+=c.nodeSize}),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==pt)&&(i&&this.protectLocalComposition(e,i),Oi(this.contentDOM,this.children,e),It&&od(this.dom))}localCompositionInfo(e,t){let{from:n,to:s}=e.state.selection;if(!(e.state.selection instanceof V)||n<t||s>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,l=id(this.node.content,i,n-t,s-t);return l<0?null:{node:o,pos:l,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:s}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new Uu(this,o,t,s);e.input.compositionNodes.push(i),this.children=Hr(this.children,n,n+s.length,e,i)}update(e,t,n,s){return this.dirty==Ae||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,s),!0)}updateInner(e,t,n,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=ke}updateOuterDeco(e){if(Hn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Di(this.dom,this.nodeDOM,Jr(this.outerDeco,this.node,t),Jr(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function vi(r,e,t,n,s){Ti(n,e,r);let o=new Rt(void 0,r,e,t,n,n,n,s,0);return o.contentDOM&&o.updateChildren(s,0),o}let Ni=class Ya extends Rt{constructor(e,t,n,s,o,i,l){super(e,t,n,s,o,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,s){return this.dirty==Ae||this.dirty!=ke&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ke||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=ke,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let s=this.node.cut(e,t),o=document.createTextNode(s.text);return new Ya(this.parent,s,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ae)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ei=class extends an{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ke&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Zu=class extends Rt{constructor(e,t,n,s,o,i,l,a,c,u){super(e,t,n,s,o,i,l,c,u),this.spec=a}update(e,t,n,s){if(this.dirty==Ae)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,s){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Oi(r,e,t){let n=r.firstChild,s=!1;for(let o=0;o<e.length;o++){let i=e[o],l=i.dom;if(l.parentNode==r){for(;l!=n;)n=Ai(n),s=!0;n=n.nextSibling}else s=!0,r.insertBefore(l,n);if(i instanceof Jn){let a=n?n.previousSibling:r.lastChild;Oi(i.contentDOM,i.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=Ai(n),s=!0;s&&t.trackWrites==r&&(t.trackWrites=null)}const cn=function(r){r&&(this.nodeName=r)};cn.prototype=Object.create(null);const mt=[new cn];function Jr(r,e,t){if(r.length==0)return mt;let n=t?mt[0]:new cn,s=[n];for(let o=0;o<r.length;o++){let i=r[o].type.attrs;if(i){i.nodeName&&s.push(n=new cn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(n=new cn(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return s}function Di(r,e,t,n){if(t==mt&&n==mt)return e;let s=e;for(let o=0;o<n.length;o++){let i=n[o],l=t[o];if(o){let a;l&&l.nodeName==i.nodeName&&s!=r&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=mt[0]),s=a}ed(s,l||mt[0],i)}return s}function ed(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<n.length;o++)s.indexOf(n[o])==-1&&r.classList.remove(n[o]);for(let o=0;o<s.length;o++)n.indexOf(s[o])==-1&&r.classList.add(s[o]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=n.exec(e.style);)r.style.removeProperty(s[1])}t.style&&(r.style.cssText+=t.style)}}function Ti(r,e,t){return Di(r,r,mt,Jr(e,t,r.nodeType!=1))}function Hn(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function Ai(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class td{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=nd(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let s=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;s<i&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=ke,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[o])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Jn.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,n))o=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,s,o){let i=this.top.children[s];return i.dirty==Ae&&i.dom==i.contentDOM&&(i.dirty=pt),i.update(e,t,n,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==n)return s}return-1}e=t}}updateNextNode(e,t,n,s,o,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Rt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ae&&Hn(t,a.outerDeco));if(!f&&a.update(e,t,n,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,n,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=pt,d.updateChildren(s,i+1),d.dirty=ke),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,s,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Hn(n,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=Rt.create(this.top,t,n,s,o,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,n,s,o){let i=Rt.create(this.top,e,t,n,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let o=new Mi(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Jn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ni)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ce||ie)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let s=new Ei(this.top,[],n,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function nd(r,e){let t=e,n=t.children.length,s=r.childCount,o=new Map,i=[];e:for(;s>0;){let l;for(;;)if(n){let c=t.children[n-1];if(c instanceof Jn)t=c,n=c.children.length;else{l=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=r.child(s-1))break;--s,o.set(l,s),i.push(l)}}return{index:s,matched:o,matches:i.reverse()}}function rd(r,e){return r.type.side-e.type.side}function sd(r,e,t,n){let s=e.locals(r),o=0;if(s.length==0){for(let c=0;c<r.childCount;c++){let u=r.child(c);n(u,s,e.forChild(o,u),c),o+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,d;for(;i<s.length&&s[i].to==o;){let y=s[i++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(rd);for(let y=0;y<d.length;y++)t(d[y],c,!!a)}else t(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<r.childCount)h=c,f=r.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=o&&l.splice(y--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)l.push(s[i++]);let p=o+f.nodeSize;if(f.isText){let y=p;i<s.length&&s[i].from<y&&(y=s[i].from);for(let x=0;x<l.length;x++)l[x].to<y&&(y=l[x].to);y<p&&(a=f.cut(y-o),f=f.cut(0,y-o),p=y,h=-1)}else for(;i<s.length&&s[i].to<p;)i++;let b=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();n(f,b,e.forChild(o,f),h),o=p}}function od(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function id(r,e,t,n){for(let s=0,o=0;s<r.childCount&&o<=n;){let i=r.child(s++),l=o;if(o+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<r.childCount;){let c=r.child(s++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;let c=l<n?a.lastIndexOf(e,n-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function Hr(r,e,t,n,s){let o=[];for(let i=0,l=0;i<r.length;i++){let a=r[i],c=l,u=l+=a.size;c>=t||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,n)),s&&(o.push(s),s=void 0),u>t&&o.push(a.slice(t-c,a.size,n)))}return o}function Kr(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let s=r.docView.nearestDesc(t.focusNode),o=s&&s.size==0,i=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=n.resolve(i),a,c;if(qn(t)){for(a=i;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&A.isSelectable(d)&&s.parent&&!(d.isInline&&Pu(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new A(i==f?l:n.resolve(f))}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=i,f=i;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);d=Math.min(d,r.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,r.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,i]=f==r.state.selection.anchor?[f,d]:[d,f],l=n.resolve(i)}else a=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=n.resolve(a);if(!c){let d=e=="pointer"||r.state.selection.head<l.pos&&!o?1:-1;c=Gr(r,u,l,d)}return c}function Pi(r){return r.editable?r.hasFocus():Fi(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function $e(r,e=!1){let t=r.state.selection;if(zi(r,t),!!Pi(r)){if(!e&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&ie){let n=r.domSelectionRange(),s=r.domObserver.currentSelection;if(n.anchorNode&&s.anchorNode&&ft(n.anchorNode,n.anchorOffset,s.anchorNode,s.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)ad(r);else{let{anchor:n,head:s}=t,o,i;Ii&&!(t instanceof V)&&(t.$from.parent.inlineContent||(o=Vi(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Vi(r,t.to))),r.docView.setSelection(n,s,r,e),Ii&&(o&&Ri(o),i&&Ri(i)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ld(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const Ii=ce||ie&&di<63;function Vi(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),s=n<t.childNodes.length?t.childNodes[n]:null,o=n?t.childNodes[n-1]:null;if(ce&&s&&s.contentEditable=="false")return Yr(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return Yr(s);if(o)return Yr(o)}}function Yr(r){return r.contentEditable="true",ce&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function Ri(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function ld(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!Pi(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function ad(r){let e=r.domSelection(),t=document.createRange();if(!e)return;let n=r.cursorWrapper.dom,s=n.nodeName=="IMG";s?t.setStart(n.parentNode,ee(n)+1):t.setStart(n,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!r.state.selection.visible&&he&&Ue<=11&&(n.disabled=!0,n.disabled=!1)}function zi(r,e){if(e instanceof A){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(ji(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else ji(r)}function ji(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function Gr(r,e,t,n){return r.someProp("createSelectionBetween",s=>s(r,e,t))||V.between(e,t,n)}function Bi(r){return r.editable&&!r.hasFocus()?!1:Fi(r)}function Fi(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function cd(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return ft(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Xr(r,e){let{$anchor:t,$head:n}=r.selection,s=e>0?t.max(n):t.min(n),o=s.parent.inlineContent?s.depth?r.doc.resolve(e>0?s.after():s.before()):null:s;return o&&P.findFrom(o,e)}function et(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function Li(r,e,t){let n=r.state.selection;if(n instanceof V)if(t.indexOf("s")>-1){let{$head:s}=n,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=r.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return et(r,new V(n.$anchor,i))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let s=Xr(r.state,e);return s&&s instanceof A?et(r,s):!1}else if(!(xe&&t.indexOf("m")>-1)){let s=n.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let l=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=r.docView.descAt(l))&&!i.contentDOM?A.isSelectable(o)?et(r,new A(e<0?r.state.doc.resolve(s.pos-o.nodeSize):s)):on?et(r,new V(r.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof A&&n.node.isInline)return et(r,new V(e>0?n.$to:n.$from));{let s=Xr(r.state,e);return s?et(r,s):!1}}}function Kn(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function un(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function zt(r,e){return e<0?ud(r):dd(r)}function ud(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let s,o,i=!1;for(ve&&t.nodeType==1&&n<Kn(t)&&un(t.childNodes[n],-1)&&(i=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(un(l,-1))s=t,o=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if($i(t))break;{let l=t.previousSibling;for(;l&&un(l,-1);)s=t.parentNode,o=ee(l),l=l.previousSibling;if(l)t=l,n=Kn(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}i?Qr(r,t,n):s&&Qr(r,s,o)}function dd(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let s=Kn(t),o,i;for(;;)if(n<s){if(t.nodeType!=1)break;let l=t.childNodes[n];if(un(l,1))o=t,i=++n;else break}else{if($i(t))break;{let l=t.nextSibling;for(;l&&un(l,1);)o=l.parentNode,i=ee(l)+1,l=l.nextSibling;if(l)t=l,n=0,s=Kn(t);else{if(t=t.parentNode,t==r.dom)break;n=s=0}}}o&&Qr(r,o,i)}function $i(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function fd(r,e){for(;r&&e==r.childNodes.length&&!sn(r);)e=ee(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=0}}function hd(r,e){for(;r&&!e&&!sn(r);)e=ee(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function Qr(r,e,t){if(e.nodeType!=3){let o,i;(i=fd(e,t))?(e=i,t=0):(o=hd(e,t))&&(e=o,t=o.nodeValue.length)}let n=r.domSelection();if(!n)return;if(qn(n)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),n.removeAllRanges(),n.addRange(o)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:s}=r;setTimeout(()=>{r.state==s&&$e(r)},50)}function Wi(r,e){let t=r.state.doc.resolve(e);if(!(ie||Ru)&&t.parent.inlineContent){let s=r.coordsAtPos(e);if(e>t.start()){let o=r.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<t.end()){let o=r.coordsAtPos(e+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function _i(r,e,t){let n=r.state.selection;if(n instanceof V&&!n.empty||t.indexOf("s")>-1||xe&&t.indexOf("m")>-1)return!1;let{$from:s,$to:o}=n;if(!s.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let i=Xr(r.state,e);if(i&&i instanceof A)return et(r,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=n instanceof ge?P.near(i,e):P.findFrom(i,e);return l?et(r,l):!1}return!1}function qi(r,e){if(!(r.state.selection instanceof V))return!0;let{$head:t,$anchor:n,empty:s}=r.state.selection;if(!t.sameParent(n))return!0;if(!s)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let i=r.state.tr;return e<0?i.delete(t.pos-o.nodeSize,t.pos):i.delete(t.pos,t.pos+o.nodeSize),r.dispatch(i),!0}return!1}function Ji(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function pd(r){if(!ce||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;Ji(r,n,"true"),setTimeout(()=>Ji(r,n,"false"),20)}return!1}function md(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function gd(r,e){let t=e.keyCode,n=md(e);if(t==8||xe&&t==72&&n=="c")return qi(r,-1)||zt(r,-1);if(t==46&&!e.shiftKey||xe&&t==68&&n=="c")return qi(r,1)||zt(r,1);if(t==13||t==27)return!0;if(t==37||xe&&t==66&&n=="c"){let s=t==37?Wi(r,r.state.selection.from)=="ltr"?-1:1:-1;return Li(r,s,n)||zt(r,s)}else if(t==39||xe&&t==70&&n=="c"){let s=t==39?Wi(r,r.state.selection.from)=="ltr"?1:-1:1;return Li(r,s,n)||zt(r,s)}else{if(t==38||xe&&t==80&&n=="c")return _i(r,-1,n)||zt(r,-1);if(t==40||xe&&t==78&&n=="c")return pd(r)||_i(r,1,n)||zt(r,1);if(n==(xe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ur(r,e){r.someProp("transformCopied",h=>{e=h(e,r)});let t=[],{content:n,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){s--,o--;let h=n.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),n=h.content}let i=r.someProp("clipboardSerializer")||ze.fromSchema(r.state.schema),l=Zi(),a=l.createElement("div");a.appendChild(i.serializeFragment(n,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Qi[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${o}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=r.someProp("clipboardTextSerializer",h=>h(e,r))||e.content.textBetween(0,e.content.size,`
|
|
30
30
|
|
|
31
|
-
`);return{dom:a,text:f,slice:e}}function Hi(r,e,t,n,s){let o=s.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(n||o||!t);if(a){if(r.someProp("transformPastedText",f=>{e=f(e,o||n,r)}),o)return e?new
|
|
32
|
-
`))),0,0):O.empty;let d=r.someProp("clipboardTextParser",f=>f(e,s,n,r));if(d)l=d;else{let f=s.marks(),{schema:h}=r.state,p=ze.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let y=i.appendChild(document.createElement("p"));b&&y.appendChild(p.serializeNode(h.text(b,f)))})}}else r.someProp("transformPastedHTML",d=>{t=d(t,r)}),i=kd(t),on&&wd(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||In.fromSchema(r.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!yd.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Sd(Xi(l,+u[1],+u[2]),u[4]);else if(l=O.maxOpen(bd(l.content,s),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Xi(l,d,f)}return r.someProp("transformPasted",d=>{l=d(l,r)}),l}const yd=/^(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 bd(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),o,i=[];if(r.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&o.length&&Yi(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=Gi(i[i.length-1],o.length));let u=Ki(l,a);i.push(u),s=s.matchType(u.type),o=a}}),i)return S.from(i)}return r}function Ki(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,S.from(r));return r}function Yi(r,e,t,n,s){if(s<r.length&&s<e.length&&r[s]==e[s]){let o=Yi(r,e,t,n.lastChild,s+1);if(o)return n.copy(n.content.replaceChild(n.childCount-1,o));if(n.contentMatchAt(n.childCount).matchType(s==r.length-1?t.type:r[s+1]))return n.copy(n.content.append(S.from(Ki(t,r,s+1))))}}function Gi(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,Gi(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(S.empty,!0);return r.copy(t.append(n))}function Zr(r,e,t,n,s,o){let i=e<0?r.firstChild:r.lastChild,l=i.content;return r.childCount>1&&(o=0),s<n-1&&(l=Zr(l,e,t,n,s+1,o)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(S.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,i.copy(l))}function Xi(r,e,t){return e<r.openStart&&(r=new O(Zr(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new O(Zr(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const Qi={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 Ui=null;function Zi(){return Ui||(Ui=document.implementation.createHTMLDocument("title"))}let es=null;function xd(r){let e=window.trustedTypes;return e?(es||(es=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),es.createHTML(r)):r}function kd(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=Zi().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),s;if((s=n&&Qi[n[1].toLowerCase()])&&(r=s.map(o=>"<"+o+">").join("")+r+s.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=xd(r),s)for(let o=0;o<s.length;o++)t=t.querySelector(s[o])||t;return t}function wd(r){let e=r.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function Sd(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:s,openStart:o,openEnd:i}=r;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;s=S.from(a.create(n[l+1],s)),o++,i++}return new O(s,o,i)}const ue={},de={},Cd={touchstart:!0,touchmove:!0};class Md{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function vd(r){for(let e in ue){let t=ue[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Od(r,n)&&!ns(r,n)&&(r.editable||!(n.type in de))&&t(r,n)},Cd[e]?{passive:!0}:void 0)}ce&&r.dom.addEventListener("input",()=>null),ts(r)}function tt(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Nd(r){r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function ts(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>ns(r,n))})}function ns(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Od(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Ed(r,e){!ns(r,e)&&ue[e.type]&&(r.editable||!(e.type in de))&&ue[e.type](r,e)}de.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!tl(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(Fe&&ie&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),It&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",s=>s(r,ht(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||gd(r,t)?t.preventDefault():tt(r,"key")},de.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)},de.keypress=(r,e)=>{let t=e;if(tl(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||xe&&t.metaKey)return;if(r.someProp("handleKeyPress",s=>s(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof V)||!n.$from.sameParent(n.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!r.someProp("handleTextInput",o=>o(r,n.$from.pos,n.$to.pos,s))&&r.dispatch(r.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function Yn(r){return{left:r.clientX,top:r.clientY}}function Dd(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function rs(r,e,t,n,s){if(n==-1)return!1;let o=r.state.doc.resolve(n);for(let i=o.depth+1;i>0;i--)if(r.someProp(e,l=>i>o.depth?l(r,t,o.nodeAfter,o.before(i),s,!0):l(r,t,o.node(i),o.before(i),s,!1)))return!0;return!1}function jt(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function Td(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&A.isSelectable(n)?(jt(r,new A(t)),!0):!1}function Ad(r,e){if(e==-1)return!1;let t=r.state.selection,n,s;t instanceof A&&(n=t.node);let o=r.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let l=i>o.depth?o.nodeAfter:o.node(i);if(A.isSelectable(l)){n&&t.$from.depth>0&&i>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?s=o.before(t.$from.depth):s=o.before(i);break}}return s!=null?(jt(r,A.create(r.state.doc,s)),!0):!1}function Pd(r,e,t,n,s){return rs(r,"handleClickOn",e,t,n)||r.someProp("handleClick",o=>o(r,e,n))||(s?Ad(r,t):Td(r,t))}function Id(r,e,t,n){return rs(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",s=>s(r,e,n))}function Vd(r,e,t,n){return rs(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",s=>s(r,e,n))||Rd(r,t,n)}function Rd(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(jt(r,V.create(n,0,n.content.size)),!0):!1;let s=n.resolve(e);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),l=s.before(o);if(i.inlineContent)jt(r,V.create(n,l+1,l+1+i.content.size));else if(A.isSelectable(i))jt(r,A.create(n,l));else continue;return!0}}function ss(r){return Gn(r)}const el=xe?"metaKey":"ctrlKey";ue.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=ss(r),s=Date.now(),o="singleClick";s-r.input.lastClick.time<500&&Dd(t,r.input.lastClick)&&!t[el]&&(r.input.lastClick.type=="singleClick"?o="doubleClick":r.input.lastClick.type=="doubleClick"&&(o="tripleClick")),r.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:o};let i=r.posAtCoords(Yn(t));i&&(o=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new zd(r,i,t,!!n)):(o=="doubleClick"?Id:Vd)(r,i.pos,i.inside,t)?t.preventDefault():tt(r,"pointer"))};class zd{constructor(e,t,n,s){this.view=e,this.pos=t,this.event=n,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[el],this.allowDefault=n.shiftKey;let o,i;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,i=u.depth?u.before():0}const l=s?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof A&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ve&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),tt(e,"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(()=>$e(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Yn(e))),this.updateAllowDefault(e),this.allowDefault||!t?tt(this.view,"pointer"):Pd(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ce&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!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)?(jt(this.view,P.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):tt(this.view,"pointer")}move(e){this.updateAllowDefault(e),tt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ue.touchstart=r=>{r.input.lastTouch=Date.now(),ss(r),tt(r,"pointer")},ue.touchmove=r=>{r.input.lastTouch=Date.now(),tt(r,"pointer")},ue.contextmenu=r=>ss(r);function tl(r,e){return r.composing?!0:ce&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const jd=Fe?5e3:-1;de.compositionstart=de.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof V&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))r.markCursor=r.state.storedMarks||t.marks(),Gn(r,!0),r.markCursor=null;else if(Gn(r,!e.selection.empty),ve&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let s=n.focusNode,o=n.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let l=r.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}r.input.composing=!0}nl(r,jd)},de.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,nl(r,20))};function nl(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>Gn(r),e))}function rl(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Fd());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function Bd(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=Tu(e.focusNode,e.focusOffset),n=Au(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let s=n.pmViewDesc,o=r.domObserver.lastChangedTextNode;if(t==o||n==o)return o;if(!s||!s.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return n}}return t||n}function Fd(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function Gn(r,e=!1){if(!(Fe&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),rl(r),e||r.docView&&r.docView.dirty){let t=Kr(r);return t&&!t.eq(r.state.selection)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!r.state.selection.empty?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function Ld(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),s=document.createRange();s.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}const dn=he&&Ue<15||It&&zu<604;ue.copy=de.cut=(r,e)=>{let t=e,n=r.state.selection,s=t.type=="cut";if(n.empty)return;let o=dn?null:t.clipboardData,i=n.content(),{dom:l,text:a}=Ur(r,i);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Ld(r,l),s&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $d(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function Wd(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let s=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?fn(r,n.value,null,s,e):fn(r,n.textContent,n.innerHTML,s,e)},50)}function fn(r,e,t,n,s){let o=Hi(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,s,o||O.empty)))return!0;if(!o)return!1;let i=$d(o),l=i?r.state.tr.replaceSelectionWith(i,n):r.state.tr.replaceSelection(o);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function sl(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}de.paste=(r,e)=>{let t=e;if(r.composing&&!Fe)return;let n=dn?null:t.clipboardData,s=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&fn(r,sl(n),n.getData("text/html"),s,t)?t.preventDefault():Wd(r,t)};class ol{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const _d=xe?"altKey":"ctrlKey";function il(r,e){let t=r.someProp("dragCopies",n=>!n(e));return t??!e[_d]}ue.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let s=r.state.selection,o=s.empty?null:r.posAtCoords(Yn(t)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof A?s.to-1:s.to))){if(n&&n.mightDrag)i=A.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=r.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=r.docView&&(i=A.create(r.state.doc,d.posBefore))}}let l=(i||r.state.selection).content(),{dom:a,text:c,slice:u}=Ur(r,l);(!t.dataTransfer.files.length||!ie||di>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(dn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",dn||t.dataTransfer.setData("text/plain",c),r.dragging=new ol(u,il(r,t),i)},ue.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)},de.dragover=de.dragenter=(r,e)=>e.preventDefault(),de.drop=(r,e)=>{let t=e,n=r.dragging;if(r.dragging=null,!t.dataTransfer)return;let s=r.posAtCoords(Yn(t));if(!s)return;let o=r.state.doc.resolve(s.pos),i=n&&n.slice;i?r.someProp("transformPasted",p=>{i=p(i,r)}):i=Hi(r,sl(t.dataTransfer),dn?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(n&&il(r,t));if(r.someProp("handleDrop",p=>p(r,t,i||O.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?Po(r.state.doc,o.pos,i):o.pos;a==null&&(a=o.pos);let c=r.state.tr;if(l){let{node:p}=n;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&A.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new A(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,y,x,k)=>p=k),c.setSelection(Gr(r,h,c.doc.resolve(p)))}r.focus(),r.dispatch(c.setMeta("uiEvent","drop"))},ue.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&$e(r)},20))},ue.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)},ue.beforeinput=(r,e)=>{if(ie&&Fe&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",o=>o(r,ht(8,"Backspace")))))return;let{$cursor:s}=r.state.selection;s&&s.pos>0&&r.dispatch(r.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let r in de)ue[r]=de[r];function hn(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}class Xn{constructor(e,t){this.toDOM=e,this.spec=t||gt,this.side=this.spec.side||0}map(e,t,n,s){let{pos:o,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new te(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Xn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&hn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class nt{constructor(e,t){this.attrs=e,this.spec=t||gt}map(e,t,n,s){let o=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new te(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof nt&&hn(this.attrs,e.attrs)&&hn(this.spec,e.spec)}static is(e){return e.type instanceof nt}destroy(){}}class is{constructor(e,t){this.attrs=e,this.spec=t||gt}map(e,t,n,s){let o=e.mapResult(t.from+s,1);if(o.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=o.pos?null:new te(o.pos-n,i.pos-n,this)}valid(e,t){let{index:n,offset:s}=e.content.findIndex(t.from),o;return s==t.from&&!(o=e.child(n)).isText&&s+o.nodeSize==t.to}eq(e){return this==e||e instanceof is&&hn(this.attrs,e.attrs)&&hn(this.spec,e.spec)}destroy(){}}class te{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new te(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new te(e,e,new Xn(t,n))}static inline(e,t,n,s){return new te(e,t,new nt(n,s))}static node(e,t,n,s){return new te(e,t,new is(n,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof nt}get widget(){return this.type instanceof Xn}}const Bt=[],gt={};class j{constructor(e,t){this.local=e.length?e:Bt,this.children=t.length?t:Bt}static create(e,t){return t.length?Qn(t,e,0,gt):le}find(e,t,n){let s=[];return this.findInner(e??0,t??1e9,s,0,n),s}findInner(e,t,n,s,o){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&n.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,n,s+l,o)}}map(e,t,n){return this==le||e.maps.length==0?this:this.mapInner(e,t,0,0,n||gt)}mapInner(e,t,n,s,o){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,n,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?qd(this.children,i||[],e,t,n,s,o):i?new j(i.sort(yt),Bt):le}add(e,t){return t.length?this==le?j.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let s,o=0;e.forEach((l,a)=>{let c=a+n,u;if(u=cl(t,l,c)){for(s||(s=this.children.slice());o<s.length&&s[o]<a;)o+=3;s[o]==a?s[o+2]=s[o+2].addInner(l,u,c+1):s.splice(o,0,a,a+l.nodeSize,Qn(u,l,c+1,gt)),o+=3}});let i=al(o?ul(t):t,-n);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new j(i.length?this.local.concat(i).sort(yt):this.local,s||this.children)}remove(e){return e.length==0||this==le?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,s=this.local;for(let o=0;o<n.length;o+=3){let i,l=n[o]+t,a=n[o+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;n==this.children&&(n=this.children.slice());let c=n[o+2].removeInner(i,l+1);c!=le?n[o+2]=c:(n.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<e.length;o++)if(i=e[o])for(let l=0;l<s.length;l++)s[l].eq(i,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return n==this.children&&s==this.local?this:s.length||n.length?new j(s,n):le}forChild(e,t){if(this==le)return this;if(t.isLeaf)return j.empty;let n,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let o=e+1,i=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>o&&a.type instanceof nt){let c=Math.max(o,a.from)-o,u=Math.min(i,a.to)-o;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new j(s.sort(yt),Bt);return n?new ll([l,n]):l}return n||le}eq(e){if(this==e)return!0;if(!(e instanceof j)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return ls(this.localsInner(e))}localsInner(e){if(this==le)return Bt;if(e.inlineContent||!this.local.some(nt.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof nt||t.push(this.local[n]);return t}forEachSet(e){e(this)}}j.empty=new j([],[]),j.removeOverlap=ls;const le=j.empty;let ll=class Jt{constructor(e){this.members=e}map(e,t){const n=this.members.map(s=>s.map(e,t,gt));return Jt.from(n)}forChild(e,t){if(t.isLeaf)return j.empty;let n=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,t);o!=le&&(o instanceof Jt?n=n.concat(o.members):n.push(o))}return Jt.from(n)}eq(e){if(!(e instanceof Jt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!t)t=o;else{n&&(t=t.slice(),n=!1);for(let i=0;i<o.length;i++)t.push(o[i])}}return t?ls(n?t:t.sort(yt)):Bt}static from(e){switch(e.length){case 0:return le;case 1:return e[0];default:return new Jt(e.every(t=>t instanceof j)?e:e.reduce((t,n)=>t.concat(n instanceof j?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function qd(r,e,t,n,s,o,i){let l=r.slice();for(let c=0,u=o;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,h,p,b)=>{let y=b-p-(h-f);for(let x=0;x<l.length;x+=3){let k=l[x+1];if(k<0||f>k+u-d)continue;let w=l[x]+u-d;h>=w?l[x+1]=f<=w?-2:-1:f>=u&&y&&(l[x]+=y,l[x+1]+=y)}d+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(r[c]+o),d=u-s;if(d<0||d>=n.content.size){a=!0;continue}let f=t.map(r[c+1]+o,-1),h=f-s,{index:p,offset:b}=n.content.findIndex(d),y=n.maybeChild(p);if(y&&b==d&&b+y.nodeSize==h){let x=l[c+2].mapInner(t,y,u+1,r[c]+o+1,i);x!=le?(l[c]=d,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Jd(l,r,e,t,s,o,i),u=Qn(c,n,0,i);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new j(e.sort(yt),l)}function al(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let s=r[n];t.push(new te(s.from+e,s.to+e,s.type))}return t}function Jd(r,e,t,n,s,o,i){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(n,s,c);d?t.push(d):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<r.length;a+=3)r[a+1]==-1&&l(r[a+2],e[a]+o+1);return t}function cl(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,s=null;for(let o=0,i;o<r.length;o++)(i=r[o])&&i.from>t&&i.to<n&&((s||(s=[])).push(i),r[o]=null);return s}function ul(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function Qn(r,e,t,n){let s=[],o=!1;e.forEach((l,a)=>{let c=cl(r,l,a+t);if(c){o=!0;let u=Qn(c,l,t+a+1,n);u!=le&&s.push(a,a+l.nodeSize,u)}});let i=al(o?ul(r):r,-t).sort(yt);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(n.onRemove&&n.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new j(i,s):le}function yt(r,e){return r.from-e.from||r.to-e.to}function ls(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let s=t+1;s<e.length;s++){let o=e[s];if(o.from==n.from){o.to!=n.to&&(e==r&&(e=r.slice()),e[s]=o.copy(o.from,n.to),dl(e,s+1,o.copy(n.to,o.to)));continue}else{o.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,o.from),dl(e,s,n.copy(o.from,n.to)));break}}}return e}function dl(r,e,t){for(;e<r.length&&yt(t,r[e])>0;)e++;r.splice(e,0,t)}function as(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=le&&e.push(n)}),r.cursorWrapper&&e.push(j.create(r.state.doc,[r.cursorWrapper.deco])),ll.from(e)}const Hd={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Kd=he&&Ue<=11;class Yd{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Gd{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Yd,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let s=0;s<n.length;s++)this.queue.push(n[s]);he&&Ue<=11&&n.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),Kd&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Hd)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Bi(this.view)){if(this.suppressingSelectionUpdates)return $e(this.view);if(he&&Ue<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ft(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let o=e.focusNode;o;o=Pt(o))t.add(o);for(let o=e.anchorNode;o;o=Pt(o))if(t.has(o)){n=o;break}let s=n&&this.view.docView.nearestDesc(n);if(s&&s.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Bi(e)&&!this.ignoreSelectionChange(n),o=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],a);d&&(o=o<0?d.from:Math.min(d.from,o),i=i<0?d.to:Math.max(d.to,i),d.typeOver&&(l=!0))}if(ve&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||Ud(e,d)!=h)&&f.remove()}}}let c=null;o<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&qn(n)&&(c=Kr(e))&&c.eq(P.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,$e(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),Xd(e)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||$e(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let s=e.previousSibling,o=e.nextSibling;if(he&&Ue<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f)}let i=s&&s.parentNode==e.target?ee(s)+1:0,l=n.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?ee(o):e.target.childNodes.length,c=n.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let fl=new WeakMap,hl=!1;function Xd(r){if(!fl.has(r)&&(fl.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=ve,hl)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),hl=!0}}function pl(r,e){let t=e.startContainer,n=e.startOffset,s=e.endContainer,o=e.endOffset,i=r.domAtPos(r.state.selection.anchor);return ft(i.node,i.offset,s,o)&&([t,n,s,o]=[s,o,t,n]),{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:o}}function Qd(r,e){if(e.getComposedRanges){let s=e.getComposedRanges(r.root)[0];if(s)return pl(r,s)}let t;function n(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?pl(r,t):null}function Ud(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function Zd(r,e,t){let{node:n,fromOffset:s,toOffset:o,from:i,to:l}=r.docView.parseRange(e,t),a=r.domSelectionRange(),c,u=a.anchorNode;if(u&&r.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],qn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&r.input.lastKeyCode===8)for(let y=o;y>s;y--){let x=n.childNodes[y-1],k=x.pmViewDesc;if(x.nodeName=="BR"&&!k){o=y;break}if(!k||k.size)break}let d=r.state.doc,f=r.someProp("domParser")||In.fromSchema(r.state.schema),h=d.resolve(i),p=null,b=f.parse(n,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:o,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:ef,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=y),p={anchor:y+i,head:x+i}}return{doc:b,sel:p,from:i,to:l}}function ef(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(ce&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(r.parentNode.lastChild==r||ce&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}const tf=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function nf(r,e,t,n,s){let o=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let D=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,X=Kr(r,D);if(X&&!r.state.selection.eq(X)){if(ie&&Fe&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",ae=>ae(r,ht(13,"Enter"))))return;let F=r.state.tr.setSelection(X);D=="pointer"?F.setMeta("pointer",!0):D=="key"&&F.scrollIntoView(),o&&F.setMeta("composition",o),r.dispatch(F)}return}let i=r.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,c=Zd(r,e,t),u=r.state.doc,d=u.slice(c.from,c.to),f,h;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(f=r.state.selection.to,h="end"):(f=r.state.selection.from,h="start"),r.input.lastKeyCode=null;let p=of(d.content,c.doc.content,c.from,f,h);if(p&&r.input.domChangeCount++,(It&&r.input.lastIOSEnter>Date.now()-225||Fe)&&s.some(D=>D.nodeType==1&&!tf.test(D.nodeName))&&(!p||p.endA>=p.endB)&&r.someProp("handleKeyDown",D=>D(r,ht(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!p)if(n&&a instanceof V&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let D=ml(r,r.state.doc,c.sel);if(D&&!D.eq(r.state.selection)){let X=r.state.tr.setSelection(D);o&&X.setMeta("composition",o),r.dispatch(X)}}return}r.state.selection.from<r.state.selection.to&&p.start==p.endB&&r.state.selection instanceof V&&(p.start>r.state.selection.from&&p.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?p.start=r.state.selection.from:p.endA<r.state.selection.to&&p.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(p.endB+=r.state.selection.to-p.endA,p.endA=r.state.selection.to)),he&&Ue<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let b=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),x=u.resolve(p.start),k=b.sameParent(y)&&b.parent.inlineContent&&x.end()>=p.endA,w;if((It&&r.input.lastIOSEnter>Date.now()-225&&(!k||s.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!k&&b.pos<c.doc.content.size&&(!b.sameParent(y)||!b.parent.inlineContent)&&!/\S/.test(c.doc.textBetween(b.pos,y.pos,"",""))&&(w=P.findFrom(c.doc.resolve(b.pos+1),1,!0))&&w.head>b.pos)&&r.someProp("handleKeyDown",D=>D(r,ht(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>p.start&&sf(u,p.start,p.endA,b,y)&&r.someProp("handleKeyDown",D=>D(r,ht(8,"Backspace")))){Fe&&ie&&r.domObserver.suppressSelectionUpdates();return}ie&&p.endB==p.start&&(r.input.lastChromeDelete=Date.now()),Fe&&!k&&b.start()!=y.start()&&y.parentOffset==0&&b.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(D){return D(r,ht(13,"Enter"))})},20));let N=p.start,E=p.endA,M,T,I;if(k){if(b.pos==y.pos)he&&Ue<=11&&b.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>$e(r),20)),M=r.state.tr.delete(N,E),T=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&(I=rf(b.parent.content.cut(b.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start()))))M=r.state.tr,I.type=="add"?M.addMark(N,E,I.mark):M.removeMark(N,E,I.mark);else if(b.parent.child(b.index()).isText&&b.index()==y.index()-(y.textOffset?0:1)){let D=b.parent.textBetween(b.parentOffset,y.parentOffset);if(r.someProp("handleTextInput",X=>X(r,N,E,D)))return;M=r.state.tr.insertText(D,N,E)}}if(M||(M=r.state.tr.replace(N,E,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let D=ml(r,M.doc,c.sel);D&&!(ie&&r.composing&&D.empty&&(p.start!=p.endB||r.input.lastChromeDelete<Date.now()-100)&&(D.head==N||D.head==M.mapping.map(E)-1)||he&&D.empty&&D.head==N)&&M.setSelection(D)}T&&M.ensureMarks(T),o&&M.setMeta("composition",o),r.dispatch(M.scrollIntoView())}function ml(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Gr(r,e.resolve(t.anchor),e.resolve(t.head))}function rf(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,s=t,o=n,i,l,a;for(let u=0;u<n.length;u++)s=n[u].removeFromSet(s);for(let u=0;u<t.length;u++)o=t[u].removeFromSet(o);if(s.length==1&&o.length==0)l=s[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&o.length==1)l=o[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(S.from(c).eq(r))return{mark:l,type:i}}function sf(r,e,t,n,s){if(t-e<=s.pos-n.pos||cs(n,!0,!1)<s.pos)return!1;let o=r.resolve(e);if(!n.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=r.resolve(cs(o,!0,!0));return!i.parent.isTextblock||i.pos>t||cs(i,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(i.parent.content)}function cs(r,e,t){let n=r.depth,s=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,s++,e=!1;if(t){let o=r.node(n).maybeChild(r.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function of(r,e,t,n,s){let o=r.findDiffStart(e,t);if(o==null)return null;let{a:i,b:l}=r.findDiffEnd(e,t+r.size,t+e.size);if(s=="end"){let a=Math.max(0,o-Math.min(i,l));n-=i+a-o}if(i<o&&r.size<e.size){let a=n<=o&&n>=i?o-n:0;o-=a,o&&o<e.size&&gl(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-i),i=o}else if(l<o){let a=n<=o&&n>=l?o-n:0;o-=a,o&&o<r.size&&gl(r.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function gl(r){if(r.length!=2)return!1;let e=r.charCodeAt(0),t=r.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class lf{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Md,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(wl),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=xl(this),bl(this),this.nodeViews=kl(this),this.docView=vi(this.state.doc,yl(this),as(this),this.dom,this),this.domObserver=new Gd(this,(n,s,o,i)=>nf(this,n,s,o,i)),this.domObserver.start(),vd(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ts(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(wl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(rl(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=kl(this);cf(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ts(this),this.editable=xl(this),bl(this);let a=as(this),c=yl(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(i=!0);let f=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Fu(this);if(i){this.domObserver.stop();let h=d&&(he||ie)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&af(s.selection,e.selection);if(d){let p=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Bd(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=vi(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cd(this))?$e(this,h):(zi(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((n=this.dragging)===null||n===void 0)&&n.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Lu(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof A){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&fi(this,t.getBoundingClientRect(),e)}else fi(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,s=-1;if(this.state.doc.nodeAt(n.from)==n.node)s=n.from;else{let o=n.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==n.node&&(s=o)}this.dragging=new ol(e.slice,e.move,s<0?void 0:A.create(this.state.doc,s))}someProp(e,t){let n=this._props&&this._props[e],s;if(n!=null&&(s=t?t(n):n))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let o=this.state.plugins;if(o)for(let i=0;i<o.length;i++){let l=o[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(he){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&$u(this.dom),$e(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Hu(this,e)}coordsAtPos(e,t=1){return bi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let s=this.docView.posFromDOM(e,t,n);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return Qu(this,t||this.state,e)}pasteHTML(e,t){return fn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return fn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ur(this,e)}destroy(){this.docView&&(Nd(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],as(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Eu())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ed(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ce&&this.root.nodeType===11&&Iu(this.dom.ownerDocument)==this.dom&&Qd(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function yl(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[te.node(0,r.state.doc.content.size,e)]}function bl(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:te.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function xl(r){return!r.someProp("editable",e=>e(r.state)===!1)}function af(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function kl(r){let e=Object.create(null);function t(n){for(let s in n)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=n[s])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function cf(r,e){let t=0,n=0;for(let s in r){if(r[s]!=e[s])return!0;t++}for(let s in e)n++;return t!=n}function wl(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class $ extends P{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return $.valid(n)?new $(n):P.near(n)}content(){return O.empty}eq(e){return e instanceof $&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new $(e.resolve(t.pos))}getBookmark(){return new us(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!uf(e)||!df(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&$.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if($.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!A.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),n=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if($.valid(l))return l}return null}}}$.prototype.visible=!1,$.findFrom=$.findGapCursorFrom,P.jsonID("gapcursor",$);class us{constructor(e){this.pos=e}map(e){return new us(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return $.valid(t)?new $(t):P.near(t)}}function uf(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let s=n.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function df(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let s=n.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function ff(){return new Ee({props:{decorations:gf,createSelectionBetween(r,e,t){return e.pos==t.pos&&$.valid(t)?new $(t):null},handleClick:pf,handleKeyDown:hf,handleDOMEvents:{beforeinput:mf}}})}const hf=Ar({ArrowLeft:Un("horiz",-1),ArrowRight:Un("horiz",1),ArrowUp:Un("vert",-1),ArrowDown:Un("vert",1)});function Un(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,s,o){let i=n.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof V){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let c=$.findGapCursorFrom(l,e,a);return c?(s&&s(n.tr.setSelection(new $(c))),!0):!1}}function pf(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!$.valid(n))return!1;let s=r.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&A.isSelectable(r.state.doc.nodeAt(s.inside))?!1:(r.dispatch(r.state.tr.setSelection(new $(n))),!0)}function mf(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof $))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let s=S.empty;for(let i=n.length-1;i>=0;i--)s=S.from(n[i].createAndFill(null,s));let o=r.state.tr.replace(t.pos,t.pos,new O(s,0,0));return o.setSelection(V.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function gf(r){if(!(r.selection instanceof $))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",j.create(r.doc,[te.widget(r.selection.head,e,{key:"gapcursor"})])}const yf=["ol",0],bf=["ul",0],xf=["li",0],kf={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(r){return{order:r.hasAttribute("start")?+r.getAttribute("start"):1}}}],toDOM(r){return r.attrs.order==1?yf:["ol",{start:r.attrs.order},0]}},wf={parseDOM:[{tag:"ul"}],toDOM(){return bf}},Sf={parseDOM:[{tag:"li"}],toDOM(){return xf},defining:!0};function ds(r,e){let t={};for(let n in r)t[n]=r[n];for(let n in e)t[n]=e[n];return t}function Cf(r,e,t){return r.append({ordered_list:ds(kf,{content:"list_item+",group:t}),bullet_list:ds(wf,{content:"list_item+",group:t}),list_item:ds(Sf,{content:e})})}function Zn(r,e=null){return function(t,n){let{$from:s,$to:o}=t.selection,i=s.blockRange(o);if(!i)return!1;let l=n?t.tr:null;return Mf(l,i,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function Mf(r,e,t,n=null){let s=!1,o=e,i=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=i.resolve(e.start-2);o=new Dn(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Dn(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=kr(o,t,n,e);return l?(r&&vf(r,e,l,s,t),!0):!1}function vf(r,e,t,n,s){let o=S.empty;for(let u=t.length-1;u>=0;u--)o=S.from(t[u].type.create(t[u].attrs,o));r.step(new U(e.start-(n?2:0),e.end,e.start,e.end,new O(o,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==s&&(i=u+1);let l=t.length-i,a=e.start+t.length-(n?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&vt(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return r}function Nf(r,e){return function(t,n){let{$from:s,$to:o,node:i}=t.selection;if(i&&i.isBlock||s.depth<2||!s.sameParent(o))return!1;let l=s.node(-1);if(l.type!=r)return!1;if(s.parent.content.size==0&&s.node(-1).childCount==s.indexAfter(-1)){if(s.depth==3||s.node(-3).type!=r||s.index(-2)!=s.node(-2).childCount-1)return!1;if(n){let d=S.empty,f=s.index(-1)?1:s.index(-2)?2:3;for(let x=s.depth-f;x>=s.depth-3;x--)d=S.from(s.node(x).copy(d));let h=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;d=d.append(S.from(r.createAndFill()));let p=s.before(s.depth-(f-1)),b=t.tr.replace(p,s.after(-h),new O(d,4-f,0)),y=-1;b.doc.nodesBetween(p,b.doc.content.size,(x,k)=>{if(y>-1)return!1;x.isTextblock&&x.content.size==0&&(y=k+1)}),y>-1&&b.setSelection(P.near(b.doc.resolve(y))),n(b.scrollIntoView())}return!0}let a=o.pos==s.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(s.pos,o.pos),u=a?[null,{type:a}]:void 0;return vt(c.doc,s.pos,2,u)?(n&&n(c.split(s.pos,2,u).scrollIntoView()),!0):!1}}function Of(r){return function(e,t){let{$from:n,$to:s}=e.selection,o=n.blockRange(s,i=>i.childCount>0&&i.firstChild.type==r);return o?t?n.node(o.depth-1).type==r?Ef(e,t,r,o):Df(e,t,o):!0:!1}}function Ef(r,e,t,n){let s=r.tr,o=n.end,i=n.$to.end(n.depth);o<i&&(s.step(new U(o-1,i,o,i,new O(S.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new Dn(s.doc.resolve(n.$from.pos),s.doc.resolve(i),n.depth));const l=Zt(n);if(l==null)return!1;s.lift(n,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return Nt(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function Df(r,e,t){let n=r.tr,s=t.parent;for(let h=t.end,p=t.endIndex-1,b=t.startIndex;p>b;p--)h-=s.child(p).nodeSize,n.delete(h-1,h+1);let o=n.doc.resolve(t.start),i=o.nodeAfter;if(n.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?S.empty:S.from(s))))return!1;let d=o.pos,f=d+i.nodeSize;return n.step(new U(d-(l?1:0),f+(a?1:0),d+1,f-1,new O((l?S.empty:S.from(s.copy(S.empty))).append(a?S.empty:S.from(s.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function Tf(r){return function(e,t){let{$from:n,$to:s}=e.selection,o=n.blockRange(s,c=>c.childCount>0&&c.firstChild.type==r);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let l=o.parent,a=l.child(i-1);if(a.type!=r)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=S.from(c?r.create():null),d=new O(S.from(r.create(null,S.from(l.type.create(null,u)))),c?3:1,0),f=o.start,h=o.end;t(e.tr.step(new U(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}class rt{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Af(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}}function Af(r){return function(e,t,n,s){let o=r;if(t[1]){let i=t[0].lastIndexOf(t[1]);o+=t[0].slice(i+t[1].length),n+=i;let l=n-s;l>0&&(o=t[0].slice(i-l,i)+o,n=s)}return e.tr.insertText(o,n,s)}}const Pf=500;function If({rules:r}){let e=new Ee({state:{init(){return null},apply(t,n){let s=t.getMeta(this);return s||(t.selectionSet||t.docChanged?null:n)}},props:{handleTextInput(t,n,s,o){return Sl(t,n,s,o,r,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:n}=t.state.selection;n&&Sl(t,n.pos,n.pos,"",r,e)})}}},isInputRules:!0});return e}function Sl(r,e,t,n,s,o){if(r.composing)return!1;let i=r.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Pf),l.parentOffset,null,"")+n;for(let c=0;c<s.length;c++){let u=s[c];if(!u.inCodeMark&&l.marks().some(h=>h.type.spec.code))continue;if(l.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let d=u.match.exec(a),f=d&&d[0].length>=n.length&&u.handler(i,d,e-(d[0].length-n.length),t);if(f)return u.undoable&&f.setMeta(o,{transform:f,from:e,to:t,text:n}),r.dispatch(f),!0}return!1}const Vf=(r,e)=>{let t=r.plugins;for(let n=0;n<t.length;n++){let s=t[n],o;if(s.spec.isInputRules&&(o=s.getState(r))){if(e){let i=r.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a--)i.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,r.schema.text(o.text,a))}else i.delete(o.from,o.to);e(i)}return!0}}return!1},Rf=new rt(/--$/,"—",{inCodeMark:!1}),zf=new rt(/\.\.\.$/,"…",{inCodeMark:!1}),jf=new rt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),Bf=new rt(/"$/,"”",{inCodeMark:!1}),Ff=new rt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),Lf=new rt(/'$/,"’",{inCodeMark:!1}),$f=[jf,Bf,Ff,Lf];function fs(r,e,t=null,n){return new rt(r,(s,o,i,l)=>{let a=t instanceof Function?t(o):t,c=s.tr.delete(i,l),u=c.doc.resolve(i),d=u.blockRange(),f=d&&kr(d,e,a);if(!f)return null;c.wrap(d,f);let h=c.doc.resolve(i-1).nodeBefore;return h&&h.type==e&&Nt(c.doc,i-1)&&(!n||n(o,h))&&c.join(i-1),c})}function Cl(r,e,t=null){return new rt(r,(n,s,o,i)=>{let l=n.doc.resolve(o),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?n.tr.delete(o,i).setBlockType(o,o,e,a):null})}const Ml=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Wf(r,e){let t={},n;function s(o,i){t[o]=i}if(s("Mod-z",Vr),s("Shift-Mod-z",Wn),s("Backspace",Vf),Ml||s("Mod-y",Wn),s("Alt-ArrowUp",ti),s("Alt-ArrowDown",pu),s("Mod-BracketLeft",Rr),s("Escape",jr),(n=r.marks.strong)&&(s("Mod-b",ye(n)),s("Mod-B",ye(n))),(n=r.marks.em)&&(s("Mod-i",ye(n)),s("Mod-I",ye(n))),(n=r.marks.code)&&s("Mod-`",ye(n)),(n=r.nodes.bullet_list)&&s("Shift-Ctrl-8",Zn(n)),(n=r.nodes.ordered_list)&&s("Shift-Ctrl-9",Zn(n)),(n=r.nodes.blockquote)&&s("Ctrl->",oi(n)),n=r.nodes.hard_break){let o=n,i=_n(ni,(l,a)=>(a&&a(l.tr.replaceSelectionWith(o.create()).scrollIntoView()),!0));s("Mod-Enter",i),s("Shift-Enter",i),Ml&&s("Ctrl-Enter",i)}if((n=r.nodes.list_item)&&(s("Enter",Nf(n)),s("Mod-[",Of(n)),s("Mod-]",Tf(n))),(n=r.nodes.paragraph)&&s("Shift-Ctrl-0",At(n)),(n=r.nodes.code_block)&&s("Shift-Ctrl-\\",At(n)),n=r.nodes.heading)for(let o=1;o<=6;o++)s("Shift-Ctrl-"+o,At(n,{level:o}));if(n=r.nodes.horizontal_rule){let o=n;s("Mod-_",(i,l)=>(l&&l(i.tr.replaceSelectionWith(o.create()).scrollIntoView()),!0))}return t}function _f(r){return fs(/^\s*>\s$/,r)}function qf(r){return fs(/^(\d+)\.\s$/,r,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Jf(r){return fs(/^\s*([-+*])\s$/,r)}function Hf(r){return Cl(/^```$/,r)}function Kf(r,e){return Cl(new RegExp("^(#{1,"+e+"})\\s$"),r,t=>({level:t[1].length}))}function Yf(r){let e=$f.concat(zf,Rf),t;return(t=r.nodes.blockquote)&&e.push(_f(t)),(t=r.nodes.ordered_list)&&e.push(qf(t)),(t=r.nodes.bullet_list)&&e.push(Jf(t)),(t=r.nodes.code_block)&&e.push(Hf(t)),(t=r.nodes.heading)&&e.push(Kf(t,6)),If({rules:e})}const We=new Ye("ImagePluginKey"),Gf=r=>new Ee({key:We,state:{init(){return{set:j.empty,schema:r.schema,upload:r.upload}},apply(t,n){let s=n.set.map(t.mapping,t.doc);const o=t.getMeta(We);if(o&&o.add){const i=document.createElement("placeholder"),l=te.widget(o.add.pos,i,{id:o.add.id,key:`imgphd${o.add.id}`});s=s.add(t.doc,[l])}else o&&o.remove&&(s=s.remove(s.find(void 0,void 0,i=>i.id==o.remove.id)));return{...n,set:s}}},props:{decorations(t){var n;return(n=this.getState(t))==null?void 0:n.set}}}),Xf=(r,e)=>{const t=We.getState(r).set,n=t==null?void 0:t.find(void 0,void 0,s=>s.id==e);return n!=null&&n.length?n[0].from:null},Qf=async(r,e,t,n)=>{if(!e)return;const s=Date.now(),o=r.state.tr;n===void 0&&(o.selection.empty||o.deleteSelection(),n=o.selection.from),o.setMeta(We,{add:{id:s,pos:n}}),r.dispatch(o);try{const i=We.getState(r.state),l=i.schema,a=i.upload;if(!a)throw new Error("uploadImage: Image upload function not defined");const c=await a(e);if(typeof c=="string")throw new Error(c);const u=Xf(r.state,s);if(u===null){console.warn("uploadImage: The image was removed from the document during upload");return}r.dispatch(r.state.tr.replaceWith(u,u,l.nodes.image.create({fid:c,title:t})).setMeta(We,{remove:{id:s}}))}catch(i){r.dispatch(r.state.tr.setMeta(We,{remove:{id:s}})),console.error(`uploadImage: ${i}`)}},Uf=(r,e,t,n)=>{if(!e)return;const s=r.state.tr;n===void 0&&(s.selection.empty||s.deleteSelection(),n=s.selection.from);const o=We.getState(r.state).schema;r.dispatch(r.state.tr.replaceWith(n,n,o.nodes.image.create({src:e,title:t})))};var hs,ps;if(typeof WeakMap<"u"){let r=new WeakMap;hs=e=>r.get(e),ps=(e,t)=>(r.set(e,t),t)}else{const r=[];let t=0;hs=n=>{for(let s=0;s<r.length;s+=2)if(r[s]==n)return r[s+1]},ps=(n,s)=>(t==10&&(t=0),r[t++]=n,r[t++]=s)}var G=class{constructor(r,e,t,n){this.width=r,this.height=e,this.map=t,this.problems=n}findCell(r){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=r)continue;const n=e%this.width,s=e/this.width|0;let o=n+1,i=s+1;for(let l=1;o<this.width&&this.map[e+l]==t;l++)o++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:n,top:s,right:o,bottom:i}}throw new RangeError(`No cell with offset ${r} found`)}colCount(r){for(let e=0;e<this.map.length;e++)if(this.map[e]==r)return e%this.width;throw new RangeError(`No cell with offset ${r} found`)}nextCell(r,e,t){const{left:n,right:s,top:o,bottom:i}=this.findCell(r);return e=="horiz"?(t<0?n==0:s==this.width)?null:this.map[o*this.width+(t<0?n-1:s)]:(t<0?o==0:i==this.height)?null:this.map[n+this.width*(t<0?o-1:i)]}rectBetween(r,e){const{left:t,right:n,top:s,bottom:o}=this.findCell(r),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(s,a),right:Math.max(n,l),bottom:Math.max(o,c)}}cellsInRect(r){const e=[],t={};for(let n=r.top;n<r.bottom;n++)for(let s=r.left;s<r.right;s++){const o=n*this.width+s,i=this.map[o];t[i]||(t[i]=!0,!(s==r.left&&s&&this.map[o-1]==i||n==r.top&&n&&this.map[o-this.width]==i)&&e.push(i))}return e}positionAt(r,e,t){for(let n=0,s=0;;n++){const o=s+t.child(n).nodeSize;if(n==r){let i=e+r*this.width;const l=(r+1)*this.width;for(;i<l&&this.map[i]<s;)i++;return i==l?o-1:this.map[i]}s=o}}static get(r){return hs(r)||ps(r,Zf(r))}};function Zf(r){if(r.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+r.type.name);const e=eh(r),t=r.childCount,n=[];let s=0,o=null;const i=[];for(let c=0,u=e*t;c<u;c++)n[c]=0;for(let c=0,u=0;c<t;c++){const d=r.child(c);u++;for(let p=0;;p++){for(;s<n.length&&n[s]!=0;)s++;if(p==d.childCount)break;const b=d.child(p),{colspan:y,rowspan:x,colwidth:k}=b.attrs;for(let w=0;w<x;w++){if(w+c>=t){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:x-w});break}const N=s+w*e;for(let E=0;E<y;E++){n[N+E]==0?n[N+E]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:y-E});const M=k&&k[E];if(M){const T=(N+E)%e*2,I=i[T];I==null||I!=M&&i[T+1]==1?(i[T]=M,i[T+1]=1):I==M&&i[T+1]++}}}s+=y,u+=b.nodeSize}const f=(c+1)*e;let h=0;for(;s<f;)n[s++]==0&&h++;h&&(o||(o=[])).push({type:"missing",row:c,n:h}),u++}(e===0||t===0)&&(o||(o=[])).push({type:"zero_sized"});const l=new G(e,t,n,o);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&th(l,i,r),l}function eh(r){let e=-1,t=!1;for(let n=0;n<r.childCount;n++){const s=r.child(n);let o=0;if(t)for(let i=0;i<n;i++){const l=r.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>n&&(o+=c.attrs.colspan)}}for(let i=0;i<s.childCount;i++){const l=s.child(i);o+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function th(r,e,t){r.problems||(r.problems=[]);const n={};for(let s=0;s<r.map.length;s++){const o=r.map[s];if(n[o])continue;n[o]=!0;const i=t.nodeAt(o);if(!i)throw new RangeError(`No cell with offset ${o} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const u=(s+c)%r.width,d=e[u*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=nh(a)))[c]=d)}l&&r.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:l})}}function nh(r){if(r.colwidth)return r.colwidth.slice();const e=[];for(let t=0;t<r.colspan;t++)e.push(0);return e}function vl(r,e){if(typeof r=="string")return{};const t=r.getAttribute("data-colwidth"),n=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,s=Number(r.getAttribute("colspan")||1),o={colspan:s,rowspan:Number(r.getAttribute("rowspan")||1),colwidth:n&&n.length==s?n:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(r);a!=null&&(o[i]=a)}return o}function Nl(r,e){const t={};r.attrs.colspan!=1&&(t.colspan=r.attrs.colspan),r.attrs.rowspan!=1&&(t.rowspan=r.attrs.rowspan),r.attrs.colwidth&&(t["data-colwidth"]=r.attrs.colwidth.join(","));for(const n in e){const s=e[n].setDOMAttr;s&&s(r.attrs[n],t)}return t}function rh(r){if(r!==null){if(!Array.isArray(r))throw new TypeError("colwidth must be null or an array");for(const e of r)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function sh(r){const e=r.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:rh}};for(const n in e)t[n]={default:e[n].default,validate:e[n].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:r.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:r.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:n=>vl(n,e)}],toDOM(n){return["td",Nl(n,e),0]}},table_header:{content:r.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:n=>vl(n,e)}],toDOM(n){return["th",Nl(n,e),0]}}}}function fe(r){let e=r.cached.tableNodeTypes;if(!e){e=r.cached.tableNodeTypes={};for(const t in r.nodes){const n=r.nodes[t],s=n.spec.tableRole;s&&(e[s]=n)}}return e}var st=new Ye("selectingCells");function pn(r){for(let e=r.depth-1;e>0;e--)if(r.node(e).type.spec.tableRole=="row")return r.node(0).resolve(r.before(e+1));return null}function oh(r){for(let e=r.depth;e>0;e--){const t=r.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return r.node(e)}return null}function we(r){const e=r.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function er(r){const e=r.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=pn(e.$head)||ih(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function ih(r){for(let e=r.nodeAfter,t=r.pos;e;e=e.firstChild,t++){const n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return r.doc.resolve(t)}for(let e=r.nodeBefore,t=r.pos;e;e=e.lastChild,t--){const n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return r.doc.resolve(t-e.nodeSize)}}function Ol(r){return r.parent.type.spec.tableRole=="row"&&!!r.nodeAfter}function lh(r){return r.node(0).resolve(r.pos+r.nodeAfter.nodeSize)}function ms(r,e){return r.depth==e.depth&&r.pos>=e.start(-1)&&r.pos<=e.end(-1)}function El(r,e,t){const n=r.node(-1),s=G.get(n),o=r.start(-1),i=s.nextCell(r.pos-o,e,t);return i==null?null:r.node(0).resolve(o+i)}function bt(r,e,t=1){const n={...r,colspan:r.colspan-t};return n.colwidth&&(n.colwidth=n.colwidth.slice(),n.colwidth.splice(e,t),n.colwidth.some(s=>s>0)||(n.colwidth=null)),n}function Dl(r,e,t=1){const n={...r,colspan:r.colspan+t};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let s=0;s<t;s++)n.colwidth.splice(e,0,0)}return n}function ah(r,e,t){const n=fe(e.type.schema).header_cell;for(let s=0;s<r.height;s++)if(e.nodeAt(r.map[t+s*r.width]).type!=n)return!1;return!0}var L=class qe extends P{constructor(e,t=e){const n=e.node(-1),s=G.get(n),o=e.start(-1),i=s.rectBetween(e.pos-o,t.pos-o),l=e.node(0),a=s.cellsInRect(i).filter(u=>u!=t.pos-o);a.unshift(t.pos-o);const c=a.map(u=>{const d=n.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const f=o+u+1;return new Bo(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const n=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(Ol(n)&&Ol(s)&&ms(n,s)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?qe.rowSelection(n,s):o&&this.isColSelection()?qe.colSelection(n,s):new qe(n,s)}return V.between(n,s)}content(){const e=this.$anchorCell.node(-1),t=G.get(e),n=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},i=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let u=a*t.width+s.left,d=s.left;d<s.right;d++,u++){const f=t.map[u];if(o[f])continue;o[f]=!0;const h=t.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const b=s.left-h.left,y=h.right-s.right;if(b>0||y>0){let x=p.attrs;if(b>0&&(x=bt(x,0,b)),y>0&&(x=bt(x,x.colspan-y,y)),h.left<s.left){if(p=p.type.createAndFill(x),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(x)}`)}else p=p.type.create(x,p.content)}if(h.top<s.top||h.bottom>s.bottom){const x={...p.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?p=p.type.createAndFill(x):p=p.type.create(x,p.content)}c.push(p)}i.push(e.child(a).copy(S.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new O(S.from(l),1,1)}replace(e,t=O.empty){const n=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){const{$from:l,$to:a}=s[i],c=e.mapping.slice(n);e.replace(c.map(l.pos),c.map(a.pos),i?O.empty:t)}const o=P.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new O(S.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=G.get(t),s=this.$anchorCell.start(-1),o=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let i=0;i<o.length;i++)e(t.nodeAt(o[i]),s+o[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const n=e.node(-1),s=G.get(n),o=e.start(-1),i=s.findCell(e.pos-o),l=s.findCell(t.pos-o),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(o+s.map[i.left])),l.bottom<s.height&&(t=a.resolve(o+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(o+s.map[l.left])),i.bottom<s.height&&(e=a.resolve(o+s.map[s.width*(s.height-1)+i.right-1]))),new qe(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=G.get(e),n=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-n),o=t.colCount(this.$headCell.pos-n);if(Math.min(s,o)>0)return!1;const i=s+this.$anchorCell.nodeAfter.attrs.colspan,l=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof qe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const n=e.node(-1),s=G.get(n),o=e.start(-1),i=s.findCell(e.pos-o),l=s.findCell(t.pos-o),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(o+s.map[i.top*s.width])),l.right<s.width&&(t=a.resolve(o+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(o+s.map[l.top*s.width])),i.right<s.width&&(e=a.resolve(o+s.map[s.width*(i.top+1)-1]))),new qe(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new qe(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){return new qe(e.resolve(t),e.resolve(n))}getBookmark(){return new ch(this.$anchorCell.pos,this.$headCell.pos)}};L.prototype.visible=!1,P.jsonID("cell",L);var ch=class Ga{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ga(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&n.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&ms(t,n)?new L(t,n):P.near(n,1)}};function uh(r){if(!(r.selection instanceof L))return null;const e=[];return r.selection.forEachCell((t,n)=>{e.push(te.node(n,n+t.nodeSize,{class:"selectedCell"}))}),j.create(r.doc,e)}function dh({$from:r,$to:e}){if(r.pos==e.pos||r.pos<e.pos-6)return!1;let t=r.pos,n=e.pos,s=r.depth;for(;s>=0&&!(r.after(s+1)<r.end(s));s--,t++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,n--);return t==n&&/row|table/.test(r.node(s).type.spec.tableRole)}function fh({$from:r,$to:e}){let t,n;for(let s=r.depth;s>0;s--){const o=r.node(s);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){t=o;break}}for(let s=e.depth;s>0;s--){const o=e.node(s);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}return t!==n&&e.parentOffset===0}function hh(r,e,t){const n=(e||r).selection,s=(e||r).doc;let o,i;if(n instanceof A&&(i=n.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")o=L.create(s,n.from);else if(i=="row"){const l=s.resolve(n.from+1);o=L.rowSelection(l,l)}else if(!t){const l=G.get(n.node),a=n.from+1,c=a+l.map[l.width*l.height-1];o=L.create(s,a+1,c)}}else n instanceof V&&dh(n)?o=V.create(s,n.from):n instanceof V&&fh(n)&&(o=V.create(s,n.$from.start(),n.$from.end()));return o&&(e||(e=r.tr)).setSelection(o),e}var ph=new Ye("fix-tables");function Tl(r,e,t,n){const s=r.childCount,o=e.childCount;e:for(let i=0,l=0;i<o;i++){const a=e.child(i);for(let c=l,u=Math.min(s,i+3);c<u;c++)if(r.child(c)==a){l=c+1,t+=a.nodeSize;continue e}n(a,t),l<s&&r.child(l).sameMarkup(a)?Tl(r.child(l),a,t+1,n):a.nodesBetween(0,a.content.size,n,t+1),t+=a.nodeSize}}function gs(r,e){let t;const n=(s,o)=>{s.type.spec.tableRole=="table"&&(t=mh(r,s,o,t))};return e?e.doc!=r.doc&&Tl(e.doc,r.doc,0,n):r.doc.descendants(n),t}function mh(r,e,t,n){const s=G.get(e);if(!s.problems)return n;n||(n=r.tr);const o=[];for(let a=0;a<s.height;a++)o.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)o[c.row+f]+=c.n;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,bt(d,d.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=n.mapping.map(t);n.delete(u,u+e.nodeSize)}}let i,l;for(let a=0;a<o.length;a++)o[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const u=e.child(a),d=c+u.nodeSize,f=o[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<f;y++){const x=fe(r.schema)[h].createAndFill();x&&p.push(x)}const b=(a==0||i==a-1)&&l==a?c+1:d-1;n.insert(n.mapping.map(b),p)}c=d}return n.setMeta(ph,{fixTables:!0})}function Pe(r){const e=r.selection,t=er(r),n=t.node(-1),s=t.start(-1),o=G.get(n);return{...e instanceof L?o.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o.findCell(t.pos-s),tableStart:s,map:o,table:n}}function Al(r,{map:e,tableStart:t,table:n},s){let o=s>0?-1:0;ah(e,n,s+o)&&(o=s==0||s==e.width?null:0);for(let i=0;i<e.height;i++){const l=i*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=n.nodeAt(a);r.setNodeMarkup(r.mapping.map(t+a),null,Dl(c.attrs,s-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=o==null?fe(n.type.schema).cell:n.nodeAt(e.map[l+o]).type,c=e.positionAt(i,s,n);r.insert(r.mapping.map(t+c),a.createAndFill())}}return r}function gh(r,e){if(!we(r))return!1;if(e){const t=Pe(r);e(Al(r.tr,t,t.left))}return!0}function yh(r,e){if(!we(r))return!1;if(e){const t=Pe(r);e(Al(r.tr,t,t.right))}return!0}function bh(r,{map:e,table:t,tableStart:n},s){const o=r.mapping.maps.length;for(let i=0;i<e.height;){const l=i*e.width+s,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)r.setNodeMarkup(r.mapping.slice(o).map(n+a),null,bt(u,s-e.colCount(a)));else{const d=r.mapping.slice(o).map(n+a);r.delete(d,d+c.nodeSize)}i+=u.rowspan}}function xh(r,e){if(!we(r))return!1;if(e){const t=Pe(r),n=r.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;bh(n,t,s),s!=t.left;s--){const o=t.tableStart?n.doc.nodeAt(t.tableStart-1):n.doc;if(!o)throw RangeError("No table found");t.table=o,t.map=G.get(o)}e(n)}return!0}function kh(r,e,t){var n;const s=fe(e.type.schema).header_cell;for(let o=0;o<r.width;o++)if(((n=e.nodeAt(r.map[o+t*r.width]))==null?void 0:n.type)!=s)return!1;return!0}function Pl(r,{map:e,tableStart:t,table:n},s){var o;let i=t;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;const l=[];let a=s>0?-1:0;kh(e,n,s+a)&&(a=s==0||s==e.height?null:0);for(let c=0,u=e.width*s;c<e.width;c++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],f=n.nodeAt(d).attrs;r.setNodeMarkup(t+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{const d=a==null?fe(n.type.schema).cell:(o=n.nodeAt(e.map[u+a*e.width]))==null?void 0:o.type,f=d==null?void 0:d.createAndFill();f&&l.push(f)}return r.insert(i,fe(n.type.schema).row.create(null,l)),r}function wh(r,e){if(!we(r))return!1;if(e){const t=Pe(r);e(Pl(r.tr,t,t.top))}return!0}function Sh(r,e){if(!we(r))return!1;if(e){const t=Pe(r);e(Pl(r.tr,t,t.bottom))}return!0}function Ch(r,{map:e,table:t,tableStart:n},s){let o=0;for(let c=0;c<s;c++)o+=t.child(c).nodeSize;const i=o+t.child(s).nodeSize,l=r.mapping.maps.length;r.delete(o+n,i+n);const a=new Set;for(let c=0,u=s*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),s>0&&d==e.map[u-e.width]){const f=t.nodeAt(d).attrs;r.setNodeMarkup(r.mapping.slice(l).map(d+n),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(s<e.height&&d==e.map[u+e.width]){const f=t.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),b=e.positionAt(s+1,c,t);r.insert(r.mapping.slice(l).map(n+b),p),c+=h.colspan-1}}}}function Mh(r,e){if(!we(r))return!1;if(e){const t=Pe(r),n=r.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;Ch(n,t,s),s!=t.top;s--){const o=t.tableStart?n.doc.nodeAt(t.tableStart-1):n.doc;if(!o)throw RangeError("No table found");t.table=o,t.map=G.get(t.table)}e(n)}return!0}function Il(r){const e=r.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function vh({width:r,height:e,map:t},n){let s=n.top*r+n.left,o=s,i=(n.bottom-1)*r+n.left,l=s+(n.right-n.left-1);for(let a=n.top;a<n.bottom;a++){if(n.left>0&&t[o]==t[o-1]||n.right<r&&t[l]==t[l+1])return!0;o+=r,l+=r}for(let a=n.left;a<n.right;a++){if(n.top>0&&t[s]==t[s-r]||n.bottom<e&&t[i]==t[i+r])return!0;s++,i++}return!1}function Nh(r,e){const t=r.selection;if(!(t instanceof L)||t.$anchorCell.pos==t.$headCell.pos)return!1;const n=Pe(r),{map:s}=n;if(vh(s,n))return!1;if(e){const o=r.tr,i={};let l=S.empty,a,c;for(let u=n.top;u<n.bottom;u++)for(let d=n.left;d<n.right;d++){const f=s.map[u*s.width+d],h=n.table.nodeAt(f);if(!(i[f]||!h))if(i[f]=!0,a==null)a=f,c=h;else{Il(h)||(l=l.append(h.content));const p=o.mapping.map(f+n.tableStart);o.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(o.setNodeMarkup(a+n.tableStart,null,{...Dl(c.attrs,c.attrs.colspan,n.right-n.left-c.attrs.colspan),rowspan:n.bottom-n.top}),l.size){const u=a+1+c.content.size,d=Il(c)?a+1:u;o.replaceWith(d+n.tableStart,u+n.tableStart,l)}o.setSelection(new L(o.doc.resolve(a+n.tableStart))),e(o)}return!0}function Oh(r,e){const t=fe(r.schema);return Eh(({node:n})=>t[n.type.spec.tableRole])(r,e)}function Eh(r){return(e,t)=>{var n;const s=e.selection;let o,i;if(s instanceof L){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;o=s.$anchorCell.nodeAfter,i=s.$anchorCell.pos}else{if(o=oh(s.$from),!o)return!1;i=(n=pn(s.$from))==null?void 0:n.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(t){let l=o.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=Pe(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=o.nodeSize);for(let b=u.left,y=0;b<u.right;b++,y++)b==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),r({node:o,row:h,col:b}).createAndFill(a[y]))}d.setNodeMarkup(i,r({node:o,row:u.top,col:u.left}),a[0]),s instanceof L&&d.setSelection(new L(d.doc.resolve(s.$anchorCell.pos),f?d.doc.resolve(f):void 0)),t(d)}return!0}}function Ft(r,e){return function(t,n){if(!we(t))return!1;const s=er(t);if(s.nodeAfter.attrs[r]===e)return!1;if(n){const o=t.tr;t.selection instanceof L?t.selection.forEachCell((i,l)=>{i.attrs[r]!==e&&o.setNodeMarkup(l,null,{...i.attrs,[r]:e})}):o.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[r]:e}),n(o)}return!0}}function Dh(r){return function(e,t){if(!we(e))return!1;if(t){const n=fe(e.schema),s=Pe(e),o=e.tr,i=s.map.cellsInRect(r=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:r=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=i.map(a=>s.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==n.header_cell&&o.setNodeMarkup(s.tableStart+i[a],n.cell,l[a].attrs);if(o.steps.length==0)for(let a=0;a<i.length;a++)o.setNodeMarkup(s.tableStart+i[a],n.header_cell,l[a].attrs);t(o)}return!0}}function Vl(r,e,t){const n=e.map.cellsInRect({left:0,top:0,right:r=="row"?e.map.width:1,bottom:r=="column"?e.map.height:1});for(let s=0;s<n.length;s++){const o=e.table.nodeAt(n[s]);if(o&&o.type!==t.header_cell)return!1}return!0}function ys(r,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Dh(r):function(t,n){if(!we(t))return!1;if(n){const s=fe(t.schema),o=Pe(t),i=t.tr,l=Vl("row",o,s),a=Vl("column",o,s),u=(r==="column"?l:r==="row"?a:!1)?1:0,d=r=="column"?{left:0,top:u,right:1,bottom:o.map.height}:r=="row"?{left:u,top:0,right:o.map.width,bottom:1}:o,f=r=="column"?a?s.cell:s.header_cell:r=="row"?l?s.cell:s.header_cell:s.cell;o.map.cellsInRect(d).forEach(h=>{const p=h+o.tableStart,b=i.doc.nodeAt(p);b&&i.setNodeMarkup(p,f,b.attrs)}),n(i)}return!0}}var Th=ys("row",{useDeprecatedLogic:!0}),Ah=ys("column",{useDeprecatedLogic:!0}),Ph=ys("cell",{useDeprecatedLogic:!0});function Ih(r,e){if(e<0){const t=r.nodeBefore;if(t)return r.pos-t.nodeSize;for(let n=r.index(-1)-1,s=r.before();n>=0;n--){const o=r.node(-1).child(n),i=o.lastChild;if(i)return s-1-i.nodeSize;s-=o.nodeSize}}else{if(r.index()<r.parent.childCount-1)return r.pos+r.nodeAfter.nodeSize;const t=r.node(-1);for(let n=r.indexAfter(-1),s=r.after();n<t.childCount;n++){const o=t.child(n);if(o.childCount)return s+1;s+=o.nodeSize}}return null}function Rl(r){return function(e,t){if(!we(e))return!1;const n=Ih(er(e),r);if(n==null)return!1;if(t){const s=e.doc.resolve(n);t(e.tr.setSelection(V.between(s,lh(s))).scrollIntoView())}return!0}}function Vh(r,e){const t=r.selection.$anchor;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="table")return e&&e(r.tr.delete(t.before(n),t.after(n)).scrollIntoView()),!0;return!1}function tr(r,e){const t=r.selection;if(!(t instanceof L))return!1;if(e){const n=r.tr,s=fe(r.schema).cell.createAndFill().content;t.forEachCell((o,i)=>{o.content.eq(s)||n.replace(n.mapping.map(i+1),n.mapping.map(i+o.nodeSize-1),new O(s,0,0))}),n.docChanged&&e(n)}return!0}function Rh(r){if(!r.size)return null;let{content:e,openStart:t,openEnd:n}=r;for(;e.childCount==1&&(t>0&&n>0||e.child(0).type.spec.tableRole=="table");)t--,n--,e=e.child(0).content;const s=e.child(0),o=s.type.spec.tableRole,i=s.type.schema,l=[];if(o=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,n-1);(u||d)&&(c=bs(fe(i).row,new O(c,u,d)).content),l.push(c)}else if(o=="cell"||o=="header_cell")l.push(t||n?bs(fe(i).row,new O(e,t,n)).content:e);else return null;return zh(i,l)}function zh(r,e){const t=[];for(let s=0;s<e.length;s++){const o=e[s];for(let i=o.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=o.child(i).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let n=0;for(let s=0;s<t.length;s++)n=Math.max(n,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(S.empty),t[s]<n){const o=fe(r).cell.createAndFill(),i=[];for(let l=t[s];l<n;l++)i.push(o);e[s]=e[s].append(S.from(i))}return{height:e.length,width:n,rows:e}}function bs(r,e){const t=r.createAndFill();return new jo(t).replace(0,t.content.size,e).doc}function jh({width:r,height:e,rows:t},n,s){if(r!=n){const o=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=o[l]||0,d=0;u<n;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>n&&(f=f.type.createChecked(bt(f.attrs,f.attrs.colspan,u+f.attrs.colspan-n),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)o[l+h]=(o[l+h]||0)+f.attrs.colspan}i.push(S.from(c))}t=i,r=n}if(e!=s){const o=[];for(let i=0,l=0;i<s;i++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);i+d.attrs.rowspan>s&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,s-d.attrs.rowspan)},d.content)),a.push(d)}o.push(S.from(a))}t=o,e=s}return{width:r,height:e,rows:t}}function Bh(r,e,t,n,s,o,i){const l=r.doc.type.schema,a=fe(l);let c,u;if(s>e.width)for(let d=0,f=0;d<e.height;d++){const h=t.child(d);f+=h.nodeSize;const p=[];let b;h.lastChild==null||h.lastChild.type==a.cell?b=c||(c=a.cell.createAndFill()):b=u||(u=a.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(b);r.insert(r.mapping.slice(i).map(f-1+n),p)}if(o>e.height){const d=[];for(let p=0,b=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const y=p>=e.width?!1:t.nodeAt(e.map[b+p]).type==a.header_cell;d.push(y?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,S.from(d)),h=[];for(let p=e.height;p<o;p++)h.push(f);r.insert(r.mapping.slice(i).map(n+t.nodeSize-2),h)}return!!(c||u)}function zl(r,e,t,n,s,o,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=s;c<o;c++){const u=i*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const f=t.nodeAt(d),{top:h,left:p}=e.findCell(d);r.setNodeMarkup(r.mapping.slice(l).map(d+n),null,{...f.attrs,rowspan:i-h}),r.insert(r.mapping.slice(l).map(e.positionAt(i,p,t)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-i})),c+=f.attrs.colspan-1}}return a}function jl(r,e,t,n,s,o,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=s;c<o;c++){const u=c*e.width+i,d=e.map[u];if(e.map[u-1]==d){a=!0;const f=t.nodeAt(d),h=e.colCount(d),p=r.mapping.slice(l).map(d+n);r.setNodeMarkup(p,null,bt(f.attrs,i-h,f.attrs.colspan-(i-h))),r.insert(p+f.nodeSize,f.type.createAndFill(bt(f.attrs,0,i-h))),c+=f.attrs.rowspan-1}}return a}function Bl(r,e,t,n,s){let o=t?r.doc.nodeAt(t-1):r.doc;if(!o)throw new Error("No table found");let i=G.get(o);const{top:l,left:a}=n,c=a+s.width,u=l+s.height,d=r.tr;let f=0;function h(){if(o=t?d.doc.nodeAt(t-1):d.doc,!o)throw new Error("No table found");i=G.get(o),f=d.mapping.maps.length}Bh(d,i,o,t,c,u,f)&&h(),zl(d,i,o,t,a,c,l,f)&&h(),zl(d,i,o,t,a,c,u,f)&&h(),jl(d,i,o,t,l,u,a,f)&&h(),jl(d,i,o,t,l,u,c,f)&&h();for(let p=l;p<u;p++){const b=i.positionAt(p,a,o),y=i.positionAt(p,c,o);d.replace(d.mapping.slice(f).map(b+t),d.mapping.slice(f).map(y+t),new O(s.rows[p-l],0,0))}h(),d.setSelection(new L(d.doc.resolve(t+i.positionAt(l,a,o)),d.doc.resolve(t+i.positionAt(u-1,c-1,o)))),e(d)}var Fh=Ar({ArrowLeft:rr("horiz",-1),ArrowRight:rr("horiz",1),ArrowUp:rr("vert",-1),ArrowDown:rr("vert",1),"Shift-ArrowLeft":sr("horiz",-1),"Shift-ArrowRight":sr("horiz",1),"Shift-ArrowUp":sr("vert",-1),"Shift-ArrowDown":sr("vert",1),Backspace:tr,"Mod-Backspace":tr,Delete:tr,"Mod-Delete":tr});function nr(r,e,t){return t.eq(r.selection)?!1:(e&&e(r.tr.setSelection(t).scrollIntoView()),!0)}function rr(r,e){return(t,n,s)=>{if(!s)return!1;const o=t.selection;if(o instanceof L)return nr(t,n,P.near(o.$headCell,e));if(r!="horiz"&&!o.empty)return!1;const i=Fl(s,r,e);if(i==null)return!1;if(r=="horiz")return nr(t,n,P.near(t.doc.resolve(o.head+e),e));{const l=t.doc.resolve(i),a=El(l,r,e);let c;return a?c=P.near(a,1):e<0?c=P.near(t.doc.resolve(l.before(-1)),-1):c=P.near(t.doc.resolve(l.after(-1)),1),nr(t,n,c)}}}function sr(r,e){return(t,n,s)=>{if(!s)return!1;const o=t.selection;let i;if(o instanceof L)i=o;else{const a=Fl(s,r,e);if(a==null)return!1;i=new L(t.doc.resolve(a))}const l=El(i.$headCell,r,e);return l?nr(t,n,new L(i.$anchorCell,l)):!1}}function Lh(r,e){const t=r.state.doc,n=pn(t.resolve(e));return n?(r.dispatch(r.state.tr.setSelection(new L(n))),!0):!1}function $h(r,e,t){if(!we(r.state))return!1;let n=Rh(t);const s=r.state.selection;if(s instanceof L){n||(n={width:1,height:1,rows:[S.from(bs(fe(r.state.schema).cell,t))]});const o=s.$anchorCell.node(-1),i=s.$anchorCell.start(-1),l=G.get(o).rectBetween(s.$anchorCell.pos-i,s.$headCell.pos-i);return n=jh(n,l.right-l.left,l.bottom-l.top),Bl(r.state,r.dispatch,i,l,n),!0}else if(n){const o=er(r.state),i=o.start(-1);return Bl(r.state,r.dispatch,i,G.get(o.node(-1)).findCell(o.pos-i),n),!0}else return!1}function Wh(r,e){var t;if(e.ctrlKey||e.metaKey)return;const n=Ll(r,e.target);let s;if(e.shiftKey&&r.state.selection instanceof L)o(r.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&n&&(s=pn(r.state.selection.$anchor))!=null&&((t=xs(r,e))==null?void 0:t.pos)!=s.pos)o(s,e),e.preventDefault();else if(!n)return;function o(a,c){let u=xs(r,c);const d=st.getState(r.state)==null;if(!u||!ms(a,u))if(d)u=a;else return;const f=new L(a,u);if(d||!r.state.selection.eq(f)){const h=r.state.tr.setSelection(f);d&&h.setMeta(st,a.pos),r.dispatch(h)}}function i(){r.root.removeEventListener("mouseup",i),r.root.removeEventListener("dragstart",i),r.root.removeEventListener("mousemove",l),st.getState(r.state)!=null&&r.dispatch(r.state.tr.setMeta(st,-1))}function l(a){const c=a,u=st.getState(r.state);let d;if(u!=null)d=r.state.doc.resolve(u);else if(Ll(r,c.target)!=n&&(d=xs(r,e),!d))return i();d&&o(d,c)}r.root.addEventListener("mouseup",i),r.root.addEventListener("dragstart",i),r.root.addEventListener("mousemove",l)}function Fl(r,e,t){if(!(r.state.selection instanceof V))return null;const{$head:n}=r.state.selection;for(let s=n.depth-1;s>=0;s--){const o=n.node(s);if((t<0?n.index(s):n.indexAfter(s))!=(t<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=n.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return r.endOfTextblock(a)?l:null}}return null}function Ll(r,e){for(;e&&e!=r.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function xs(r,e){const t=r.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?pn(r.state.doc.resolve(t.pos)):null}new Ye("tableColumnResizing");function _h({allowTableNodeSelection:r=!1}={}){return new Ee({key:st,state:{init(){return null},apply(e,t){const n=e.getMeta(st);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;const{deleted:s,pos:o}=e.mapping.mapResult(t);return s?null:o}},props:{decorations:uh,handleDOMEvents:{mousedown:Wh},createSelectionBetween(e){return st.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Lh,handleKeyDown:Fh,handlePaste:$h},appendTransaction(e,t,n){return hh(n,gs(n,t),r)}})}const Lt=m.createContext(null),qh=m.createContext(null),$l=m.createContext(null),or=new WeakMap;function Jh(r){const e=Object.create(null);e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",s=>{if(typeof s=="function"&&(s=s(r.state)),s)for(const o in s)o=="class"?e.class+=" "+s[o]:o=="style"?e.style=(e.style?e.style+";":"")+s[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(s[o]))}),e.translate||(e.translate="no");const t=[te.node(0,r.state.doc.content.size,e)],n=or.get(r);return!n||n[0].to!==r.state.doc.content.size||!n[0].type.eq(t[0].type)?(or.set(r,t),t):n}const Hh=[],Kh={},ks=j.empty;let Wl=class Ht{constructor(e){B(this,"members");this.members=e}map(e,t){const n=this.members.map(s=>s.map(e,t,Kh));return Ht.from(n)}forChild(e,t){if(t.isLeaf)return j.empty;let n=[];for(let s=0;s<this.members.length;s++){const o=this.members[s].forChild(e,t);o!=ks&&(o instanceof Ht?n=n.concat(o.members):n.push(o))}return Ht.from(n)}eq(e){if(!(e instanceof Ht)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let s=0;s<this.members.length;s++){const o=this.members[s].localsInner(e);if(o.length)if(!t)t=o;else{n&&(t=t.slice(),n=!1);for(let i=0;i<o.length;i++)t.push(o[i])}}return t?Yh(n?t:t.sort(_l)):Hh}static from(e){switch(e.length){case 0:return ks;case 1:return e[0];default:return new Ht(e.every(t=>t instanceof j)?e:e.reduce((t,n)=>t.concat(n instanceof j?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function _l(r,e){return r.from-e.from||r.to-e.to}function Yh(r){let e=r;for(let t=0;t<e.length-1;t++){const n=e[t];if(n.from!=n.to)for(let s=t+1;s<e.length;s++){const o=e[s];if(o.from==n.from){o.to!=n.to&&(e==r&&(e=r.slice()),e[s]=o.copy(o.from,n.to),ql(e,s+1,o.copy(n.to,o.to)));continue}else{o.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,o.from),ql(e,s,n.copy(o.from,n.to)));break}}}return e}function ql(r,e,t){for(;e<r.length&&_l(t,r[e])>0;)e++;r.splice(e,0,t)}const ws=new WeakMap;function Gh(r,e){const t=[];r.someProp("decorations",i=>{const l=i(r.state);l&&l!=ks&&t.push(l)}),e&&t.push(j.create(r.state.doc,[e]));const n=ws.get(r);if(!n){const i=Wl.from(t);return ws.set(r,i),i}let s=0,o=!0;if(n.forEachSet(i=>{t[s++]!==i&&(o=!1)}),s!==t.length&&(o=!1),!o){const i=Wl.from(t);return ws.set(r,i),i}return n}const Xh=new Pn({nodes:{doc:{content:"text*"},text:{inline:!0}}}),Ss=Ke.create({schema:Xh});function Jl(r){const e=Object.create(null);function t(n){for(const s in n)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=n[s])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function Qh(r,e){let t=0,n=0;for(const s in r){if(r[s]!=e[s])return!0;t++}for(const s in e)n++;return t!=n}class xt extends lf{constructor(t,n){var e=(...ug)=>(super(...ug),B(this,"nextProps"),B(this,"prevState"),this);const s=[...t.mount.childNodes],o=[...t.mount.attributes];for(const i of o)t.mount.removeAttributeNode(i);try{e(t,{state:Ss}),this.domObserver.stop(),this.domObserver.observer=null,this.domObserver.queue=[]}finally{t.mount.replaceChildren(...s);for(const i of t.mount.attributes)t.mount.removeAttributeNode(i);for(const i of o)t.mount.setAttributeNode(i)}this.prevState=Ss,this.nextProps=n,this.state=n.state,this.nodeViews=Jl(this),this.docView.destroy(),this.docView=null}get props(){return this.nextProps}setProps(t){this.update({...this.props,...t})}update(t){const n=this.nextProps;if(this.nextProps=t,this.state=t.state,n.state.plugins!==t.state.plugins||n.plugins!==t.plugins||n.nodeViews!==t.nodeViews){const s=Jl(this);Qh(this.nodeViews,s)&&(this.nodeViews=s)}this.editable=!this.someProp("editable",s=>s(this.state)===!1)}updateState(t){this.setProps({state:t})}someProp(t,n){if(!this.props)return;const s=this.props[t];if(s){const o=n?n(s):s;if(o)return o}for(const o of this.props.plugins??[]){const i=o.props[t];if(i){const l=n?n(i):i;if(l)return l}}for(const o of this.state.plugins){const i=o.props[t];if(i){const l=n?n(i):i;if(l)return l}}}destroy(){const t=[...this.dom.childNodes];try{super.destroy()}finally{this.dom.replaceChildren(...t)}}commitPendingEffects(){this.state=this.prevState,this.docView.markDirty(-1,-1),super.update(this.nextProps),this.prevState=this.state}}class Hl{constructor(e){B(this,"props");B(this,"nodeViews");this.props=e,this.nodeViews={}}get composing(){return!1}get dom(){return null}get editable(){return!1}get state(){return this.props.state}setProps(e){return this.update({...this.props,...e})}update(e){this.props=e}updateState(e){this.setProps({state:e})}someProp(e,t){const n=this.props[e];if(n){const s=t?t(n):n;if(s)return s}for(const s of this.props.plugins??[]){const o=s.props[e];if(o){const i=t?t(o):o;if(i)return i}}for(const s of this.state.plugins){const o=s.props[e];if(o){const i=t?t(o):o;if(i)return i}}}destroy(){}domSelectionRange(){return{anchorNode:null,anchorOffset:0,focusNode:null,focusOffset:0}}domSelection(){return null}}const ot=function(r){for(let e=0;;e++)if(r=r.previousSibling,!r)return e},Kl=function(r,e,t,n){return t&&(Yl(r,e,t,n,-1)||Yl(r,e,t,n,1))},Uh=/^(img|br|input|textarea|hr)$/i;function Yl(r,e,t,n,s){for(;;){if(r==t&&e==n)return!0;if(e==(s<0?0:Gl(r))){const o=r.parentNode;if(!o||o.nodeType!=1||Zh(r)||Uh.test(r.nodeName)||r.contentEditable=="false")return!1;e=ot(r)+(s<0?0:1),r=o}else if(r.nodeType==1){if(r=r.childNodes[e+(s<0?-1:0)],r.contentEditable=="false")return!1;e=s<0?Gl(r):0}else return!1}}function Gl(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Zh(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const Xl=m.createContext(null);function ne(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];typeof document>"u"||m.useLayoutEffect(...e)}function ep(r,e){const t=m.useContext(Xl);ne(()=>t(r),e)}function Ie(r,e){const{view:t,flushSyncRef:n}=m.useContext(Lt);ep(()=>{if(t instanceof xt){n.current=!1;const s=r(t);return n.current=!0,s}},e&&[t,...e])}const tp=m.forwardRef(function(e,t){let{widget:n,getPos:s,...o}=e;const[i,l]=m.useState(!0),a=m.useRef(null);return m.useImperativeHandle(t,()=>a.current,[]),Ie(c=>{if(!c||!a.current)return;c.domObserver.disconnectSelection();const u=c.domSelection(),d=document.createRange(),f=a.current;f.nodeName=="IMG"&&f.parentNode?d.setEnd(f.parentNode,ot(f)+1):d.setEnd(f,0),d.collapse(!1),u.removeAllRanges(),u.addRange(d),l(!1),c.domObserver.connectSelection()},[]),i?m.createElement("img",{ref:a,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...o}):null});function np(r,e){if(r==e)return!0;for(const t in r)if(r[t]!==e[t])return!1;for(const t in e)if(!(t in r))return!1;return!0}const rp={side:0};class $t{constructor(e,t){B(this,"Component");B(this,"side");B(this,"spec");this.Component=e,this.spec=t??rp,this.side=this.spec.side??0}map(e,t,n,s){const{pos:o,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new te(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof $t&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&np(this.spec,e.spec))}destroy(){}}function sp(r,e,t){return new te(r,r,new $t(e,t))}function Cs(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(e===null)return!1;const n=t.from??r.state.selection.from,s=t.to??r.state.selection.to;if(r.someProp("handleTextInput",i=>i(r,n,s,e)))return!0;const{tr:o}=r.state;return t.marks&&o.ensureMarks(t.marks),o.insertText(e,n,s),r.dispatch(o),!0}function op(r){let e=null,t=null;return new Ee({props:{handleDOMEvents:{compositionstart(n){const{state:s}=n;n.dispatch(s.tr.deleteSelection());const o=s.selection.$from;e=s.storedMarks??o.marks(),e&&r(sp(s.selection.from,tp,{key:"cursor-wrapper",marks:e}));const{node:i}=n.domAtPos(o.pos);t=[];for(const l of i.childNodes)t.push(l);return n.input.composing=!0,!0},compositionupdate(){return!0},compositionend(n,s){n.input.composing=!1;const{state:o}=n,{node:i}=n.domAtPos(o.selection.from);if(t&&(t.forEach((l,a)=>{if(i.childNodes.length<=a){i.appendChild(l);return}i.replaceChild(l,i.childNodes.item(a))}),i.childNodes.length>t.length))for(let l=t.length;l<i.childNodes.length;l++)i.removeChild(i.childNodes.item(l));return s.data&&Cs(n,s.data,{marks:e}),e=null,t=null,r(null),!0},beforeinput(n,s){var o,i;switch(s.preventDefault(),s.inputType){case"insertParagraph":case"insertLineBreak":{n.input.lastIOSEnter=0;const l=new KeyboardEvent("keydown",{bubbles:!0,cancelable:!0,key:"Enter",code:"Enter",keyCode:13,shiftKey:s.inputType==="insertLineBreak"});return n.someProp("handleKeyDown",a=>a(n,l))??!1}case"insertReplacementText":{const l=s.getTargetRanges();(i=(o=s.dataTransfer)==null?void 0:o.items[0])==null||i.getAsString(a=>{for(const c of l){const u=n.posAtDOM(c.startContainer,c.startOffset,1),d=n.posAtDOM(c.endContainer,c.endOffset,1);Cs(n,a,{from:u,to:d})}});break}case"insertText":{Cs(n,s.data);break}case"deleteWordBackward":case"deleteHardLineBackward":case"deleteSoftLineBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteHardLineForward":case"deleteSoftLineForward":case"deleteContentForward":case"deleteContent":{const l=s.getTargetRanges(),{tr:a}=n.state;for(const c of l){const u=n.posAtDOM(c.startContainer,c.startOffset),d=n.posAtDOM(c.endContainer,c.endOffset),{doc:f}=n.state,h=f.resolve(u).marksAcross(f.resolve(d));a.delete(u,d).setStoredMarks(h)}n.dispatch(a);break}}return!0}}}})}function ip(r){const e={};for(const[n,s]of r.entries()){let o=function(i,l){for(const a of s){let c=!1;if(Re.unstable_batchedUpdates(()=>{c=!!a.call(this,i,l)}),c||l.defaultPrevented)return!0}return!1};e[n]=o}return new Ee({key:new Ye("@handlewithcare/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function lp(){const[r,e]=m.useState(new Map),t=m.useCallback((o,i)=>{const l=r.get(o)??[];l.unshift(i),r.has(o)||(r.set(o,l),e(new Map(r)))},[r]),n=m.useCallback((o,i)=>{const l=r.get(o);l==null||l.splice(l.indexOf(i),1)},[r]),s=m.useMemo(()=>ip(r),[r]);return{registerEventListener:t,unregisterEventListener:n,componentEventListenersPlugin:s}}function Ql(){const[,r]=m.useReducer(e=>e+1,0);return r}let Ul=!1;function ap(r,e){process.env.NODE_ENV!=="production"&&e.defaultState!==void 0&&e.state!==void 0&&!Ul&&(console.error("A component contains a ProseMirror editor with both state and defaultState props. ProseMirror editors must be either controlled or uncontrolled (specify either the state prop, or the defaultState prop, but not both). Decide between using a controlled or uncontrolled ProseMirror editor and remove one of these props. More info: https://reactjs.org/link/controlled-components"),Ul=!0);const t=m.useRef(!0),[n,s]=m.useState(null),o=Ql(),i=e.defaultState??Ss,[l,a]=m.useState(i),c=e.state??l,{componentEventListenersPlugin:u,registerEventListener:d,unregisterEventListener:f}=lp(),h=m.useCallback(N=>{Re.flushSync(()=>{s(N)})},[]),p=m.useMemo(()=>[...e.plugins??[],u,op(h)],[e.plugins,u,h]),b=m.useCallback(function(E){t.current?Re.flushSync(()=>{e.state||a(M=>M.apply(E)),e.dispatchTransaction&&e.dispatchTransaction.call(this,E)}):(e.state||a(M=>M.apply(E)),e.dispatchTransaction&&e.dispatchTransaction.call(this,E))},[e.dispatchTransaction,e.state]),y={...e,state:c,plugins:p,dispatchTransaction:b},[x,k]=m.useState(()=>new Hl(y));return ne(()=>()=>{x.destroy()},[x]),ne(()=>{if(r!==x.dom)if(r){const N=new xt({mount:r},y);N.dom.addEventListener("compositionend",o),k(N)}else{const N=new Hl(y);k(N)}else x instanceof xt&&x.commitPendingEffects()}),x.update(y),{editor:m.useMemo(()=>({view:x,cursorWrapper:n,flushSyncRef:t,registerEventListener:d,unregisterEventListener:f}),[n,d,f,x]),state:c}}function cp(r){let{children:e}=r;const t=m.useRef(new Set).current,n=m.useRef(new Set).current,s=m.useRef(!1),o=Ql(),i=m.useRef(!0),l=m.useCallback(()=>{i.current||(o(),i.current=!0)},[o]),a=m.useCallback(c=>{let u;const d=()=>{u=c()};return t.add(d),l(),()=>{t.delete(d),u&&(s.current?(n.add(u),l()):u())}},[t,n,l]);return ne(()=>(i.current=!1,t.forEach(c=>c()),t.clear(),()=>{n.forEach(c=>c()),n.clear()})),ne(()=>(s.current=!0,()=>{s.current=!1}),[]),m.createElement(Xl.Provider,{value:a},e)}const Ne=m.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}}),Ve=typeof navigator<"u"?navigator:null,Zl=typeof document<"u"?document:null,kt=Ve&&Ve.userAgent||"",Ms=/Edge\/(\d+)/.exec(kt),ea=/MSIE \d/.exec(kt),vs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(kt),Ns=!!(ea||vs||Ms);ea?document.documentMode:vs?+vs[1]:Ms&&+Ms[1];const ta=!Ns&&/gecko\/(\d+)/i.test(kt);ta&&+(/Firefox\/(\d+)/.exec(kt)||[0,0])[1];const Os=!Ns&&/Chrome\/(\d+)/.exec(kt),up=!!Os;Os&&+Os[1];const na=!Ns&&!!Ve&&/Apple Computer/.test(Ve.vendor);na&&(/Mobile\/\w+/.test(kt)||!!Ve&&Ve.maxTouchPoints>2)||Ve&&/Mac/.test(Ve.platform),Ve&&/Win/.test(Ve.platform),!!Zl&&"webkitFontSmoothing"in Zl.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];const Wt={gecko:ta,chrome:up,safari:na};function wt(r,e){return r instanceof gn?1:e instanceof gn?-1:r.getPos()-e.getPos()}const it=0,ra=1,ir=2,St=3;class mn{constructor(e,t,n,s,o){B(this,"parent");B(this,"children");B(this,"getPos");B(this,"dom");B(this,"contentDOM");B(this,"dirty");B(this,"node");this.parent=e,this.children=t,this.getPos=n,this.dom=s,this.contentDOM=o,this.dirty=it,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){const s=this.children[t];if(s==e)return n;n+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let o,i;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ot(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;for(let n=!0,s=e;s;s=s.parentNode){const o=this.getDesc(s);let i;if(o&&(!t||o.node))if(n&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))n=!1;else return o}}getDesc(e){const t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let s=e;s;s=s.parentNode){const o=this.getDesc(s);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let s=this.children[t];const o=n+s.size;if(n==e&&o!=n){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){const l=s.children[i];if(l.size){s=l;break}}return s}if(e<o)return s.descAt(e-n-s.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,s=0;for(let o=0;n<this.children.length;n++){const i=this.children[n],l=o+i.size;if(l>e||i instanceof gn){s=e-o;break}o=l}if(s)return this.children[n].domFromPos(s-this.children[n].border,t);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof Es&&o.side>=0;n--);if(t<=0){let o,i=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,i=!1);return o&&t&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?ot(o.dom)+1:0}}else{let o,i=!0;for(;o=n<this.children.length?this.children[n]:null,!(!o||o.dom.parentNode==this.contentDOM);n++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?ot(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=n,l=0;;l++){const a=this.children[l],c=i+a.size;if(s==-1&&e<=c){const u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let d=l;d>0;d--){const f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=ot(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){const d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=ot(d.dom);break}t+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;const t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){const{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n){var h;let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const o=Math.min(e,t),i=Math.max(e,t);for(let p=0,b=0;p<this.children.length;p++){const y=this.children[p],x=b+y.size;if(o>b&&i<x)return y.setSelection(e-b-y.border,t-b-y.border,n,s);b=x}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1);const c=n.root.getSelection(),u=n.domSelectionRange();let d=!1;if((Wt.gecko||Wt.safari)&&e==t){const{node:p,offset:b}=l;if(p.nodeType==3){if(d=!!(b&&((h=p.nodeValue)==null?void 0:h[b-1])==`
|
|
33
|
-
`),d&&b==p.nodeValue.length)for(let y=p,x;y;y=y.parentNode){if(x=y.nextSibling){x.nodeName=="BR"&&(l=a={node:x.parentNode,offset:ot(x)+1});break}const k=y.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{const y=p.childNodes[b-1];d=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Wt.gecko&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){const p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(s=!0)}if(!(s||d&&Wt.safari)&&Kl(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Kl(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!d){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){const b=l;l=a,a=b}const p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,s=0;s<this.children.length;s++){const o=this.children[s],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){const l=n+o.border,a=i-o.border;if(e>=l&&t<=a){this.dirty=e==n||t==i?ir:ra,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=St:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?ir:St}n=i}this.dirty=ir}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const n=e==1?ir:ra;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class Es extends mn{constructor(t,n,s,o){super(t,[],n,o,null);B(this,"widget");this.widget=s,this.widget=s}matchesWidget(t){return this.dirty==it&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){const n=this.widget.spec.stopEvent;return n?n(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}get domAtom(){return!0}get side(){return this.widget.type.side}}class Ds extends mn{constructor(t,n,s,o,i){super(t,[],n,s,null);B(this,"textDOM");B(this,"text");this.textDOM=o,this.text=i}get size(){return this.text.length}localPosFromDOM(t,n){return t!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class dp extends mn{constructor(t,n,s,o,i,l,a){super(t,n,s,i,l);B(this,"mark");B(this,"spec");this.mark=o,this.spec=a}parseRule(){return this.dirty&St||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=St&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=it){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty<this.dirty&&(s.dirty=this.dirty),this.dirty=it}}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class sa extends mn{constructor(t,n,s,o,i,l,a,c,u){super(t,n,s,a,c);B(this,"node");B(this,"outerDeco");B(this,"innerDeco");B(this,"nodeDOM");this.node=o,this.outerDeco=i,this.innerDeco=l,this.nodeDOM=u}parseRule(){if(this.node.type.spec.reparseInView)return null;const t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){const s=this.children[n];if(this.dom.contains(s.dom.parentNode)){t.contentElement=s.dom.parentNode;break}}t.contentElement||(t.getContent=()=>S.empty)}return t}matchesNode(t,n,s){return this.dirty==it&&t.eq(this.node)&&mp(n,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,n){}update(t,n,s,o){return this.dirty==St||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,s,o),!0)}updateInner(t,n,s,o){this.updateOuterDeco(n),this.node=t,this.innerDeco=s,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=it}updateOuterDeco(t){this.outerDeco=t}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}class fp extends sa{constructor(e,t,n,s,o,i,l,a){super(e,t,n,s,o,i,l,null,a)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,s){return this.dirty=it,!0}inParent(){const e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=St)}get domAtom(){return!1}}class gn extends mn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==it&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}let hp=class extends sa{constructor(t,n,s,o,i,l,a,c,u,d){super(t,n,s,o,i,l,a,c,u);B(this,"spec");this.spec=d}update(t,n,s,o){if(this.dirty==St)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){const i=this.spec.update(t,n,s);return i&&this.updateInner(t,n,s,o),i}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,n,s,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,n,s,o){this.spec.setSelection?this.spec.setSelection(t,n,s.root):super.setSelection(t,n,s,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}};class pp extends hp{updateChildren(e,t){}updateOuterDeco(e){this.outerDeco=e}destroy(){this.children=[],super.destroy()}}function mp(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function oa(r,e){var t,n;return(r==null?void 0:r.contentDOM)??((n=(t=e[0])==null?void 0:t.dom)==null?void 0:n.parentElement)??null}function Ts(r,e,t){const{view:n}=m.useContext(Lt),{parentRef:s,siblingsRef:o}=m.useContext(Ne),[i,l]=m.useState(null),[a,c]=m.useState(null),[u,d]=m.useState(null),f=m.useRef(),h=m.useRef([]),p=m.useCallback(k=>{if(!(n instanceof xt))return;const w=r.current;if(!w)return;const{node:N,getPos:E,decorations:M,innerDecorations:T}=k,I=e(N,n,E,M,T);if(!I)return;const D=s.current,X=h.current,F=oa(I,X),ae=I.dom,ar=new pp(D,X,E,N,M,T,w,F,ae,I);return l(w),d(F),c(ae),ar},[r,s,e,n]),b=m.useCallback(k=>{if(!(n instanceof xt))return!1;const w=f.current;if(!w)return!1;const N=r.current;if(!N||N!==w.dom||oa(w,w.children)!==w.contentDOM||!N.contains(w.nodeDOM))return!1;const{node:M,decorations:T,innerDecorations:I}=k;return w.matchesNode(M,T,I)||w.update(M,T,I,n)},[r,n]),y=m.useCallback(()=>{const k=f.current;if(!k)return;k.destroy();const w=o.current;if(w.includes(k)){const N=w.indexOf(k);w.splice(N,1)}l(null),d(null),c(null)},[o]);return ne(()=>{var M;b(t)||(y(),f.current=p(t));const k=f.current;if(!k)return;n.dom===k.dom&&n instanceof xt&&(n.docView=k);const w=s.current,N=o.current,E=h.current;k.parent=w,N.includes(k)||N.push(k),N.sort(wt);for(const T of E)if(T.parent=k,T instanceof Ds){const I=(M=k==null?void 0:k.contentDOM)==null?void 0:M.firstChild;if(!I)throw new Error("Started a composition but couldn't find the text node it belongs to.");let D=I;for(;D.firstChild;)D=D.firstChild;if(!D||!(D instanceof Text))throw new Error("Started a composition but couldn't find the text node it belongs to.");T.dom=I,T.textDOM=D,T.text=D.data,T.textDOM.pmViewDesc=T,n.input.compositionNodes.push(T)}}),ne(()=>()=>{y(),f.current=void 0},[y]),{childContextValue:m.useMemo(()=>({parentRef:f,siblingsRef:h}),[h,f]),dom:i,contentDOM:u,nodeDOM:a,ref:r}}function gp(r,e){return r.type.side-e.type.side}function yp(r,e,t,n){const s=e.locals(r);let o=0;if(s.length==0){for(let c=0;c<r.childCount;c++){const u=r.child(c);n(u,s,e.forChild(o,u),o,c),o+=u.nodeSize}return}let i=0;const l=[];let a=null;for(let c=0;;){if(i<s.length&&s[i].to==o){let p,b;for(;i<s.length&&s[i].to==o;){const y=s[i++];(y.widget||y.type instanceof $t)&&(p?(b||(b=[p])).push(y):p=y)}if(p)if(b){b.sort(gp);for(let y=0;y<b.length;y++)t(b[y],!(b[y].type instanceof $t),o,c+y,!!a)}else t(p,!(p.type instanceof $t),o,c,!!a)}let u,d;if(a)d=-1,u=a,a=null;else if(c<r.childCount)d=c,u=r.child(c++);else break;for(let p=0;p<l.length;p++)l[p].to<=o&&l.splice(p--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)l.push(s[i++]);let f=o+u.nodeSize;if(u.isText){let p=f;i<s.length&&s[i].from<p&&(p=s[i].from);for(let b=0;b<l.length;b++)l[b].to<p&&(p=l[b].to);p<f&&(a=u.cut(p-o),u=u.cut(0,p-o),f=p,d=-1)}const h=u.isInline&&!u.isLeaf?l.filter(p=>!p.inline):l.slice();n(u,h,e.forChild(o,u),o,d),o=f}}function ia(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const la=new Ye("@handlewithcare/react-prosemirror/reactKeys");function bp(){let r=!1;return new Ee({key:la,state:{init(e,t){const n={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((s,o)=>{const i=ia();return n.posToKey.set(o,i),n.keyToPos.set(i,o),!0}),n},apply(e,t,n,s){if(!e.docChanged||r)return t;const o={posToKey:new Map,keyToPos:new Map},i=Array.from(t.posToKey.entries()).sort((l,a)=>{let[c]=l,[u]=a;return c-u});for(const[l,a]of i){const{pos:c,deleted:u}=e.mapping.mapResult(l);u||(o.posToKey.set(c,a),o.keyToPos.set(a,c))}return s.doc.descendants((l,a)=>{if(o.posToKey.has(a))return!0;const c=ia();return o.posToKey.set(a,c),o.keyToPos.set(c,a),!0}),o}},props:{handleDOMEvents:{compositionstart:()=>{r=!0},compositionend:()=>{r=!1}}}})}function xp(){const{view:r}=m.useContext(Lt);return la.getState(r.state)}var aa={exports:{}};/*!
|
|
31
|
+
`);return{dom:a,text:f,slice:e}}function Hi(r,e,t,n,s){let o=s.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(n||o||!t);if(a){if(r.someProp("transformPastedText",f=>{e=f(e,o||n,r)}),o)return e?new E(S.from(r.state.schema.text(e.replace(/\r\n?/g,`
|
|
32
|
+
`))),0,0):E.empty;let d=r.someProp("clipboardTextParser",f=>f(e,s,n,r));if(d)l=d;else{let f=s.marks(),{schema:h}=r.state,p=ze.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let y=i.appendChild(document.createElement("p"));b&&y.appendChild(p.serializeNode(h.text(b,f)))})}}else r.someProp("transformPastedHTML",d=>{t=d(t,r)}),i=kd(t),on&&wd(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||In.fromSchema(r.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!yd.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Sd(Xi(l,+u[1],+u[2]),u[4]);else if(l=E.maxOpen(bd(l.content,s),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Xi(l,d,f)}return r.someProp("transformPasted",d=>{l=d(l,r)}),l}const yd=/^(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 bd(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),o,i=[];if(r.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&o.length&&Yi(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=Gi(i[i.length-1],o.length));let u=Ki(l,a);i.push(u),s=s.matchType(u.type),o=a}}),i)return S.from(i)}return r}function Ki(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,S.from(r));return r}function Yi(r,e,t,n,s){if(s<r.length&&s<e.length&&r[s]==e[s]){let o=Yi(r,e,t,n.lastChild,s+1);if(o)return n.copy(n.content.replaceChild(n.childCount-1,o));if(n.contentMatchAt(n.childCount).matchType(s==r.length-1?t.type:r[s+1]))return n.copy(n.content.append(S.from(Ki(t,r,s+1))))}}function Gi(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,Gi(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(S.empty,!0);return r.copy(t.append(n))}function Zr(r,e,t,n,s,o){let i=e<0?r.firstChild:r.lastChild,l=i.content;return r.childCount>1&&(o=0),s<n-1&&(l=Zr(l,e,t,n,s+1,o)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(S.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,i.copy(l))}function Xi(r,e,t){return e<r.openStart&&(r=new E(Zr(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new E(Zr(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const Qi={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 Ui=null;function Zi(){return Ui||(Ui=document.implementation.createHTMLDocument("title"))}let es=null;function xd(r){let e=window.trustedTypes;return e?(es||(es=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),es.createHTML(r)):r}function kd(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=Zi().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),s;if((s=n&&Qi[n[1].toLowerCase()])&&(r=s.map(o=>"<"+o+">").join("")+r+s.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=xd(r),s)for(let o=0;o<s.length;o++)t=t.querySelector(s[o])||t;return t}function wd(r){let e=r.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function Sd(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:s,openStart:o,openEnd:i}=r;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;s=S.from(a.create(n[l+1],s)),o++,i++}return new E(s,o,i)}const ue={},de={},Cd={touchstart:!0,touchmove:!0};class Md{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function vd(r){for(let e in ue){let t=ue[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Ed(r,n)&&!ns(r,n)&&(r.editable||!(n.type in de))&&t(r,n)},Cd[e]?{passive:!0}:void 0)}ce&&r.dom.addEventListener("input",()=>null),ts(r)}function tt(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Nd(r){r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function ts(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>ns(r,n))})}function ns(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Ed(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Od(r,e){!ns(r,e)&&ue[e.type]&&(r.editable||!(e.type in de))&&ue[e.type](r,e)}de.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!tl(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(Fe&&ie&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),It&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",s=>s(r,ht(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||gd(r,t)?t.preventDefault():tt(r,"key")},de.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)},de.keypress=(r,e)=>{let t=e;if(tl(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||xe&&t.metaKey)return;if(r.someProp("handleKeyPress",s=>s(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof V)||!n.$from.sameParent(n.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!r.someProp("handleTextInput",o=>o(r,n.$from.pos,n.$to.pos,s))&&r.dispatch(r.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function Yn(r){return{left:r.clientX,top:r.clientY}}function Dd(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function rs(r,e,t,n,s){if(n==-1)return!1;let o=r.state.doc.resolve(n);for(let i=o.depth+1;i>0;i--)if(r.someProp(e,l=>i>o.depth?l(r,t,o.nodeAfter,o.before(i),s,!0):l(r,t,o.node(i),o.before(i),s,!1)))return!0;return!1}function jt(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function Td(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&A.isSelectable(n)?(jt(r,new A(t)),!0):!1}function Ad(r,e){if(e==-1)return!1;let t=r.state.selection,n,s;t instanceof A&&(n=t.node);let o=r.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let l=i>o.depth?o.nodeAfter:o.node(i);if(A.isSelectable(l)){n&&t.$from.depth>0&&i>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?s=o.before(t.$from.depth):s=o.before(i);break}}return s!=null?(jt(r,A.create(r.state.doc,s)),!0):!1}function Pd(r,e,t,n,s){return rs(r,"handleClickOn",e,t,n)||r.someProp("handleClick",o=>o(r,e,n))||(s?Ad(r,t):Td(r,t))}function Id(r,e,t,n){return rs(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",s=>s(r,e,n))}function Vd(r,e,t,n){return rs(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",s=>s(r,e,n))||Rd(r,t,n)}function Rd(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(jt(r,V.create(n,0,n.content.size)),!0):!1;let s=n.resolve(e);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),l=s.before(o);if(i.inlineContent)jt(r,V.create(n,l+1,l+1+i.content.size));else if(A.isSelectable(i))jt(r,A.create(n,l));else continue;return!0}}function ss(r){return Gn(r)}const el=xe?"metaKey":"ctrlKey";ue.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=ss(r),s=Date.now(),o="singleClick";s-r.input.lastClick.time<500&&Dd(t,r.input.lastClick)&&!t[el]&&(r.input.lastClick.type=="singleClick"?o="doubleClick":r.input.lastClick.type=="doubleClick"&&(o="tripleClick")),r.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:o};let i=r.posAtCoords(Yn(t));i&&(o=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new zd(r,i,t,!!n)):(o=="doubleClick"?Id:Vd)(r,i.pos,i.inside,t)?t.preventDefault():tt(r,"pointer"))};class zd{constructor(e,t,n,s){this.view=e,this.pos=t,this.event=n,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[el],this.allowDefault=n.shiftKey;let o,i;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,i=u.depth?u.before():0}const l=s?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof A&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ve&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),tt(e,"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(()=>$e(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Yn(e))),this.updateAllowDefault(e),this.allowDefault||!t?tt(this.view,"pointer"):Pd(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ce&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!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)?(jt(this.view,P.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):tt(this.view,"pointer")}move(e){this.updateAllowDefault(e),tt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ue.touchstart=r=>{r.input.lastTouch=Date.now(),ss(r),tt(r,"pointer")},ue.touchmove=r=>{r.input.lastTouch=Date.now(),tt(r,"pointer")},ue.contextmenu=r=>ss(r);function tl(r,e){return r.composing?!0:ce&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const jd=Fe?5e3:-1;de.compositionstart=de.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof V&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))r.markCursor=r.state.storedMarks||t.marks(),Gn(r,!0),r.markCursor=null;else if(Gn(r,!e.selection.empty),ve&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let s=n.focusNode,o=n.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let l=r.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}r.input.composing=!0}nl(r,jd)},de.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,nl(r,20))};function nl(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>Gn(r),e))}function rl(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Fd());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function Bd(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=Tu(e.focusNode,e.focusOffset),n=Au(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let s=n.pmViewDesc,o=r.domObserver.lastChangedTextNode;if(t==o||n==o)return o;if(!s||!s.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return n}}return t||n}function Fd(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function Gn(r,e=!1){if(!(Fe&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),rl(r),e||r.docView&&r.docView.dirty){let t=Kr(r);return t&&!t.eq(r.state.selection)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!r.state.selection.empty?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function Ld(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),s=document.createRange();s.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}const dn=he&&Ue<15||It&&zu<604;ue.copy=de.cut=(r,e)=>{let t=e,n=r.state.selection,s=t.type=="cut";if(n.empty)return;let o=dn?null:t.clipboardData,i=n.content(),{dom:l,text:a}=Ur(r,i);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Ld(r,l),s&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $d(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function Wd(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let s=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?fn(r,n.value,null,s,e):fn(r,n.textContent,n.innerHTML,s,e)},50)}function fn(r,e,t,n,s){let o=Hi(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,s,o||E.empty)))return!0;if(!o)return!1;let i=$d(o),l=i?r.state.tr.replaceSelectionWith(i,n):r.state.tr.replaceSelection(o);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function sl(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}de.paste=(r,e)=>{let t=e;if(r.composing&&!Fe)return;let n=dn?null:t.clipboardData,s=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&fn(r,sl(n),n.getData("text/html"),s,t)?t.preventDefault():Wd(r,t)};class ol{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const _d=xe?"altKey":"ctrlKey";function il(r,e){let t=r.someProp("dragCopies",n=>!n(e));return t??!e[_d]}ue.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let s=r.state.selection,o=s.empty?null:r.posAtCoords(Yn(t)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof A?s.to-1:s.to))){if(n&&n.mightDrag)i=A.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=r.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=r.docView&&(i=A.create(r.state.doc,d.posBefore))}}let l=(i||r.state.selection).content(),{dom:a,text:c,slice:u}=Ur(r,l);(!t.dataTransfer.files.length||!ie||di>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(dn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",dn||t.dataTransfer.setData("text/plain",c),r.dragging=new ol(u,il(r,t),i)},ue.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)},de.dragover=de.dragenter=(r,e)=>e.preventDefault(),de.drop=(r,e)=>{let t=e,n=r.dragging;if(r.dragging=null,!t.dataTransfer)return;let s=r.posAtCoords(Yn(t));if(!s)return;let o=r.state.doc.resolve(s.pos),i=n&&n.slice;i?r.someProp("transformPasted",p=>{i=p(i,r)}):i=Hi(r,sl(t.dataTransfer),dn?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(n&&il(r,t));if(r.someProp("handleDrop",p=>p(r,t,i||E.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?Po(r.state.doc,o.pos,i):o.pos;a==null&&(a=o.pos);let c=r.state.tr;if(l){let{node:p}=n;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&A.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new A(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,y,x,k)=>p=k),c.setSelection(Gr(r,h,c.doc.resolve(p)))}r.focus(),r.dispatch(c.setMeta("uiEvent","drop"))},ue.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&$e(r)},20))},ue.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)},ue.beforeinput=(r,e)=>{if(ie&&Fe&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",o=>o(r,ht(8,"Backspace")))))return;let{$cursor:s}=r.state.selection;s&&s.pos>0&&r.dispatch(r.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let r in de)ue[r]=de[r];function hn(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}class Xn{constructor(e,t){this.toDOM=e,this.spec=t||gt,this.side=this.spec.side||0}map(e,t,n,s){let{pos:o,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new te(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Xn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&hn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class nt{constructor(e,t){this.attrs=e,this.spec=t||gt}map(e,t,n,s){let o=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new te(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof nt&&hn(this.attrs,e.attrs)&&hn(this.spec,e.spec)}static is(e){return e.type instanceof nt}destroy(){}}class is{constructor(e,t){this.attrs=e,this.spec=t||gt}map(e,t,n,s){let o=e.mapResult(t.from+s,1);if(o.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=o.pos?null:new te(o.pos-n,i.pos-n,this)}valid(e,t){let{index:n,offset:s}=e.content.findIndex(t.from),o;return s==t.from&&!(o=e.child(n)).isText&&s+o.nodeSize==t.to}eq(e){return this==e||e instanceof is&&hn(this.attrs,e.attrs)&&hn(this.spec,e.spec)}destroy(){}}class te{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new te(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new te(e,e,new Xn(t,n))}static inline(e,t,n,s){return new te(e,t,new nt(n,s))}static node(e,t,n,s){return new te(e,t,new is(n,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof nt}get widget(){return this.type instanceof Xn}}const Bt=[],gt={};class j{constructor(e,t){this.local=e.length?e:Bt,this.children=t.length?t:Bt}static create(e,t){return t.length?Qn(t,e,0,gt):le}find(e,t,n){let s=[];return this.findInner(e??0,t??1e9,s,0,n),s}findInner(e,t,n,s,o){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&n.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,n,s+l,o)}}map(e,t,n){return this==le||e.maps.length==0?this:this.mapInner(e,t,0,0,n||gt)}mapInner(e,t,n,s,o){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,n,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?qd(this.children,i||[],e,t,n,s,o):i?new j(i.sort(yt),Bt):le}add(e,t){return t.length?this==le?j.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let s,o=0;e.forEach((l,a)=>{let c=a+n,u;if(u=cl(t,l,c)){for(s||(s=this.children.slice());o<s.length&&s[o]<a;)o+=3;s[o]==a?s[o+2]=s[o+2].addInner(l,u,c+1):s.splice(o,0,a,a+l.nodeSize,Qn(u,l,c+1,gt)),o+=3}});let i=al(o?ul(t):t,-n);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new j(i.length?this.local.concat(i).sort(yt):this.local,s||this.children)}remove(e){return e.length==0||this==le?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,s=this.local;for(let o=0;o<n.length;o+=3){let i,l=n[o]+t,a=n[o+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;n==this.children&&(n=this.children.slice());let c=n[o+2].removeInner(i,l+1);c!=le?n[o+2]=c:(n.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<e.length;o++)if(i=e[o])for(let l=0;l<s.length;l++)s[l].eq(i,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return n==this.children&&s==this.local?this:s.length||n.length?new j(s,n):le}forChild(e,t){if(this==le)return this;if(t.isLeaf)return j.empty;let n,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let o=e+1,i=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>o&&a.type instanceof nt){let c=Math.max(o,a.from)-o,u=Math.min(i,a.to)-o;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new j(s.sort(yt),Bt);return n?new ll([l,n]):l}return n||le}eq(e){if(this==e)return!0;if(!(e instanceof j)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return ls(this.localsInner(e))}localsInner(e){if(this==le)return Bt;if(e.inlineContent||!this.local.some(nt.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof nt||t.push(this.local[n]);return t}forEachSet(e){e(this)}}j.empty=new j([],[]),j.removeOverlap=ls;const le=j.empty;let ll=class Jt{constructor(e){this.members=e}map(e,t){const n=this.members.map(s=>s.map(e,t,gt));return Jt.from(n)}forChild(e,t){if(t.isLeaf)return j.empty;let n=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,t);o!=le&&(o instanceof Jt?n=n.concat(o.members):n.push(o))}return Jt.from(n)}eq(e){if(!(e instanceof Jt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!t)t=o;else{n&&(t=t.slice(),n=!1);for(let i=0;i<o.length;i++)t.push(o[i])}}return t?ls(n?t:t.sort(yt)):Bt}static from(e){switch(e.length){case 0:return le;case 1:return e[0];default:return new Jt(e.every(t=>t instanceof j)?e:e.reduce((t,n)=>t.concat(n instanceof j?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function qd(r,e,t,n,s,o,i){let l=r.slice();for(let c=0,u=o;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,h,p,b)=>{let y=b-p-(h-f);for(let x=0;x<l.length;x+=3){let k=l[x+1];if(k<0||f>k+u-d)continue;let w=l[x]+u-d;h>=w?l[x+1]=f<=w?-2:-1:f>=u&&y&&(l[x]+=y,l[x+1]+=y)}d+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(r[c]+o),d=u-s;if(d<0||d>=n.content.size){a=!0;continue}let f=t.map(r[c+1]+o,-1),h=f-s,{index:p,offset:b}=n.content.findIndex(d),y=n.maybeChild(p);if(y&&b==d&&b+y.nodeSize==h){let x=l[c+2].mapInner(t,y,u+1,r[c]+o+1,i);x!=le?(l[c]=d,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Jd(l,r,e,t,s,o,i),u=Qn(c,n,0,i);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new j(e.sort(yt),l)}function al(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let s=r[n];t.push(new te(s.from+e,s.to+e,s.type))}return t}function Jd(r,e,t,n,s,o,i){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(n,s,c);d?t.push(d):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<r.length;a+=3)r[a+1]==-1&&l(r[a+2],e[a]+o+1);return t}function cl(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,s=null;for(let o=0,i;o<r.length;o++)(i=r[o])&&i.from>t&&i.to<n&&((s||(s=[])).push(i),r[o]=null);return s}function ul(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function Qn(r,e,t,n){let s=[],o=!1;e.forEach((l,a)=>{let c=cl(r,l,a+t);if(c){o=!0;let u=Qn(c,l,t+a+1,n);u!=le&&s.push(a,a+l.nodeSize,u)}});let i=al(o?ul(r):r,-t).sort(yt);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(n.onRemove&&n.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new j(i,s):le}function yt(r,e){return r.from-e.from||r.to-e.to}function ls(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let s=t+1;s<e.length;s++){let o=e[s];if(o.from==n.from){o.to!=n.to&&(e==r&&(e=r.slice()),e[s]=o.copy(o.from,n.to),dl(e,s+1,o.copy(n.to,o.to)));continue}else{o.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,o.from),dl(e,s,n.copy(o.from,n.to)));break}}}return e}function dl(r,e,t){for(;e<r.length&&yt(t,r[e])>0;)e++;r.splice(e,0,t)}function as(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=le&&e.push(n)}),r.cursorWrapper&&e.push(j.create(r.state.doc,[r.cursorWrapper.deco])),ll.from(e)}const Hd={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Kd=he&&Ue<=11;class Yd{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Gd{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Yd,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let s=0;s<n.length;s++)this.queue.push(n[s]);he&&Ue<=11&&n.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),Kd&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Hd)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Bi(this.view)){if(this.suppressingSelectionUpdates)return $e(this.view);if(he&&Ue<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ft(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let o=e.focusNode;o;o=Pt(o))t.add(o);for(let o=e.anchorNode;o;o=Pt(o))if(t.has(o)){n=o;break}let s=n&&this.view.docView.nearestDesc(n);if(s&&s.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Bi(e)&&!this.ignoreSelectionChange(n),o=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],a);d&&(o=o<0?d.from:Math.min(d.from,o),i=i<0?d.to:Math.max(d.to,i),d.typeOver&&(l=!0))}if(ve&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||Ud(e,d)!=h)&&f.remove()}}}let c=null;o<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&qn(n)&&(c=Kr(e))&&c.eq(P.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,$e(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),Xd(e)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||$e(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let s=e.previousSibling,o=e.nextSibling;if(he&&Ue<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f)}let i=s&&s.parentNode==e.target?ee(s)+1:0,l=n.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?ee(o):e.target.childNodes.length,c=n.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let fl=new WeakMap,hl=!1;function Xd(r){if(!fl.has(r)&&(fl.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=ve,hl)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),hl=!0}}function pl(r,e){let t=e.startContainer,n=e.startOffset,s=e.endContainer,o=e.endOffset,i=r.domAtPos(r.state.selection.anchor);return ft(i.node,i.offset,s,o)&&([t,n,s,o]=[s,o,t,n]),{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:o}}function Qd(r,e){if(e.getComposedRanges){let s=e.getComposedRanges(r.root)[0];if(s)return pl(r,s)}let t;function n(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?pl(r,t):null}function Ud(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function Zd(r,e,t){let{node:n,fromOffset:s,toOffset:o,from:i,to:l}=r.docView.parseRange(e,t),a=r.domSelectionRange(),c,u=a.anchorNode;if(u&&r.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],qn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&r.input.lastKeyCode===8)for(let y=o;y>s;y--){let x=n.childNodes[y-1],k=x.pmViewDesc;if(x.nodeName=="BR"&&!k){o=y;break}if(!k||k.size)break}let d=r.state.doc,f=r.someProp("domParser")||In.fromSchema(r.state.schema),h=d.resolve(i),p=null,b=f.parse(n,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:o,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:ef,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=y),p={anchor:y+i,head:x+i}}return{doc:b,sel:p,from:i,to:l}}function ef(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(ce&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(r.parentNode.lastChild==r||ce&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}const tf=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function nf(r,e,t,n,s){let o=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let D=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,X=Kr(r,D);if(X&&!r.state.selection.eq(X)){if(ie&&Fe&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",ae=>ae(r,ht(13,"Enter"))))return;let F=r.state.tr.setSelection(X);D=="pointer"?F.setMeta("pointer",!0):D=="key"&&F.scrollIntoView(),o&&F.setMeta("composition",o),r.dispatch(F)}return}let i=r.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,c=Zd(r,e,t),u=r.state.doc,d=u.slice(c.from,c.to),f,h;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(f=r.state.selection.to,h="end"):(f=r.state.selection.from,h="start"),r.input.lastKeyCode=null;let p=of(d.content,c.doc.content,c.from,f,h);if(p&&r.input.domChangeCount++,(It&&r.input.lastIOSEnter>Date.now()-225||Fe)&&s.some(D=>D.nodeType==1&&!tf.test(D.nodeName))&&(!p||p.endA>=p.endB)&&r.someProp("handleKeyDown",D=>D(r,ht(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!p)if(n&&a instanceof V&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let D=ml(r,r.state.doc,c.sel);if(D&&!D.eq(r.state.selection)){let X=r.state.tr.setSelection(D);o&&X.setMeta("composition",o),r.dispatch(X)}}return}r.state.selection.from<r.state.selection.to&&p.start==p.endB&&r.state.selection instanceof V&&(p.start>r.state.selection.from&&p.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?p.start=r.state.selection.from:p.endA<r.state.selection.to&&p.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(p.endB+=r.state.selection.to-p.endA,p.endA=r.state.selection.to)),he&&Ue<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let b=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),x=u.resolve(p.start),k=b.sameParent(y)&&b.parent.inlineContent&&x.end()>=p.endA,w;if((It&&r.input.lastIOSEnter>Date.now()-225&&(!k||s.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!k&&b.pos<c.doc.content.size&&(!b.sameParent(y)||!b.parent.inlineContent)&&!/\S/.test(c.doc.textBetween(b.pos,y.pos,"",""))&&(w=P.findFrom(c.doc.resolve(b.pos+1),1,!0))&&w.head>b.pos)&&r.someProp("handleKeyDown",D=>D(r,ht(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>p.start&&sf(u,p.start,p.endA,b,y)&&r.someProp("handleKeyDown",D=>D(r,ht(8,"Backspace")))){Fe&&ie&&r.domObserver.suppressSelectionUpdates();return}ie&&p.endB==p.start&&(r.input.lastChromeDelete=Date.now()),Fe&&!k&&b.start()!=y.start()&&y.parentOffset==0&&b.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(D){return D(r,ht(13,"Enter"))})},20));let N=p.start,O=p.endA,M,T,I;if(k){if(b.pos==y.pos)he&&Ue<=11&&b.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>$e(r),20)),M=r.state.tr.delete(N,O),T=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&(I=rf(b.parent.content.cut(b.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start()))))M=r.state.tr,I.type=="add"?M.addMark(N,O,I.mark):M.removeMark(N,O,I.mark);else if(b.parent.child(b.index()).isText&&b.index()==y.index()-(y.textOffset?0:1)){let D=b.parent.textBetween(b.parentOffset,y.parentOffset);if(r.someProp("handleTextInput",X=>X(r,N,O,D)))return;M=r.state.tr.insertText(D,N,O)}}if(M||(M=r.state.tr.replace(N,O,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let D=ml(r,M.doc,c.sel);D&&!(ie&&r.composing&&D.empty&&(p.start!=p.endB||r.input.lastChromeDelete<Date.now()-100)&&(D.head==N||D.head==M.mapping.map(O)-1)||he&&D.empty&&D.head==N)&&M.setSelection(D)}T&&M.ensureMarks(T),o&&M.setMeta("composition",o),r.dispatch(M.scrollIntoView())}function ml(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Gr(r,e.resolve(t.anchor),e.resolve(t.head))}function rf(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,s=t,o=n,i,l,a;for(let u=0;u<n.length;u++)s=n[u].removeFromSet(s);for(let u=0;u<t.length;u++)o=t[u].removeFromSet(o);if(s.length==1&&o.length==0)l=s[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&o.length==1)l=o[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(S.from(c).eq(r))return{mark:l,type:i}}function sf(r,e,t,n,s){if(t-e<=s.pos-n.pos||cs(n,!0,!1)<s.pos)return!1;let o=r.resolve(e);if(!n.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=r.resolve(cs(o,!0,!0));return!i.parent.isTextblock||i.pos>t||cs(i,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(i.parent.content)}function cs(r,e,t){let n=r.depth,s=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,s++,e=!1;if(t){let o=r.node(n).maybeChild(r.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function of(r,e,t,n,s){let o=r.findDiffStart(e,t);if(o==null)return null;let{a:i,b:l}=r.findDiffEnd(e,t+r.size,t+e.size);if(s=="end"){let a=Math.max(0,o-Math.min(i,l));n-=i+a-o}if(i<o&&r.size<e.size){let a=n<=o&&n>=i?o-n:0;o-=a,o&&o<e.size&&gl(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-i),i=o}else if(l<o){let a=n<=o&&n>=l?o-n:0;o-=a,o&&o<r.size&&gl(r.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function gl(r){if(r.length!=2)return!1;let e=r.charCodeAt(0),t=r.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class lf{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Md,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(wl),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=xl(this),bl(this),this.nodeViews=kl(this),this.docView=vi(this.state.doc,yl(this),as(this),this.dom,this),this.domObserver=new Gd(this,(n,s,o,i)=>nf(this,n,s,o,i)),this.domObserver.start(),vd(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ts(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(wl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(rl(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=kl(this);cf(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ts(this),this.editable=xl(this),bl(this);let a=as(this),c=yl(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(i=!0);let f=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Fu(this);if(i){this.domObserver.stop();let h=d&&(he||ie)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&af(s.selection,e.selection);if(d){let p=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Bd(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=vi(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cd(this))?$e(this,h):(zi(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((n=this.dragging)===null||n===void 0)&&n.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Lu(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof A){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&fi(this,t.getBoundingClientRect(),e)}else fi(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,s=-1;if(this.state.doc.nodeAt(n.from)==n.node)s=n.from;else{let o=n.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==n.node&&(s=o)}this.dragging=new ol(e.slice,e.move,s<0?void 0:A.create(this.state.doc,s))}someProp(e,t){let n=this._props&&this._props[e],s;if(n!=null&&(s=t?t(n):n))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let o=this.state.plugins;if(o)for(let i=0;i<o.length;i++){let l=o[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(he){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&$u(this.dom),$e(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Hu(this,e)}coordsAtPos(e,t=1){return bi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let s=this.docView.posFromDOM(e,t,n);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return Qu(this,t||this.state,e)}pasteHTML(e,t){return fn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return fn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ur(this,e)}destroy(){this.docView&&(Nd(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],as(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ou())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Od(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ce&&this.root.nodeType===11&&Iu(this.dom.ownerDocument)==this.dom&&Qd(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function yl(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[te.node(0,r.state.doc.content.size,e)]}function bl(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:te.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function xl(r){return!r.someProp("editable",e=>e(r.state)===!1)}function af(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function kl(r){let e=Object.create(null);function t(n){for(let s in n)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=n[s])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function cf(r,e){let t=0,n=0;for(let s in r){if(r[s]!=e[s])return!0;t++}for(let s in e)n++;return t!=n}function wl(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class $ extends P{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return $.valid(n)?new $(n):P.near(n)}content(){return E.empty}eq(e){return e instanceof $&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new $(e.resolve(t.pos))}getBookmark(){return new us(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!uf(e)||!df(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&$.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if($.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!A.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),n=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if($.valid(l))return l}return null}}}$.prototype.visible=!1,$.findFrom=$.findGapCursorFrom,P.jsonID("gapcursor",$);class us{constructor(e){this.pos=e}map(e){return new us(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return $.valid(t)?new $(t):P.near(t)}}function uf(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let s=n.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function df(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let s=n.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function ff(){return new Oe({props:{decorations:gf,createSelectionBetween(r,e,t){return e.pos==t.pos&&$.valid(t)?new $(t):null},handleClick:pf,handleKeyDown:hf,handleDOMEvents:{beforeinput:mf}}})}const hf=Ar({ArrowLeft:Un("horiz",-1),ArrowRight:Un("horiz",1),ArrowUp:Un("vert",-1),ArrowDown:Un("vert",1)});function Un(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,s,o){let i=n.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof V){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let c=$.findGapCursorFrom(l,e,a);return c?(s&&s(n.tr.setSelection(new $(c))),!0):!1}}function pf(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!$.valid(n))return!1;let s=r.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&A.isSelectable(r.state.doc.nodeAt(s.inside))?!1:(r.dispatch(r.state.tr.setSelection(new $(n))),!0)}function mf(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof $))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let s=S.empty;for(let i=n.length-1;i>=0;i--)s=S.from(n[i].createAndFill(null,s));let o=r.state.tr.replace(t.pos,t.pos,new E(s,0,0));return o.setSelection(V.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function gf(r){if(!(r.selection instanceof $))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",j.create(r.doc,[te.widget(r.selection.head,e,{key:"gapcursor"})])}const yf=["ol",0],bf=["ul",0],xf=["li",0],kf={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(r){return{order:r.hasAttribute("start")?+r.getAttribute("start"):1}}}],toDOM(r){return r.attrs.order==1?yf:["ol",{start:r.attrs.order},0]}},wf={parseDOM:[{tag:"ul"}],toDOM(){return bf}},Sf={parseDOM:[{tag:"li"}],toDOM(){return xf},defining:!0};function ds(r,e){let t={};for(let n in r)t[n]=r[n];for(let n in e)t[n]=e[n];return t}function Cf(r,e,t){return r.append({ordered_list:ds(kf,{content:"list_item+",group:t}),bullet_list:ds(wf,{content:"list_item+",group:t}),list_item:ds(Sf,{content:e})})}function Zn(r,e=null){return function(t,n){let{$from:s,$to:o}=t.selection,i=s.blockRange(o);if(!i)return!1;let l=n?t.tr:null;return Mf(l,i,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function Mf(r,e,t,n=null){let s=!1,o=e,i=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=i.resolve(e.start-2);o=new Dn(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Dn(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=kr(o,t,n,e);return l?(r&&vf(r,e,l,s,t),!0):!1}function vf(r,e,t,n,s){let o=S.empty;for(let u=t.length-1;u>=0;u--)o=S.from(t[u].type.create(t[u].attrs,o));r.step(new U(e.start-(n?2:0),e.end,e.start,e.end,new E(o,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==s&&(i=u+1);let l=t.length-i,a=e.start+t.length-(n?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&vt(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return r}function Nf(r,e){return function(t,n){let{$from:s,$to:o,node:i}=t.selection;if(i&&i.isBlock||s.depth<2||!s.sameParent(o))return!1;let l=s.node(-1);if(l.type!=r)return!1;if(s.parent.content.size==0&&s.node(-1).childCount==s.indexAfter(-1)){if(s.depth==3||s.node(-3).type!=r||s.index(-2)!=s.node(-2).childCount-1)return!1;if(n){let d=S.empty,f=s.index(-1)?1:s.index(-2)?2:3;for(let x=s.depth-f;x>=s.depth-3;x--)d=S.from(s.node(x).copy(d));let h=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;d=d.append(S.from(r.createAndFill()));let p=s.before(s.depth-(f-1)),b=t.tr.replace(p,s.after(-h),new E(d,4-f,0)),y=-1;b.doc.nodesBetween(p,b.doc.content.size,(x,k)=>{if(y>-1)return!1;x.isTextblock&&x.content.size==0&&(y=k+1)}),y>-1&&b.setSelection(P.near(b.doc.resolve(y))),n(b.scrollIntoView())}return!0}let a=o.pos==s.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(s.pos,o.pos),u=a?[null,{type:a}]:void 0;return vt(c.doc,s.pos,2,u)?(n&&n(c.split(s.pos,2,u).scrollIntoView()),!0):!1}}function Ef(r){return function(e,t){let{$from:n,$to:s}=e.selection,o=n.blockRange(s,i=>i.childCount>0&&i.firstChild.type==r);return o?t?n.node(o.depth-1).type==r?Of(e,t,r,o):Df(e,t,o):!0:!1}}function Of(r,e,t,n){let s=r.tr,o=n.end,i=n.$to.end(n.depth);o<i&&(s.step(new U(o-1,i,o,i,new E(S.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new Dn(s.doc.resolve(n.$from.pos),s.doc.resolve(i),n.depth));const l=Zt(n);if(l==null)return!1;s.lift(n,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return Nt(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function Df(r,e,t){let n=r.tr,s=t.parent;for(let h=t.end,p=t.endIndex-1,b=t.startIndex;p>b;p--)h-=s.child(p).nodeSize,n.delete(h-1,h+1);let o=n.doc.resolve(t.start),i=o.nodeAfter;if(n.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?S.empty:S.from(s))))return!1;let d=o.pos,f=d+i.nodeSize;return n.step(new U(d-(l?1:0),f+(a?1:0),d+1,f-1,new E((l?S.empty:S.from(s.copy(S.empty))).append(a?S.empty:S.from(s.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function Tf(r){return function(e,t){let{$from:n,$to:s}=e.selection,o=n.blockRange(s,c=>c.childCount>0&&c.firstChild.type==r);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let l=o.parent,a=l.child(i-1);if(a.type!=r)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=S.from(c?r.create():null),d=new E(S.from(r.create(null,S.from(l.type.create(null,u)))),c?3:1,0),f=o.start,h=o.end;t(e.tr.step(new U(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}class rt{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Af(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}}function Af(r){return function(e,t,n,s){let o=r;if(t[1]){let i=t[0].lastIndexOf(t[1]);o+=t[0].slice(i+t[1].length),n+=i;let l=n-s;l>0&&(o=t[0].slice(i-l,i)+o,n=s)}return e.tr.insertText(o,n,s)}}const Pf=500;function If({rules:r}){let e=new Oe({state:{init(){return null},apply(t,n){let s=t.getMeta(this);return s||(t.selectionSet||t.docChanged?null:n)}},props:{handleTextInput(t,n,s,o){return Sl(t,n,s,o,r,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:n}=t.state.selection;n&&Sl(t,n.pos,n.pos,"",r,e)})}}},isInputRules:!0});return e}function Sl(r,e,t,n,s,o){if(r.composing)return!1;let i=r.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Pf),l.parentOffset,null,"")+n;for(let c=0;c<s.length;c++){let u=s[c];if(!u.inCodeMark&&l.marks().some(h=>h.type.spec.code))continue;if(l.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let d=u.match.exec(a),f=d&&d[0].length>=n.length&&u.handler(i,d,e-(d[0].length-n.length),t);if(f)return u.undoable&&f.setMeta(o,{transform:f,from:e,to:t,text:n}),r.dispatch(f),!0}return!1}const Vf=(r,e)=>{let t=r.plugins;for(let n=0;n<t.length;n++){let s=t[n],o;if(s.spec.isInputRules&&(o=s.getState(r))){if(e){let i=r.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a--)i.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,r.schema.text(o.text,a))}else i.delete(o.from,o.to);e(i)}return!0}}return!1},Rf=new rt(/--$/,"—",{inCodeMark:!1}),zf=new rt(/\.\.\.$/,"…",{inCodeMark:!1}),jf=new rt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),Bf=new rt(/"$/,"”",{inCodeMark:!1}),Ff=new rt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),Lf=new rt(/'$/,"’",{inCodeMark:!1}),$f=[jf,Bf,Ff,Lf];function fs(r,e,t=null,n){return new rt(r,(s,o,i,l)=>{let a=t instanceof Function?t(o):t,c=s.tr.delete(i,l),u=c.doc.resolve(i),d=u.blockRange(),f=d&&kr(d,e,a);if(!f)return null;c.wrap(d,f);let h=c.doc.resolve(i-1).nodeBefore;return h&&h.type==e&&Nt(c.doc,i-1)&&(!n||n(o,h))&&c.join(i-1),c})}function Cl(r,e,t=null){return new rt(r,(n,s,o,i)=>{let l=n.doc.resolve(o),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?n.tr.delete(o,i).setBlockType(o,o,e,a):null})}const Ml=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Wf(r,e){let t={},n;function s(o,i){t[o]=i}if(s("Mod-z",Vr),s("Shift-Mod-z",Wn),s("Backspace",Vf),Ml||s("Mod-y",Wn),s("Alt-ArrowUp",ti),s("Alt-ArrowDown",pu),s("Mod-BracketLeft",Rr),s("Escape",jr),(n=r.marks.strong)&&(s("Mod-b",ye(n)),s("Mod-B",ye(n))),(n=r.marks.em)&&(s("Mod-i",ye(n)),s("Mod-I",ye(n))),(n=r.marks.code)&&s("Mod-`",ye(n)),(n=r.nodes.bullet_list)&&s("Shift-Ctrl-8",Zn(n)),(n=r.nodes.ordered_list)&&s("Shift-Ctrl-9",Zn(n)),(n=r.nodes.blockquote)&&s("Ctrl->",oi(n)),n=r.nodes.hard_break){let o=n,i=_n(ni,(l,a)=>(a&&a(l.tr.replaceSelectionWith(o.create()).scrollIntoView()),!0));s("Mod-Enter",i),s("Shift-Enter",i),Ml&&s("Ctrl-Enter",i)}if((n=r.nodes.list_item)&&(s("Enter",Nf(n)),s("Mod-[",Ef(n)),s("Mod-]",Tf(n))),(n=r.nodes.paragraph)&&s("Shift-Ctrl-0",At(n)),(n=r.nodes.code_block)&&s("Shift-Ctrl-\\",At(n)),n=r.nodes.heading)for(let o=1;o<=6;o++)s("Shift-Ctrl-"+o,At(n,{level:o}));if(n=r.nodes.horizontal_rule){let o=n;s("Mod-_",(i,l)=>(l&&l(i.tr.replaceSelectionWith(o.create()).scrollIntoView()),!0))}return t}function _f(r){return fs(/^\s*>\s$/,r)}function qf(r){return fs(/^(\d+)\.\s$/,r,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Jf(r){return fs(/^\s*([-+*])\s$/,r)}function Hf(r){return Cl(/^```$/,r)}function Kf(r,e){return Cl(new RegExp("^(#{1,"+e+"})\\s$"),r,t=>({level:t[1].length}))}function Yf(r){let e=$f.concat(zf,Rf),t;return(t=r.nodes.blockquote)&&e.push(_f(t)),(t=r.nodes.ordered_list)&&e.push(qf(t)),(t=r.nodes.bullet_list)&&e.push(Jf(t)),(t=r.nodes.code_block)&&e.push(Hf(t)),(t=r.nodes.heading)&&e.push(Kf(t,6)),If({rules:e})}const We=new Ye("ImagePluginKey"),Gf=r=>new Oe({key:We,state:{init(){return{set:j.empty,schema:r.schema,upload:r.upload}},apply(t,n){let s=n.set.map(t.mapping,t.doc);const o=t.getMeta(We);if(o&&o.add){const i=document.createElement("placeholder"),l=te.widget(o.add.pos,i,{id:o.add.id,key:`imgphd${o.add.id}`});s=s.add(t.doc,[l])}else o&&o.remove&&(s=s.remove(s.find(void 0,void 0,i=>i.id==o.remove.id)));return{...n,set:s}}},props:{decorations(t){var n;return(n=this.getState(t))==null?void 0:n.set}}}),Xf=(r,e)=>{const t=We.getState(r).set,n=t==null?void 0:t.find(void 0,void 0,s=>s.id==e);return n!=null&&n.length?n[0].from:null},Qf=async(r,e,t,n)=>{if(!e)return;const s=Date.now(),o=r.state.tr;n===void 0&&(o.selection.empty||o.deleteSelection(),n=o.selection.from),o.setMeta(We,{add:{id:s,pos:n}}),r.dispatch(o);try{const i=We.getState(r.state),l=i.schema,a=i.upload;if(!a)throw new Error("uploadImage: Image upload function not defined");const c=await a(e);if(typeof c=="string")throw new Error(c);const u=Xf(r.state,s);if(u===null){console.warn("uploadImage: The image was removed from the document during upload");return}r.dispatch(r.state.tr.replaceWith(u,u,l.nodes.image.create({fid:c,title:t})).setMeta(We,{remove:{id:s}}))}catch(i){r.dispatch(r.state.tr.setMeta(We,{remove:{id:s}})),console.error(`uploadImage: ${i}`)}},Uf=(r,e,t,n)=>{if(!e)return;const s=r.state.tr;n===void 0&&(s.selection.empty||s.deleteSelection(),n=s.selection.from);const o=We.getState(r.state).schema;r.dispatch(r.state.tr.replaceWith(n,n,o.nodes.image.create({src:e,title:t})))};var hs,ps;if(typeof WeakMap<"u"){let r=new WeakMap;hs=e=>r.get(e),ps=(e,t)=>(r.set(e,t),t)}else{const r=[];let t=0;hs=n=>{for(let s=0;s<r.length;s+=2)if(r[s]==n)return r[s+1]},ps=(n,s)=>(t==10&&(t=0),r[t++]=n,r[t++]=s)}var G=class{constructor(r,e,t,n){this.width=r,this.height=e,this.map=t,this.problems=n}findCell(r){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=r)continue;const n=e%this.width,s=e/this.width|0;let o=n+1,i=s+1;for(let l=1;o<this.width&&this.map[e+l]==t;l++)o++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:n,top:s,right:o,bottom:i}}throw new RangeError(`No cell with offset ${r} found`)}colCount(r){for(let e=0;e<this.map.length;e++)if(this.map[e]==r)return e%this.width;throw new RangeError(`No cell with offset ${r} found`)}nextCell(r,e,t){const{left:n,right:s,top:o,bottom:i}=this.findCell(r);return e=="horiz"?(t<0?n==0:s==this.width)?null:this.map[o*this.width+(t<0?n-1:s)]:(t<0?o==0:i==this.height)?null:this.map[n+this.width*(t<0?o-1:i)]}rectBetween(r,e){const{left:t,right:n,top:s,bottom:o}=this.findCell(r),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(s,a),right:Math.max(n,l),bottom:Math.max(o,c)}}cellsInRect(r){const e=[],t={};for(let n=r.top;n<r.bottom;n++)for(let s=r.left;s<r.right;s++){const o=n*this.width+s,i=this.map[o];t[i]||(t[i]=!0,!(s==r.left&&s&&this.map[o-1]==i||n==r.top&&n&&this.map[o-this.width]==i)&&e.push(i))}return e}positionAt(r,e,t){for(let n=0,s=0;;n++){const o=s+t.child(n).nodeSize;if(n==r){let i=e+r*this.width;const l=(r+1)*this.width;for(;i<l&&this.map[i]<s;)i++;return i==l?o-1:this.map[i]}s=o}}static get(r){return hs(r)||ps(r,Zf(r))}};function Zf(r){if(r.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+r.type.name);const e=eh(r),t=r.childCount,n=[];let s=0,o=null;const i=[];for(let c=0,u=e*t;c<u;c++)n[c]=0;for(let c=0,u=0;c<t;c++){const d=r.child(c);u++;for(let p=0;;p++){for(;s<n.length&&n[s]!=0;)s++;if(p==d.childCount)break;const b=d.child(p),{colspan:y,rowspan:x,colwidth:k}=b.attrs;for(let w=0;w<x;w++){if(w+c>=t){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:x-w});break}const N=s+w*e;for(let O=0;O<y;O++){n[N+O]==0?n[N+O]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:y-O});const M=k&&k[O];if(M){const T=(N+O)%e*2,I=i[T];I==null||I!=M&&i[T+1]==1?(i[T]=M,i[T+1]=1):I==M&&i[T+1]++}}}s+=y,u+=b.nodeSize}const f=(c+1)*e;let h=0;for(;s<f;)n[s++]==0&&h++;h&&(o||(o=[])).push({type:"missing",row:c,n:h}),u++}(e===0||t===0)&&(o||(o=[])).push({type:"zero_sized"});const l=new G(e,t,n,o);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&th(l,i,r),l}function eh(r){let e=-1,t=!1;for(let n=0;n<r.childCount;n++){const s=r.child(n);let o=0;if(t)for(let i=0;i<n;i++){const l=r.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>n&&(o+=c.attrs.colspan)}}for(let i=0;i<s.childCount;i++){const l=s.child(i);o+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function th(r,e,t){r.problems||(r.problems=[]);const n={};for(let s=0;s<r.map.length;s++){const o=r.map[s];if(n[o])continue;n[o]=!0;const i=t.nodeAt(o);if(!i)throw new RangeError(`No cell with offset ${o} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const u=(s+c)%r.width,d=e[u*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=nh(a)))[c]=d)}l&&r.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:l})}}function nh(r){if(r.colwidth)return r.colwidth.slice();const e=[];for(let t=0;t<r.colspan;t++)e.push(0);return e}function vl(r,e){if(typeof r=="string")return{};const t=r.getAttribute("data-colwidth"),n=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,s=Number(r.getAttribute("colspan")||1),o={colspan:s,rowspan:Number(r.getAttribute("rowspan")||1),colwidth:n&&n.length==s?n:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(r);a!=null&&(o[i]=a)}return o}function Nl(r,e){const t={};r.attrs.colspan!=1&&(t.colspan=r.attrs.colspan),r.attrs.rowspan!=1&&(t.rowspan=r.attrs.rowspan),r.attrs.colwidth&&(t["data-colwidth"]=r.attrs.colwidth.join(","));for(const n in e){const s=e[n].setDOMAttr;s&&s(r.attrs[n],t)}return t}function rh(r){if(r!==null){if(!Array.isArray(r))throw new TypeError("colwidth must be null or an array");for(const e of r)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function sh(r){const e=r.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:rh}};for(const n in e)t[n]={default:e[n].default,validate:e[n].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:r.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:r.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:n=>vl(n,e)}],toDOM(n){return["td",Nl(n,e),0]}},table_header:{content:r.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:n=>vl(n,e)}],toDOM(n){return["th",Nl(n,e),0]}}}}function fe(r){let e=r.cached.tableNodeTypes;if(!e){e=r.cached.tableNodeTypes={};for(const t in r.nodes){const n=r.nodes[t],s=n.spec.tableRole;s&&(e[s]=n)}}return e}var st=new Ye("selectingCells");function pn(r){for(let e=r.depth-1;e>0;e--)if(r.node(e).type.spec.tableRole=="row")return r.node(0).resolve(r.before(e+1));return null}function oh(r){for(let e=r.depth;e>0;e--){const t=r.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return r.node(e)}return null}function we(r){const e=r.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function er(r){const e=r.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=pn(e.$head)||ih(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function ih(r){for(let e=r.nodeAfter,t=r.pos;e;e=e.firstChild,t++){const n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return r.doc.resolve(t)}for(let e=r.nodeBefore,t=r.pos;e;e=e.lastChild,t--){const n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return r.doc.resolve(t-e.nodeSize)}}function El(r){return r.parent.type.spec.tableRole=="row"&&!!r.nodeAfter}function lh(r){return r.node(0).resolve(r.pos+r.nodeAfter.nodeSize)}function ms(r,e){return r.depth==e.depth&&r.pos>=e.start(-1)&&r.pos<=e.end(-1)}function Ol(r,e,t){const n=r.node(-1),s=G.get(n),o=r.start(-1),i=s.nextCell(r.pos-o,e,t);return i==null?null:r.node(0).resolve(o+i)}function bt(r,e,t=1){const n={...r,colspan:r.colspan-t};return n.colwidth&&(n.colwidth=n.colwidth.slice(),n.colwidth.splice(e,t),n.colwidth.some(s=>s>0)||(n.colwidth=null)),n}function Dl(r,e,t=1){const n={...r,colspan:r.colspan+t};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let s=0;s<t;s++)n.colwidth.splice(e,0,0)}return n}function ah(r,e,t){const n=fe(e.type.schema).header_cell;for(let s=0;s<r.height;s++)if(e.nodeAt(r.map[t+s*r.width]).type!=n)return!1;return!0}var L=class qe extends P{constructor(e,t=e){const n=e.node(-1),s=G.get(n),o=e.start(-1),i=s.rectBetween(e.pos-o,t.pos-o),l=e.node(0),a=s.cellsInRect(i).filter(u=>u!=t.pos-o);a.unshift(t.pos-o);const c=a.map(u=>{const d=n.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const f=o+u+1;return new Bo(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const n=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(El(n)&&El(s)&&ms(n,s)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?qe.rowSelection(n,s):o&&this.isColSelection()?qe.colSelection(n,s):new qe(n,s)}return V.between(n,s)}content(){const e=this.$anchorCell.node(-1),t=G.get(e),n=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},i=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let u=a*t.width+s.left,d=s.left;d<s.right;d++,u++){const f=t.map[u];if(o[f])continue;o[f]=!0;const h=t.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const b=s.left-h.left,y=h.right-s.right;if(b>0||y>0){let x=p.attrs;if(b>0&&(x=bt(x,0,b)),y>0&&(x=bt(x,x.colspan-y,y)),h.left<s.left){if(p=p.type.createAndFill(x),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(x)}`)}else p=p.type.create(x,p.content)}if(h.top<s.top||h.bottom>s.bottom){const x={...p.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?p=p.type.createAndFill(x):p=p.type.create(x,p.content)}c.push(p)}i.push(e.child(a).copy(S.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new E(S.from(l),1,1)}replace(e,t=E.empty){const n=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){const{$from:l,$to:a}=s[i],c=e.mapping.slice(n);e.replace(c.map(l.pos),c.map(a.pos),i?E.empty:t)}const o=P.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new E(S.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=G.get(t),s=this.$anchorCell.start(-1),o=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let i=0;i<o.length;i++)e(t.nodeAt(o[i]),s+o[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const n=e.node(-1),s=G.get(n),o=e.start(-1),i=s.findCell(e.pos-o),l=s.findCell(t.pos-o),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(o+s.map[i.left])),l.bottom<s.height&&(t=a.resolve(o+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(o+s.map[l.left])),i.bottom<s.height&&(e=a.resolve(o+s.map[s.width*(s.height-1)+i.right-1]))),new qe(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=G.get(e),n=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-n),o=t.colCount(this.$headCell.pos-n);if(Math.min(s,o)>0)return!1;const i=s+this.$anchorCell.nodeAfter.attrs.colspan,l=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof qe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const n=e.node(-1),s=G.get(n),o=e.start(-1),i=s.findCell(e.pos-o),l=s.findCell(t.pos-o),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(o+s.map[i.top*s.width])),l.right<s.width&&(t=a.resolve(o+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(o+s.map[l.top*s.width])),i.right<s.width&&(e=a.resolve(o+s.map[s.width*(i.top+1)-1]))),new qe(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new qe(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){return new qe(e.resolve(t),e.resolve(n))}getBookmark(){return new ch(this.$anchorCell.pos,this.$headCell.pos)}};L.prototype.visible=!1,P.jsonID("cell",L);var ch=class Ga{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ga(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&n.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&ms(t,n)?new L(t,n):P.near(n,1)}};function uh(r){if(!(r.selection instanceof L))return null;const e=[];return r.selection.forEachCell((t,n)=>{e.push(te.node(n,n+t.nodeSize,{class:"selectedCell"}))}),j.create(r.doc,e)}function dh({$from:r,$to:e}){if(r.pos==e.pos||r.pos<e.pos-6)return!1;let t=r.pos,n=e.pos,s=r.depth;for(;s>=0&&!(r.after(s+1)<r.end(s));s--,t++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,n--);return t==n&&/row|table/.test(r.node(s).type.spec.tableRole)}function fh({$from:r,$to:e}){let t,n;for(let s=r.depth;s>0;s--){const o=r.node(s);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){t=o;break}}for(let s=e.depth;s>0;s--){const o=e.node(s);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}return t!==n&&e.parentOffset===0}function hh(r,e,t){const n=(e||r).selection,s=(e||r).doc;let o,i;if(n instanceof A&&(i=n.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")o=L.create(s,n.from);else if(i=="row"){const l=s.resolve(n.from+1);o=L.rowSelection(l,l)}else if(!t){const l=G.get(n.node),a=n.from+1,c=a+l.map[l.width*l.height-1];o=L.create(s,a+1,c)}}else n instanceof V&&dh(n)?o=V.create(s,n.from):n instanceof V&&fh(n)&&(o=V.create(s,n.$from.start(),n.$from.end()));return o&&(e||(e=r.tr)).setSelection(o),e}var ph=new Ye("fix-tables");function Tl(r,e,t,n){const s=r.childCount,o=e.childCount;e:for(let i=0,l=0;i<o;i++){const a=e.child(i);for(let c=l,u=Math.min(s,i+3);c<u;c++)if(r.child(c)==a){l=c+1,t+=a.nodeSize;continue e}n(a,t),l<s&&r.child(l).sameMarkup(a)?Tl(r.child(l),a,t+1,n):a.nodesBetween(0,a.content.size,n,t+1),t+=a.nodeSize}}function gs(r,e){let t;const n=(s,o)=>{s.type.spec.tableRole=="table"&&(t=mh(r,s,o,t))};return e?e.doc!=r.doc&&Tl(e.doc,r.doc,0,n):r.doc.descendants(n),t}function mh(r,e,t,n){const s=G.get(e);if(!s.problems)return n;n||(n=r.tr);const o=[];for(let a=0;a<s.height;a++)o.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)o[c.row+f]+=c.n;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,bt(d,d.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=n.mapping.map(t);n.delete(u,u+e.nodeSize)}}let i,l;for(let a=0;a<o.length;a++)o[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const u=e.child(a),d=c+u.nodeSize,f=o[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<f;y++){const x=fe(r.schema)[h].createAndFill();x&&p.push(x)}const b=(a==0||i==a-1)&&l==a?c+1:d-1;n.insert(n.mapping.map(b),p)}c=d}return n.setMeta(ph,{fixTables:!0})}function Pe(r){const e=r.selection,t=er(r),n=t.node(-1),s=t.start(-1),o=G.get(n);return{...e instanceof L?o.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o.findCell(t.pos-s),tableStart:s,map:o,table:n}}function Al(r,{map:e,tableStart:t,table:n},s){let o=s>0?-1:0;ah(e,n,s+o)&&(o=s==0||s==e.width?null:0);for(let i=0;i<e.height;i++){const l=i*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=n.nodeAt(a);r.setNodeMarkup(r.mapping.map(t+a),null,Dl(c.attrs,s-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=o==null?fe(n.type.schema).cell:n.nodeAt(e.map[l+o]).type,c=e.positionAt(i,s,n);r.insert(r.mapping.map(t+c),a.createAndFill())}}return r}function gh(r,e){if(!we(r))return!1;if(e){const t=Pe(r);e(Al(r.tr,t,t.left))}return!0}function yh(r,e){if(!we(r))return!1;if(e){const t=Pe(r);e(Al(r.tr,t,t.right))}return!0}function bh(r,{map:e,table:t,tableStart:n},s){const o=r.mapping.maps.length;for(let i=0;i<e.height;){const l=i*e.width+s,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)r.setNodeMarkup(r.mapping.slice(o).map(n+a),null,bt(u,s-e.colCount(a)));else{const d=r.mapping.slice(o).map(n+a);r.delete(d,d+c.nodeSize)}i+=u.rowspan}}function xh(r,e){if(!we(r))return!1;if(e){const t=Pe(r),n=r.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;bh(n,t,s),s!=t.left;s--){const o=t.tableStart?n.doc.nodeAt(t.tableStart-1):n.doc;if(!o)throw RangeError("No table found");t.table=o,t.map=G.get(o)}e(n)}return!0}function kh(r,e,t){var n;const s=fe(e.type.schema).header_cell;for(let o=0;o<r.width;o++)if(((n=e.nodeAt(r.map[o+t*r.width]))==null?void 0:n.type)!=s)return!1;return!0}function Pl(r,{map:e,tableStart:t,table:n},s){var o;let i=t;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;const l=[];let a=s>0?-1:0;kh(e,n,s+a)&&(a=s==0||s==e.height?null:0);for(let c=0,u=e.width*s;c<e.width;c++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],f=n.nodeAt(d).attrs;r.setNodeMarkup(t+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{const d=a==null?fe(n.type.schema).cell:(o=n.nodeAt(e.map[u+a*e.width]))==null?void 0:o.type,f=d==null?void 0:d.createAndFill();f&&l.push(f)}return r.insert(i,fe(n.type.schema).row.create(null,l)),r}function wh(r,e){if(!we(r))return!1;if(e){const t=Pe(r);e(Pl(r.tr,t,t.top))}return!0}function Sh(r,e){if(!we(r))return!1;if(e){const t=Pe(r);e(Pl(r.tr,t,t.bottom))}return!0}function Ch(r,{map:e,table:t,tableStart:n},s){let o=0;for(let c=0;c<s;c++)o+=t.child(c).nodeSize;const i=o+t.child(s).nodeSize,l=r.mapping.maps.length;r.delete(o+n,i+n);const a=new Set;for(let c=0,u=s*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),s>0&&d==e.map[u-e.width]){const f=t.nodeAt(d).attrs;r.setNodeMarkup(r.mapping.slice(l).map(d+n),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(s<e.height&&d==e.map[u+e.width]){const f=t.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),b=e.positionAt(s+1,c,t);r.insert(r.mapping.slice(l).map(n+b),p),c+=h.colspan-1}}}}function Mh(r,e){if(!we(r))return!1;if(e){const t=Pe(r),n=r.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;Ch(n,t,s),s!=t.top;s--){const o=t.tableStart?n.doc.nodeAt(t.tableStart-1):n.doc;if(!o)throw RangeError("No table found");t.table=o,t.map=G.get(t.table)}e(n)}return!0}function Il(r){const e=r.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function vh({width:r,height:e,map:t},n){let s=n.top*r+n.left,o=s,i=(n.bottom-1)*r+n.left,l=s+(n.right-n.left-1);for(let a=n.top;a<n.bottom;a++){if(n.left>0&&t[o]==t[o-1]||n.right<r&&t[l]==t[l+1])return!0;o+=r,l+=r}for(let a=n.left;a<n.right;a++){if(n.top>0&&t[s]==t[s-r]||n.bottom<e&&t[i]==t[i+r])return!0;s++,i++}return!1}function Nh(r,e){const t=r.selection;if(!(t instanceof L)||t.$anchorCell.pos==t.$headCell.pos)return!1;const n=Pe(r),{map:s}=n;if(vh(s,n))return!1;if(e){const o=r.tr,i={};let l=S.empty,a,c;for(let u=n.top;u<n.bottom;u++)for(let d=n.left;d<n.right;d++){const f=s.map[u*s.width+d],h=n.table.nodeAt(f);if(!(i[f]||!h))if(i[f]=!0,a==null)a=f,c=h;else{Il(h)||(l=l.append(h.content));const p=o.mapping.map(f+n.tableStart);o.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(o.setNodeMarkup(a+n.tableStart,null,{...Dl(c.attrs,c.attrs.colspan,n.right-n.left-c.attrs.colspan),rowspan:n.bottom-n.top}),l.size){const u=a+1+c.content.size,d=Il(c)?a+1:u;o.replaceWith(d+n.tableStart,u+n.tableStart,l)}o.setSelection(new L(o.doc.resolve(a+n.tableStart))),e(o)}return!0}function Eh(r,e){const t=fe(r.schema);return Oh(({node:n})=>t[n.type.spec.tableRole])(r,e)}function Oh(r){return(e,t)=>{var n;const s=e.selection;let o,i;if(s instanceof L){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;o=s.$anchorCell.nodeAfter,i=s.$anchorCell.pos}else{if(o=oh(s.$from),!o)return!1;i=(n=pn(s.$from))==null?void 0:n.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(t){let l=o.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=Pe(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=o.nodeSize);for(let b=u.left,y=0;b<u.right;b++,y++)b==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),r({node:o,row:h,col:b}).createAndFill(a[y]))}d.setNodeMarkup(i,r({node:o,row:u.top,col:u.left}),a[0]),s instanceof L&&d.setSelection(new L(d.doc.resolve(s.$anchorCell.pos),f?d.doc.resolve(f):void 0)),t(d)}return!0}}function Ft(r,e){return function(t,n){if(!we(t))return!1;const s=er(t);if(s.nodeAfter.attrs[r]===e)return!1;if(n){const o=t.tr;t.selection instanceof L?t.selection.forEachCell((i,l)=>{i.attrs[r]!==e&&o.setNodeMarkup(l,null,{...i.attrs,[r]:e})}):o.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[r]:e}),n(o)}return!0}}function Dh(r){return function(e,t){if(!we(e))return!1;if(t){const n=fe(e.schema),s=Pe(e),o=e.tr,i=s.map.cellsInRect(r=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:r=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=i.map(a=>s.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==n.header_cell&&o.setNodeMarkup(s.tableStart+i[a],n.cell,l[a].attrs);if(o.steps.length==0)for(let a=0;a<i.length;a++)o.setNodeMarkup(s.tableStart+i[a],n.header_cell,l[a].attrs);t(o)}return!0}}function Vl(r,e,t){const n=e.map.cellsInRect({left:0,top:0,right:r=="row"?e.map.width:1,bottom:r=="column"?e.map.height:1});for(let s=0;s<n.length;s++){const o=e.table.nodeAt(n[s]);if(o&&o.type!==t.header_cell)return!1}return!0}function ys(r,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Dh(r):function(t,n){if(!we(t))return!1;if(n){const s=fe(t.schema),o=Pe(t),i=t.tr,l=Vl("row",o,s),a=Vl("column",o,s),u=(r==="column"?l:r==="row"?a:!1)?1:0,d=r=="column"?{left:0,top:u,right:1,bottom:o.map.height}:r=="row"?{left:u,top:0,right:o.map.width,bottom:1}:o,f=r=="column"?a?s.cell:s.header_cell:r=="row"?l?s.cell:s.header_cell:s.cell;o.map.cellsInRect(d).forEach(h=>{const p=h+o.tableStart,b=i.doc.nodeAt(p);b&&i.setNodeMarkup(p,f,b.attrs)}),n(i)}return!0}}var Th=ys("row",{useDeprecatedLogic:!0}),Ah=ys("column",{useDeprecatedLogic:!0}),Ph=ys("cell",{useDeprecatedLogic:!0});function Ih(r,e){if(e<0){const t=r.nodeBefore;if(t)return r.pos-t.nodeSize;for(let n=r.index(-1)-1,s=r.before();n>=0;n--){const o=r.node(-1).child(n),i=o.lastChild;if(i)return s-1-i.nodeSize;s-=o.nodeSize}}else{if(r.index()<r.parent.childCount-1)return r.pos+r.nodeAfter.nodeSize;const t=r.node(-1);for(let n=r.indexAfter(-1),s=r.after();n<t.childCount;n++){const o=t.child(n);if(o.childCount)return s+1;s+=o.nodeSize}}return null}function Rl(r){return function(e,t){if(!we(e))return!1;const n=Ih(er(e),r);if(n==null)return!1;if(t){const s=e.doc.resolve(n);t(e.tr.setSelection(V.between(s,lh(s))).scrollIntoView())}return!0}}function Vh(r,e){const t=r.selection.$anchor;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="table")return e&&e(r.tr.delete(t.before(n),t.after(n)).scrollIntoView()),!0;return!1}function tr(r,e){const t=r.selection;if(!(t instanceof L))return!1;if(e){const n=r.tr,s=fe(r.schema).cell.createAndFill().content;t.forEachCell((o,i)=>{o.content.eq(s)||n.replace(n.mapping.map(i+1),n.mapping.map(i+o.nodeSize-1),new E(s,0,0))}),n.docChanged&&e(n)}return!0}function Rh(r){if(!r.size)return null;let{content:e,openStart:t,openEnd:n}=r;for(;e.childCount==1&&(t>0&&n>0||e.child(0).type.spec.tableRole=="table");)t--,n--,e=e.child(0).content;const s=e.child(0),o=s.type.spec.tableRole,i=s.type.schema,l=[];if(o=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,n-1);(u||d)&&(c=bs(fe(i).row,new E(c,u,d)).content),l.push(c)}else if(o=="cell"||o=="header_cell")l.push(t||n?bs(fe(i).row,new E(e,t,n)).content:e);else return null;return zh(i,l)}function zh(r,e){const t=[];for(let s=0;s<e.length;s++){const o=e[s];for(let i=o.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=o.child(i).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let n=0;for(let s=0;s<t.length;s++)n=Math.max(n,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(S.empty),t[s]<n){const o=fe(r).cell.createAndFill(),i=[];for(let l=t[s];l<n;l++)i.push(o);e[s]=e[s].append(S.from(i))}return{height:e.length,width:n,rows:e}}function bs(r,e){const t=r.createAndFill();return new jo(t).replace(0,t.content.size,e).doc}function jh({width:r,height:e,rows:t},n,s){if(r!=n){const o=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=o[l]||0,d=0;u<n;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>n&&(f=f.type.createChecked(bt(f.attrs,f.attrs.colspan,u+f.attrs.colspan-n),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)o[l+h]=(o[l+h]||0)+f.attrs.colspan}i.push(S.from(c))}t=i,r=n}if(e!=s){const o=[];for(let i=0,l=0;i<s;i++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);i+d.attrs.rowspan>s&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,s-d.attrs.rowspan)},d.content)),a.push(d)}o.push(S.from(a))}t=o,e=s}return{width:r,height:e,rows:t}}function Bh(r,e,t,n,s,o,i){const l=r.doc.type.schema,a=fe(l);let c,u;if(s>e.width)for(let d=0,f=0;d<e.height;d++){const h=t.child(d);f+=h.nodeSize;const p=[];let b;h.lastChild==null||h.lastChild.type==a.cell?b=c||(c=a.cell.createAndFill()):b=u||(u=a.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(b);r.insert(r.mapping.slice(i).map(f-1+n),p)}if(o>e.height){const d=[];for(let p=0,b=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const y=p>=e.width?!1:t.nodeAt(e.map[b+p]).type==a.header_cell;d.push(y?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,S.from(d)),h=[];for(let p=e.height;p<o;p++)h.push(f);r.insert(r.mapping.slice(i).map(n+t.nodeSize-2),h)}return!!(c||u)}function zl(r,e,t,n,s,o,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=s;c<o;c++){const u=i*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const f=t.nodeAt(d),{top:h,left:p}=e.findCell(d);r.setNodeMarkup(r.mapping.slice(l).map(d+n),null,{...f.attrs,rowspan:i-h}),r.insert(r.mapping.slice(l).map(e.positionAt(i,p,t)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-i})),c+=f.attrs.colspan-1}}return a}function jl(r,e,t,n,s,o,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=s;c<o;c++){const u=c*e.width+i,d=e.map[u];if(e.map[u-1]==d){a=!0;const f=t.nodeAt(d),h=e.colCount(d),p=r.mapping.slice(l).map(d+n);r.setNodeMarkup(p,null,bt(f.attrs,i-h,f.attrs.colspan-(i-h))),r.insert(p+f.nodeSize,f.type.createAndFill(bt(f.attrs,0,i-h))),c+=f.attrs.rowspan-1}}return a}function Bl(r,e,t,n,s){let o=t?r.doc.nodeAt(t-1):r.doc;if(!o)throw new Error("No table found");let i=G.get(o);const{top:l,left:a}=n,c=a+s.width,u=l+s.height,d=r.tr;let f=0;function h(){if(o=t?d.doc.nodeAt(t-1):d.doc,!o)throw new Error("No table found");i=G.get(o),f=d.mapping.maps.length}Bh(d,i,o,t,c,u,f)&&h(),zl(d,i,o,t,a,c,l,f)&&h(),zl(d,i,o,t,a,c,u,f)&&h(),jl(d,i,o,t,l,u,a,f)&&h(),jl(d,i,o,t,l,u,c,f)&&h();for(let p=l;p<u;p++){const b=i.positionAt(p,a,o),y=i.positionAt(p,c,o);d.replace(d.mapping.slice(f).map(b+t),d.mapping.slice(f).map(y+t),new E(s.rows[p-l],0,0))}h(),d.setSelection(new L(d.doc.resolve(t+i.positionAt(l,a,o)),d.doc.resolve(t+i.positionAt(u-1,c-1,o)))),e(d)}var Fh=Ar({ArrowLeft:rr("horiz",-1),ArrowRight:rr("horiz",1),ArrowUp:rr("vert",-1),ArrowDown:rr("vert",1),"Shift-ArrowLeft":sr("horiz",-1),"Shift-ArrowRight":sr("horiz",1),"Shift-ArrowUp":sr("vert",-1),"Shift-ArrowDown":sr("vert",1),Backspace:tr,"Mod-Backspace":tr,Delete:tr,"Mod-Delete":tr});function nr(r,e,t){return t.eq(r.selection)?!1:(e&&e(r.tr.setSelection(t).scrollIntoView()),!0)}function rr(r,e){return(t,n,s)=>{if(!s)return!1;const o=t.selection;if(o instanceof L)return nr(t,n,P.near(o.$headCell,e));if(r!="horiz"&&!o.empty)return!1;const i=Fl(s,r,e);if(i==null)return!1;if(r=="horiz")return nr(t,n,P.near(t.doc.resolve(o.head+e),e));{const l=t.doc.resolve(i),a=Ol(l,r,e);let c;return a?c=P.near(a,1):e<0?c=P.near(t.doc.resolve(l.before(-1)),-1):c=P.near(t.doc.resolve(l.after(-1)),1),nr(t,n,c)}}}function sr(r,e){return(t,n,s)=>{if(!s)return!1;const o=t.selection;let i;if(o instanceof L)i=o;else{const a=Fl(s,r,e);if(a==null)return!1;i=new L(t.doc.resolve(a))}const l=Ol(i.$headCell,r,e);return l?nr(t,n,new L(i.$anchorCell,l)):!1}}function Lh(r,e){const t=r.state.doc,n=pn(t.resolve(e));return n?(r.dispatch(r.state.tr.setSelection(new L(n))),!0):!1}function $h(r,e,t){if(!we(r.state))return!1;let n=Rh(t);const s=r.state.selection;if(s instanceof L){n||(n={width:1,height:1,rows:[S.from(bs(fe(r.state.schema).cell,t))]});const o=s.$anchorCell.node(-1),i=s.$anchorCell.start(-1),l=G.get(o).rectBetween(s.$anchorCell.pos-i,s.$headCell.pos-i);return n=jh(n,l.right-l.left,l.bottom-l.top),Bl(r.state,r.dispatch,i,l,n),!0}else if(n){const o=er(r.state),i=o.start(-1);return Bl(r.state,r.dispatch,i,G.get(o.node(-1)).findCell(o.pos-i),n),!0}else return!1}function Wh(r,e){var t;if(e.ctrlKey||e.metaKey)return;const n=Ll(r,e.target);let s;if(e.shiftKey&&r.state.selection instanceof L)o(r.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&n&&(s=pn(r.state.selection.$anchor))!=null&&((t=xs(r,e))==null?void 0:t.pos)!=s.pos)o(s,e),e.preventDefault();else if(!n)return;function o(a,c){let u=xs(r,c);const d=st.getState(r.state)==null;if(!u||!ms(a,u))if(d)u=a;else return;const f=new L(a,u);if(d||!r.state.selection.eq(f)){const h=r.state.tr.setSelection(f);d&&h.setMeta(st,a.pos),r.dispatch(h)}}function i(){r.root.removeEventListener("mouseup",i),r.root.removeEventListener("dragstart",i),r.root.removeEventListener("mousemove",l),st.getState(r.state)!=null&&r.dispatch(r.state.tr.setMeta(st,-1))}function l(a){const c=a,u=st.getState(r.state);let d;if(u!=null)d=r.state.doc.resolve(u);else if(Ll(r,c.target)!=n&&(d=xs(r,e),!d))return i();d&&o(d,c)}r.root.addEventListener("mouseup",i),r.root.addEventListener("dragstart",i),r.root.addEventListener("mousemove",l)}function Fl(r,e,t){if(!(r.state.selection instanceof V))return null;const{$head:n}=r.state.selection;for(let s=n.depth-1;s>=0;s--){const o=n.node(s);if((t<0?n.index(s):n.indexAfter(s))!=(t<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=n.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return r.endOfTextblock(a)?l:null}}return null}function Ll(r,e){for(;e&&e!=r.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function xs(r,e){const t=r.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?pn(r.state.doc.resolve(t.pos)):null}new Ye("tableColumnResizing");function _h({allowTableNodeSelection:r=!1}={}){return new Oe({key:st,state:{init(){return null},apply(e,t){const n=e.getMeta(st);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;const{deleted:s,pos:o}=e.mapping.mapResult(t);return s?null:o}},props:{decorations:uh,handleDOMEvents:{mousedown:Wh},createSelectionBetween(e){return st.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Lh,handleKeyDown:Fh,handlePaste:$h},appendTransaction(e,t,n){return hh(n,gs(n,t),r)}})}const Lt=m.createContext(null),qh=m.createContext(null),$l=m.createContext(null),or=new WeakMap;function Jh(r){const e=Object.create(null);e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",s=>{if(typeof s=="function"&&(s=s(r.state)),s)for(const o in s)o=="class"?e.class+=" "+s[o]:o=="style"?e.style=(e.style?e.style+";":"")+s[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(s[o]))}),e.translate||(e.translate="no");const t=[te.node(0,r.state.doc.content.size,e)],n=or.get(r);return!n||n[0].to!==r.state.doc.content.size||!n[0].type.eq(t[0].type)?(or.set(r,t),t):n}const Hh=[],Kh={},ks=j.empty;let Wl=class Ht{constructor(e){B(this,"members");this.members=e}map(e,t){const n=this.members.map(s=>s.map(e,t,Kh));return Ht.from(n)}forChild(e,t){if(t.isLeaf)return j.empty;let n=[];for(let s=0;s<this.members.length;s++){const o=this.members[s].forChild(e,t);o!=ks&&(o instanceof Ht?n=n.concat(o.members):n.push(o))}return Ht.from(n)}eq(e){if(!(e instanceof Ht)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let s=0;s<this.members.length;s++){const o=this.members[s].localsInner(e);if(o.length)if(!t)t=o;else{n&&(t=t.slice(),n=!1);for(let i=0;i<o.length;i++)t.push(o[i])}}return t?Yh(n?t:t.sort(_l)):Hh}static from(e){switch(e.length){case 0:return ks;case 1:return e[0];default:return new Ht(e.every(t=>t instanceof j)?e:e.reduce((t,n)=>t.concat(n instanceof j?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function _l(r,e){return r.from-e.from||r.to-e.to}function Yh(r){let e=r;for(let t=0;t<e.length-1;t++){const n=e[t];if(n.from!=n.to)for(let s=t+1;s<e.length;s++){const o=e[s];if(o.from==n.from){o.to!=n.to&&(e==r&&(e=r.slice()),e[s]=o.copy(o.from,n.to),ql(e,s+1,o.copy(n.to,o.to)));continue}else{o.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,o.from),ql(e,s,n.copy(o.from,n.to)));break}}}return e}function ql(r,e,t){for(;e<r.length&&_l(t,r[e])>0;)e++;r.splice(e,0,t)}const ws=new WeakMap;function Gh(r,e){const t=[];r.someProp("decorations",i=>{const l=i(r.state);l&&l!=ks&&t.push(l)}),e&&t.push(j.create(r.state.doc,[e]));const n=ws.get(r);if(!n){const i=Wl.from(t);return ws.set(r,i),i}let s=0,o=!0;if(n.forEachSet(i=>{t[s++]!==i&&(o=!1)}),s!==t.length&&(o=!1),!o){const i=Wl.from(t);return ws.set(r,i),i}return n}const Xh=new Pn({nodes:{doc:{content:"text*"},text:{inline:!0}}}),Ss=Ke.create({schema:Xh});function Jl(r){const e=Object.create(null);function t(n){for(const s in n)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=n[s])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function Qh(r,e){let t=0,n=0;for(const s in r){if(r[s]!=e[s])return!0;t++}for(const s in e)n++;return t!=n}class xt extends lf{constructor(t,n){var e=(...ug)=>(super(...ug),B(this,"nextProps"),B(this,"prevState"),this);const s=[...t.mount.childNodes],o=[...t.mount.attributes];for(const i of o)t.mount.removeAttributeNode(i);try{e(t,{state:Ss}),this.domObserver.stop(),this.domObserver.observer=null,this.domObserver.queue=[]}finally{t.mount.replaceChildren(...s);for(const i of t.mount.attributes)t.mount.removeAttributeNode(i);for(const i of o)t.mount.setAttributeNode(i)}this.prevState=Ss,this.nextProps=n,this.state=n.state,this.nodeViews=Jl(this),this.docView.destroy(),this.docView=null}get props(){return this.nextProps}setProps(t){this.update({...this.props,...t})}update(t){const n=this.nextProps;if(this.nextProps=t,this.state=t.state,n.state.plugins!==t.state.plugins||n.plugins!==t.plugins||n.nodeViews!==t.nodeViews){const s=Jl(this);Qh(this.nodeViews,s)&&(this.nodeViews=s)}this.editable=!this.someProp("editable",s=>s(this.state)===!1)}updateState(t){this.setProps({state:t})}someProp(t,n){if(!this.props)return;const s=this.props[t];if(s){const o=n?n(s):s;if(o)return o}for(const o of this.props.plugins??[]){const i=o.props[t];if(i){const l=n?n(i):i;if(l)return l}}for(const o of this.state.plugins){const i=o.props[t];if(i){const l=n?n(i):i;if(l)return l}}}destroy(){const t=[...this.dom.childNodes];try{super.destroy()}finally{this.dom.replaceChildren(...t)}}commitPendingEffects(){this.state=this.prevState,this.docView.markDirty(-1,-1),super.update(this.nextProps),this.prevState=this.state}}class Hl{constructor(e){B(this,"props");B(this,"nodeViews");this.props=e,this.nodeViews={}}get composing(){return!1}get dom(){return null}get editable(){return!1}get state(){return this.props.state}setProps(e){return this.update({...this.props,...e})}update(e){this.props=e}updateState(e){this.setProps({state:e})}someProp(e,t){const n=this.props[e];if(n){const s=t?t(n):n;if(s)return s}for(const s of this.props.plugins??[]){const o=s.props[e];if(o){const i=t?t(o):o;if(i)return i}}for(const s of this.state.plugins){const o=s.props[e];if(o){const i=t?t(o):o;if(i)return i}}}destroy(){}domSelectionRange(){return{anchorNode:null,anchorOffset:0,focusNode:null,focusOffset:0}}domSelection(){return null}}const ot=function(r){for(let e=0;;e++)if(r=r.previousSibling,!r)return e},Kl=function(r,e,t,n){return t&&(Yl(r,e,t,n,-1)||Yl(r,e,t,n,1))},Uh=/^(img|br|input|textarea|hr)$/i;function Yl(r,e,t,n,s){for(;;){if(r==t&&e==n)return!0;if(e==(s<0?0:Gl(r))){const o=r.parentNode;if(!o||o.nodeType!=1||Zh(r)||Uh.test(r.nodeName)||r.contentEditable=="false")return!1;e=ot(r)+(s<0?0:1),r=o}else if(r.nodeType==1){if(r=r.childNodes[e+(s<0?-1:0)],r.contentEditable=="false")return!1;e=s<0?Gl(r):0}else return!1}}function Gl(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Zh(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const Xl=m.createContext(null);function ne(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];typeof document>"u"||m.useLayoutEffect(...e)}function ep(r,e){const t=m.useContext(Xl);ne(()=>t(r),e)}function Ie(r,e){const{view:t,flushSyncRef:n}=m.useContext(Lt);ep(()=>{if(t instanceof xt){n.current=!1;const s=r(t);return n.current=!0,s}},e&&[t,...e])}const tp=m.forwardRef(function(e,t){let{widget:n,getPos:s,...o}=e;const[i,l]=m.useState(!0),a=m.useRef(null);return m.useImperativeHandle(t,()=>a.current,[]),Ie(c=>{if(!c||!a.current)return;c.domObserver.disconnectSelection();const u=c.domSelection(),d=document.createRange(),f=a.current;f.nodeName=="IMG"&&f.parentNode?d.setEnd(f.parentNode,ot(f)+1):d.setEnd(f,0),d.collapse(!1),u.removeAllRanges(),u.addRange(d),l(!1),c.domObserver.connectSelection()},[]),i?m.createElement("img",{ref:a,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...o}):null});function np(r,e){if(r==e)return!0;for(const t in r)if(r[t]!==e[t])return!1;for(const t in e)if(!(t in r))return!1;return!0}const rp={side:0};class $t{constructor(e,t){B(this,"Component");B(this,"side");B(this,"spec");this.Component=e,this.spec=t??rp,this.side=this.spec.side??0}map(e,t,n,s){const{pos:o,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new te(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof $t&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&np(this.spec,e.spec))}destroy(){}}function sp(r,e,t){return new te(r,r,new $t(e,t))}function Cs(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(e===null)return!1;const n=t.from??r.state.selection.from,s=t.to??r.state.selection.to;if(r.someProp("handleTextInput",i=>i(r,n,s,e)))return!0;const{tr:o}=r.state;return t.marks&&o.ensureMarks(t.marks),o.insertText(e,n,s),r.dispatch(o),!0}function op(r){let e=null,t=null;return new Oe({props:{handleDOMEvents:{compositionstart(n){const{state:s}=n;n.dispatch(s.tr.deleteSelection());const o=s.selection.$from;e=s.storedMarks??o.marks(),e&&r(sp(s.selection.from,tp,{key:"cursor-wrapper",marks:e}));const{node:i}=n.domAtPos(o.pos);t=[];for(const l of i.childNodes)t.push(l);return n.input.composing=!0,!0},compositionupdate(){return!0},compositionend(n,s){n.input.composing=!1;const{state:o}=n,{node:i}=n.domAtPos(o.selection.from);if(t&&(t.forEach((l,a)=>{if(i.childNodes.length<=a){i.appendChild(l);return}i.replaceChild(l,i.childNodes.item(a))}),i.childNodes.length>t.length))for(let l=t.length;l<i.childNodes.length;l++)i.removeChild(i.childNodes.item(l));return s.data&&Cs(n,s.data,{marks:e}),e=null,t=null,r(null),!0},beforeinput(n,s){var o,i;switch(s.preventDefault(),s.inputType){case"insertParagraph":case"insertLineBreak":{n.input.lastIOSEnter=0;const l=new KeyboardEvent("keydown",{bubbles:!0,cancelable:!0,key:"Enter",code:"Enter",keyCode:13,shiftKey:s.inputType==="insertLineBreak"});return n.someProp("handleKeyDown",a=>a(n,l))??!1}case"insertReplacementText":{const l=s.getTargetRanges();(i=(o=s.dataTransfer)==null?void 0:o.items[0])==null||i.getAsString(a=>{for(const c of l){const u=n.posAtDOM(c.startContainer,c.startOffset,1),d=n.posAtDOM(c.endContainer,c.endOffset,1);Cs(n,a,{from:u,to:d})}});break}case"insertText":{Cs(n,s.data);break}case"deleteWordBackward":case"deleteHardLineBackward":case"deleteSoftLineBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteHardLineForward":case"deleteSoftLineForward":case"deleteContentForward":case"deleteContent":{const l=s.getTargetRanges(),{tr:a}=n.state;for(const c of l){const u=n.posAtDOM(c.startContainer,c.startOffset),d=n.posAtDOM(c.endContainer,c.endOffset),{doc:f}=n.state,h=f.resolve(u).marksAcross(f.resolve(d));a.delete(u,d).setStoredMarks(h)}n.dispatch(a);break}}return!0}}}})}function ip(r){const e={};for(const[n,s]of r.entries()){let o=function(i,l){for(const a of s){let c=!1;if(Re.unstable_batchedUpdates(()=>{c=!!a.call(this,i,l)}),c||l.defaultPrevented)return!0}return!1};e[n]=o}return new Oe({key:new Ye("@handlewithcare/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function lp(){const[r,e]=m.useState(new Map),t=m.useCallback((o,i)=>{const l=r.get(o)??[];l.unshift(i),r.has(o)||(r.set(o,l),e(new Map(r)))},[r]),n=m.useCallback((o,i)=>{const l=r.get(o);l==null||l.splice(l.indexOf(i),1)},[r]),s=m.useMemo(()=>ip(r),[r]);return{registerEventListener:t,unregisterEventListener:n,componentEventListenersPlugin:s}}function Ql(){const[,r]=m.useReducer(e=>e+1,0);return r}let Ul=!1;function ap(r,e){process.env.NODE_ENV!=="production"&&e.defaultState!==void 0&&e.state!==void 0&&!Ul&&(console.error("A component contains a ProseMirror editor with both state and defaultState props. ProseMirror editors must be either controlled or uncontrolled (specify either the state prop, or the defaultState prop, but not both). Decide between using a controlled or uncontrolled ProseMirror editor and remove one of these props. More info: https://reactjs.org/link/controlled-components"),Ul=!0);const t=m.useRef(!0),[n,s]=m.useState(null),o=Ql(),i=e.defaultState??Ss,[l,a]=m.useState(i),c=e.state??l,{componentEventListenersPlugin:u,registerEventListener:d,unregisterEventListener:f}=lp(),h=m.useCallback(N=>{Re.flushSync(()=>{s(N)})},[]),p=m.useMemo(()=>[...e.plugins??[],u,op(h)],[e.plugins,u,h]),b=m.useCallback(function(O){t.current?Re.flushSync(()=>{e.state||a(M=>M.apply(O)),e.dispatchTransaction&&e.dispatchTransaction.call(this,O)}):(e.state||a(M=>M.apply(O)),e.dispatchTransaction&&e.dispatchTransaction.call(this,O))},[e.dispatchTransaction,e.state]),y={...e,state:c,plugins:p,dispatchTransaction:b},[x,k]=m.useState(()=>new Hl(y));return ne(()=>()=>{x.destroy()},[x]),ne(()=>{if(r!==x.dom)if(r){const N=new xt({mount:r},y);N.dom.addEventListener("compositionend",o),k(N)}else{const N=new Hl(y);k(N)}else x instanceof xt&&x.commitPendingEffects()}),x.update(y),{editor:m.useMemo(()=>({view:x,cursorWrapper:n,flushSyncRef:t,registerEventListener:d,unregisterEventListener:f}),[n,d,f,x]),state:c}}function cp(r){let{children:e}=r;const t=m.useRef(new Set).current,n=m.useRef(new Set).current,s=m.useRef(!1),o=Ql(),i=m.useRef(!0),l=m.useCallback(()=>{i.current||(o(),i.current=!0)},[o]),a=m.useCallback(c=>{let u;const d=()=>{u=c()};return t.add(d),l(),()=>{t.delete(d),u&&(s.current?(n.add(u),l()):u())}},[t,n,l]);return ne(()=>(i.current=!1,t.forEach(c=>c()),t.clear(),()=>{n.forEach(c=>c()),n.clear()})),ne(()=>(s.current=!0,()=>{s.current=!1}),[]),m.createElement(Xl.Provider,{value:a},e)}const Ne=m.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}}),Ve=typeof navigator<"u"?navigator:null,Zl=typeof document<"u"?document:null,kt=Ve&&Ve.userAgent||"",Ms=/Edge\/(\d+)/.exec(kt),ea=/MSIE \d/.exec(kt),vs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(kt),Ns=!!(ea||vs||Ms);ea?document.documentMode:vs?+vs[1]:Ms&&+Ms[1];const ta=!Ns&&/gecko\/(\d+)/i.test(kt);ta&&+(/Firefox\/(\d+)/.exec(kt)||[0,0])[1];const Es=!Ns&&/Chrome\/(\d+)/.exec(kt),up=!!Es;Es&&+Es[1];const na=!Ns&&!!Ve&&/Apple Computer/.test(Ve.vendor);na&&(/Mobile\/\w+/.test(kt)||!!Ve&&Ve.maxTouchPoints>2)||Ve&&/Mac/.test(Ve.platform),Ve&&/Win/.test(Ve.platform),!!Zl&&"webkitFontSmoothing"in Zl.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];const Wt={gecko:ta,chrome:up,safari:na};function wt(r,e){return r instanceof gn?1:e instanceof gn?-1:r.getPos()-e.getPos()}const it=0,ra=1,ir=2,St=3;class mn{constructor(e,t,n,s,o){B(this,"parent");B(this,"children");B(this,"getPos");B(this,"dom");B(this,"contentDOM");B(this,"dirty");B(this,"node");this.parent=e,this.children=t,this.getPos=n,this.dom=s,this.contentDOM=o,this.dirty=it,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){const s=this.children[t];if(s==e)return n;n+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let o,i;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ot(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;for(let n=!0,s=e;s;s=s.parentNode){const o=this.getDesc(s);let i;if(o&&(!t||o.node))if(n&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))n=!1;else return o}}getDesc(e){const t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let s=e;s;s=s.parentNode){const o=this.getDesc(s);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let s=this.children[t];const o=n+s.size;if(n==e&&o!=n){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){const l=s.children[i];if(l.size){s=l;break}}return s}if(e<o)return s.descAt(e-n-s.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,s=0;for(let o=0;n<this.children.length;n++){const i=this.children[n],l=o+i.size;if(l>e||i instanceof gn){s=e-o;break}o=l}if(s)return this.children[n].domFromPos(s-this.children[n].border,t);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof Os&&o.side>=0;n--);if(t<=0){let o,i=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,i=!1);return o&&t&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?ot(o.dom)+1:0}}else{let o,i=!0;for(;o=n<this.children.length?this.children[n]:null,!(!o||o.dom.parentNode==this.contentDOM);n++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?ot(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=n,l=0;;l++){const a=this.children[l],c=i+a.size;if(s==-1&&e<=c){const u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let d=l;d>0;d--){const f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=ot(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){const d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=ot(d.dom);break}t+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;const t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){const{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n){var h;let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const o=Math.min(e,t),i=Math.max(e,t);for(let p=0,b=0;p<this.children.length;p++){const y=this.children[p],x=b+y.size;if(o>b&&i<x)return y.setSelection(e-b-y.border,t-b-y.border,n,s);b=x}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1);const c=n.root.getSelection(),u=n.domSelectionRange();let d=!1;if((Wt.gecko||Wt.safari)&&e==t){const{node:p,offset:b}=l;if(p.nodeType==3){if(d=!!(b&&((h=p.nodeValue)==null?void 0:h[b-1])==`
|
|
33
|
+
`),d&&b==p.nodeValue.length)for(let y=p,x;y;y=y.parentNode){if(x=y.nextSibling){x.nodeName=="BR"&&(l=a={node:x.parentNode,offset:ot(x)+1});break}const k=y.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{const y=p.childNodes[b-1];d=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Wt.gecko&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){const p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(s=!0)}if(!(s||d&&Wt.safari)&&Kl(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Kl(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!d){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){const b=l;l=a,a=b}const p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,s=0;s<this.children.length;s++){const o=this.children[s],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){const l=n+o.border,a=i-o.border;if(e>=l&&t<=a){this.dirty=e==n||t==i?ir:ra,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=St:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?ir:St}n=i}this.dirty=ir}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const n=e==1?ir:ra;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class Os extends mn{constructor(t,n,s,o){super(t,[],n,o,null);B(this,"widget");this.widget=s,this.widget=s}matchesWidget(t){return this.dirty==it&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){const n=this.widget.spec.stopEvent;return n?n(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}get domAtom(){return!0}get side(){return this.widget.type.side}}class Ds extends mn{constructor(t,n,s,o,i){super(t,[],n,s,null);B(this,"textDOM");B(this,"text");this.textDOM=o,this.text=i}get size(){return this.text.length}localPosFromDOM(t,n){return t!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class dp extends mn{constructor(t,n,s,o,i,l,a){super(t,n,s,i,l);B(this,"mark");B(this,"spec");this.mark=o,this.spec=a}parseRule(){return this.dirty&St||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=St&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=it){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty<this.dirty&&(s.dirty=this.dirty),this.dirty=it}}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class sa extends mn{constructor(t,n,s,o,i,l,a,c,u){super(t,n,s,a,c);B(this,"node");B(this,"outerDeco");B(this,"innerDeco");B(this,"nodeDOM");this.node=o,this.outerDeco=i,this.innerDeco=l,this.nodeDOM=u}parseRule(){if(this.node.type.spec.reparseInView)return null;const t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){const s=this.children[n];if(this.dom.contains(s.dom.parentNode)){t.contentElement=s.dom.parentNode;break}}t.contentElement||(t.getContent=()=>S.empty)}return t}matchesNode(t,n,s){return this.dirty==it&&t.eq(this.node)&&mp(n,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,n){}update(t,n,s,o){return this.dirty==St||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,s,o),!0)}updateInner(t,n,s,o){this.updateOuterDeco(n),this.node=t,this.innerDeco=s,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=it}updateOuterDeco(t){this.outerDeco=t}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}class fp extends sa{constructor(e,t,n,s,o,i,l,a){super(e,t,n,s,o,i,l,null,a)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,s){return this.dirty=it,!0}inParent(){const e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=St)}get domAtom(){return!1}}class gn extends mn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==it&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}let hp=class extends sa{constructor(t,n,s,o,i,l,a,c,u,d){super(t,n,s,o,i,l,a,c,u);B(this,"spec");this.spec=d}update(t,n,s,o){if(this.dirty==St)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){const i=this.spec.update(t,n,s);return i&&this.updateInner(t,n,s,o),i}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,n,s,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,n,s,o){this.spec.setSelection?this.spec.setSelection(t,n,s.root):super.setSelection(t,n,s,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}};class pp extends hp{updateChildren(e,t){}updateOuterDeco(e){this.outerDeco=e}destroy(){this.children=[],super.destroy()}}function mp(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function oa(r,e){var t,n;return(r==null?void 0:r.contentDOM)??((n=(t=e[0])==null?void 0:t.dom)==null?void 0:n.parentElement)??null}function Ts(r,e,t){const{view:n}=m.useContext(Lt),{parentRef:s,siblingsRef:o}=m.useContext(Ne),[i,l]=m.useState(null),[a,c]=m.useState(null),[u,d]=m.useState(null),f=m.useRef(),h=m.useRef([]),p=m.useCallback(k=>{if(!(n instanceof xt))return;const w=r.current;if(!w)return;const{node:N,getPos:O,decorations:M,innerDecorations:T}=k,I=e(N,n,O,M,T);if(!I)return;const D=s.current,X=h.current,F=oa(I,X),ae=I.dom,ar=new pp(D,X,O,N,M,T,w,F,ae,I);return l(w),d(F),c(ae),ar},[r,s,e,n]),b=m.useCallback(k=>{if(!(n instanceof xt))return!1;const w=f.current;if(!w)return!1;const N=r.current;if(!N||N!==w.dom||oa(w,w.children)!==w.contentDOM||!N.contains(w.nodeDOM))return!1;const{node:M,decorations:T,innerDecorations:I}=k;return w.matchesNode(M,T,I)||w.update(M,T,I,n)},[r,n]),y=m.useCallback(()=>{const k=f.current;if(!k)return;k.destroy();const w=o.current;if(w.includes(k)){const N=w.indexOf(k);w.splice(N,1)}l(null),d(null),c(null)},[o]);return ne(()=>{var M;b(t)||(y(),f.current=p(t));const k=f.current;if(!k)return;n.dom===k.dom&&n instanceof xt&&(n.docView=k);const w=s.current,N=o.current,O=h.current;k.parent=w,N.includes(k)||N.push(k),N.sort(wt);for(const T of O)if(T.parent=k,T instanceof Ds){const I=(M=k==null?void 0:k.contentDOM)==null?void 0:M.firstChild;if(!I)throw new Error("Started a composition but couldn't find the text node it belongs to.");let D=I;for(;D.firstChild;)D=D.firstChild;if(!D||!(D instanceof Text))throw new Error("Started a composition but couldn't find the text node it belongs to.");T.dom=I,T.textDOM=D,T.text=D.data,T.textDOM.pmViewDesc=T,n.input.compositionNodes.push(T)}}),ne(()=>()=>{y(),f.current=void 0},[y]),{childContextValue:m.useMemo(()=>({parentRef:f,siblingsRef:h}),[h,f]),dom:i,contentDOM:u,nodeDOM:a,ref:r}}function gp(r,e){return r.type.side-e.type.side}function yp(r,e,t,n){const s=e.locals(r);let o=0;if(s.length==0){for(let c=0;c<r.childCount;c++){const u=r.child(c);n(u,s,e.forChild(o,u),o,c),o+=u.nodeSize}return}let i=0;const l=[];let a=null;for(let c=0;;){if(i<s.length&&s[i].to==o){let p,b;for(;i<s.length&&s[i].to==o;){const y=s[i++];(y.widget||y.type instanceof $t)&&(p?(b||(b=[p])).push(y):p=y)}if(p)if(b){b.sort(gp);for(let y=0;y<b.length;y++)t(b[y],!(b[y].type instanceof $t),o,c+y,!!a)}else t(p,!(p.type instanceof $t),o,c,!!a)}let u,d;if(a)d=-1,u=a,a=null;else if(c<r.childCount)d=c,u=r.child(c++);else break;for(let p=0;p<l.length;p++)l[p].to<=o&&l.splice(p--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)l.push(s[i++]);let f=o+u.nodeSize;if(u.isText){let p=f;i<s.length&&s[i].from<p&&(p=s[i].from);for(let b=0;b<l.length;b++)l[b].to<p&&(p=l[b].to);p<f&&(a=u.cut(p-o),u=u.cut(0,p-o),f=p,d=-1)}const h=u.isInline&&!u.isLeaf?l.filter(p=>!p.inline):l.slice();n(u,h,e.forChild(o,u),o,d),o=f}}function ia(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const la=new Ye("@handlewithcare/react-prosemirror/reactKeys");function bp(){let r=!1;return new Oe({key:la,state:{init(e,t){const n={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((s,o)=>{const i=ia();return n.posToKey.set(o,i),n.keyToPos.set(i,o),!0}),n},apply(e,t,n,s){if(!e.docChanged||r)return t;const o={posToKey:new Map,keyToPos:new Map},i=Array.from(t.posToKey.entries()).sort((l,a)=>{let[c]=l,[u]=a;return c-u});for(const[l,a]of i){const{pos:c,deleted:u}=e.mapping.mapResult(l);u||(o.posToKey.set(c,a),o.keyToPos.set(a,c))}return s.doc.descendants((l,a)=>{if(o.posToKey.has(a))return!0;const c=ia();return o.posToKey.set(a,c),o.keyToPos.set(c,a),!0}),o}},props:{handleDOMEvents:{compositionstart:()=>{r=!0},compositionend:()=>{r=!1}}}})}function xp(){const{view:r}=m.useContext(Lt);return la.getState(r.state)}var aa={exports:{}};/*!
|
|
34
34
|
Copyright (c) 2018 Jed Watson.
|
|
35
35
|
Licensed under the MIT License (MIT), see
|
|
36
36
|
http://jedwatson.github.io/classnames
|
|
37
|
-
*/(function(r){(function(){var e={}.hasOwnProperty;function t(){for(var o="",i=0;i<arguments.length;i++){var l=arguments[i];l&&(o=s(o,n(l)))}return o}function n(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return t.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var i="";for(var l in o)e.call(o,l)&&o[l]&&(i=s(i,l));return i}function s(o,i){return i?o?o+" "+i:o+i:o}r.exports?(t.default=t,r.exports=t):window.classNames=t})()})(aa);var kp=aa.exports;const wp=Xa(kp);let ca=!1;function Sp(){if(ca)return;const r=console.error;console.error=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const[s,o,i]=t;typeof s=="string"&&s.includes("Invalid DOM property `%s`. Did you mean `%s`?")&&o==="STYLE"&&i==="style"||r(...t)},ca=!0}function Cp(r,e){return!("STYLE"in r)||typeof r.STYLE!="string"?!("STYLE"in e)||typeof e.STYLE!="string"?void 0:e.STYLE:!("STYLE"in e)||typeof e.STYLE!="string"?r.STYLE:`${r.STYLE.match(/;\s*$/)?r.STYLE:`${r.STYLE};`} ${e.STYLE}`}function ua(r,e){return{...r,...e,className:wp(r.className,e.className),STYLE:Cp(r,e),style:{...r.style,...e.style}}}function da(r){Sp();const e={};for(const[t,n]of Object.entries(r))switch(t.toLowerCase()){case"class":{e.className=n;break}case"style":{e.STYLE=n;break}case"autocapitalize":{e.autoCapitalize=n;break}case"contenteditable":{if(n===""||n==="true"){e.contentEditable=!0;break}if(n==="false"){e.contentEditable=!1;break}if(n==="plaintext-only"){e.contentEditable="plaintext-only";break}e.contentEditable=null;break}case"draggable":{e.draggable=n!=null;break}case"enterkeyhint":{e.enterKeyHint=n;break}case"for":{e.htmlFor=n;break}case"hidden":{e.hidden=n;break}case"inputmode":{e.inputMode=n;break}case"itemprop":{e.itemProp=n;break}case"spellcheck":{if(n===""||n==="true"){e.spellCheck=!0;break}if(n==="false"){e.spellCheck=!1;break}e.spellCheck=null;break}case"tabindex":{const s=parseInt(n,10);Number.isNaN(s)||(e.tabIndex=s);break}case"autocomplete":{e.autoComplete=n;break}case"autofocus":{e.autoFocus=n!=null;break}case"formaction":{e.formAction=n;break}case"formenctype":{e.formEnctype=n;break}case"formmethod":{e.formMethod=n;break}case"formnovalidate":{e.formNoValidate=n;break}case"formtarget":{e.formTarget=n;break}case"maxlength":{const s=parseInt(n,10);Number.isNaN(s)||(e.maxLength=n);break}case"minlength":{const s=parseInt(n,10);Number.isNaN(s)||(e.minLength=n);break}case"max":{const s=parseInt(n,10);Number.isNaN(s)||(e.max=n);break}case"min":{const s=parseInt(n,10);Number.isNaN(s)||(e.min=n);break}case"multiple":{e.multiple=n!=null;break}case"readonly":{e.readOnly=n!=null;break}case"required":{e.required=n!=null;break}case"size":{const s=parseInt(n,10);Number.isNaN(s)||(e.size=n);break}case"step":{if(n==="any"){e.step=n;break}const s=parseInt(n,10);!Number.isNaN(s)&&s>0&&(e.step=n);break}case"disabled":{e.disabled=n!=null;break}case"rows":{const s=parseInt(n,10);Number.isNaN(s)||(e.rows=n);break}default:{e[t]=n;break}}return e}function fa(r){if(!Array.isArray(r))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const e=r[1];let t=1;e&&typeof e=="object"&&e.nodeType==null&&!Array.isArray(e)&&(t=2);for(let n=t;n<r.length;n++){const s=r[n];if(s===0||fa(s))return!0}return!1}const As=m.memo(m.forwardRef(function(e,t){let{outputSpec:n,isMark:s,children:o,...i}=e;if(typeof n=="string")return m.createElement(m.Fragment,null,n);if(!Array.isArray(n))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const a=n[0].replace(" ",":"),c=n[1];let u={ref:t,...i},d=1;c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)&&(d=2,u=ua(da(c),u));const f=[];for(let h=d;h<n.length;h++){const p=n[h];if(p===0){if(h<n.length-1||h>d)throw new RangeError("Content hole must be the only child of its parent node");return m.createElement(a,u,o)}f.push(m.createElement(As,{outputSpec:p},o))}return s&&!fa(n)&&f.push(o),m.createElement(a,u,...f)})),ha=m.memo(m.forwardRef(function(e,t){let{mark:n,getPos:s,children:o}=e;const{siblingsRef:i,parentRef:l}=m.useContext(Ne),a=m.useRef(void 0),c=m.useRef([]),u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const d=m.useMemo(()=>{var h,p;return(p=(h=n.type.spec).toDOM)==null?void 0:p.call(h,n,!0)},[n]);if(!d)throw new Error(`Mark spec for ${n.type.name} is missing toDOM`);ne(()=>{const h=i.current;return()=>{if(a.current&&h.includes(a.current)){const p=h.indexOf(a.current);h.splice(p,1)}}},[i]),ne(()=>{if(!u.current)return;const h=c.current[0];a.current?(a.current.parent=l.current,a.current.spec.dom=a.current.dom=u.current,a.current.children=c.current,a.current.spec.contentDOM=a.current.contentDOM=(h==null?void 0:h.dom.parentElement)??u.current,a.current.mark=n):a.current=new dp(l.current,c.current,s,n,u.current,(h==null?void 0:h.dom.parentElement)??u.current,{dom:u.current,contentDOM:(h==null?void 0:h.dom.parentElement)??u.current}),i.current.includes(a.current)||i.current.push(a.current),i.current.sort(wt);for(const p of c.current)p.parent=a.current});const f=m.useMemo(()=>({parentRef:a,siblingsRef:c}),[c,a]);return m.createElement(As,{ref:u,outputSpec:d,isMark:!0},m.createElement(Ne.Provider,{value:f},o))}));function Mp(r){let{widget:e,getPos:t}=r;const{siblingsRef:n,parentRef:s}=m.useContext(Ne),o=m.useRef(null),i=m.useRef(null);return ne(()=>{const l=n.current;return()=>{if(o.current&&l.includes(o.current)){const a=l.indexOf(o.current);l.splice(a,1)}}},[n]),Ie(l=>{if(!i.current)return;const a=e.type.toDOM;let c=typeof a=="function"?a(l,t):a;if(!e.type.spec.raw){if(c.nodeType!=1){const u=document.createElement("span");u.appendChild(c),c=u}c.contentEditable="false",c.classList.add("ProseMirror-widget")}i.current.firstElementChild!==c&&i.current.replaceChildren(c)}),ne(()=>{i.current&&(o.current?(o.current.parent=s.current,o.current.widget=e,o.current.dom=i.current):o.current=new Es(s.current,t,e,i.current),n.current.includes(o.current)||n.current.push(o.current),n.current.sort(wt))}),m.createElement("span",{ref:i})}const vp=m.memo(function(e){let{constructor:t,node:n,getPos:s,innerDeco:o,outerDeco:i}=e;const l=m.useRef(null),a=m.useRef(null),c=m.useMemo(()=>({node:n,getPos:s,decorations:i,innerDecorations:o}),[n,s,i,o]),u=function(){var N,E;for(var y=arguments.length,x=new Array(y),k=0;k<y;k++)x[k]=arguments[k];const w=t(...x);if(!w||!w.dom){const M=(E=(N=n.type.spec).toDOM)==null?void 0:E.call(N,n);if(!M)throw new Error(`Node spec for ${n.type.name} is missing toDOM`);return ze.renderSpec(document,M,null)}return w},{childContextValue:d,contentDOM:f}=Ts(l,function(){var T,I,D,X;for(var y=arguments.length,x=new Array(y),k=0;k<y;k++)x[k]=arguments[k];const w=u(...x),N=w.contentDOM,E=w.dom,M=a.current??l.current;return M.appendChild(E),!N&&E instanceof HTMLElement&&E.tagName!=="BR"&&(E.hasAttribute("contenteditable")||(E.contentEditable="false"),n.type.spec.draggable&&(E.draggable=!0)),{...w,destroy(){w.destroy&&w.destroy(),M.removeChild(E)},selectNode:(T=w.selectNode)==null?void 0:T.bind(w),deselectNode:(I=w.deselectNode)==null?void 0:I.bind(w),stopEvent:(D=w.stopEvent)==null?void 0:D.bind(w),ignoreMutation:(X=w.ignoreMutation)==null?void 0:X.bind(w)}},c),h=n.isInline?"span":"div",p={ref:a},b=!n.isLeaf&&f?Re.createPortal(m.createElement(Ne.Provider,{value:d},m.createElement(zs,{getPos:s,node:n,innerDecorations:o})),f):null;return m.cloneElement(i.reduce(lr,m.createElement(h,p,b)),{ref:l})}),Np=m.forwardRef(function(e,t){let{nodeProps:{node:n},children:s,...o}=e;const i=m.useMemo(()=>{var l,a;return(a=(l=n.type.spec).toDOM)==null?void 0:a.call(l,n)},[n]);if(!i)throw new Error(`Node spec for ${n.type.name} is missing toDOM`);return m.createElement(As,{...o,outputSpec:i,ref:t},s)}),Op=m.createContext(null),Ep=m.createContext(null),pa=m.createContext(null),Dp=m.memo(function(e){let{component:t,outerDeco:n,getPos:s,node:o,innerDeco:i}=e;const[l,a]=m.useState(!1),[c,u]=m.useState(!1),d=m.useRef(null),f=m.useRef(null),h=m.useRef(null),p=m.useRef(null),b=m.useRef(null),y=m.useRef(null),x=m.useCallback((F,ae)=>(h.current=F,p.current=ae,a(!0),()=>{h.current=null,p.current=null,a(!1)}),[]),k=m.useCallback(F=>(b.current=F,()=>{b.current=null}),[]),w=m.useCallback(F=>(y.current=F,()=>(y.current=null,()=>{y.current=null})),[]),N=m.useMemo(()=>({node:o,getPos:s,decorations:n,innerDecorations:i}),[s,i,o,n]),{childContextValue:E,contentDOM:M,nodeDOM:T}=Ts(d,()=>(u(!1),{dom:f.current??d.current,update(){return!0},multiType:!0,selectNode(){const F=h.current;F&&F(),u(!0)},deselectNode(){const F=p.current;F&&F(),u(!1)},stopEvent(F){const ae=b.current;return ae?ae(F):!1},ignoreMutation(F){const ae=y.current;return ae?ae(F):!1}}),N),I={nodeProps:N,...!M&&!N.node.isText&&(T==null?void 0:T.nodeName)!=="BR"?{contentEditable:!1,suppressContentEditableWarning:!0}:null,...!l&&c?{className:"ProseMirror-selectednode"}:null,...!l&&c||o.type.spec.draggable?{draggable:!0}:null,ref:f},D=o.isLeaf?null:m.createElement(zs,{getPos:s,node:o,innerDecorations:i}),X=m.cloneElement(n.reduce(lr,m.createElement(t,I,D)),{ref:d});return m.createElement(Ep.Provider,{value:x},m.createElement(pa.Provider,{value:k},m.createElement(Op.Provider,{value:w},m.createElement(Ne.Provider,{value:E},X))))}),ma=m.memo(function(e){const{components:t,constructors:n}=m.useContext($l),s=t[e.node.type.name]??Np,o=n[e.node.type.name],i=m.useMemo(()=>o?function(a){return m.createElement(vp,{constructor:o,...a})}:function(a){return m.createElement(Dp,{component:s,...a})},[o,s]);return m.createElement(i,e)});function Tp(r){let{getPos:e}=r;const{siblingsRef:t,parentRef:n}=m.useContext(Ne),s=m.useRef(null),o=m.useRef(null),[i,l]=m.useState(!1);return ne(()=>{const a=t.current;return()=>{if(s.current&&a.includes(s.current)){const c=a.indexOf(s.current);a.splice(c,1)}}},[t]),ne(()=>{var c;const a=t.current[t.current.length-1];if((Wt.safari||Wt.chrome)&&((c=a==null?void 0:a.dom)==null?void 0:c.contentEditable)=="false"){l(!0);return}o.current&&(s.current?(s.current.parent=n.current,s.current.dom=o.current):s.current=new gn(n.current,[],e,o.current,null),t.current.includes(s.current)||t.current.push(s.current),t.current.sort(wt))}),i?m.createElement("img",{ref:o,className:"ProseMirror-separator"}):null}var Ps={exports:{}},Se={};/**
|
|
37
|
+
*/(function(r){(function(){var e={}.hasOwnProperty;function t(){for(var o="",i=0;i<arguments.length;i++){var l=arguments[i];l&&(o=s(o,n(l)))}return o}function n(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return t.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var i="";for(var l in o)e.call(o,l)&&o[l]&&(i=s(i,l));return i}function s(o,i){return i?o?o+" "+i:o+i:o}r.exports?(t.default=t,r.exports=t):window.classNames=t})()})(aa);var kp=aa.exports;const wp=Xa(kp);let ca=!1;function Sp(){if(ca)return;const r=console.error;console.error=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const[s,o,i]=t;typeof s=="string"&&s.includes("Invalid DOM property `%s`. Did you mean `%s`?")&&o==="STYLE"&&i==="style"||r(...t)},ca=!0}function Cp(r,e){return!("STYLE"in r)||typeof r.STYLE!="string"?!("STYLE"in e)||typeof e.STYLE!="string"?void 0:e.STYLE:!("STYLE"in e)||typeof e.STYLE!="string"?r.STYLE:`${r.STYLE.match(/;\s*$/)?r.STYLE:`${r.STYLE};`} ${e.STYLE}`}function ua(r,e){return{...r,...e,className:wp(r.className,e.className),STYLE:Cp(r,e),style:{...r.style,...e.style}}}function da(r){Sp();const e={};for(const[t,n]of Object.entries(r))switch(t.toLowerCase()){case"class":{e.className=n;break}case"style":{e.STYLE=n;break}case"autocapitalize":{e.autoCapitalize=n;break}case"contenteditable":{if(n===""||n==="true"){e.contentEditable=!0;break}if(n==="false"){e.contentEditable=!1;break}if(n==="plaintext-only"){e.contentEditable="plaintext-only";break}e.contentEditable=null;break}case"draggable":{e.draggable=n!=null;break}case"enterkeyhint":{e.enterKeyHint=n;break}case"for":{e.htmlFor=n;break}case"hidden":{e.hidden=n;break}case"inputmode":{e.inputMode=n;break}case"itemprop":{e.itemProp=n;break}case"spellcheck":{if(n===""||n==="true"){e.spellCheck=!0;break}if(n==="false"){e.spellCheck=!1;break}e.spellCheck=null;break}case"tabindex":{const s=parseInt(n,10);Number.isNaN(s)||(e.tabIndex=s);break}case"autocomplete":{e.autoComplete=n;break}case"autofocus":{e.autoFocus=n!=null;break}case"formaction":{e.formAction=n;break}case"formenctype":{e.formEnctype=n;break}case"formmethod":{e.formMethod=n;break}case"formnovalidate":{e.formNoValidate=n;break}case"formtarget":{e.formTarget=n;break}case"maxlength":{const s=parseInt(n,10);Number.isNaN(s)||(e.maxLength=n);break}case"minlength":{const s=parseInt(n,10);Number.isNaN(s)||(e.minLength=n);break}case"max":{const s=parseInt(n,10);Number.isNaN(s)||(e.max=n);break}case"min":{const s=parseInt(n,10);Number.isNaN(s)||(e.min=n);break}case"multiple":{e.multiple=n!=null;break}case"readonly":{e.readOnly=n!=null;break}case"required":{e.required=n!=null;break}case"size":{const s=parseInt(n,10);Number.isNaN(s)||(e.size=n);break}case"step":{if(n==="any"){e.step=n;break}const s=parseInt(n,10);!Number.isNaN(s)&&s>0&&(e.step=n);break}case"disabled":{e.disabled=n!=null;break}case"rows":{const s=parseInt(n,10);Number.isNaN(s)||(e.rows=n);break}default:{e[t]=n;break}}return e}function fa(r){if(!Array.isArray(r))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const e=r[1];let t=1;e&&typeof e=="object"&&e.nodeType==null&&!Array.isArray(e)&&(t=2);for(let n=t;n<r.length;n++){const s=r[n];if(s===0||fa(s))return!0}return!1}const As=m.memo(m.forwardRef(function(e,t){let{outputSpec:n,isMark:s,children:o,...i}=e;if(typeof n=="string")return m.createElement(m.Fragment,null,n);if(!Array.isArray(n))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const a=n[0].replace(" ",":"),c=n[1];let u={ref:t,...i},d=1;c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)&&(d=2,u=ua(da(c),u));const f=[];for(let h=d;h<n.length;h++){const p=n[h];if(p===0){if(h<n.length-1||h>d)throw new RangeError("Content hole must be the only child of its parent node");return m.createElement(a,u,o)}f.push(m.createElement(As,{outputSpec:p},o))}return s&&!fa(n)&&f.push(o),m.createElement(a,u,...f)})),ha=m.memo(m.forwardRef(function(e,t){let{mark:n,getPos:s,children:o}=e;const{siblingsRef:i,parentRef:l}=m.useContext(Ne),a=m.useRef(void 0),c=m.useRef([]),u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const d=m.useMemo(()=>{var h,p;return(p=(h=n.type.spec).toDOM)==null?void 0:p.call(h,n,!0)},[n]);if(!d)throw new Error(`Mark spec for ${n.type.name} is missing toDOM`);ne(()=>{const h=i.current;return()=>{if(a.current&&h.includes(a.current)){const p=h.indexOf(a.current);h.splice(p,1)}}},[i]),ne(()=>{if(!u.current)return;const h=c.current[0];a.current?(a.current.parent=l.current,a.current.spec.dom=a.current.dom=u.current,a.current.children=c.current,a.current.spec.contentDOM=a.current.contentDOM=(h==null?void 0:h.dom.parentElement)??u.current,a.current.mark=n):a.current=new dp(l.current,c.current,s,n,u.current,(h==null?void 0:h.dom.parentElement)??u.current,{dom:u.current,contentDOM:(h==null?void 0:h.dom.parentElement)??u.current}),i.current.includes(a.current)||i.current.push(a.current),i.current.sort(wt);for(const p of c.current)p.parent=a.current});const f=m.useMemo(()=>({parentRef:a,siblingsRef:c}),[c,a]);return m.createElement(As,{ref:u,outputSpec:d,isMark:!0},m.createElement(Ne.Provider,{value:f},o))}));function Mp(r){let{widget:e,getPos:t}=r;const{siblingsRef:n,parentRef:s}=m.useContext(Ne),o=m.useRef(null),i=m.useRef(null);return ne(()=>{const l=n.current;return()=>{if(o.current&&l.includes(o.current)){const a=l.indexOf(o.current);l.splice(a,1)}}},[n]),Ie(l=>{if(!i.current)return;const a=e.type.toDOM;let c=typeof a=="function"?a(l,t):a;if(!e.type.spec.raw){if(c.nodeType!=1){const u=document.createElement("span");u.appendChild(c),c=u}c.contentEditable="false",c.classList.add("ProseMirror-widget")}i.current.firstElementChild!==c&&i.current.replaceChildren(c)}),ne(()=>{i.current&&(o.current?(o.current.parent=s.current,o.current.widget=e,o.current.dom=i.current):o.current=new Os(s.current,t,e,i.current),n.current.includes(o.current)||n.current.push(o.current),n.current.sort(wt))}),m.createElement("span",{ref:i})}const vp=m.memo(function(e){let{constructor:t,node:n,getPos:s,innerDeco:o,outerDeco:i}=e;const l=m.useRef(null),a=m.useRef(null),c=m.useMemo(()=>({node:n,getPos:s,decorations:i,innerDecorations:o}),[n,s,i,o]),u=function(){var N,O;for(var y=arguments.length,x=new Array(y),k=0;k<y;k++)x[k]=arguments[k];const w=t(...x);if(!w||!w.dom){const M=(O=(N=n.type.spec).toDOM)==null?void 0:O.call(N,n);if(!M)throw new Error(`Node spec for ${n.type.name} is missing toDOM`);return ze.renderSpec(document,M,null)}return w},{childContextValue:d,contentDOM:f}=Ts(l,function(){var T,I,D,X;for(var y=arguments.length,x=new Array(y),k=0;k<y;k++)x[k]=arguments[k];const w=u(...x),N=w.contentDOM,O=w.dom,M=a.current??l.current;return M.appendChild(O),!N&&O instanceof HTMLElement&&O.tagName!=="BR"&&(O.hasAttribute("contenteditable")||(O.contentEditable="false"),n.type.spec.draggable&&(O.draggable=!0)),{...w,destroy(){w.destroy&&w.destroy(),M.removeChild(O)},selectNode:(T=w.selectNode)==null?void 0:T.bind(w),deselectNode:(I=w.deselectNode)==null?void 0:I.bind(w),stopEvent:(D=w.stopEvent)==null?void 0:D.bind(w),ignoreMutation:(X=w.ignoreMutation)==null?void 0:X.bind(w)}},c),h=n.isInline?"span":"div",p={ref:a},b=!n.isLeaf&&f?Re.createPortal(m.createElement(Ne.Provider,{value:d},m.createElement(zs,{getPos:s,node:n,innerDecorations:o})),f):null;return m.cloneElement(i.reduce(lr,m.createElement(h,p,b)),{ref:l})}),Np=m.forwardRef(function(e,t){let{nodeProps:{node:n},children:s,...o}=e;const i=m.useMemo(()=>{var l,a;return(a=(l=n.type.spec).toDOM)==null?void 0:a.call(l,n)},[n]);if(!i)throw new Error(`Node spec for ${n.type.name} is missing toDOM`);return m.createElement(As,{...o,outputSpec:i,ref:t},s)}),Ep=m.createContext(null),Op=m.createContext(null),pa=m.createContext(null),Dp=m.memo(function(e){let{component:t,outerDeco:n,getPos:s,node:o,innerDeco:i}=e;const[l,a]=m.useState(!1),[c,u]=m.useState(!1),d=m.useRef(null),f=m.useRef(null),h=m.useRef(null),p=m.useRef(null),b=m.useRef(null),y=m.useRef(null),x=m.useCallback((F,ae)=>(h.current=F,p.current=ae,a(!0),()=>{h.current=null,p.current=null,a(!1)}),[]),k=m.useCallback(F=>(b.current=F,()=>{b.current=null}),[]),w=m.useCallback(F=>(y.current=F,()=>(y.current=null,()=>{y.current=null})),[]),N=m.useMemo(()=>({node:o,getPos:s,decorations:n,innerDecorations:i}),[s,i,o,n]),{childContextValue:O,contentDOM:M,nodeDOM:T}=Ts(d,()=>(u(!1),{dom:f.current??d.current,update(){return!0},multiType:!0,selectNode(){const F=h.current;F&&F(),u(!0)},deselectNode(){const F=p.current;F&&F(),u(!1)},stopEvent(F){const ae=b.current;return ae?ae(F):!1},ignoreMutation(F){const ae=y.current;return ae?ae(F):!1}}),N),I={nodeProps:N,...!M&&!N.node.isText&&(T==null?void 0:T.nodeName)!=="BR"?{contentEditable:!1,suppressContentEditableWarning:!0}:null,...!l&&c?{className:"ProseMirror-selectednode"}:null,...!l&&c||o.type.spec.draggable?{draggable:!0}:null,ref:f},D=o.isLeaf?null:m.createElement(zs,{getPos:s,node:o,innerDecorations:i}),X=m.cloneElement(n.reduce(lr,m.createElement(t,I,D)),{ref:d});return m.createElement(Op.Provider,{value:x},m.createElement(pa.Provider,{value:k},m.createElement(Ep.Provider,{value:w},m.createElement(Ne.Provider,{value:O},X))))}),ma=m.memo(function(e){const{components:t,constructors:n}=m.useContext($l),s=t[e.node.type.name]??Np,o=n[e.node.type.name],i=m.useMemo(()=>o?function(a){return m.createElement(vp,{constructor:o,...a})}:function(a){return m.createElement(Dp,{component:s,...a})},[o,s]);return m.createElement(i,e)});function Tp(r){let{getPos:e}=r;const{siblingsRef:t,parentRef:n}=m.useContext(Ne),s=m.useRef(null),o=m.useRef(null),[i,l]=m.useState(!1);return ne(()=>{const a=t.current;return()=>{if(s.current&&a.includes(s.current)){const c=a.indexOf(s.current);a.splice(c,1)}}},[t]),ne(()=>{var c;const a=t.current[t.current.length-1];if((Wt.safari||Wt.chrome)&&((c=a==null?void 0:a.dom)==null?void 0:c.contentEditable)=="false"){l(!0);return}o.current&&(s.current?(s.current.parent=n.current,s.current.dom=o.current):s.current=new gn(n.current,[],e,o.current,null),t.current.includes(s.current)||t.current.push(s.current),t.current.sort(wt))}),i?m.createElement("img",{ref:o,className:"ProseMirror-separator"}):null}var Ps={exports:{}},Se={};/**
|
|
38
38
|
* @license React
|
|
39
39
|
* react-reconciler-reflection.production.js
|
|
40
40
|
*
|
|
@@ -50,5 +50,5 @@ React keys must be passed directly to JSX without using spread:
|
|
|
50
50
|
*
|
|
51
51
|
* This source code is licensed under the MIT license found in the
|
|
52
52
|
* LICENSE file in the root directory of this source tree.
|
|
53
|
-
*/var ya;function Pp(){return ya||(ya=1,process.env.NODE_ENV!=="production"&&function(){function r(o){var i=o,l=o;if(o.alternate)for(;i.return;)i=i.return;else{o=i;do i=o,i.flags&4098&&(l=i.return),o=i.return;while(o)}return i.tag===3?l:null}function e(o){if(r(o)!==o)throw Error("Unable to find node on an unmounted component.")}function t(o){var i=o.alternate;if(!i){if(i=r(o),i===null)throw Error("Unable to find node on an unmounted component.");return i!==o?null:o}for(var l=o,a=i;;){var c=l.return;if(c===null)break;var u=c.alternate;if(u===null){if(a=c.return,a!==null){l=a;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===l)return e(c),o;if(u===a)return e(c),i;u=u.sibling}throw Error("Unable to find node on an unmounted component.")}if(l.return!==a.return)l=c,a=u;else{for(var d=!1,f=c.child;f;){if(f===l){d=!0,l=c,a=u;break}if(f===a){d=!0,a=c,l=u;break}f=f.sibling}if(!d){for(f=u.child;f;){if(f===l){d=!0,l=u,a=c;break}if(f===a){d=!0,a=u,l=c;break}f=f.sibling}if(!d)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(l.alternate!==a)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(l.tag!==3)throw Error("Unable to find node on an unmounted component.");return l.stateNode.current===l?o:i}function n(o){var i=o.tag;if(i===5||i===26||i===27||i===6)return o;for(o=o.child;o!==null;){if(i=n(o),i!==null)return i;o=o.sibling}return null}function s(o){var i=o.tag;if(i===5||i===26||i===27||i===6)return o;for(o=o.child;o!==null;){if(o.tag!==4&&(i=s(o),i!==null))return i;o=o.sibling}return null}Ce.doesFiberContain=function(o,i){for(var l=o.alternate;i!==null;){if(i===o||i===l)return!0;i=i.return}return!1},Ce.findCurrentFiberUsingSlowPath=t,Ce.findCurrentHostFiber=function(o){return o=t(o),o!==null?n(o):null},Ce.findCurrentHostFiberWithNoPortals=function(o){return o=t(o),o!==null?s(o):null},Ce.getContainerFromFiber=function(o){return o.tag===3?o.stateNode.containerInfo:null},Ce.getNearestMountedFiber=r,Ce.getSuspenseInstanceFromFiber=function(o){if(o.tag===13){var i=o.memoizedState;if(i===null&&(o=o.alternate,o!==null&&(i=o.memoizedState)),i!==null)return i.dehydrated}return null},Ce.isFiberMounted=function(o){return r(o)===o},Ce.isFiberSuspenseAndTimedOut=function(o){var i=o.memoizedState;return o.tag===13&&i!==null&&i.dehydrated===null},Ce.isMounted=function(o){return(o=o._reactInternals)?r(o)===o:!1}}()),Ce}process.env.NODE_ENV==="production"?Ps.exports=Ap():Ps.exports=Pp();var Ip=Ps.exports;function Vp(r){return r._reactInternals}function cg(r){return r}function Rp(r){const e=Vp(r);if(e===void 0){if(typeof r.render=="function")throw new Error("Unable to find node on an unmounted component.");{const n=Object.keys(r).join(",");throw new Error(`Argument appears to not be a ReactComponent. Keys: ${n}`)}}const t=Ip.findCurrentHostFiber(e);return t===null?null:t.stateNode}function zp(r){return Rp(r)}function jp(r,e){if(r===e)return!0;if(!r||!e)return!1;const t=Object.keys(r),n=Object.keys(e),s=t.length;if(n.length!==s)return!1;for(let o=0;o<s;o++){const i=t[o];if(r[i]!==e[i]||!Object.prototype.hasOwnProperty.call(e,i))return!1}return!0}class Bp extends m.Component{constructor(){super(...arguments);B(this,"viewDescRef",null);B(this,"renderRef",null)}updateEffect(){const{view:t,decorations:n,siblingsRef:s,parentRef:o,getPos:i,node:l}=this.props,a=zp(this);if(!a){if(!t.composing)return;this.viewDescRef=new Ds(o.current,i,document.createElement("div"),document.createTextNode(l.text??""),l.text??"");return}let c=a;for(;c.firstChild;)c=c.firstChild;!this.viewDescRef||this.viewDescRef instanceof Ds?this.viewDescRef=new fp(void 0,[],i,l,n,j.empty,a,c):(this.viewDescRef.parent=o.current,this.viewDescRef.children=[],this.viewDescRef.node=l,this.viewDescRef.outerDeco=n,this.viewDescRef.innerDeco=j.empty,this.viewDescRef.dom=a,this.viewDescRef.dom.pmViewDesc=this.viewDescRef,this.viewDescRef.nodeDOM=c),s.current.includes(this.viewDescRef)||s.current.push(this.viewDescRef),s.current.sort(wt)}shouldComponentUpdate(t){return!jp(this.props,t)}componentDidMount(){this.updateEffect()}componentDidUpdate(){this.updateEffect()}componentWillUnmount(){const{siblingsRef:t}=this.props;if(this.viewDescRef&&t.current.includes(this.viewDescRef)){const n=t.current.indexOf(this.viewDescRef);t.current.splice(n,1)}}render(){const{view:t,getPos:n,node:s,decorations:o}=this.props;return t.composing&&t.state.selection.from>=n()&&t.state.selection.from<=n()+s.nodeSize?this.renderRef:(this.renderRef=o.reduce(lr,s.text),this.renderRef)}}function Fp(r){let{getPos:e}=r;const{siblingsRef:t,parentRef:n}=m.useContext(Ne),s=m.useRef(null),o=m.useRef(null);return ne(()=>{const i=t.current;return()=>{if(s.current&&i.includes(s.current)){const l=i.indexOf(s.current);i.splice(l,1)}}},[t]),ne(()=>{o.current&&(s.current?(s.current.parent=n.current,s.current.dom=o.current):s.current=new gn(n.current,[],e,o.current,null),t.current.includes(s.current)||t.current.push(s.current),t.current.sort(wt))}),m.createElement("br",{ref:o,className:"ProseMirror-trailingBreak"})}function Lp(r){let{widget:e,getPos:t}=r;const{siblingsRef:n,parentRef:s}=m.useContext(Ne),o=m.useRef(null),i=m.useRef(null);ne(()=>{const a=n.current;return()=>{if(o.current&&a.includes(o.current)){const c=a.indexOf(o.current);a.splice(c,1)}}},[n]),ne(()=>{i.current&&(o.current?(o.current.parent=s.current,o.current.widget=e,o.current.dom=i.current):o.current=new Es(s.current,t,e,i.current),n.current.includes(o.current)||n.current.push(o.current),n.current.sort(wt))});const{Component:l}=e.type;return l&&m.createElement(l,{ref:i,widget:e,getPos:t,contentEditable:!1})}function lr(r,e){const{nodeName:t,...n}=e.type.attrs,s=da(n);return t||typeof r=="string"?m.createElement(t??"span",s,r):m.cloneElement(r,ua(r.props,s))}function Is(r,e){var t,n,s;return r.type===e.type&&r.marks.every(o=>o.isInSet(e.marks))&&e.marks.every(o=>o.isInSet(r.marks))&&r.key===e.key&&(r.type==="node"?((t=r.outerDeco)==null?void 0:t.length)===((n=e.outerDeco)==null?void 0:n.length)&&((s=r.outerDeco)==null?void 0:s.every(o=>{var i;return(i=e.outerDeco)==null?void 0:i.some(l=>o.from===l.from&&o.to&&l.to&&o.type.eq(l.type))}))&&r.innerDeco.eq(e.innerDeco):!0)&&r.node===e.node&&r.widget===e.widget}const $p=m.memo(function(e){let{child:t,getInnerPos:n}=e;const{view:s}=m.useContext(Lt),o=m.useRef(t);o.current=t;const i=m.useCallback(()=>n()+o.current.offset,[n]);return t.type==="widget"?m.createElement(Lp,{key:t.key,widget:t.widget,getPos:i}):t.type==="native-widget"?m.createElement(Mp,{key:t.key,widget:t.widget,getPos:i}):t.type==="hack"?m.createElement(t.component,{key:t.key,getPos:i}):t.node.isText?m.createElement(Ne.Consumer,{key:t.key},l=>{let{siblingsRef:a,parentRef:c}=l;return m.createElement(Bp,{view:s,node:t.node,getPos:i,siblingsRef:a,parentRef:c,decorations:t.outerDeco})}):m.createElement(ma,{key:t.key,node:t.node,getPos:i,outerDeco:t.outerDeco,innerDeco:t.innerDeco})}),Wp=m.memo(function(e){let{childViews:t,getInnerPos:n}=e;const s=t[0],o=m.useRef(s);o.current=s;const i=m.useCallback(()=>n()+o.current.offset,[n]),l=s.marks[0];return l?m.createElement(ha,{key:s.key,mark:l,getPos:i},m.createElement(Vs,{key:s.key,getInnerPos:n,childViews:t.map(a=>({...a,marks:a.marks.slice(1)}))})):m.createElement(m.Fragment,null,t.map(a=>m.createElement($p,{key:a.key,child:a,getInnerPos:n})))}),Vs=m.memo(function(e){let{getInnerPos:t,childViews:n}=e;const s=n.reduce((o,i)=>{var c;const l=o[o.length-1];if(!l)return[[i]];const a=l[l.length-1];return a?!i.marks.length&&!a.marks.length||i.marks.length&&a.marks.length&&((c=i.marks[0])!=null&&c.eq(a.marks[0]))?[...o.slice(0,o.length-1),[...l.slice(0,l.length),i]]:[...o,[i]]:[...o.slice(0,o.length),[i]]},[]);return m.createElement(m.Fragment,null,s.map(o=>{const i=o[0];return i?m.createElement(Wp,{key:i.key,childViews:o,getInnerPos:t}):null}))});function Rs(r,e,t,n,s,o){const i=r+e,l=s==null?void 0:s.get(i);if(n==="widget"||n==="native-widget")return o.type.spec.key?o.type.spec.key:(n==="widget"&&console.warn(`Widget at position ${i} doesn't have a key specified. React ProseMirror will generate a key partially based on this widget’s index into its parent’s children. This can cause issues if there are multiple adjacent widgets.`),`${l}-${t}`);if(l)return l;const a=r-1,c=s==null?void 0:s.get(a);return c?`${c}-${e}`:i}function _p(r,e){if(!e||e.widget.type.side>=0||!r||!r.node.isInline)return;const t=r.marks;e.marks=e.marks.reduce((n,s)=>s.addToSet(n),t)}function qp(r,e){if(!e.node.isInline)return;const t=e.marks;for(let n=r.length-1;n>=0;n--){const s=r[n];s.widget.type.side<0||(s.marks=s.marks.reduce((o,i)=>i.addToSet(o),t))}}const Jp=m.memo(function(e){let{child:t,getInnerPos:n}=e;const s=m.useRef(t);s.current=t;const o=m.useCallback(()=>n()+s.current.offset,[n]);return t.type==="node"?t.marks.reduce((i,l)=>m.createElement(ha,{mark:l,getPos:o},i),m.createElement(ma,{key:t.key,outerDeco:t.outerDeco,node:t.node,innerDeco:t.innerDeco,getPos:o})):m.createElement(Vs,{key:t.key,childViews:[t],getInnerPos:n})});function Hp(r,e){return r.length?r.every(t=>t.type!=="node"||t.node.isInline)?[m.createElement(Vs,{key:r[0].key,childViews:r,getInnerPos:e})]:r.map(t=>m.createElement(Jp,{key:t.key,child:t,getInnerPos:e})):[]}const zs=m.memo(function(e){let{getPos:t,node:n,innerDecorations:s}=e;const o=xp(),i=m.useCallback(()=>t()+1,[t]),l=m.useRef(new Map).current;if(!n)return null;const a=new Map;let c=[],u=null;yp(n,s,(h,p,b,y)=>{const x=h.type.spec.marks??[];let k;if(p){k=Rs(i(),b,y,"native-widget",o==null?void 0:o.posToKey,h);const N={type:"native-widget",widget:h,marks:x,offset:b,index:y,key:k},E=l.get(k);E&&Is(E,N)?E.offset=b:l.set(k,N),a.set(k,a.size)}else{k=Rs(i(),b,y,"widget",o==null?void 0:o.posToKey,h);const N={type:"widget",widget:h,marks:x,offset:b,index:y,key:k},E=l.get(k);E&&Is(E,N)?E.offset=b:l.set(k,N),a.set(k,a.size)}const w=l.get(k);c.push(w),_p(u,l.get(k))},(h,p,b,y,x)=>{const k=Rs(i(),y,x,"node",o==null?void 0:o.posToKey),w={type:"node",node:h,marks:h.marks,innerDeco:b,outerDeco:p,offset:y,index:x,key:k},N=l.get(k);N&&Is(N,w)?(N.offset=y,u=N):(l.set(k,w),u=w),a.set(k,a.size),qp(c,u),c=[]});for(const h of l.keys())a.has(h)||l.delete(h);const d=Array.from(l.values()).sort((h,p)=>a.get(h.key)-a.get(p.key));if(n.isTextblock){const h=d[d.length-1];(!h||h.type!=="node"||h.node.isInline&&!h.node.isText||/\n$/.test(h.node.text))&&d.push({type:"hack",component:Tp,marks:[],offset:(h==null?void 0:h.offset)??0,index:((h==null?void 0:h.index)??0)+2,key:"trailing-hack-img"},{type:"hack",component:Fp,marks:[],offset:(h==null?void 0:h.offset)??0,index:((h==null?void 0:h.index)??0)+1,key:"trailing-hack-br"})}const f=Hp(d,i);return m.createElement(m.Fragment,null,f)}),Kp=m.memo(m.forwardRef(function(e,t){let{as:n,node:s,getPos:o,decorations:i,innerDecorations:l,setMount:a,...c}=e;const u=m.useRef(null);m.useImperativeHandle(t,()=>u.current),m.useImperativeHandle(a,()=>u.current);const d=m.useMemo(()=>({node:s,getPos:o,decorations:i,innerDecorations:l}),[s,o,i,l]),{childContextValue:f}=Ts(u,()=>{const y=u.current;return{dom:y,contentDOM:y,update(){return!0}}},d),h=m.createElement(Ne.Provider,{value:f},m.createElement(zs,{getPos:o,node:s,innerDecorations:l})),p={...c,suppressContentEditableWarning:!0,ref:u},b=n?m.cloneElement(n,p,h):m.createElement("div",p,h);return d.decorations.reduce(lr,b)})),ba=m.createContext(null),xa=m.forwardRef(function(e,t){let{as:n,...s}=e;const o=m.useContext(ba);return m.createElement(Kp,{ref:t,...s,...o,as:n})});function Yp(){return-1}function Gp(r){let{className:e,children:t,nodeViews:n,customNodeViews:s,...o}=r;const[i,l]=m.useState(null),{editor:a,state:c}=ap(i,{...o,nodeViews:s}),u=a.view.nodeViews,d=m.useMemo(()=>({components:{...n},constructors:u}),[u,n]),f=c.doc,h=Jh(a.view),p=Gh(a.view,a.cursorWrapper),b=m.useMemo(()=>({className:e,setMount:l,node:f,getPos:Yp,decorations:h,innerDecorations:p}),[e,f,h,p]);return m.createElement(Lt.Provider,{value:a},m.createElement(qh.Provider,{value:c},m.createElement($l.Provider,{value:d},m.createElement(ba.Provider,{value:b},t))))}function ka(r){return m.createElement(cp,null,m.createElement(Gp,r))}function Xp(r){if(!(r instanceof xt))throw new DOMException("ProseMirror document is not mounted","InvalidStateError")}function re(r){const e=m.useRef(r),{view:t}=m.useContext(Lt);return Ie(()=>{e.current=r},[r]),m.useCallback(function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];return Xp(t),e.current(t,...s)},[t])}function wa(r){const e=m.useContext(pa),t=re(r);Ie(()=>e(t),[e,t])}const Sa=r=>[_h(),Tr({Tab:Rl(1),"Shift-Tab":Rl(-1)}),Yf(r.schema),Tr(Wf(r.schema)),Tr(vu),Nu({color:"#F00",width:2}),ff(),lu(),Gf(r),bp()],Qp=["p",0],Up=["blockquote",0],Zp=["hr"],em=["pre",["code",0]],tm=["br"],nm={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Qp}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return Up}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Zp}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(r){return["h"+r.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return em}},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(r){return{src:r.getAttribute("src"),title:r.getAttribute("title"),alt:r.getAttribute("alt")}}}],toDOM(r){let{src:e,alt:t,title:n}=r.attrs;return["img",{src:e,alt:t,title:n}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return tm}}},rm=["em",0],sm=["strong",0],om=["code",0],im={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(r){return{href:r.getAttribute("href"),title:r.getAttribute("title")}}}],toDOM(r){let{href:e,title:t}=r.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:r=>r.type.name=="em"}],toDOM(){return rm}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:r=>r.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:r=>r.type.name=="strong"},{style:"font-weight",getAttrs:r=>/^(bold(er)?|[5-9]\d{2,})$/.test(r)&&null}],toDOM(){return sm}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return om}}},Ca=new Pn({nodes:nm,marks:im}),Ma=Ca.spec.marks.append({underline:{parseDOM:[{tag:"u"},{style:"font-style=underline"}],toDOM(){return["u",0]}},strikethrough:{parseDOM:[{tag:"s"},{style:"font-style=strike"},{style:"font-style=strikethrough"}],toDOM(){return["s",0]}}});let _t="",va="",Na="",Ct="",yn="";const lm=r=>{_t=r.api_url??_t,va=r.video_image??va,Na=r.empty_image??Na,Ct=r.error_image??Ct,yn=r.error_embed??yn},bn=(r,e)=>{try{const t=new URL(r);if(t.hostname!=="vkvideo.ru"&&t.hostname!=="vk.com"&&t.hostname!=="vk.ru")throw new Error;let n,s;if(t.pathname==="/video_ext.php")n=t.searchParams.get("id"),s=t.searchParams.get("oid");else if(t.pathname.startsWith("/video"))[s,n]=t.pathname.slice(6).split("_");else throw new Error;if(!n||!s)throw new Error;return e?`https://vkvideo.ru/video_ext.php?oid=${s}&id=${n}&hd=2`:!0}catch{return e?"":!1}},xn=(r,e)=>{try{const t=new URL(r);if(t.hostname!=="rutube.ru")throw new Error;let n;if(t.pathname.startsWith("/video/"))n=t.pathname.split("/")[2];else if(t.pathname.startsWith("/play/embed/"))n=t.pathname.split("/")[3];else throw new Error;if(!n)throw new Error;return e?`https://rutube.ru/play/embed/${n}`:!0}catch{return e?"":!1}},kn=(r,e)=>{try{const t=new URL(r);if(t.hostname!=="youtube.com"&&t.hostname!=="www.youtube.com"&&t.hostname!=="youtu.be")throw new Error;if(t.hostname==="youtu.be")return e?`https://youtube.com/embed${t.pathname}`:!0;let n;if(t.pathname==="/watch")n=t.searchParams.get("v");else if(t.pathname.startsWith("/live/"))n=t.pathname.split("/")[2];else if(t.pathname.startsWith("/embed/"))n=t.pathname.split("/")[2];else throw new Error;if(!n)throw new Error;return e?`https://youtube.com/embed/${n}`:!0}catch{return e?"":!1}},js=r=>{try{const e=new URL(r);switch(e.hostname){case"vkvideo.ru":case"vk.com":case"vk.ru":return bn(e,!0)+"";case"rutube.ru":return xn(e,!0)+"";case"youtube.com":case"www.youtube.com":case"youtu.be":return kn(e,!0)+"";default:throw new Error}}catch{return""}},am={atom:!0,attrs:{fid:{default:null,validate:"string|null|number"},src:{default:null,validate:"string|null"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"block",parseDOM:[{tag:"img[src]",getAttrs(r){let e=r.getAttribute("src");return e||(e=Ct),e.startsWith("data:")&&(e=Ct),{src:e,fid:r.getAttribute("fid"),alt:r.getAttribute("alt"),title:r.getAttribute("title")}}}],toDOM(r){let{fid:e,src:t,alt:n,title:s}=r.attrs;return e&&(t=`${_t}/${e}`),t||(t=Ct),["div",{title:s,class:"image"},["img",{fid:e,src:t,alt:n,title:s}]]}},cm={atom:!0,attrs:{title:{default:null,validate:"string|null"},src:{validate:r=>{if(typeof r!="string"){if(Array.isArray(r)){r.forEach(e=>{if(typeof e!="string")throw new Error("One of the video sources is not a string")});return}throw new Error("Video source must be a string or array of strings")}}}},group:"block",parseDOM:[{tag:"iframe[src]",getAttrs(r){return{src:r.getAttribute("src"),title:r.getAttribute("title")}}}],toDOM(r){const{src:e,title:t}=r.attrs,n="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",s=Array.isArray(e)?e[0]:e;return js(s)?["div",{title:t,class:"video"},["iframe",{src:s,title:t,allow:n}]]:["div",{title:t,class:"image"},["img",{src:yn}]]}},um={content:"inline*",group:"block",attrs:{align:{default:null,validate:"string|null"}},parseDOM:[{tag:"p",getAttrs(r){let e=r.getAttribute("align");return e!=="right"&&e!=="center"&&e!=="justify"&&(e=null),{align:e}}}],toDOM(r){const{align:e}=r.attrs;return["p",{align:e},0]}},dm={attrs:{level:{default:1,validate:"number"}},content:"inline*",marks:"underline strikethrough",group:"block",parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(r){return["h"+r.attrs.level,0]}},fm={atom:!0,content:"image*",group:"block",toDOM(){return["div",{class:"carousel"},0]}},Oa=Ca.spec.nodes.remove("image").append({image:am,video:cm}),wn=new Pn({nodes:Oa.remove("horizontal_rule").remove("heading"),marks:Ma}),hm=Oa.remove("heading").remove("paragraph").prepend({paragraph:um}).append({heading:dm}).append({carousel:fm}).append(sh({tableGroup:"block",cellContent:"(paragraph | ordered_list | bullet_list)+",cellAttributes:{halign:{default:null,getFromDOM(r){const e=r.getAttribute("align")||null;return e==="left"||e==="right"||e==="center"?e:null},setDOMAttr(r,e){r&&(e.style=(e.style||"")+`text-align: ${r};`)}},valign:{default:null,getFromDOM(r){const e=r.style.verticalAlign||null;return e==="top"||e==="bottom"||e==="middle"?e:null},setDOMAttr(r,e){r&&(e.style=(e.style||"")+`vertical-align: ${r};`)}}}})),_e=new Pn({nodes:Cf(hm,"(paragraph | ordered_list | bullet_list)+","block"),marks:Ma}),pm=r=>{if(r)try{const e=pe.fromJSON(_e,JSON.parse(r)),t=ze.fromSchema(_e).serializeFragment(e.content);return In.fromSchema(wn).parse(t)}catch(e){console.error(`Can not convert content to simple schema: ${e}`)}},Sn=({ref:r,item:e})=>{const[t,n]=m.useState(!0),[s,o]=m.useState(!1),[i,l]=m.useState(!1);Ie(c=>{c&&(n(e.isActive&&e.isActive(c.state)),l(e.isSelected&&!e.isSelected(c.state)),e.isDisabled?o(e.isDisabled(c.state)):o(!e.command(c.state)))});const a=re(c=>{c&&(s||e.command(c.state,c.dispatch,c),c.focus())});return i?null:g.jsx("div",{ref:r,className:`MenuItem ${t?"active":""} ${s?"disabled":""}`,onClick:c=>{c.stopPropagation(),c.preventDefault(),a()},children:e.icon})},Ea=({schema:r})=>{const[e,t]=m.useState(void 0),[n,s]=m.useState(void 0);return m.useEffect(()=>{if(t(void 0),s(void 0),r.nodes.paragraph){const o=r.nodes.paragraph;t({icon:g.jsx(v.Icons.Type,{}),command:At(o)})}if(r.nodes.code_block){const o=r.nodes.code_block;s({icon:g.jsx(v.Icons.CodeXml,{}),command:At(o)})}},[r]),g.jsxs(g.Fragment,{children:[e&&g.jsx(Sn,{item:e}),n&&g.jsx(Sn,{item:n})]})},Cn=({items:r})=>g.jsx("div",{className:"MenuBlock",children:r.map((e,t)=>g.jsx(Sn,{item:e},t))}),mm=({schema:r,isOpen:e,onClose:t})=>{const n=re((s,o)=>{s&&(ye(r.marks.link,{href:o})(s.state,s.dispatch),t(),s.focus())});return g.jsx(v.Prompt,{title:"Введите URL для ссылки",isOpen:e,onCancel:t,onSubmit:n})},Da=({schema:r})=>{const[e,t]=m.useState([]),[n,s]=m.useState(!1);return m.useEffect(()=>{const o=[];if(r.marks.strong){const i=r.marks.strong;o.push({icon:g.jsx(v.Icons.Bold,{}),command:ye(i),isActive:l=>Mt(l,i)})}if(r.marks.em){const i=r.marks.em;o.push({icon:g.jsx(v.Icons.Italic,{}),command:ye(i),isActive:l=>Mt(l,i)})}if(r.marks.underline){const i=r.marks.underline;o.push({icon:g.jsx(v.Icons.Underline,{}),command:ye(i),isActive:l=>Mt(l,i)})}if(r.marks.strikethrough){const i=r.marks.strikethrough;o.push({icon:g.jsx(v.Icons.Strikethrough,{}),command:ye(i),isActive:l=>Mt(l,i)})}if(r.marks.code){const i=r.marks.code;o.push({icon:g.jsx(v.Icons.Code,{}),command:ye(i),isActive:l=>Mt(l,i)})}if(r.marks.link){const i=r.marks.link;o.push({icon:g.jsx(v.Icons.Link,{}),isActive:l=>Mt(l,i),isDisabled:l=>l.selection.empty?!0:!ye(i)(l),command:(l,a,c)=>(Mt(l,i)?(ye(i)(l,a),c==null||c.focus()):s(!0),!0)})}t(o)},[r]),e.length<1?null:g.jsxs(g.Fragment,{children:[g.jsx(Cn,{items:e}),g.jsx(mm,{isOpen:n,schema:r,onClose:()=>s(!1)})]})};function Mt(r,e){let{from:t,$from:n,to:s,empty:o}=r.selection;return o?!!e.isInSet(r.storedMarks||n.marks()):r.doc.rangeHasMark(t,s,e)}const Ta=()=>g.jsxs("div",{className:"MenuBlock",children:[g.jsx(Sn,{item:{icon:g.jsx(v.Icons.Undo,{}),command:Vr}}),g.jsx(Sn,{item:{icon:g.jsx(v.Icons.Redo,{}),command:Wn}})]}),Aa=({schema:r})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{const n=[];if(r.nodes.bullet_list){const s=r.nodes.bullet_list;n.push({icon:g.jsx(v.Icons.List,{}),command:(o,i)=>Zn(s)(o,i)})}if(r.nodes.ordered_list){const s=r.nodes.ordered_list;n.push({icon:g.jsx(v.Icons.ListOrdered,{}),command:(o,i)=>Zn(s)(o,i)})}if(r.nodes.blockquote){const s=r.nodes.blockquote;n.push({icon:g.jsx(v.Icons.Quote,{}),command:(o,i)=>oi(s)(o,i)})}t(n)},[r]),e.length<1?null:g.jsx(Cn,{items:e})},Pa=({pos:r,isOpen:e,onClose:t})=>{const[n,s]=m.useState(""),[o,i]=m.useState(),[l,a]=m.useState(""),[c,u]=m.useState(!1);m.useEffect(()=>{s(""),a(""),i(void 0)},[e]),Ie(f=>{if(!f||!e)return;const h=We.getState(f.state);u(h.upload!==void 0)},[e]);const d=re(f=>{f&&(c?Qf(f,o,l,r):Uf(f,n,l,r),f.focus(),t())});return g.jsxs(v.Modal,{isOpen:e,onClose:t,children:[g.jsx("h1",{children:"Вставка картинки"}),g.jsxs(v.Form,{submit:"Вставить",submitType:"Success",onSubmit:d,onCancel:t,children:[c?g.jsx(v.Image,{id:"image",value:o,onChange:i,text:g.jsxs("span",{children:[g.jsx(v.Icons.Image,{}),g.jsx("br",{}),"Выберите файл"]}),required:!0,label:"Картинка"}):g.jsx(v.Input,{id:"href",value:n,onChange:s,required:!0,label:"Ссылка на картинку"}),g.jsx(v.Input,{id:"value",value:l,onChange:a,label:"Подпись"})]})]})},gm=({schema:r,isOpen:e,onClose:t})=>{const[n,s]=m.useState(""),[o,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(""),[h,p]=m.useState(!0);m.useEffect(()=>{s(""),i(""),a(""),u(""),f(""),r.nodes.table?p(!1):p(!0)},[e]);const b=re(x=>{const k=r.nodes.video;if(!x||!k)return;let w=[];if(h){if(w=js(n),!w)return}else{if(!o&&!l&&!c)return;const N=xn(l,!0)+"",E=kn(c,!0)+"",M=bn(o,!0)+"";N&&w.push(N),E&&w.push(E),M&&w.push(M)}x.dispatch(x.state.tr.replaceSelectionWith(k.create({src:w,title:d}))),x.focus(),t()}),y=()=>h?!!js(n):l&&!xn(l)||c&&!kn(c)||o&&!bn(o)?!1:!!(l||c||o);return r.nodes.video?g.jsxs(v.Modal,{isOpen:e,onClose:t,children:[g.jsx("h1",{children:"Вставка видео"}),g.jsxs(v.Form,{submit:"Вставить",submitType:"Success",onSubmit:b,onCancel:t,children:[h?g.jsx(v.Input,{id:"url",value:n,onChange:s,label:"Ссылка на видео",bottom:"Поддерживаются VK Video, RuTube и YouTube",required:!y()}):g.jsxs(g.Fragment,{children:[g.jsx(v.Input,{id:"vkvideo",value:o,onChange:i,label:"Ссылка на VK Video",required:!y()}),g.jsx(v.Input,{id:"rutube",value:l,onChange:a,label:"Ссылка на RuTube",required:!y()}),g.jsx(v.Input,{id:"youtube",value:c,onChange:u,label:"Ссылка на YouTube",required:!y()})]}),g.jsx(v.Input,{id:"value",value:d,onChange:f,label:"Подпись"})]})]}):null},Ia=({schema:r})=>{const[e,t]=m.useState([]),[n,s]=m.useState(!1),[o,i]=m.useState(!1);return m.useEffect(()=>{const l=[];if(r.nodes.image){const a=r.nodes.image;l.push({icon:g.jsx(v.Icons.Image,{}),isDisabled:c=>!Bs(c,a),command:()=>(s(!0),!0)})}if(r.nodes.video){const a=r.nodes.video;l.push({icon:g.jsx(v.Icons.Film,{}),isDisabled:c=>!Bs(c,a),command:()=>(i(!0),!0)})}if(r.nodes.horizontal_rule){const a=r.nodes.horizontal_rule;l.push({icon:g.jsx(v.Icons.FlipVertical,{}),isDisabled:c=>!Bs(c,a),command:(c,u)=>u?(u(c.tr.replaceSelectionWith(a.create())),!0):!1})}r.nodes.table&&l.push({icon:g.jsx(v.Icons.Table,{}),isDisabled:we,command:ym()}),t(l)},[r]),e.length<1?null:g.jsxs(g.Fragment,{children:[g.jsx(Cn,{items:e}),g.jsx(Pa,{isOpen:n,onClose:()=>s(!1)}),g.jsx(gm,{isOpen:o,schema:r,onClose:()=>i(!1)})]})},Bs=(r,e)=>{let t=r.selection.$from;for(let n=t.depth;n>=0;n--){let s=t.index(n);if(t.node(n).canReplaceWith(s,s,e))return!0}return!1};function ym(){return(r,e)=>{const t=r.tr.selection.anchor+1,n=r.tr,s=r.schema.nodes.table_cell.createAndFill(),o=r.schema.nodes.table.create(null,S.fromArray([r.schema.nodes.table_row.create(null,S.fromArray([s,s,s])),r.schema.nodes.table_row.create(null,S.fromArray([s,s,s]))]));return e&&e(n.replaceSelectionWith(o).scrollIntoView().setSelection(V.near(n.doc.resolve(t)))),!0}}const Va=({schema:r})=>r.nodes.carousel?g.jsx(Cn,{items:[{icon:g.jsx(v.Icons.JoinUp,{}),command:ti},{icon:g.jsx(v.Icons.IndentDecrease,{}),command:Rr},{icon:g.jsx(v.Icons.SquareDashed,{}),command:jr}]}):g.jsx(Cn,{items:[{icon:g.jsx(v.Icons.IndentDecrease,{}),command:Rr},{icon:g.jsx(v.Icons.SquareDashed,{}),command:jr}]}),bm=({schema:r})=>g.jsxs("div",{className:"SimpleMenuBar",children:[g.jsx("div",{className:"MenuBlock",children:g.jsx(Ea,{schema:r})}),g.jsx(Da,{schema:r}),g.jsx(Ia,{schema:r}),g.jsx(Aa,{schema:r}),g.jsx(Va,{schema:r}),g.jsx(Ta,{})]}),Ra=m.forwardRef(function({children:e,nodeProps:t,...n},s){const[o,i]=m.useState(t.node.attrs.alt??""),[l,a]=m.useState(t.node.attrs.title??""),[c,u]=m.useState(!1),[d,f]=m.useState("");wa((x,k)=>x?!(k instanceof MouseEvent):!1),Ie(x=>{if(f(""),u(!1),!x||!x.state.schema.nodes.carousel)return;const k=t.getPos(),w=x.state.doc.resolve(k).parent;if(u(w.type.name!=="carousel"),w.type.name==="carousel"){let N=0;w.forEach((E,M)=>{E===t.node&&(N=M+1)}),f(N?`${N} / ${w.childCount}`:"")}});const h=re((x,k)=>{if(!x)return;i(k);const w=x.state.tr,N=t.getPos();x.dispatch(w.setNodeMarkup(N,null,{...t.node.attrs,alt:k})),x.focus()}),p=re((x,k)=>{if(!x)return;a(k);const w=x.state.tr,N=t.getPos();x.dispatch(w.setNodeMarkup(N,null,{...t.node.attrs,title:k})),x.focus()}),b=re(x=>{if(!x)return;const k=t.getPos(),w=t.node.nodeSize,N=t.node.attrs,E=x.state.schema,M=E.nodes.carousel.create(null,E.nodes.image.create(N));x.dispatch(x.state.tr.replaceWith(k,k+w,M))}),y=re(x=>{if(!x)return;const k=x.state.tr,w=t.getPos(),N=t.node.nodeSize;x.dispatch(k.delete(w,w+N))});return g.jsxs("div",{...n,ref:s,className:"image",title:t.node.attrs.title,children:[g.jsxs("div",{className:"image-buttons",children:[c&&g.jsx("div",{onClick:b,className:"text-button",children:"Сделать карусель"}),d&&g.jsx("div",{className:"text-button",children:d}),g.jsx("div",{onClick:y,children:g.jsx(v.Icons.Trash,{})})]}),g.jsx("div",{className:"image-title",children:g.jsx(v.Editable,{value:o,placeholder:"Alt: описание изображения (не обязательно)",onChange:h,empty:!0,style:{textAlign:"center",cursor:"text"}})}),g.jsx("img",{title:t.node.attrs.title,alt:t.node.attrs.alt,src:t.node.attrs.fid?`${_t}/${t.node.attrs.fid}`:t.node.attrs.src}),g.jsx("div",{className:"image-title",children:g.jsx(v.Editable,{value:l,placeholder:"Title: подпись под изображением (не обязательно)",onChange:p,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),za=m.forwardRef(function({children:e,nodeProps:t,...n},s){const[o,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(""),[h,p]=m.useState(t.node.attrs.title??""),b="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";wa(()=>!0),m.useEffect(()=>{let x=t.node.attrs.src;typeof x=="string"&&(x=[x]),x.forEach(k=>{xn(k)?(i(k),a(k)):kn(k)?(i(k),u(k)):bn(k)&&(i(k),f(k))})},[t]);const y=re((x,k)=>{if(!x)return;p(k);const{$from:w,$to:N}=x.state.selection,E=w.blockRange(N);if(E){const M=x.state.doc;let T=x.state.tr;M.nodesBetween(E.start,E.end,(I,D)=>{I.type.name==="video"&&(T=T.setNodeMarkup(D,null,{...t.node.attrs,title:k}))}),x.dispatch(T)}x.focus()});return g.jsxs("div",{...n,ref:s,className:"video",title:t.node.attrs.title,children:[g.jsxs("div",{className:"video-switcher",children:[l&&g.jsx("div",{onClick:()=>i(l),className:o===l?"active":"",children:"RuTube"}),c&&g.jsx("div",{onClick:()=>i(c),className:o===c?"active":"",children:"YouTube"}),d&&g.jsx("div",{onClick:()=>i(d),className:o===d?"active":"",children:"VK Video"})]}),o?g.jsx("iframe",{src:o,allow:b}):g.jsx("img",{src:yn}),g.jsx("div",{className:"video-title",children:g.jsx(v.Editable,{value:h,placeholder:"Подпись под видео (не обязательно)",onChange:y,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),ja=({onSave:r,disabled:e=!1,notEmpty:t=!0})=>{const[n,s]=m.useState(!0),[o,i]=m.useState(!1);Ie(a=>{let c=!0;if(t){const u=a.state.doc;c=!!u.textBetween(0,u.content.size,void 0," ").length}s(c)});const l=re(async a=>{i(!0);try{let c;const u=gs(a.state);if(u){const f=a.state.apply(u.setMeta("addToHistory",!1));c=JSON.stringify(f.doc.toJSON())}else c=JSON.stringify(a.state.doc.toJSON());const d=await r({content:c,format:"prose"});if(d)throw new Error(d)}catch(c){console.error(`Can not save doc: ${c}`)}i(!1),a.focus()});return g.jsx(v.Button,{type:"Accent",disabled:e||!n||o,label:o?"Сохраняю":"Сохранить",size:"Small",onClick:l})},xm=({title:r=!1,content:e,onSave:t,onCancel:n,onChange:s,onUpload:o})=>{const[i,l]=m.useState(""),[a,c]=m.useState();m.useEffect(()=>{const h=Ke.create({doc:pm(e),schema:wn,plugins:Sa({schema:wn,upload:o})});c(h),r!==!1&&l(typeof r=="string"?r:"")},[r,e]);const u=()=>r!==!1?i.trim().length>0:!0,d=h=>{!t||!u()||t({...h,name:i})},f=()=>{n&&n()};return a?g.jsxs("div",{className:"ProseNotes",children:[r!==!1&&g.jsx("input",{className:"ProseNotesTitle",onChange:h=>l(h.currentTarget.value),value:i,placeholder:"Укажите заголовок"}),g.jsxs(ka,{state:a,dispatchTransaction:h=>c(p=>{const b=p==null?void 0:p.apply(h);return b&&h.docChanged&&s&&s(!0),b}),nodeViews:{image:Ra,video:za},children:[g.jsxs("div",{className:"ProseNotesContent",children:[g.jsx(bm,{schema:wn}),g.jsx(xa,{})]}),(t||n)&&g.jsxs("div",{className:"ProseNotesButtons",children:[n&&g.jsx("span",{className:"a small",onClick:f,children:"Отменить"}),t&&g.jsx(ja,{onSave:d,disabled:!u()})]})]})]}):null},km=({schema:r})=>{const e=m.useRef(null),[t,n]=m.useState([]),[s,o]=m.useState([]),[i,l]=m.useState(!1);Ie(c=>{const u=r.nodes.heading;if(!c||!u||!i)return;const d=[],f=[];for(let h=2;h<7;h++){const b=At(u,{level:h});f[h]=b,d[h]={id:h,icon:g.jsx(wm,{level:h}),text:`уровень ${h}`,disabled:!b(c.state)}}n(d),o(f)},[i]);const a=re((c,u)=>{!c||!u.id||(s[u.id](c.state,c.dispatch,c),l(!1),c.focus())});return r.nodes.heading?g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:e,className:"MenuItem",onClick:()=>l(!0),children:g.jsx(v.Icons.Heading,{})}),e.current&&g.jsx(v.Menu,{parent:e.current,items:t,isOpen:i,onClose:()=>l(!1),onClick:a,horizontal:"inner-left"})]}):null},wm=({level:r})=>{switch(r){case 2:return g.jsx(v.Icons.Heading2,{});case 3:return g.jsx(v.Icons.Heading3,{});case 4:return g.jsx(v.Icons.Heading4,{});case 5:return g.jsx(v.Icons.Heading5,{});case 6:return g.jsx(v.Icons.Heading6,{});default:return g.jsx(v.Icons.Heading,{})}},Sm=[{id:"left",icon:g.jsx(v.Icons.AlignLeft,{}),text:"Прижать влево"},{id:"right",icon:g.jsx(v.Icons.AlignRight,{}),text:"Прижать вправо"},{id:"center",icon:g.jsx(v.Icons.AlignCenter,{}),text:"Отцентровать"},{id:"justify",icon:g.jsx(v.Icons.AlignJustify,{}),text:"Выровнять по краям"}],Cm=({schema:r})=>{const e=m.useRef(null),[t,n]=m.useState(!1),s=re((o,i)=>{if(!o||!i.id)return;const l=i.id==="left"?null:i.id,{$from:a,$to:c}=o.state.selection,u=a.blockRange(c);if(u){const d=o.state.doc;let f=o.state.tr;d.nodesBetween(u.start,u.end,(h,p)=>{h.type.name==="paragraph"&&(f=f.setNodeMarkup(p,null,{align:l}))}),o.dispatch(f)}o.focus(),n(!1)});return r.nodes.paragraph?g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:e,className:"MenuItem",onClick:()=>n(!0),children:g.jsx(v.Icons.AlignLeft,{})}),e.current&&g.jsx(v.Menu,{parent:e.current,items:Sm,isOpen:t,onClose:()=>n(!1),onClick:s,horizontal:"inner-left"})]}):null},Mm=({schema:r,onSave:e,onView:t})=>g.jsxs("div",{className:"MenuBar",children:[g.jsxs("div",{className:"MenuBlock",children:[g.jsx(km,{schema:r}),g.jsx(Ea,{schema:r})]}),g.jsx(Da,{schema:r}),g.jsx(Ia,{schema:r}),g.jsx(Aa,{schema:r}),g.jsx(Cm,{schema:r}),g.jsx(Va,{schema:r}),g.jsx(Ta,{}),t&&g.jsx("div",{className:"MenuItem",onClick:()=>t(),children:g.jsx(v.Icons.Eye,{})}),g.jsx("div",{className:"MenuBlock",children:g.jsx(ja,{onSave:e})})]}),vm=7,Ba=1,Mn=50,Nm=({width:r,onChange:e,onWidth:t})=>{const[n,s]=m.useState(!1),[o,i]=m.useState(0),[l,a]=m.useState(0),[c,u]=m.useState(r),d=p=>{const b=r[l],y=r[l+1],x=[...c];return b+p<Mn&&(p=Mn-b),y-p<Mn&&(p=y-Mn),x[l]=b+p,x[l+1]=y-p,x};m.useEffect(()=>{u(r)},[r]),m.useEffect(()=>{const p=y=>{if(!n)return;s(!1),y.preventDefault(),y.stopPropagation();const x=y.clientX-o,k=d(x);t(k)},b=y=>{if(!n)return;y.preventDefault(),y.stopPropagation();const x=y.clientX-o,k=d(x);u(k),e(k)};return document.addEventListener("mouseup",p),document.addEventListener("mousemove",b),()=>{document.removeEventListener("mouseup",p),document.removeEventListener("mousemove",b)}},[n,l]);const f=(p,b)=>{b!==r.length-1&&(p.preventDefault(),p.stopPropagation(),s(!0),i(p.clientX),a(b))},h=p=>c.slice(0,p+1).reduce((b,y)=>b+y,0)+p+Ba-Math.floor(vm/2);return g.jsx("div",{className:"table-resizer",children:c.map((p,b)=>g.jsx("div",{style:{left:h(b)+"px"},onMouseDown:y=>f(y,b)},b))})},Om=m.forwardRef(function({children:e,nodeProps:t,...n},s){var d;const o=m.useRef(null),i=m.useRef(null),[l,a]=m.useState([]),c=re((f,h)=>{if(!f)return;const p=t.node,b=t.getPos()+1,y=G.get(p),x=f.state.tr;for(let k=0;k<y.height;k++)for(let w=0;w<y.width;){const N=k*y.width+w,E=y.map[N],M=p.nodeAt(E).attrs,T=h.slice(w,w+M.colspan);k&&y.map[N]==y.map[N-y.width]||x.setNodeMarkup(b+E,null,{...M,colwidth:T}),w+=M.colspan}x.docChanged&&f.dispatch(x)});m.useEffect(()=>{if(!o.current||!i.current)return;const h=t.node.firstChild;if(!h)return;let p=[];for(let M=0;M<h.childCount;M++){const T=h.child(M),{colspan:I,colwidth:D}=T.attrs;p=p.concat(Array.isArray(D)?D:Array(I).fill(0))}const b=p.filter(M=>!M).length,y=p.reduce((M,T)=>M+T,0),x=(p.length+1)*Ba,k=Math.max(b?(o.current.offsetWidth-y-x)/b:0,Mn);p=p.map(M=>M||k);const w=p.reduce((M,T)=>M+T,0),N=i.current.offsetWidth-x-16,E=N/w;p=p.map(M=>Math.round(M*E)),p[p.length-1]+=N-p.reduce((M,T)=>M+T,0),a(p)},[t,o,i,(d=i.current)==null?void 0:d.offsetWidth]);const u=re(f=>{Vh(f.state,f.dispatch)});return g.jsxs("div",{...n,className:"table-wrapper",ref:f=>{i.current=f,s&&(typeof s=="function"?s(f):s.current=f)},children:[g.jsx(Nm,{width:l,onChange:a,onWidth:c}),g.jsxs("table",{ref:o,children:[g.jsx("colgroup",{children:l.map((f,h)=>g.jsx("col",{width:f},h))}),g.jsx("caption",{onClick:u,children:g.jsx(v.Icons.Trash,{})}),g.jsx("tbody",{children:e})]})]})}),Em=[{id:"toggleHeaderRow",text:"Toggle header row",icon:g.jsx(v.Icons.Heading,{})},{id:"addRowBefore",text:"Insert row before",icon:g.jsx(v.Icons.RowInsertBefore,{})},{id:"addRowAfter",text:"Insert row after",icon:g.jsx(v.Icons.RowInsertAfter,{})},{id:"deleteRow",text:"Delete row",icon:g.jsx(v.Icons.Trash,{})}],Dm=[{id:"toggleHeaderColumn",text:"Toggle header column",icon:g.jsx(v.Icons.Heading,{})},{id:"addColumnBefore",text:"Insert column before",icon:g.jsx(v.Icons.ColumnInsertBefore,{})},{id:"addColumnAfter",text:"Insert column after",icon:g.jsx(v.Icons.ColumnInsertAfter,{})},{id:"deleteColumn",text:"Delete column",icon:g.jsx(v.Icons.Trash,{})}],Tm=[{id:"toggleHeaderCell",text:"Toggle header",icon:g.jsx(v.Icons.Heading,{})},{id:"alignLeft",text:"Horizontal align left",icon:g.jsx(v.Icons.AlignLeft,{})},{id:"alignCenter",text:"Horizontal align center",icon:g.jsx(v.Icons.AlignCenter,{})},{id:"alignRight",text:"Horizontal align Right",icon:g.jsx(v.Icons.AlignRight,{})},{id:"alignTop",text:"Vertical align top",icon:g.jsx(v.Icons.AlignTop,{})},{id:"alignMiddle",text:"Vertical align middle",icon:g.jsx(v.Icons.AlignMiddle,{})},{id:"alignBottom",text:"Vertical align bottom",icon:g.jsx(v.Icons.AlignBottom,{})},{id:"mergeCells",text:"Merge cells",icon:g.jsx(v.Icons.CellsMerge,{})},{id:"splitCell",text:"Split cell",icon:g.jsx(v.Icons.CellsSplit,{})}],Fa=({x:r,y:e,isRowMenuOpen:t,isCellMenuOpen:n,isColumnMenuOpen:s,onRowMenuClose:o,onCellMenuClose:i,onColumnMenuClose:l})=>{const a=re((c,u)=>{if(c){switch(u.id){case"toggleHeaderRow":Th(c.state,c.dispatch);break;case"addRowBefore":wh(c.state,c.dispatch);break;case"addRowAfter":Sh(c.state,c.dispatch);break;case"deleteRow":Mh(c.state,c.dispatch);break;case"toggleHeaderColumn":Ah(c.state,c.dispatch);break;case"addColumnBefore":gh(c.state,c.dispatch);break;case"addColumnAfter":yh(c.state,c.dispatch);break;case"deleteColumn":xh(c.state,c.dispatch);break;case"mergeCells":Nh(c.state,c.dispatch);break;case"splitCell":Oh(c.state,c.dispatch);break;case"toggleHeaderCell":Ph(c.state,c.dispatch);break;case"alignLeft":Ft("halign","left")(c.state,c.dispatch);break;case"alignCenter":Ft("halign","center")(c.state,c.dispatch);break;case"alignRight":Ft("halign","right")(c.state,c.dispatch);break;case"alignTop":Ft("valign","top")(c.state,c.dispatch);break;case"alignMiddle":Ft("valign","middle")(c.state,c.dispatch);break;case"alignBottom":Ft("valign","bottom")(c.state,c.dispatch);break}o(),i(),l(),c.focus()}});return g.jsxs(g.Fragment,{children:[g.jsx(v.Menu,{x:r,y:e,items:Em,isOpen:t,onClose:o,onClick:a}),g.jsx(v.Menu,{x:r,y:e,items:Tm,isOpen:n,onClose:i,onClick:a}),g.jsx(v.Menu,{x:r,y:e,items:Dm,isOpen:s,onClose:l,onClick:a})]})},La=m.forwardRef(function({children:e,nodeProps:t,...n},s){const o=m.useRef(null),[i,l]=m.useState(0),[a,c]=m.useState(0),[u,d]=m.useState(!1),[f,h]=m.useState(!1),[p,b]=m.useState(!1);m.useEffect(()=>{const k=w=>{o.current!==w.target&&(d(!1),h(!1),b(!1))};return document.addEventListener("contextmenu",k,!0),()=>document.removeEventListener("contextmenu",k,!0)},[]);const y=k=>{k.preventDefault(),k.stopPropagation(),d(!1),h(!1),b(!1),l(k.clientX),c(k.clientY);const w=k.currentTarget.getBoundingClientRect();k.clientY<w.y?b(!0):k.clientX<w.x?d(!0):h(!0)},x=k=>{d(!1),h(!1),b(!1),l(k.clientX),c(k.clientY);const w=k.currentTarget.getBoundingClientRect();if(k.clientY<w.y)b(!0);else if(k.clientX<w.x)d(!0);else return;k.preventDefault(),k.stopPropagation()};return t.node.type.spec.tableRole==="header_cell"?g.jsxs("th",{...n,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:x,onContextMenu:y,ref:k=>{o.current=k,s&&(typeof s=="function"?s(k):s.current=k)},children:[e,g.jsx(Fa,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>d(!1),isCellMenuOpen:f,onCellMenuClose:()=>h(!1),isColumnMenuOpen:p,onColumnMenuClose:()=>b(!1)})]}):g.jsxs("td",{...n,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:x,onContextMenu:y,ref:k=>{o.current=k,s&&(typeof s=="function"?s(k):s.current=k)},children:[e,g.jsx(Fa,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>d(!1),isCellMenuOpen:f,onCellMenuClose:()=>h(!1),isColumnMenuOpen:p,onColumnMenuClose:()=>b(!1)})]})}),Am=m.forwardRef(function({children:e,nodeProps:t,...n},s){var E;const o=m.useRef(null),[i,l]=m.useState(!1),[a,c]=m.useState(!1),[u,d]=m.useState(!1),[f,h]=m.useState(),[p,b]=m.useState(),y=M=>{const T=M.scrollLeft,I=M.clientWidth,D=M.scrollWidth;c(T>0),d(T<D-I*1.5)};m.useEffect(()=>{o.current&&(p&&o.current.scrollWidth>p&&(o.current.scrollLeft=o.current.scrollWidth-o.current.clientWidth),b(o.current.scrollWidth))},[(E=o.current)==null?void 0:E.scrollWidth]),m.useEffect(()=>{h(t.getPos()+t.node.nodeSize-1),o.current&&t.node.childCount>1&&y(o.current)},[t,o]),Ie(M=>{if(!M||t.node.childCount>0)return;const T=M.state.tr,I=t.getPos(),D=t.node.nodeSize;M.dispatch(T.delete(I,I+D))},[t]);const x=re(M=>{if(!M)return;const T=t.getPos(),I=t.node.nodeSize;M.dispatch(M.state.tr.delete(T,T+I))}),k=()=>{l(!0)},w=M=>{y(M.currentTarget)},N=(M,T)=>{if(M.stopPropagation(),!o.current)return;const I=o.current.clientWidth;let D=o.current.scrollLeft+T*I;o.current.scrollLeft=D};return g.jsxs("div",{ref:s,...n,className:"carousel",children:[g.jsx("div",{className:"carousel-list",ref:o,onScroll:w,children:e}),g.jsxs("div",{className:"carousel-buttons",children:[g.jsx("div",{onClick:x,className:"text-button",children:"Удалить карусель"}),g.jsx("div",{onClick:k,children:g.jsx(v.Icons.Plus,{})})]}),a&&g.jsx("div",{className:"carousel-prev",onClick:M=>N(M,-1),children:g.jsx(v.Icons.ChevronLeft,{})}),u&&g.jsx("div",{className:"carousel-next",onClick:M=>N(M,1),children:g.jsx(v.Icons.ChevronRight,{})}),g.jsx(Pa,{pos:f,isOpen:i,onClose:()=>l(!1)})]})}),Pm=({content:r,onSave:e,onView:t,onChange:n,onUpload:s})=>{const[o,i]=m.useState();m.useEffect(()=>{let a;if(r)try{a=pe.fromJSON(_e,JSON.parse(r))}catch(d){console.error(`Can not parse Prose format: ${d}`)}let c=Ke.create({doc:a,schema:_e,plugins:Sa({schema:_e,upload:s})});const u=gs(c);u&&(c=c.apply(u.setMeta("addToHistory",!1))),i(c)},[r]);const l=async a=>{const c=await e(a);return n&&n(!1),c};return o?g.jsx("div",{className:"ProseEditor",children:g.jsxs(ka,{state:o,dispatchTransaction:a=>i(c=>{const u=c==null?void 0:c.apply(a);return u&&a.docChanged&&n&&n(!0),u}),nodeViews:{image:Ra,video:za,table:Om,table_header:La,table_cell:La,carousel:Am},children:[g.jsx(Mm,{schema:_e,onSave:l,onView:t}),g.jsx(xa,{})]})}):null},Im=({node:r})=>{const[e,t]=m.useState();return m.useEffect(()=>{var s;const n=(s=r.attrs)==null?void 0:s.align;t(n!=="right"&&n!=="center"&&n!=="justify"?void 0:{textAlign:n})},[r]),g.jsx("p",{style:e,children:Array.isArray(r.content)&&r.content.map((n,s)=>g.jsx(J,{node:n},s))})},Vm=({node:r})=>{if(!r.text)return null;const e=(t,n)=>{var i;if(!Array.isArray(r.marks))return g.jsx(g.Fragment,{children:n});if(!t.length)return g.jsx(g.Fragment,{children:n});const s=t[0].type,o=(i=t[0].attrs)==null?void 0:i.href;switch(s){case"em":return g.jsx("em",{children:e(t.slice(1),n)});case"code":return g.jsx("code",{children:e(t.slice(1),n)});case"strong":return g.jsx("strong",{children:e(t.slice(1),n)});case"underline":return g.jsx("u",{children:e(t.slice(1),n)});case"strikethrough":return g.jsx("s",{children:e(t.slice(1),n)});case"link":return o?g.jsx("a",{target:"_blank",href:o,children:e(t.slice(1),n)}):g.jsx(g.Fragment,{children:e(t.slice(1),n)});default:return g.jsx(g.Fragment,{children:e(t.slice(1),n)})}};return e(r.marks,r.text)},Rm=({node:r,className:e})=>g.jsx("div",{className:e,children:Array.isArray(r.content)&&r.content.map((t,n)=>g.jsx(J,{node:t},n))}),zm=({node:r})=>{const e=m.useRef(null),[t,n]=m.useState(""),[s,o]=m.useState(""),[i,l]=m.useState(""),[a,c]=m.useState(!1);m.useEffect(()=>{const d=()=>{c(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",d),()=>document.removeEventListener("fullscreenchange",d)},[]),m.useEffect(()=>{var h,p,b,y,x,k,w;let d=(h=r.attrs)==null?void 0:h.fid,f=(p=r.attrs)!=null&&p.src?`${(b=r.attrs)==null?void 0:b.src}`:"";d&&(f=`${_t}/${d}`),f||(f=Ct),n(f),o((y=r.attrs)!=null&&y.alt?`${(x=r.attrs)==null?void 0:x.alt}`:""),l((k=r.attrs)!=null&&k.title?`${(w=r.attrs)==null?void 0:w.title}`:"")},[r]);const u=d=>{var f;d.stopPropagation(),a?document.exitFullscreen():(f=e.current)==null||f.requestFullscreen()};return t?g.jsxs("div",{ref:e,className:"image",children:[g.jsx("img",{src:t,onClick:u,alt:s,title:i}),i&&g.jsx("div",{className:"image-title",children:i}),g.jsx("div",{className:"image-full",onClick:u,children:a?g.jsx(v.Icons.Minimize,{}):g.jsx(v.Icons.Maximize,{})})]}):null},jm=({node:r})=>g.jsx("blockquote",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(J,{node:e},t))}),Bm=50,Fm=({node:r})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{if(t([]),!Array.isArray(r.content))return;const n=r.content[0];if(!Array.isArray(n.content))return;let s=[];for(let i=0;i<n.content.length;i++){const l=n.content[i].attrs;if(!l)return;const{colspan:a,colwidth:c}=l;s=s.concat(Array.isArray(c)?c:Array(a).fill(Bm))}const o=s.reduce((i,l)=>i+l,0);s=s.map(i=>Math.round(i*100/o)),s[s.length-1]+=100-s.reduce((i,l)=>i+l,0),t(s)},[r]),g.jsxs("table",{children:[e.length>0&&g.jsx("colgroup",{children:e.map((n,s)=>g.jsx("col",{width:`${n}%`},s))}),g.jsx("tbody",{children:Array.isArray(r.content)&&r.content.map((n,s)=>g.jsx(J,{node:n},s))})]})},Lm=({node:r})=>g.jsx("tr",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(J,{node:e},t))}),$m=({node:r})=>{const[e,t]=m.useState(),[n,s]=m.useState(),[o,i]=m.useState(),[l,a]=m.useState();return m.useEffect(()=>{var c,u,d,f;t((c=r.attrs)==null?void 0:c.halign),s((u=r.attrs)==null?void 0:u.valign),i((d=r.attrs)!=null&&d.rowspan?parseInt(r.attrs.rowspan+""):1),a((f=r.attrs)!=null&&f.colspan?parseInt(r.attrs.colspan+""):1)},[r]),r.type==="table_header"?g.jsx("th",{colSpan:l,rowSpan:o,style:{textAlign:e,verticalAlign:n},children:Array.isArray(r.content)&&r.content.map((c,u)=>g.jsx(J,{node:c},u))}):g.jsx("td",{colSpan:l,rowSpan:o,style:{textAlign:e,verticalAlign:n},children:Array.isArray(r.content)&&r.content.map((c,u)=>g.jsx(J,{node:c},u))})},Wm=({node:r})=>{var e;if(!Array.isArray(r.content))return null;switch((e=r.attrs)==null?void 0:e.level){case 1:return g.jsx("h1",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});case 2:return g.jsx("h2",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});case 3:return g.jsx("h3",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});case 4:return g.jsx("h4",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});case 5:return g.jsx("h5",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});case 6:return g.jsx("h6",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});default:return g.jsx("h2",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))})}},_m=({node:r})=>Array.isArray(r.content)?r.type==="bullet_list"?g.jsx("ul",{children:r.content.map((e,t)=>g.jsx(J,{node:e},t))}):g.jsx("ol",{children:r.content.map((e,t)=>g.jsx(J,{node:e},t))}):null,qm=({node:r})=>g.jsx("li",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(J,{node:e},t))}),Jm=({node:r})=>g.jsx("pre",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(J,{node:e},t))}),Hm=()=>g.jsx("hr",{}),Km=({node:r})=>{const[e,t]=m.useState(""),[n,s]=m.useState(""),[o,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(0),h="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";return m.useEffect(()=>{var b,y;u((b=r.attrs)!=null&&b.title?`${r.attrs.title}`:"");let p=(y=r.attrs)==null?void 0:y.src;typeof p=="string"&&(p=[p]),p.forEach(x=>{xn(x)?(t(x),s(x)):kn(x)?(t(x),i(x)):bn(x)&&(t(x),a(x))})},[r]),m.useEffect(()=>{let p=0;n&&p++,o&&p++,l&&p++,f(p)},[n,o,l]),d?g.jsxs("div",{className:"video",children:[d>1&&g.jsxs("div",{className:"video-switcher",children:[n&&g.jsx("div",{onClick:()=>t(n),className:e===n?"active":"",children:"RuTube"}),o&&g.jsx("div",{onClick:()=>t(o),className:e===o?"active":"",children:"YouTube"}),l&&g.jsx("div",{onClick:()=>t(l),className:e===l?"active":"",children:"VK Video"})]}),g.jsx("iframe",{src:e,allow:h}),c&&g.jsx("div",{className:"video-title",children:c})]}):g.jsxs("div",{className:"image",children:[g.jsx("img",{src:yn}),c&&g.jsx("div",{className:"image-title",children:c})]})},Ym=()=>g.jsx("br",{}),Gm=({node:r})=>{const e=m.useRef(null),t=m.useRef(null),[n,s]=m.useState(!1),[o,i]=m.useState(!1),[l,a]=m.useState(!1),[c,u]=m.useState(1),[d,f]=m.useState(1),h=y=>{const x=y.scrollLeft,k=y.clientWidth,w=y.scrollWidth;i(x>k/2),a(x<w-k*1.5),u(Math.round(x/k+1))};m.useEffect(()=>{var y;a(Array.isArray(r.content)&&r.content.length>1),f(((y=r.content)==null?void 0:y.length)??1),u(1)},[r]),m.useEffect(()=>{const y=()=>{s(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",y),()=>document.removeEventListener("fullscreenchange",y)},[]),m.useEffect(()=>{if(!n)return;const y=x=>{x.key==="ArrowLeft"&&b(null,-1),x.key==="ArrowRight"&&b(null,1)};return document.body.addEventListener("keydown",y),()=>document.body.removeEventListener("keydown",y)},[n]);const p=y=>{var x;y.stopPropagation(),n?document.exitFullscreen():(x=t.current)==null||x.requestFullscreen()},b=(y,x)=>{if(y==null||y.stopPropagation(),!e.current)return;const k=e.current.clientWidth;let w=e.current.scrollLeft+x*k;e.current.scrollLeft=w};return Array.isArray(r.content)?g.jsxs("div",{className:"carousel",ref:t,children:[g.jsx("div",{className:"carousel-list",ref:e,onScroll:y=>h(y.currentTarget),children:r.content.map((y,x)=>g.jsx(Xm,{node:y,onClick:p},x))}),g.jsxs("div",{className:"carousel-numb",children:[c," / ",d]}),g.jsx("div",{className:"carousel-full",onClick:p,children:n?g.jsx(v.Icons.Minimize,{}):g.jsx(v.Icons.Maximize,{})}),o&&g.jsx("div",{className:"carousel-prev",onClick:y=>b(y,-1),children:g.jsx(v.Icons.ChevronLeft,{})}),l&&g.jsx("div",{className:"carousel-next",onClick:y=>b(y,1),children:g.jsx(v.Icons.ChevronRight,{})})]}):null},Xm=({node:r,onClick:e})=>{const[t,n]=m.useState(""),[s,o]=m.useState(""),[i,l]=m.useState("");return m.useEffect(()=>{var f,h,p,b;let a=(f=r.attrs)==null?void 0:f.fid,c=(h=r.attrs)!=null&&h.src?`${r.attrs.src}`:"",u=(p=r.attrs)!=null&&p.alt?`${r.attrs.alt}`:"",d=(b=r.attrs)!=null&&b.title?`${r.attrs.title}`:"";a&&(c=`${_t}/${a}`),c||(c=Ct),n(c),o(u),l(d)},[r]),r.type!=="image"?null:g.jsxs("div",{className:"image",children:[t&&g.jsx("img",{src:t,onClick:e,alt:s,title:i}),i&&g.jsx("div",{className:"image-title",children:i})]})},J=({node:r,className:e})=>r?(n=>{switch(n.type){case"doc":return g.jsx(Rm,{node:n,className:e});case"list_item":return g.jsx(qm,{node:n});case"bullet_list":case"ordered_list":return g.jsx(_m,{node:n});case"image":return g.jsx(zm,{node:n});case"video":return g.jsx(Km,{node:n});case"text":return g.jsx(Vm,{node:n});case"table":return g.jsx(Fm,{node:n});case"table_row":return g.jsx(Lm,{node:n});case"table_cell":case"table_header":return g.jsx($m,{node:n});case"heading":return g.jsx(Wm,{node:n});case"code_block":return g.jsx(Jm,{node:n});case"paragraph":return g.jsx(Im,{node:n});case"blockquote":return g.jsx(jm,{node:n});case"carousel":return g.jsx(Gm,{node:n});case"horizontal_rule":return g.jsx(Hm,{});case"hard_break":return g.jsx(Ym,{});default:return g.jsx("span",{className:"unknown_node_type",children:n.type})}})(r):null,Qm=({content:r})=>{const[e,t]=m.useState(),[n,s]=m.useState(!1);return m.useEffect(()=>{try{s(!1);const o=JSON.parse(r);t(o)}catch(o){s(!0),console.error(`Can not parse Prose format: ${o}`)}},[r]),n?g.jsx("div",{className:"error",children:"ОШИБКА"}):g.jsx(J,{node:e,className:"ProseViewer"})},Um=({content:r})=>{const e=m.useRef(null),[t,n]=m.useState(!1);return m.useEffect(()=>{var s;try{n(!1);const o=pe.fromJSON(_e,JSON.parse(r)),i=ze.fromSchema(_e).serializeFragment(o.content);(s=e.current)==null||s.appendChild(i)}catch(o){n(!0),console.error(`Can not parse Prose format: ${o}`)}},[e,r]),g.jsx("div",{ref:e,className:"ProseViewer",children:t&&g.jsx("div",{className:"error",children:"ОШИБКА"})})},Zm='{"type":"doc","content":[{"type":"paragraph","attrs":{"align":null},"content":[{"type":"text","text":"@"}]}]}',eg='{"type":"doc","content":[{"type":"paragraph","attrs":{"align":null},"content":[{"type":"text","text":"При парсинге документа произошла ошибка"}]}]}',tg=(r,e,t)=>{if(!r)return Zm;try{const s=new DOMParser().parseFromString(r,"text/html");if(t){const i=s.getElementsByTagName("img");for(var n=0;n<i.length;n++){const l=i[n].getAttribute(t);l&&i[n].setAttribute("fid",l)}}const o=In.fromSchema(e?wn:_e).parse(s).toJSON();return JSON.stringify(o)}catch(s){return console.error(`Can not convert html content to prose format: ${s}`),eg}};_.DOM=Um,_.Editor=Pm,_.Notes=xm,_.Viewer=Qm,_.htmlToProse=tg,_.setConfig=lm,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
53
|
+
*/var ya;function Pp(){return ya||(ya=1,process.env.NODE_ENV!=="production"&&function(){function r(o){var i=o,l=o;if(o.alternate)for(;i.return;)i=i.return;else{o=i;do i=o,i.flags&4098&&(l=i.return),o=i.return;while(o)}return i.tag===3?l:null}function e(o){if(r(o)!==o)throw Error("Unable to find node on an unmounted component.")}function t(o){var i=o.alternate;if(!i){if(i=r(o),i===null)throw Error("Unable to find node on an unmounted component.");return i!==o?null:o}for(var l=o,a=i;;){var c=l.return;if(c===null)break;var u=c.alternate;if(u===null){if(a=c.return,a!==null){l=a;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===l)return e(c),o;if(u===a)return e(c),i;u=u.sibling}throw Error("Unable to find node on an unmounted component.")}if(l.return!==a.return)l=c,a=u;else{for(var d=!1,f=c.child;f;){if(f===l){d=!0,l=c,a=u;break}if(f===a){d=!0,a=c,l=u;break}f=f.sibling}if(!d){for(f=u.child;f;){if(f===l){d=!0,l=u,a=c;break}if(f===a){d=!0,a=u,l=c;break}f=f.sibling}if(!d)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(l.alternate!==a)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(l.tag!==3)throw Error("Unable to find node on an unmounted component.");return l.stateNode.current===l?o:i}function n(o){var i=o.tag;if(i===5||i===26||i===27||i===6)return o;for(o=o.child;o!==null;){if(i=n(o),i!==null)return i;o=o.sibling}return null}function s(o){var i=o.tag;if(i===5||i===26||i===27||i===6)return o;for(o=o.child;o!==null;){if(o.tag!==4&&(i=s(o),i!==null))return i;o=o.sibling}return null}Ce.doesFiberContain=function(o,i){for(var l=o.alternate;i!==null;){if(i===o||i===l)return!0;i=i.return}return!1},Ce.findCurrentFiberUsingSlowPath=t,Ce.findCurrentHostFiber=function(o){return o=t(o),o!==null?n(o):null},Ce.findCurrentHostFiberWithNoPortals=function(o){return o=t(o),o!==null?s(o):null},Ce.getContainerFromFiber=function(o){return o.tag===3?o.stateNode.containerInfo:null},Ce.getNearestMountedFiber=r,Ce.getSuspenseInstanceFromFiber=function(o){if(o.tag===13){var i=o.memoizedState;if(i===null&&(o=o.alternate,o!==null&&(i=o.memoizedState)),i!==null)return i.dehydrated}return null},Ce.isFiberMounted=function(o){return r(o)===o},Ce.isFiberSuspenseAndTimedOut=function(o){var i=o.memoizedState;return o.tag===13&&i!==null&&i.dehydrated===null},Ce.isMounted=function(o){return(o=o._reactInternals)?r(o)===o:!1}}()),Ce}process.env.NODE_ENV==="production"?Ps.exports=Ap():Ps.exports=Pp();var Ip=Ps.exports;function Vp(r){return r._reactInternals}function cg(r){return r}function Rp(r){const e=Vp(r);if(e===void 0){if(typeof r.render=="function")throw new Error("Unable to find node on an unmounted component.");{const n=Object.keys(r).join(",");throw new Error(`Argument appears to not be a ReactComponent. Keys: ${n}`)}}const t=Ip.findCurrentHostFiber(e);return t===null?null:t.stateNode}function zp(r){return Rp(r)}function jp(r,e){if(r===e)return!0;if(!r||!e)return!1;const t=Object.keys(r),n=Object.keys(e),s=t.length;if(n.length!==s)return!1;for(let o=0;o<s;o++){const i=t[o];if(r[i]!==e[i]||!Object.prototype.hasOwnProperty.call(e,i))return!1}return!0}class Bp extends m.Component{constructor(){super(...arguments);B(this,"viewDescRef",null);B(this,"renderRef",null)}updateEffect(){const{view:t,decorations:n,siblingsRef:s,parentRef:o,getPos:i,node:l}=this.props,a=zp(this);if(!a){if(!t.composing)return;this.viewDescRef=new Ds(o.current,i,document.createElement("div"),document.createTextNode(l.text??""),l.text??"");return}let c=a;for(;c.firstChild;)c=c.firstChild;!this.viewDescRef||this.viewDescRef instanceof Ds?this.viewDescRef=new fp(void 0,[],i,l,n,j.empty,a,c):(this.viewDescRef.parent=o.current,this.viewDescRef.children=[],this.viewDescRef.node=l,this.viewDescRef.outerDeco=n,this.viewDescRef.innerDeco=j.empty,this.viewDescRef.dom=a,this.viewDescRef.dom.pmViewDesc=this.viewDescRef,this.viewDescRef.nodeDOM=c),s.current.includes(this.viewDescRef)||s.current.push(this.viewDescRef),s.current.sort(wt)}shouldComponentUpdate(t){return!jp(this.props,t)}componentDidMount(){this.updateEffect()}componentDidUpdate(){this.updateEffect()}componentWillUnmount(){const{siblingsRef:t}=this.props;if(this.viewDescRef&&t.current.includes(this.viewDescRef)){const n=t.current.indexOf(this.viewDescRef);t.current.splice(n,1)}}render(){const{view:t,getPos:n,node:s,decorations:o}=this.props;return t.composing&&t.state.selection.from>=n()&&t.state.selection.from<=n()+s.nodeSize?this.renderRef:(this.renderRef=o.reduce(lr,s.text),this.renderRef)}}function Fp(r){let{getPos:e}=r;const{siblingsRef:t,parentRef:n}=m.useContext(Ne),s=m.useRef(null),o=m.useRef(null);return ne(()=>{const i=t.current;return()=>{if(s.current&&i.includes(s.current)){const l=i.indexOf(s.current);i.splice(l,1)}}},[t]),ne(()=>{o.current&&(s.current?(s.current.parent=n.current,s.current.dom=o.current):s.current=new gn(n.current,[],e,o.current,null),t.current.includes(s.current)||t.current.push(s.current),t.current.sort(wt))}),m.createElement("br",{ref:o,className:"ProseMirror-trailingBreak"})}function Lp(r){let{widget:e,getPos:t}=r;const{siblingsRef:n,parentRef:s}=m.useContext(Ne),o=m.useRef(null),i=m.useRef(null);ne(()=>{const a=n.current;return()=>{if(o.current&&a.includes(o.current)){const c=a.indexOf(o.current);a.splice(c,1)}}},[n]),ne(()=>{i.current&&(o.current?(o.current.parent=s.current,o.current.widget=e,o.current.dom=i.current):o.current=new Os(s.current,t,e,i.current),n.current.includes(o.current)||n.current.push(o.current),n.current.sort(wt))});const{Component:l}=e.type;return l&&m.createElement(l,{ref:i,widget:e,getPos:t,contentEditable:!1})}function lr(r,e){const{nodeName:t,...n}=e.type.attrs,s=da(n);return t||typeof r=="string"?m.createElement(t??"span",s,r):m.cloneElement(r,ua(r.props,s))}function Is(r,e){var t,n,s;return r.type===e.type&&r.marks.every(o=>o.isInSet(e.marks))&&e.marks.every(o=>o.isInSet(r.marks))&&r.key===e.key&&(r.type==="node"?((t=r.outerDeco)==null?void 0:t.length)===((n=e.outerDeco)==null?void 0:n.length)&&((s=r.outerDeco)==null?void 0:s.every(o=>{var i;return(i=e.outerDeco)==null?void 0:i.some(l=>o.from===l.from&&o.to&&l.to&&o.type.eq(l.type))}))&&r.innerDeco.eq(e.innerDeco):!0)&&r.node===e.node&&r.widget===e.widget}const $p=m.memo(function(e){let{child:t,getInnerPos:n}=e;const{view:s}=m.useContext(Lt),o=m.useRef(t);o.current=t;const i=m.useCallback(()=>n()+o.current.offset,[n]);return t.type==="widget"?m.createElement(Lp,{key:t.key,widget:t.widget,getPos:i}):t.type==="native-widget"?m.createElement(Mp,{key:t.key,widget:t.widget,getPos:i}):t.type==="hack"?m.createElement(t.component,{key:t.key,getPos:i}):t.node.isText?m.createElement(Ne.Consumer,{key:t.key},l=>{let{siblingsRef:a,parentRef:c}=l;return m.createElement(Bp,{view:s,node:t.node,getPos:i,siblingsRef:a,parentRef:c,decorations:t.outerDeco})}):m.createElement(ma,{key:t.key,node:t.node,getPos:i,outerDeco:t.outerDeco,innerDeco:t.innerDeco})}),Wp=m.memo(function(e){let{childViews:t,getInnerPos:n}=e;const s=t[0],o=m.useRef(s);o.current=s;const i=m.useCallback(()=>n()+o.current.offset,[n]),l=s.marks[0];return l?m.createElement(ha,{key:s.key,mark:l,getPos:i},m.createElement(Vs,{key:s.key,getInnerPos:n,childViews:t.map(a=>({...a,marks:a.marks.slice(1)}))})):m.createElement(m.Fragment,null,t.map(a=>m.createElement($p,{key:a.key,child:a,getInnerPos:n})))}),Vs=m.memo(function(e){let{getInnerPos:t,childViews:n}=e;const s=n.reduce((o,i)=>{var c;const l=o[o.length-1];if(!l)return[[i]];const a=l[l.length-1];return a?!i.marks.length&&!a.marks.length||i.marks.length&&a.marks.length&&((c=i.marks[0])!=null&&c.eq(a.marks[0]))?[...o.slice(0,o.length-1),[...l.slice(0,l.length),i]]:[...o,[i]]:[...o.slice(0,o.length),[i]]},[]);return m.createElement(m.Fragment,null,s.map(o=>{const i=o[0];return i?m.createElement(Wp,{key:i.key,childViews:o,getInnerPos:t}):null}))});function Rs(r,e,t,n,s,o){const i=r+e,l=s==null?void 0:s.get(i);if(n==="widget"||n==="native-widget")return o.type.spec.key?o.type.spec.key:(n==="widget"&&console.warn(`Widget at position ${i} doesn't have a key specified. React ProseMirror will generate a key partially based on this widget’s index into its parent’s children. This can cause issues if there are multiple adjacent widgets.`),`${l}-${t}`);if(l)return l;const a=r-1,c=s==null?void 0:s.get(a);return c?`${c}-${e}`:i}function _p(r,e){if(!e||e.widget.type.side>=0||!r||!r.node.isInline)return;const t=r.marks;e.marks=e.marks.reduce((n,s)=>s.addToSet(n),t)}function qp(r,e){if(!e.node.isInline)return;const t=e.marks;for(let n=r.length-1;n>=0;n--){const s=r[n];s.widget.type.side<0||(s.marks=s.marks.reduce((o,i)=>i.addToSet(o),t))}}const Jp=m.memo(function(e){let{child:t,getInnerPos:n}=e;const s=m.useRef(t);s.current=t;const o=m.useCallback(()=>n()+s.current.offset,[n]);return t.type==="node"?t.marks.reduce((i,l)=>m.createElement(ha,{mark:l,getPos:o},i),m.createElement(ma,{key:t.key,outerDeco:t.outerDeco,node:t.node,innerDeco:t.innerDeco,getPos:o})):m.createElement(Vs,{key:t.key,childViews:[t],getInnerPos:n})});function Hp(r,e){return r.length?r.every(t=>t.type!=="node"||t.node.isInline)?[m.createElement(Vs,{key:r[0].key,childViews:r,getInnerPos:e})]:r.map(t=>m.createElement(Jp,{key:t.key,child:t,getInnerPos:e})):[]}const zs=m.memo(function(e){let{getPos:t,node:n,innerDecorations:s}=e;const o=xp(),i=m.useCallback(()=>t()+1,[t]),l=m.useRef(new Map).current;if(!n)return null;const a=new Map;let c=[],u=null;yp(n,s,(h,p,b,y)=>{const x=h.type.spec.marks??[];let k;if(p){k=Rs(i(),b,y,"native-widget",o==null?void 0:o.posToKey,h);const N={type:"native-widget",widget:h,marks:x,offset:b,index:y,key:k},O=l.get(k);O&&Is(O,N)?O.offset=b:l.set(k,N),a.set(k,a.size)}else{k=Rs(i(),b,y,"widget",o==null?void 0:o.posToKey,h);const N={type:"widget",widget:h,marks:x,offset:b,index:y,key:k},O=l.get(k);O&&Is(O,N)?O.offset=b:l.set(k,N),a.set(k,a.size)}const w=l.get(k);c.push(w),_p(u,l.get(k))},(h,p,b,y,x)=>{const k=Rs(i(),y,x,"node",o==null?void 0:o.posToKey),w={type:"node",node:h,marks:h.marks,innerDeco:b,outerDeco:p,offset:y,index:x,key:k},N=l.get(k);N&&Is(N,w)?(N.offset=y,u=N):(l.set(k,w),u=w),a.set(k,a.size),qp(c,u),c=[]});for(const h of l.keys())a.has(h)||l.delete(h);const d=Array.from(l.values()).sort((h,p)=>a.get(h.key)-a.get(p.key));if(n.isTextblock){const h=d[d.length-1];(!h||h.type!=="node"||h.node.isInline&&!h.node.isText||/\n$/.test(h.node.text))&&d.push({type:"hack",component:Tp,marks:[],offset:(h==null?void 0:h.offset)??0,index:((h==null?void 0:h.index)??0)+2,key:"trailing-hack-img"},{type:"hack",component:Fp,marks:[],offset:(h==null?void 0:h.offset)??0,index:((h==null?void 0:h.index)??0)+1,key:"trailing-hack-br"})}const f=Hp(d,i);return m.createElement(m.Fragment,null,f)}),Kp=m.memo(m.forwardRef(function(e,t){let{as:n,node:s,getPos:o,decorations:i,innerDecorations:l,setMount:a,...c}=e;const u=m.useRef(null);m.useImperativeHandle(t,()=>u.current),m.useImperativeHandle(a,()=>u.current);const d=m.useMemo(()=>({node:s,getPos:o,decorations:i,innerDecorations:l}),[s,o,i,l]),{childContextValue:f}=Ts(u,()=>{const y=u.current;return{dom:y,contentDOM:y,update(){return!0}}},d),h=m.createElement(Ne.Provider,{value:f},m.createElement(zs,{getPos:o,node:s,innerDecorations:l})),p={...c,suppressContentEditableWarning:!0,ref:u},b=n?m.cloneElement(n,p,h):m.createElement("div",p,h);return d.decorations.reduce(lr,b)})),ba=m.createContext(null),xa=m.forwardRef(function(e,t){let{as:n,...s}=e;const o=m.useContext(ba);return m.createElement(Kp,{ref:t,...s,...o,as:n})});function Yp(){return-1}function Gp(r){let{className:e,children:t,nodeViews:n,customNodeViews:s,...o}=r;const[i,l]=m.useState(null),{editor:a,state:c}=ap(i,{...o,nodeViews:s}),u=a.view.nodeViews,d=m.useMemo(()=>({components:{...n},constructors:u}),[u,n]),f=c.doc,h=Jh(a.view),p=Gh(a.view,a.cursorWrapper),b=m.useMemo(()=>({className:e,setMount:l,node:f,getPos:Yp,decorations:h,innerDecorations:p}),[e,f,h,p]);return m.createElement(Lt.Provider,{value:a},m.createElement(qh.Provider,{value:c},m.createElement($l.Provider,{value:d},m.createElement(ba.Provider,{value:b},t))))}function ka(r){return m.createElement(cp,null,m.createElement(Gp,r))}function Xp(r){if(!(r instanceof xt))throw new DOMException("ProseMirror document is not mounted","InvalidStateError")}function re(r){const e=m.useRef(r),{view:t}=m.useContext(Lt);return Ie(()=>{e.current=r},[r]),m.useCallback(function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];return Xp(t),e.current(t,...s)},[t])}function wa(r){const e=m.useContext(pa),t=re(r);Ie(()=>e(t),[e,t])}const Sa=r=>[_h(),Tr({Tab:Rl(1),"Shift-Tab":Rl(-1)}),Yf(r.schema),Tr(Wf(r.schema)),Tr(vu),Nu({color:"#F00",width:2}),ff(),lu(),Gf(r),bp()],Qp=["p",0],Up=["blockquote",0],Zp=["hr"],em=["pre",["code",0]],tm=["br"],nm={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Qp}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return Up}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Zp}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(r){return["h"+r.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return em}},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(r){return{src:r.getAttribute("src"),title:r.getAttribute("title"),alt:r.getAttribute("alt")}}}],toDOM(r){let{src:e,alt:t,title:n}=r.attrs;return["img",{src:e,alt:t,title:n}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return tm}}},rm=["em",0],sm=["strong",0],om=["code",0],im={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(r){return{href:r.getAttribute("href"),title:r.getAttribute("title")}}}],toDOM(r){let{href:e,title:t}=r.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:r=>r.type.name=="em"}],toDOM(){return rm}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:r=>r.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:r=>r.type.name=="strong"},{style:"font-weight",getAttrs:r=>/^(bold(er)?|[5-9]\d{2,})$/.test(r)&&null}],toDOM(){return sm}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return om}}},Ca=new Pn({nodes:nm,marks:im}),Ma=Ca.spec.marks.append({underline:{parseDOM:[{tag:"u"},{style:"font-style=underline"}],toDOM(){return["u",0]}},strikethrough:{parseDOM:[{tag:"s"},{style:"font-style=strike"},{style:"font-style=strikethrough"}],toDOM(){return["s",0]}}});let _t="",va="",Na="",Ct="",yn="";const lm=r=>{_t=r.api_url??_t,va=r.video_image??va,Na=r.empty_image??Na,Ct=r.error_image??Ct,yn=r.error_embed??yn},bn=(r,e)=>{try{const t=new URL(r);if(t.hostname!=="vkvideo.ru"&&t.hostname!=="vk.com"&&t.hostname!=="vk.ru")throw new Error;let n,s;if(t.pathname==="/video_ext.php")n=t.searchParams.get("id"),s=t.searchParams.get("oid");else if(t.pathname.startsWith("/video"))[s,n]=t.pathname.slice(6).split("_");else throw new Error;if(!n||!s)throw new Error;return e?`https://vkvideo.ru/video_ext.php?oid=${s}&id=${n}&hd=2`:!0}catch{return e?"":!1}},xn=(r,e)=>{try{const t=new URL(r);if(t.hostname!=="rutube.ru")throw new Error;let n;if(t.pathname.startsWith("/video/"))n=t.pathname.split("/")[2];else if(t.pathname.startsWith("/play/embed/"))n=t.pathname.split("/")[3];else throw new Error;if(!n)throw new Error;return e?`https://rutube.ru/play/embed/${n}`:!0}catch{return e?"":!1}},kn=(r,e)=>{try{const t=new URL(r);if(t.hostname!=="youtube.com"&&t.hostname!=="www.youtube.com"&&t.hostname!=="youtu.be")throw new Error;if(t.hostname==="youtu.be")return e?`https://youtube.com/embed${t.pathname}`:!0;let n;if(t.pathname==="/watch")n=t.searchParams.get("v");else if(t.pathname.startsWith("/live/"))n=t.pathname.split("/")[2];else if(t.pathname.startsWith("/embed/"))n=t.pathname.split("/")[2];else throw new Error;if(!n)throw new Error;return e?`https://youtube.com/embed/${n}`:!0}catch{return e?"":!1}},js=r=>{try{const e=new URL(r);switch(e.hostname){case"vkvideo.ru":case"vk.com":case"vk.ru":return bn(e,!0)+"";case"rutube.ru":return xn(e,!0)+"";case"youtube.com":case"www.youtube.com":case"youtu.be":return kn(e,!0)+"";default:throw new Error}}catch{return""}},am={atom:!0,attrs:{fid:{default:null,validate:"string|null|number"},src:{default:null,validate:"string|null"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"block",parseDOM:[{tag:"img[src]",getAttrs(r){let e=r.getAttribute("src");return e||(e=Ct),e.startsWith("data:")&&(e=Ct),{src:e,fid:r.getAttribute("fid"),alt:r.getAttribute("alt"),title:r.getAttribute("title")}}}],toDOM(r){let{fid:e,src:t,alt:n,title:s}=r.attrs;return e&&(t=`${_t}/${e}`),t||(t=Ct),["div",{title:s,class:"image"},["img",{fid:e,src:t,alt:n,title:s}]]}},cm={atom:!0,attrs:{title:{default:null,validate:"string|null"},src:{validate:r=>{if(typeof r!="string"){if(Array.isArray(r)){r.forEach(e=>{if(typeof e!="string")throw new Error("One of the video sources is not a string")});return}throw new Error("Video source must be a string or array of strings")}}}},group:"block",parseDOM:[{tag:"iframe[src]",getAttrs(r){return{src:r.getAttribute("src"),title:r.getAttribute("title")}}}],toDOM(r){const{src:e,title:t}=r.attrs,n="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",s=Array.isArray(e)?e[0]:e;return js(s)?["div",{title:t,class:"video"},["iframe",{src:s,title:t,allow:n}]]:["div",{title:t,class:"image"},["img",{src:yn}]]}},um={content:"inline*",group:"block",attrs:{align:{default:null,validate:"string|null"}},parseDOM:[{tag:"p",getAttrs(r){let e=r.getAttribute("align");return e!=="right"&&e!=="center"&&e!=="justify"&&(e=null),{align:e}}}],toDOM(r){const{align:e}=r.attrs;return["p",{align:e},0]}},dm={attrs:{level:{default:1,validate:"number"}},content:"inline*",marks:"underline strikethrough",group:"block",parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(r){return["h"+r.attrs.level,0]}},fm={atom:!0,content:"image*",group:"block",toDOM(){return["div",{class:"carousel"},0]}},Ea=Ca.spec.nodes.remove("image").append({image:am,video:cm}),wn=new Pn({nodes:Ea.remove("horizontal_rule").remove("heading"),marks:Ma}),hm=Ea.remove("heading").remove("paragraph").prepend({paragraph:um}).append({heading:dm}).append({carousel:fm}).append(sh({tableGroup:"block",cellContent:"(paragraph | ordered_list | bullet_list)+",cellAttributes:{halign:{default:null,getFromDOM(r){const e=r.getAttribute("align")||null;return e==="left"||e==="right"||e==="center"?e:null},setDOMAttr(r,e){r&&(e.style=(e.style||"")+`text-align: ${r};`)}},valign:{default:null,getFromDOM(r){const e=r.style.verticalAlign||null;return e==="top"||e==="bottom"||e==="middle"?e:null},setDOMAttr(r,e){r&&(e.style=(e.style||"")+`vertical-align: ${r};`)}}}})),_e=new Pn({nodes:Cf(hm,"(paragraph | ordered_list | bullet_list)+","block"),marks:Ma}),pm=r=>{if(r)try{const e=pe.fromJSON(_e,JSON.parse(r)),t=ze.fromSchema(_e).serializeFragment(e.content);return In.fromSchema(wn).parse(t)}catch(e){console.error(`Can not convert content to simple schema: ${e}`)}},Sn=({ref:r,item:e})=>{const[t,n]=m.useState(!0),[s,o]=m.useState(!1),[i,l]=m.useState(!1);Ie(c=>{c&&(n(e.isActive&&e.isActive(c.state)),l(e.isSelected&&!e.isSelected(c.state)),e.isDisabled?o(e.isDisabled(c.state)):o(!e.command(c.state)))});const a=re(c=>{c&&(s||e.command(c.state,c.dispatch,c),c.focus())});return i?null:g.jsx("div",{ref:r,className:`MenuItem ${t?"active":""} ${s?"disabled":""}`,onClick:c=>{c.stopPropagation(),c.preventDefault(),a()},children:e.icon})},Oa=({schema:r})=>{const[e,t]=m.useState(void 0),[n,s]=m.useState(void 0);return m.useEffect(()=>{if(t(void 0),s(void 0),r.nodes.paragraph){const o=r.nodes.paragraph;t({icon:g.jsx(v.Icons.Type,{}),command:At(o)})}if(r.nodes.code_block){const o=r.nodes.code_block;s({icon:g.jsx(v.Icons.CodeXml,{}),command:At(o)})}},[r]),g.jsxs(g.Fragment,{children:[e&&g.jsx(Sn,{item:e}),n&&g.jsx(Sn,{item:n})]})},Cn=({items:r})=>g.jsx("div",{className:"MenuBlock",children:r.map((e,t)=>g.jsx(Sn,{item:e},t))}),mm=({schema:r,isOpen:e,onClose:t})=>{const n=re((s,o)=>{s&&(ye(r.marks.link,{href:o})(s.state,s.dispatch),t(),s.focus())});return g.jsx(v.Prompt,{title:"Введите URL для ссылки",isOpen:e,onCancel:t,onSubmit:n})},Da=({schema:r})=>{const[e,t]=m.useState([]),[n,s]=m.useState(!1);return m.useEffect(()=>{const o=[];if(r.marks.strong){const i=r.marks.strong;o.push({icon:g.jsx(v.Icons.Bold,{}),command:ye(i),isActive:l=>Mt(l,i)})}if(r.marks.em){const i=r.marks.em;o.push({icon:g.jsx(v.Icons.Italic,{}),command:ye(i),isActive:l=>Mt(l,i)})}if(r.marks.underline){const i=r.marks.underline;o.push({icon:g.jsx(v.Icons.Underline,{}),command:ye(i),isActive:l=>Mt(l,i)})}if(r.marks.strikethrough){const i=r.marks.strikethrough;o.push({icon:g.jsx(v.Icons.Strikethrough,{}),command:ye(i),isActive:l=>Mt(l,i)})}if(r.marks.code){const i=r.marks.code;o.push({icon:g.jsx(v.Icons.Code,{}),command:ye(i),isActive:l=>Mt(l,i)})}if(r.marks.link){const i=r.marks.link;o.push({icon:g.jsx(v.Icons.Link,{}),isActive:l=>Mt(l,i),isDisabled:l=>l.selection.empty?!0:!ye(i)(l),command:(l,a,c)=>(Mt(l,i)?(ye(i)(l,a),c==null||c.focus()):s(!0),!0)})}t(o)},[r]),e.length<1?null:g.jsxs(g.Fragment,{children:[g.jsx(Cn,{items:e}),g.jsx(mm,{isOpen:n,schema:r,onClose:()=>s(!1)})]})};function Mt(r,e){let{from:t,$from:n,to:s,empty:o}=r.selection;return o?!!e.isInSet(r.storedMarks||n.marks()):r.doc.rangeHasMark(t,s,e)}const Ta=()=>g.jsxs("div",{className:"MenuBlock",children:[g.jsx(Sn,{item:{icon:g.jsx(v.Icons.Undo,{}),command:Vr}}),g.jsx(Sn,{item:{icon:g.jsx(v.Icons.Redo,{}),command:Wn}})]}),Aa=({schema:r})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{const n=[];if(r.nodes.bullet_list){const s=r.nodes.bullet_list;n.push({icon:g.jsx(v.Icons.List,{}),command:(o,i)=>Zn(s)(o,i)})}if(r.nodes.ordered_list){const s=r.nodes.ordered_list;n.push({icon:g.jsx(v.Icons.ListOrdered,{}),command:(o,i)=>Zn(s)(o,i)})}if(r.nodes.blockquote){const s=r.nodes.blockquote;n.push({icon:g.jsx(v.Icons.Quote,{}),command:(o,i)=>oi(s)(o,i)})}t(n)},[r]),e.length<1?null:g.jsx(Cn,{items:e})},Pa=({pos:r,isOpen:e,onClose:t})=>{const[n,s]=m.useState(""),[o,i]=m.useState(),[l,a]=m.useState(""),[c,u]=m.useState(!1);m.useEffect(()=>{s(""),a(""),i(void 0)},[e]),Ie(f=>{if(!f||!e)return;const h=We.getState(f.state);u(h.upload!==void 0)},[e]);const d=re(f=>{f&&(c?Qf(f,o,l,r):Uf(f,n,l,r),f.focus(),t())});return g.jsxs(v.Modal,{isOpen:e,onClose:t,children:[g.jsx("h1",{children:"Вставка картинки"}),g.jsxs(v.Form,{submit:"Вставить",submitType:"Success",onSubmit:d,onCancel:t,children:[c?g.jsx(v.Image,{id:"image",value:o,onChange:i,text:g.jsxs("span",{children:[g.jsx(v.Icons.Image,{}),g.jsx("br",{}),"Выберите файл"]}),required:!0,label:"Картинка"}):g.jsx(v.Input,{id:"href",value:n,onChange:s,required:!0,label:"Ссылка на картинку"}),g.jsx(v.Input,{id:"value",value:l,onChange:a,label:"Подпись"})]})]})},gm=({schema:r,isOpen:e,onClose:t})=>{const[n,s]=m.useState(""),[o,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(""),[h,p]=m.useState(!0);m.useEffect(()=>{s(""),i(""),a(""),u(""),f(""),r.nodes.table?p(!1):p(!0)},[e]);const b=re(x=>{const k=r.nodes.video;if(!x||!k)return;let w=[];if(h){if(w=js(n),!w)return}else{if(!o&&!l&&!c)return;const N=xn(l,!0)+"",O=kn(c,!0)+"",M=bn(o,!0)+"";N&&w.push(N),O&&w.push(O),M&&w.push(M)}x.dispatch(x.state.tr.replaceSelectionWith(k.create({src:w,title:d}))),x.focus(),t()}),y=()=>h?!!js(n):l&&!xn(l)||c&&!kn(c)||o&&!bn(o)?!1:!!(l||c||o);return r.nodes.video?g.jsxs(v.Modal,{isOpen:e,onClose:t,children:[g.jsx("h1",{children:"Вставка видео"}),g.jsxs(v.Form,{submit:"Вставить",submitType:"Success",onSubmit:b,onCancel:t,children:[h?g.jsx(v.Input,{id:"url",value:n,onChange:s,label:"Ссылка на видео",bottom:"Поддерживаются VK Video, RuTube и YouTube",required:!y()}):g.jsxs(g.Fragment,{children:[g.jsx(v.Input,{id:"vkvideo",value:o,onChange:i,label:"Ссылка на VK Video",required:!y()}),g.jsx(v.Input,{id:"rutube",value:l,onChange:a,label:"Ссылка на RuTube",required:!y()}),g.jsx(v.Input,{id:"youtube",value:c,onChange:u,label:"Ссылка на YouTube",required:!y()})]}),g.jsx(v.Input,{id:"value",value:d,onChange:f,label:"Подпись"})]})]}):null},Ia=({schema:r})=>{const[e,t]=m.useState([]),[n,s]=m.useState(!1),[o,i]=m.useState(!1);return m.useEffect(()=>{const l=[];if(r.nodes.image){const a=r.nodes.image;l.push({icon:g.jsx(v.Icons.Image,{}),isDisabled:c=>!Bs(c,a),command:()=>(s(!0),!0)})}if(r.nodes.video){const a=r.nodes.video;l.push({icon:g.jsx(v.Icons.Film,{}),isDisabled:c=>!Bs(c,a),command:()=>(i(!0),!0)})}if(r.nodes.horizontal_rule){const a=r.nodes.horizontal_rule;l.push({icon:g.jsx(v.Icons.FlipVertical,{}),isDisabled:c=>!Bs(c,a),command:(c,u)=>u?(u(c.tr.replaceSelectionWith(a.create())),!0):!1})}r.nodes.table&&l.push({icon:g.jsx(v.Icons.Table,{}),isDisabled:we,command:ym()}),t(l)},[r]),e.length<1?null:g.jsxs(g.Fragment,{children:[g.jsx(Cn,{items:e}),g.jsx(Pa,{isOpen:n,onClose:()=>s(!1)}),g.jsx(gm,{isOpen:o,schema:r,onClose:()=>i(!1)})]})},Bs=(r,e)=>{let t=r.selection.$from;for(let n=t.depth;n>=0;n--){let s=t.index(n);if(t.node(n).canReplaceWith(s,s,e))return!0}return!1};function ym(){return(r,e)=>{const t=r.tr.selection.anchor+1,n=r.tr,s=r.schema.nodes.table_cell.createAndFill(),o=r.schema.nodes.table.create(null,S.fromArray([r.schema.nodes.table_row.create(null,S.fromArray([s,s,s])),r.schema.nodes.table_row.create(null,S.fromArray([s,s,s]))]));return e&&e(n.replaceSelectionWith(o).scrollIntoView().setSelection(V.near(n.doc.resolve(t)))),!0}}const Va=({schema:r})=>r.nodes.carousel?g.jsx(Cn,{items:[{icon:g.jsx(v.Icons.JoinUp,{}),command:ti},{icon:g.jsx(v.Icons.IndentDecrease,{}),command:Rr},{icon:g.jsx(v.Icons.SquareDashed,{}),command:jr}]}):g.jsx(Cn,{items:[{icon:g.jsx(v.Icons.IndentDecrease,{}),command:Rr},{icon:g.jsx(v.Icons.SquareDashed,{}),command:jr}]}),bm=({schema:r})=>g.jsxs("div",{className:"SimpleMenuBar",children:[g.jsx("div",{className:"MenuBlock",children:g.jsx(Oa,{schema:r})}),g.jsx(Da,{schema:r}),g.jsx(Ia,{schema:r}),g.jsx(Aa,{schema:r}),g.jsx(Va,{schema:r}),g.jsx(Ta,{})]}),Ra=m.forwardRef(function({children:e,nodeProps:t,...n},s){const[o,i]=m.useState(t.node.attrs.alt??""),[l,a]=m.useState(t.node.attrs.title??""),[c,u]=m.useState(!1),[d,f]=m.useState("");wa((x,k)=>x?!(k instanceof MouseEvent):!1),Ie(x=>{if(f(""),u(!1),!x||!x.state.schema.nodes.carousel)return;const k=t.getPos(),w=x.state.doc.resolve(k).parent;if(u(w.type.name!=="carousel"),w.type.name==="carousel"){let N=0;w.forEach((O,M)=>{O===t.node&&(N=M+1)}),f(N?`${N} / ${w.childCount}`:"")}});const h=re((x,k)=>{if(!x)return;i(k);const w=x.state.tr,N=t.getPos();x.dispatch(w.setNodeMarkup(N,null,{...t.node.attrs,alt:k})),x.focus()}),p=re((x,k)=>{if(!x)return;a(k);const w=x.state.tr,N=t.getPos();x.dispatch(w.setNodeMarkup(N,null,{...t.node.attrs,title:k})),x.focus()}),b=re(x=>{if(!x)return;const k=t.getPos(),w=t.node.nodeSize,N=t.node.attrs,O=x.state.schema,M=O.nodes.carousel.create(null,O.nodes.image.create(N));x.dispatch(x.state.tr.replaceWith(k,k+w,M))}),y=re(x=>{if(!x)return;const k=x.state.tr,w=t.getPos(),N=t.node.nodeSize;x.dispatch(k.delete(w,w+N))});return g.jsxs("div",{...n,ref:s,className:"image",title:t.node.attrs.title,children:[g.jsxs("div",{className:"image-buttons",children:[c&&g.jsx("div",{onClick:b,className:"text-button",children:"Сделать карусель"}),d&&g.jsx("div",{className:"text-button",children:d}),g.jsx("div",{onClick:y,children:g.jsx(v.Icons.Trash,{})})]}),g.jsx("div",{className:"image-title",children:g.jsx(v.Editable,{value:o,placeholder:"Alt: описание изображения (не обязательно)",onChange:h,empty:!0,style:{textAlign:"center",cursor:"text"}})}),g.jsx("img",{title:t.node.attrs.title,alt:t.node.attrs.alt,src:t.node.attrs.fid?`${_t}/${t.node.attrs.fid}`:t.node.attrs.src}),g.jsx("div",{className:"image-title",children:g.jsx(v.Editable,{value:l,placeholder:"Title: подпись под изображением (не обязательно)",onChange:p,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),za=m.forwardRef(function({children:e,nodeProps:t,...n},s){const[o,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(""),[h,p]=m.useState(t.node.attrs.title??""),b="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";wa(()=>!0),m.useEffect(()=>{let x=t.node.attrs.src;typeof x=="string"&&(x=[x]),x.forEach(k=>{xn(k)?(i(k),a(k)):kn(k)?(i(k),u(k)):bn(k)&&(i(k),f(k))})},[t]);const y=re((x,k)=>{if(!x)return;p(k);const{$from:w,$to:N}=x.state.selection,O=w.blockRange(N);if(O){const M=x.state.doc;let T=x.state.tr;M.nodesBetween(O.start,O.end,(I,D)=>{I.type.name==="video"&&(T=T.setNodeMarkup(D,null,{...t.node.attrs,title:k}))}),x.dispatch(T)}x.focus()});return g.jsxs("div",{...n,ref:s,className:"video",title:t.node.attrs.title,children:[g.jsxs("div",{className:"video-switcher",children:[l&&g.jsx("div",{onClick:()=>i(l),className:o===l?"active":"",children:"RuTube"}),c&&g.jsx("div",{onClick:()=>i(c),className:o===c?"active":"",children:"YouTube"}),d&&g.jsx("div",{onClick:()=>i(d),className:o===d?"active":"",children:"VK Video"})]}),o?g.jsx("iframe",{src:o,allow:b}):g.jsx("img",{src:yn}),g.jsx("div",{className:"video-title",children:g.jsx(v.Editable,{value:h,placeholder:"Подпись под видео (не обязательно)",onChange:y,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),ja=({onSave:r,disabled:e=!1,notEmpty:t=!0})=>{const[n,s]=m.useState(!0),[o,i]=m.useState(!1);Ie(a=>{let c=!0;if(t){const u=a.state.doc;c=!!u.textBetween(0,u.content.size,void 0," ").length}s(c)});const l=re(async a=>{i(!0);try{let c;const u=gs(a.state);if(u){const f=a.state.apply(u.setMeta("addToHistory",!1));c=JSON.stringify(f.doc.toJSON())}else c=JSON.stringify(a.state.doc.toJSON());const d=await r({content:c,format:"prose"});if(d)throw new Error(d)}catch(c){console.error(`Can not save doc: ${c}`)}i(!1),a.focus()});return g.jsx(v.Button,{type:"Accent",disabled:e||!n||o,label:o?"Сохраняю":"Сохранить",size:"Small",onClick:l})},xm=({title:r=!1,content:e,onSave:t,onCancel:n,onChange:s,onUpload:o})=>{const[i,l]=m.useState(""),[a,c]=m.useState();m.useEffect(()=>{const h=Ke.create({doc:pm(e),schema:wn,plugins:Sa({schema:wn,upload:o})});c(h),r!==!1&&l(typeof r=="string"?r:"")},[r,e]);const u=()=>r!==!1?i.trim().length>0:!0,d=h=>{!t||!u()||t({...h,name:i})},f=()=>{n&&n()};return a?g.jsxs("div",{className:"ProseNotes",children:[r!==!1&&g.jsx("input",{className:"ProseNotesTitle",onChange:h=>l(h.currentTarget.value),value:i,placeholder:"Укажите заголовок"}),g.jsxs(ka,{state:a,dispatchTransaction:h=>c(p=>{const b=p==null?void 0:p.apply(h);return b&&h.docChanged&&s&&s(!0),b}),nodeViews:{image:Ra,video:za},children:[g.jsxs("div",{className:"ProseNotesContent",children:[g.jsx(bm,{schema:wn}),g.jsx(xa,{})]}),(t||n)&&g.jsxs("div",{className:"ProseNotesButtons",children:[n&&g.jsx("span",{className:"a small",onClick:f,children:"Отменить"}),t&&g.jsx(ja,{onSave:d,disabled:!u()})]})]})]}):null},km=({schema:r})=>{const e=m.useRef(null),[t,n]=m.useState([]),[s,o]=m.useState([]),[i,l]=m.useState(!1);Ie(c=>{const u=r.nodes.heading;if(!c||!u||!i)return;const d=[],f=[];for(let h=2;h<7;h++){const b=At(u,{level:h});f[h]=b,d[h]={id:h,icon:g.jsx(wm,{level:h}),text:`уровень ${h}`,disabled:!b(c.state)}}n(d),o(f)},[i]);const a=re((c,u)=>{!c||!u.id||(s[u.id](c.state,c.dispatch,c),l(!1),c.focus())});return r.nodes.heading?g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:e,className:"MenuItem",onClick:()=>l(!0),children:g.jsx(v.Icons.Heading,{})}),e.current&&g.jsx(v.Menu,{parent:e.current,items:t,isOpen:i,onClose:()=>l(!1),onClick:a,horizontal:"inner-left"})]}):null},wm=({level:r})=>{switch(r){case 2:return g.jsx(v.Icons.Heading2,{});case 3:return g.jsx(v.Icons.Heading3,{});case 4:return g.jsx(v.Icons.Heading4,{});case 5:return g.jsx(v.Icons.Heading5,{});case 6:return g.jsx(v.Icons.Heading6,{});default:return g.jsx(v.Icons.Heading,{})}},Sm=[{id:"left",icon:g.jsx(v.Icons.AlignLeft,{}),text:"Прижать влево"},{id:"right",icon:g.jsx(v.Icons.AlignRight,{}),text:"Прижать вправо"},{id:"center",icon:g.jsx(v.Icons.AlignCenter,{}),text:"Отцентровать"},{id:"justify",icon:g.jsx(v.Icons.AlignJustify,{}),text:"Выровнять по краям"}],Cm=({schema:r})=>{const e=m.useRef(null),[t,n]=m.useState(!1),s=re((o,i)=>{if(!o||!i.id)return;const l=i.id==="left"?null:i.id,{$from:a,$to:c}=o.state.selection,u=a.blockRange(c);if(u){const d=o.state.doc;let f=o.state.tr;d.nodesBetween(u.start,u.end,(h,p)=>{h.type.name==="paragraph"&&(f=f.setNodeMarkup(p,null,{align:l}))}),o.dispatch(f)}o.focus(),n(!1)});return r.nodes.paragraph?g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:e,className:"MenuItem",onClick:()=>n(!0),children:g.jsx(v.Icons.AlignLeft,{})}),e.current&&g.jsx(v.Menu,{parent:e.current,items:Sm,isOpen:t,onClose:()=>n(!1),onClick:s,horizontal:"inner-left"})]}):null},Mm=({schema:r,onSave:e,onView:t})=>g.jsxs("div",{className:"MenuBar",children:[g.jsxs("div",{className:"MenuBlock",children:[g.jsx(km,{schema:r}),g.jsx(Oa,{schema:r})]}),g.jsx(Da,{schema:r}),g.jsx(Ia,{schema:r}),g.jsx(Aa,{schema:r}),g.jsx(Cm,{schema:r}),g.jsx(Va,{schema:r}),g.jsx(Ta,{}),t&&g.jsx("div",{className:"MenuItem",onClick:()=>t(),children:g.jsx(v.Icons.Eye,{})}),g.jsx("div",{className:"MenuBlock",children:g.jsx(ja,{onSave:e})})]}),vm=7,Ba=1,Mn=50,Nm=({width:r,onChange:e,onWidth:t})=>{const[n,s]=m.useState(!1),[o,i]=m.useState(0),[l,a]=m.useState(0),[c,u]=m.useState(r),d=p=>{const b=r[l],y=r[l+1],x=[...c];return b+p<Mn&&(p=Mn-b),y-p<Mn&&(p=y-Mn),x[l]=b+p,x[l+1]=y-p,x};m.useEffect(()=>{u(r)},[r]),m.useEffect(()=>{const p=y=>{if(!n)return;s(!1),y.preventDefault(),y.stopPropagation();const x=y.clientX-o,k=d(x);t(k)},b=y=>{if(!n)return;y.preventDefault(),y.stopPropagation();const x=y.clientX-o,k=d(x);u(k),e(k)};return document.addEventListener("mouseup",p),document.addEventListener("mousemove",b),()=>{document.removeEventListener("mouseup",p),document.removeEventListener("mousemove",b)}},[n,l]);const f=(p,b)=>{b!==r.length-1&&(p.preventDefault(),p.stopPropagation(),s(!0),i(p.clientX),a(b))},h=p=>c.slice(0,p+1).reduce((b,y)=>b+y,0)+p+Ba-Math.floor(vm/2);return g.jsx("div",{className:"table-resizer",children:c.map((p,b)=>g.jsx("div",{style:{left:h(b)+"px"},onMouseDown:y=>f(y,b)},b))})},Em=m.forwardRef(function({children:e,nodeProps:t,...n},s){var d;const o=m.useRef(null),i=m.useRef(null),[l,a]=m.useState([]),c=re((f,h)=>{if(!f)return;const p=t.node,b=t.getPos()+1,y=G.get(p),x=f.state.tr;for(let k=0;k<y.height;k++)for(let w=0;w<y.width;){const N=k*y.width+w,O=y.map[N],M=p.nodeAt(O).attrs,T=h.slice(w,w+M.colspan);k&&y.map[N]==y.map[N-y.width]||x.setNodeMarkup(b+O,null,{...M,colwidth:T}),w+=M.colspan}x.docChanged&&f.dispatch(x)});m.useEffect(()=>{if(!o.current||!i.current)return;const h=t.node.firstChild;if(!h)return;let p=[];for(let M=0;M<h.childCount;M++){const T=h.child(M),{colspan:I,colwidth:D}=T.attrs;p=p.concat(Array.isArray(D)?D:Array(I).fill(0))}const b=p.filter(M=>!M).length,y=p.reduce((M,T)=>M+T,0),x=(p.length+1)*Ba,k=Math.max(b?(o.current.offsetWidth-y-x)/b:0,Mn);p=p.map(M=>M||k);const w=p.reduce((M,T)=>M+T,0),N=i.current.offsetWidth-x-16,O=N/w;p=p.map(M=>Math.round(M*O)),p[p.length-1]+=N-p.reduce((M,T)=>M+T,0),a(p)},[t,o,i,(d=i.current)==null?void 0:d.offsetWidth]);const u=re(f=>{Vh(f.state,f.dispatch)});return g.jsxs("div",{...n,className:"table-wrapper",ref:f=>{i.current=f,s&&(typeof s=="function"?s(f):s.current=f)},children:[g.jsx(Nm,{width:l,onChange:a,onWidth:c}),g.jsxs("table",{ref:o,children:[g.jsx("colgroup",{children:l.map((f,h)=>g.jsx("col",{width:f},h))}),g.jsx("caption",{onClick:u,children:g.jsx(v.Icons.Trash,{})}),g.jsx("tbody",{children:e})]})]})}),Om=[{id:"toggleHeaderRow",text:"Toggle header row",icon:g.jsx(v.Icons.Heading,{})},{id:"addRowBefore",text:"Insert row before",icon:g.jsx(v.Icons.RowInsertBefore,{})},{id:"addRowAfter",text:"Insert row after",icon:g.jsx(v.Icons.RowInsertAfter,{})},{id:"deleteRow",text:"Delete row",icon:g.jsx(v.Icons.Trash,{})}],Dm=[{id:"toggleHeaderColumn",text:"Toggle header column",icon:g.jsx(v.Icons.Heading,{})},{id:"addColumnBefore",text:"Insert column before",icon:g.jsx(v.Icons.ColumnInsertBefore,{})},{id:"addColumnAfter",text:"Insert column after",icon:g.jsx(v.Icons.ColumnInsertAfter,{})},{id:"deleteColumn",text:"Delete column",icon:g.jsx(v.Icons.Trash,{})}],Tm=[{id:"toggleHeaderCell",text:"Toggle header",icon:g.jsx(v.Icons.Heading,{})},{id:"alignLeft",text:"Horizontal align left",icon:g.jsx(v.Icons.AlignLeft,{})},{id:"alignCenter",text:"Horizontal align center",icon:g.jsx(v.Icons.AlignCenter,{})},{id:"alignRight",text:"Horizontal align Right",icon:g.jsx(v.Icons.AlignRight,{})},{id:"alignTop",text:"Vertical align top",icon:g.jsx(v.Icons.AlignTop,{})},{id:"alignMiddle",text:"Vertical align middle",icon:g.jsx(v.Icons.AlignMiddle,{})},{id:"alignBottom",text:"Vertical align bottom",icon:g.jsx(v.Icons.AlignBottom,{})},{id:"mergeCells",text:"Merge cells",icon:g.jsx(v.Icons.CellsMerge,{})},{id:"splitCell",text:"Split cell",icon:g.jsx(v.Icons.CellsSplit,{})}],Fa=({x:r,y:e,isRowMenuOpen:t,isCellMenuOpen:n,isColumnMenuOpen:s,onRowMenuClose:o,onCellMenuClose:i,onColumnMenuClose:l})=>{const a=re((c,u)=>{if(c){switch(u.id){case"toggleHeaderRow":Th(c.state,c.dispatch);break;case"addRowBefore":wh(c.state,c.dispatch);break;case"addRowAfter":Sh(c.state,c.dispatch);break;case"deleteRow":Mh(c.state,c.dispatch);break;case"toggleHeaderColumn":Ah(c.state,c.dispatch);break;case"addColumnBefore":gh(c.state,c.dispatch);break;case"addColumnAfter":yh(c.state,c.dispatch);break;case"deleteColumn":xh(c.state,c.dispatch);break;case"mergeCells":Nh(c.state,c.dispatch);break;case"splitCell":Eh(c.state,c.dispatch);break;case"toggleHeaderCell":Ph(c.state,c.dispatch);break;case"alignLeft":Ft("halign","left")(c.state,c.dispatch);break;case"alignCenter":Ft("halign","center")(c.state,c.dispatch);break;case"alignRight":Ft("halign","right")(c.state,c.dispatch);break;case"alignTop":Ft("valign","top")(c.state,c.dispatch);break;case"alignMiddle":Ft("valign","middle")(c.state,c.dispatch);break;case"alignBottom":Ft("valign","bottom")(c.state,c.dispatch);break}o(),i(),l(),c.focus()}});return g.jsxs(g.Fragment,{children:[g.jsx(v.Menu,{x:r,y:e,items:Om,isOpen:t,onClose:o,onClick:a}),g.jsx(v.Menu,{x:r,y:e,items:Tm,isOpen:n,onClose:i,onClick:a}),g.jsx(v.Menu,{x:r,y:e,items:Dm,isOpen:s,onClose:l,onClick:a})]})},La=m.forwardRef(function({children:e,nodeProps:t,...n},s){const o=m.useRef(null),[i,l]=m.useState(0),[a,c]=m.useState(0),[u,d]=m.useState(!1),[f,h]=m.useState(!1),[p,b]=m.useState(!1);m.useEffect(()=>{const k=w=>{o.current!==w.target&&(d(!1),h(!1),b(!1))};return document.addEventListener("contextmenu",k,!0),()=>document.removeEventListener("contextmenu",k,!0)},[]);const y=k=>{k.preventDefault(),k.stopPropagation(),d(!1),h(!1),b(!1),l(k.clientX),c(k.clientY);const w=k.currentTarget.getBoundingClientRect();k.clientY<w.y?b(!0):k.clientX<w.x?d(!0):h(!0)},x=k=>{d(!1),h(!1),b(!1),l(k.clientX),c(k.clientY);const w=k.currentTarget.getBoundingClientRect();if(k.clientY<w.y)b(!0);else if(k.clientX<w.x)d(!0);else return;k.preventDefault(),k.stopPropagation()};return t.node.type.spec.tableRole==="header_cell"?g.jsxs("th",{...n,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:x,onContextMenu:y,ref:k=>{o.current=k,s&&(typeof s=="function"?s(k):s.current=k)},children:[e,g.jsx(Fa,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>d(!1),isCellMenuOpen:f,onCellMenuClose:()=>h(!1),isColumnMenuOpen:p,onColumnMenuClose:()=>b(!1)})]}):g.jsxs("td",{...n,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:x,onContextMenu:y,ref:k=>{o.current=k,s&&(typeof s=="function"?s(k):s.current=k)},children:[e,g.jsx(Fa,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>d(!1),isCellMenuOpen:f,onCellMenuClose:()=>h(!1),isColumnMenuOpen:p,onColumnMenuClose:()=>b(!1)})]})}),Am=m.forwardRef(function({children:e,nodeProps:t,...n},s){var O;const o=m.useRef(null),[i,l]=m.useState(!1),[a,c]=m.useState(!1),[u,d]=m.useState(!1),[f,h]=m.useState(),[p,b]=m.useState(),y=M=>{const T=M.scrollLeft,I=M.clientWidth,D=M.scrollWidth;c(T>0),d(T<D-I*1.5)};m.useEffect(()=>{o.current&&(p&&o.current.scrollWidth>p&&(o.current.scrollLeft=o.current.scrollWidth-o.current.clientWidth),b(o.current.scrollWidth))},[(O=o.current)==null?void 0:O.scrollWidth]),m.useEffect(()=>{h(t.getPos()+t.node.nodeSize-1),o.current&&t.node.childCount>1&&y(o.current)},[t,o]),Ie(M=>{if(!M||t.node.childCount>0)return;const T=M.state.tr,I=t.getPos(),D=t.node.nodeSize;M.dispatch(T.delete(I,I+D))},[t]);const x=re(M=>{if(!M)return;const T=t.getPos(),I=t.node.nodeSize;M.dispatch(M.state.tr.delete(T,T+I))}),k=()=>{l(!0)},w=M=>{y(M.currentTarget)},N=(M,T)=>{if(M.stopPropagation(),!o.current)return;const I=o.current.clientWidth;let D=o.current.scrollLeft+T*I;o.current.scrollLeft=D};return g.jsxs("div",{ref:s,...n,className:"carousel",children:[g.jsx("div",{className:"carousel-list",ref:o,onScroll:w,children:e}),g.jsxs("div",{className:"carousel-buttons",children:[g.jsx("div",{onClick:x,className:"text-button",children:"Удалить карусель"}),g.jsx("div",{onClick:k,children:g.jsx(v.Icons.Plus,{})})]}),a&&g.jsx("div",{className:"carousel-prev",onClick:M=>N(M,-1),children:g.jsx(v.Icons.ChevronLeft,{})}),u&&g.jsx("div",{className:"carousel-next",onClick:M=>N(M,1),children:g.jsx(v.Icons.ChevronRight,{})}),g.jsx(Pa,{pos:f,isOpen:i,onClose:()=>l(!1)})]})}),Pm=({content:r,onSave:e,onView:t,onChange:n,onUpload:s})=>{const[o,i]=m.useState();m.useEffect(()=>{let a;if(r)try{a=pe.fromJSON(_e,JSON.parse(r))}catch(d){console.error(`Can not parse Prose format: ${d}`)}let c=Ke.create({doc:a,schema:_e,plugins:Sa({schema:_e,upload:s})});const u=gs(c);u&&(c=c.apply(u.setMeta("addToHistory",!1))),i(c)},[r]);const l=async a=>{const c=await e(a);return n&&n(!1),c};return o?g.jsx("div",{className:"ProseEditor",children:g.jsxs(ka,{state:o,dispatchTransaction:a=>i(c=>{const u=c==null?void 0:c.apply(a);return u&&a.docChanged&&n&&n(!0),u}),nodeViews:{image:Ra,video:za,table:Em,table_header:La,table_cell:La,carousel:Am},children:[g.jsx(Mm,{schema:_e,onSave:l,onView:t}),g.jsx(xa,{})]})}):null},Im=({node:r})=>{const[e,t]=m.useState();return m.useEffect(()=>{var s;const n=(s=r.attrs)==null?void 0:s.align;t(n!=="right"&&n!=="center"&&n!=="justify"?void 0:{textAlign:n})},[r]),g.jsx("p",{style:e,children:Array.isArray(r.content)&&r.content.map((n,s)=>g.jsx(J,{node:n},s))})},Vm=({node:r})=>{if(!r.text)return null;const e=(t,n)=>{var i;if(!Array.isArray(r.marks))return g.jsx(g.Fragment,{children:n});if(!t.length)return g.jsx(g.Fragment,{children:n});const s=t[0].type,o=(i=t[0].attrs)==null?void 0:i.href;switch(s){case"em":return g.jsx("em",{children:e(t.slice(1),n)});case"code":return g.jsx("code",{children:e(t.slice(1),n)});case"strong":return g.jsx("strong",{children:e(t.slice(1),n)});case"underline":return g.jsx("u",{children:e(t.slice(1),n)});case"strikethrough":return g.jsx("s",{children:e(t.slice(1),n)});case"link":return o?g.jsx("a",{target:"_blank",href:o,children:e(t.slice(1),n)}):g.jsx(g.Fragment,{children:e(t.slice(1),n)});default:return g.jsx(g.Fragment,{children:e(t.slice(1),n)})}};return e(r.marks,r.text)},Rm=({node:r,className:e})=>g.jsx("div",{className:e,children:Array.isArray(r.content)&&r.content.map((t,n)=>g.jsx(J,{node:t},n))}),zm=({node:r})=>{const e=m.useRef(null),[t,n]=m.useState(""),[s,o]=m.useState(""),[i,l]=m.useState(""),[a,c]=m.useState(!1);m.useEffect(()=>{const d=()=>{c(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",d),()=>document.removeEventListener("fullscreenchange",d)},[]),m.useEffect(()=>{var h,p,b,y,x,k,w;let d=(h=r.attrs)==null?void 0:h.fid,f=(p=r.attrs)!=null&&p.src?`${(b=r.attrs)==null?void 0:b.src}`:"";d&&(f=`${_t}/${d}`),f||(f=Ct),n(f),o((y=r.attrs)!=null&&y.alt?`${(x=r.attrs)==null?void 0:x.alt}`:""),l((k=r.attrs)!=null&&k.title?`${(w=r.attrs)==null?void 0:w.title}`:"")},[r]);const u=d=>{var f;d.stopPropagation(),a?document.exitFullscreen():(f=e.current)==null||f.requestFullscreen()};return t?g.jsxs("div",{ref:e,className:"image",children:[g.jsx("img",{src:t,onClick:u,alt:s,title:i}),i&&g.jsx("div",{className:"image-title",children:i}),g.jsx("div",{className:"image-full",onClick:u,children:a?g.jsx(v.Icons.Minimize,{}):g.jsx(v.Icons.Maximize,{})})]}):null},jm=({node:r})=>g.jsx("blockquote",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(J,{node:e},t))}),Bm=50,Fm=({node:r})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{if(t([]),!Array.isArray(r.content))return;const n=r.content[0];if(!Array.isArray(n.content))return;let s=[];for(let i=0;i<n.content.length;i++){const l=n.content[i].attrs;if(!l)return;const{colspan:a,colwidth:c}=l;s=s.concat(Array.isArray(c)?c:Array(a).fill(Bm))}const o=s.reduce((i,l)=>i+l,0);s=s.map(i=>Math.round(i*100/o)),s[s.length-1]+=100-s.reduce((i,l)=>i+l,0),t(s)},[r]),g.jsxs("table",{children:[e.length>0&&g.jsx("colgroup",{children:e.map((n,s)=>g.jsx("col",{width:`${n}%`},s))}),g.jsx("tbody",{children:Array.isArray(r.content)&&r.content.map((n,s)=>g.jsx(J,{node:n},s))})]})},Lm=({node:r})=>g.jsx("tr",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(J,{node:e},t))}),$m=({node:r})=>{const[e,t]=m.useState(),[n,s]=m.useState(),[o,i]=m.useState(),[l,a]=m.useState();return m.useEffect(()=>{var c,u,d,f;t((c=r.attrs)==null?void 0:c.halign),s((u=r.attrs)==null?void 0:u.valign),i((d=r.attrs)!=null&&d.rowspan?parseInt(r.attrs.rowspan+""):1),a((f=r.attrs)!=null&&f.colspan?parseInt(r.attrs.colspan+""):1)},[r]),r.type==="table_header"?g.jsx("th",{colSpan:l,rowSpan:o,style:{textAlign:e,verticalAlign:n},children:Array.isArray(r.content)&&r.content.map((c,u)=>g.jsx(J,{node:c},u))}):g.jsx("td",{colSpan:l,rowSpan:o,style:{textAlign:e,verticalAlign:n},children:Array.isArray(r.content)&&r.content.map((c,u)=>g.jsx(J,{node:c},u))})},Wm=({node:r})=>{var e;if(!Array.isArray(r.content))return null;switch((e=r.attrs)==null?void 0:e.level){case 1:return g.jsx("h1",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});case 2:return g.jsx("h2",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});case 3:return g.jsx("h3",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});case 4:return g.jsx("h4",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});case 5:return g.jsx("h5",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});case 6:return g.jsx("h6",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))});default:return g.jsx("h2",{children:r.content.map((t,n)=>g.jsx(J,{node:t},n))})}},_m=({node:r})=>Array.isArray(r.content)?r.type==="bullet_list"?g.jsx("ul",{children:r.content.map((e,t)=>g.jsx(J,{node:e},t))}):g.jsx("ol",{children:r.content.map((e,t)=>g.jsx(J,{node:e},t))}):null,qm=({node:r})=>g.jsx("li",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(J,{node:e},t))}),Jm=({node:r})=>g.jsx("pre",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(J,{node:e},t))}),Hm=()=>g.jsx("hr",{}),Km=({node:r})=>{const[e,t]=m.useState(""),[n,s]=m.useState(""),[o,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(0),h="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";return m.useEffect(()=>{var b,y;u((b=r.attrs)!=null&&b.title?`${r.attrs.title}`:"");let p=(y=r.attrs)==null?void 0:y.src;typeof p=="string"&&(p=[p]),p.forEach(x=>{xn(x)?(t(x),s(x)):kn(x)?(t(x),i(x)):bn(x)&&(t(x),a(x))})},[r]),m.useEffect(()=>{let p=0;n&&p++,o&&p++,l&&p++,f(p)},[n,o,l]),d?g.jsxs("div",{className:"video",children:[d>1&&g.jsxs("div",{className:"video-switcher",children:[n&&g.jsx("div",{onClick:()=>t(n),className:e===n?"active":"",children:"RuTube"}),o&&g.jsx("div",{onClick:()=>t(o),className:e===o?"active":"",children:"YouTube"}),l&&g.jsx("div",{onClick:()=>t(l),className:e===l?"active":"",children:"VK Video"})]}),g.jsx("iframe",{src:e,allow:h}),c&&g.jsx("div",{className:"video-title",children:c})]}):g.jsxs("div",{className:"image",children:[g.jsx("img",{src:yn}),c&&g.jsx("div",{className:"image-title",children:c})]})},Ym=()=>g.jsx("br",{}),Gm=({node:r})=>{const e=m.useRef(null),t=m.useRef(null),[n,s]=m.useState(!1),[o,i]=m.useState(!1),[l,a]=m.useState(!1),[c,u]=m.useState(1),[d,f]=m.useState(1),h=y=>{const x=y.scrollLeft,k=y.clientWidth,w=y.scrollWidth;i(x>k/2),a(x<w-k*1.5),u(Math.round(x/k+1))};m.useEffect(()=>{var y;a(Array.isArray(r.content)&&r.content.length>1),f(((y=r.content)==null?void 0:y.length)??1),u(1)},[r]),m.useEffect(()=>{const y=()=>{s(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",y),()=>document.removeEventListener("fullscreenchange",y)},[]),m.useEffect(()=>{if(!n)return;const y=x=>{x.key==="ArrowLeft"&&b(null,-1),x.key==="ArrowRight"&&b(null,1)};return document.body.addEventListener("keydown",y),()=>document.body.removeEventListener("keydown",y)},[n]);const p=y=>{var x;y.stopPropagation(),n?document.exitFullscreen():(x=t.current)==null||x.requestFullscreen()},b=(y,x)=>{if(y==null||y.stopPropagation(),!e.current)return;const k=e.current.clientWidth;let w=e.current.scrollLeft+x*k;e.current.scrollLeft=w};return Array.isArray(r.content)?g.jsxs("div",{className:"carousel",ref:t,children:[g.jsx("div",{className:"carousel-list",ref:e,onScroll:y=>h(y.currentTarget),children:r.content.map((y,x)=>g.jsx(Xm,{node:y,onClick:p},x))}),g.jsxs("div",{className:"carousel-numb",children:[c," / ",d]}),g.jsx("div",{className:"carousel-full",onClick:p,children:n?g.jsx(v.Icons.Minimize,{}):g.jsx(v.Icons.Maximize,{})}),o&&g.jsx("div",{className:"carousel-prev",onClick:y=>b(y,-1),children:g.jsx(v.Icons.ChevronLeft,{})}),l&&g.jsx("div",{className:"carousel-next",onClick:y=>b(y,1),children:g.jsx(v.Icons.ChevronRight,{})})]}):null},Xm=({node:r,onClick:e})=>{const[t,n]=m.useState(""),[s,o]=m.useState(""),[i,l]=m.useState("");return m.useEffect(()=>{var f,h,p,b;let a=(f=r.attrs)==null?void 0:f.fid,c=(h=r.attrs)!=null&&h.src?`${r.attrs.src}`:"",u=(p=r.attrs)!=null&&p.alt?`${r.attrs.alt}`:"",d=(b=r.attrs)!=null&&b.title?`${r.attrs.title}`:"";a&&(c=`${_t}/${a}`),c||(c=Ct),n(c),o(u),l(d)},[r]),r.type!=="image"?null:g.jsxs("div",{className:"image",children:[t&&g.jsx("img",{src:t,onClick:e,alt:s,title:i}),i&&g.jsx("div",{className:"image-title",children:i})]})},J=({node:r,className:e})=>r?(n=>{switch(n.type){case"doc":return g.jsx(Rm,{node:n,className:e});case"list_item":return g.jsx(qm,{node:n});case"bullet_list":case"ordered_list":return g.jsx(_m,{node:n});case"image":return g.jsx(zm,{node:n});case"video":return g.jsx(Km,{node:n});case"text":return g.jsx(Vm,{node:n});case"table":return g.jsx(Fm,{node:n});case"table_row":return g.jsx(Lm,{node:n});case"table_cell":case"table_header":return g.jsx($m,{node:n});case"heading":return g.jsx(Wm,{node:n});case"code_block":return g.jsx(Jm,{node:n});case"paragraph":return g.jsx(Im,{node:n});case"blockquote":return g.jsx(jm,{node:n});case"carousel":return g.jsx(Gm,{node:n});case"horizontal_rule":return g.jsx(Hm,{});case"hard_break":return g.jsx(Ym,{});default:return g.jsx("span",{className:"unknown_node_type",children:n.type})}})(r):null,Qm=({content:r})=>{const[e,t]=m.useState(),[n,s]=m.useState(!1);return m.useEffect(()=>{try{s(!1);const o=JSON.parse(r);t(o)}catch(o){s(!0),console.error(`Can not parse Prose format: ${o}`)}},[r]),n?g.jsx("div",{className:"error",children:"ОШИБКА"}):g.jsx(J,{node:e,className:"ProseViewer"})},Um=({content:r})=>{const e=m.useRef(null),[t,n]=m.useState(!1);return m.useEffect(()=>{var s;try{n(!1);const o=pe.fromJSON(_e,JSON.parse(r)),i=ze.fromSchema(_e).serializeFragment(o.content);(s=e.current)==null||s.appendChild(i)}catch(o){n(!0),console.error(`Can not parse Prose format: ${o}`)}},[e,r]),g.jsx("div",{ref:e,className:"ProseViewer",children:t&&g.jsx("div",{className:"error",children:"ОШИБКА"})})},Zm='{"type":"doc","content":[{"type":"paragraph","attrs":{"align":null},"content":[{"type":"text","text":"@"}]}]}',eg='{"type":"doc","content":[{"type":"paragraph","attrs":{"align":null},"content":[{"type":"text","text":"При парсинге документа произошла ошибка"}]}]}',tg=(r,e,t)=>{if(!r)return Zm;try{const s=new DOMParser().parseFromString(r,"text/html");if(t){const i=s.getElementsByTagName("img");for(var n=0;n<i.length;n++){const l=i[n].getAttribute(t);l&&i[n].setAttribute("fid",l)}}const o=In.fromSchema(e?wn:_e).parse(s).toJSON();return JSON.stringify(o)}catch(s){return console.error(`Can not convert html content to prose format: ${s}`),eg}};_.DOM=Um,_.Editor=Pm,_.Notes=xm,_.Viewer=Qm,_.htmlToProse=tg,_.setConfig=lm,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
54
54
|
//# sourceMappingURL=prose-editor.umd.js.map
|