@alxgrn/prose-editor 0.0.41 → 0.0.43
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/lib/index.d.ts +2 -1
- package/dist/lib/utils/convert.d.ts +6 -0
- package/dist/prose-editor.es.js +6704 -8366
- package/dist/prose-editor.es.js.map +1 -1
- package/dist/prose-editor.umd.js +23 -26
- package/dist/prose-editor.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/prose-editor.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(G,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):(G=typeof globalThis<"u"?globalThis:G||self,m(G.ProseEditor={},G.React,G.ReactDOM,G["@alxgrn/telefrag-ui"]))})(this,function(G,m,Ye,N){"use strict";var D0=Object.defineProperty;var O0=(G,m,Ye)=>m in G?D0(G,m,{enumerable:!0,configurable:!0,writable:!0,value:Ye}):G[m]=Ye;var j=(G,m,Ye)=>O0(G,typeof m!="symbol"?m+"":m,Ye);var di=document.createElement("style");di.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,.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 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(--alxgrn-button-color);background-color:var(--alxgrn-button-bg);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);opacity:.9;display:flex;align-items:center;justify-content:center}.ProseViewer div.video .video-switcher div.active,.ProseEditor div.video .video-switcher div.active,.ProseNotes div.video .video-switcher div.active{background-color:var(--alxgrn-button-bg-accent)}.ProseViewer div.video .video-switcher div:hover,.ProseEditor div.video .video-switcher div:hover,.ProseNotes div.video .video-switcher div:hover{opacity:1}.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(--alxgrn-button-color);background-color:var(--alxgrn-button-bg);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);padding:0;opacity:.9;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{opacity:1}.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{opacity:1}.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(--alxgrn-button-color);background-color:var(--alxgrn-button-bg);cursor:pointer;border-radius:var(--alxgrn-unit-small);opacity:.9;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{opacity:1}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
|
-
/*$vite$:1*/`,document.head.appendChild(
|
|
1
|
+
(function(K,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):(K=typeof globalThis<"u"?globalThis:K||self,m(K.ProseEditor={},K.React,K.ReactDOM,K["@alxgrn/telefrag-ui"]))})(this,function(K,m,Le,N){"use strict";var Eg=Object.defineProperty;var Og=(K,m,Le)=>m in K?Eg(K,m,{enumerable:!0,configurable:!0,writable:!0,value:Le}):K[m]=Le;var $=(K,m,Le)=>Og(K,typeof m!="symbol"?m+"":m,Le);var so=document.createElement("style");so.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}
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(so);function yc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var kr={exports:{}},nn={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var
|
|
10
|
+
*/var oo;function bc(){if(oo)return nn;oo=1;var r=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(n,s,o){var i=null;if(o!==void 0&&(i=""+o),s.key!==void 0&&(i=""+s.key),"key"in s){o={};for(var l in s)l!=="key"&&(o[l]=s[l])}else o=s;return s=o.ref,{$$typeof:r,type:n,key:i,ref:s!==void 0?s:null,props:o}}return nn.Fragment=e,nn.jsx=t,nn.jsxs=t,nn}var rn={};/**
|
|
11
11
|
* @license React
|
|
12
12
|
* react-jsx-runtime.development.js
|
|
13
13
|
*
|
|
@@ -15,38 +15,35 @@
|
|
|
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
|
|
18
|
+
*/var io;function xc(){return io||(io=1,process.env.NODE_ENV!=="production"&&function(){function r(k){if(k==null)return null;if(typeof k=="function")return k.$$typeof===Mg?null:k.displayName||k.name||null;if(typeof k=="string")return k;switch(k){case M:return"Fragment";case O:return"Portal";case R:return"Profiler";case D:return"StrictMode";case we:return"Suspense";case H:return"SuspenseList"}if(typeof k=="object")switch(typeof k.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),k.$$typeof){case G:return(k.displayName||"Context")+".Provider";case T:return(k._context.displayName||"Context")+".Consumer";case ce:var A=k.render;return k=k.displayName,k||(k=A.displayName||A.name||"",k=k!==""?"ForwardRef("+k+")":"ForwardRef"),k;case Ae:return A=k.displayName||null,A!==null?A:r(k.type)||"Memo";case Qs:A=k._payload,k=k._init;try{return r(k(A))}catch{}}return null}function e(k){return""+k}function t(k){try{e(k);var A=!1}catch{A=!0}if(A){A=console;var P=A.error,B=typeof Symbol=="function"&&Symbol.toStringTag&&k[Symbol.toStringTag]||k.constructor.name||"Object";return P.call(A,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",B),e(k)}}function n(){}function s(){if(In===0){tc=console.log,nc=console.info,rc=console.warn,sc=console.error,oc=console.group,ic=console.groupCollapsed,lc=console.groupEnd;var k={configurable:!0,enumerable:!0,value:n,writable:!0};Object.defineProperties(console,{info:k,log:k,warn:k,error:k,group:k,groupCollapsed:k,groupEnd:k})}In++}function o(){if(In--,In===0){var k={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:It({},k,{value:tc}),info:It({},k,{value:nc}),warn:It({},k,{value:rc}),error:It({},k,{value:sc}),group:It({},k,{value:oc}),groupCollapsed:It({},k,{value:ic}),groupEnd:It({},k,{value:lc})})}0>In&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function i(k){if(Zs===void 0)try{throw Error()}catch(P){var A=P.stack.trim().match(/\n( *(at )?)/);Zs=A&&A[1]||"",ac=-1<P.stack.indexOf(`
|
|
19
19
|
at`)?" (<anonymous>)":-1<P.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
20
|
-
`+
|
|
21
|
-
`),
|
|
22
|
-
`);for(
|
|
23
|
-
`+me[_].replace(" at new "," at ");return k.displayName&&
|
|
20
|
+
`+Zs+k+ac}function l(k,A){if(!k||eo)return"";var P=to.get(k);if(P!==void 0)return P;eo=!0,P=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var B=null;B=Pt.H,Pt.H=null,s();try{var ue={DetermineComponentFrameRoot:function(){try{if(A){var mt=function(){throw Error()};if(Object.defineProperty(mt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(mt,[])}catch(Xe){var xr=Xe}Reflect.construct(k,[],mt)}else{try{mt.call()}catch(Xe){xr=Xe}k.call(mt.prototype)}}else{try{throw Error()}catch(Xe){xr=Xe}(mt=k())&&typeof mt.catch=="function"&&mt.catch(function(){})}}catch(Xe){if(Xe&&xr&&typeof Xe.stack=="string")return[Xe.stack,xr.stack]}return[null,null]}};ue.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var _=Object.getOwnPropertyDescriptor(ue.DetermineComponentFrameRoot,"name");_&&_.configurable&&Object.defineProperty(ue.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var z=ue.DetermineComponentFrameRoot(),Ge=z[0],Zt=z[1];if(Ge&&Zt){var me=Ge.split(`
|
|
21
|
+
`),Vt=Zt.split(`
|
|
22
|
+
`);for(z=_=0;_<me.length&&!me[_].includes("DetermineComponentFrameRoot");)_++;for(;z<Vt.length&&!Vt[z].includes("DetermineComponentFrameRoot");)z++;if(_===me.length||z===Vt.length)for(_=me.length-1,z=Vt.length-1;1<=_&&0<=z&&me[_]!==Vt[z];)z--;for(;1<=_&&0<=z;_--,z--)if(me[_]!==Vt[z]){if(_!==1||z!==1)do if(_--,z--,0>z||me[_]!==Vt[z]){var Vn=`
|
|
23
|
+
`+me[_].replace(" at new "," at ");return k.displayName&&Vn.includes("<anonymous>")&&(Vn=Vn.replace("<anonymous>",k.displayName)),typeof k=="function"&&to.set(k,Vn),Vn}while(1<=_&&0<=z);break}}}finally{eo=!1,Pt.H=B,o(),Error.prepareStackTrace=P}return me=(me=k?k.displayName||k.name:"")?i(me):"",typeof k=="function"&&to.set(k,me),me}function a(k){if(k==null)return"";if(typeof k=="function"){var A=k.prototype;return l(k,!(!A||!A.isReactComponent))}if(typeof k=="string")return i(k);switch(k){case we:return i("Suspense");case H:return i("SuspenseList")}if(typeof k=="object")switch(k.$$typeof){case ce:return k=l(k.render,!1),k;case Ae:return a(k.type);case Qs:A=k._payload,k=k._init;try{return a(k(A))}catch{}}return""}function c(){var k=Pt.A;return k===null?null:k.getOwner()}function u(k){if(ec.call(k,"key")){var A=Object.getOwnPropertyDescriptor(k,"key").get;if(A&&A.isReactWarning)return!1}return k.key!==void 0}function d(k,A){function P(){cc||(cc=!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)",A))}P.isReactWarning=!0,Object.defineProperty(k,"key",{get:P,configurable:!0})}function f(){var k=r(this.type);return uc[k]||(uc[k]=!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.")),k=this.props.ref,k!==void 0?k:null}function h(k,A,P,B,ue,_){return P=_.ref,k={$$typeof:v,type:k,key:A,props:_,_owner:ue},(P!==void 0?P:null)!==null?Object.defineProperty(k,"ref",{enumerable:!1,get:f}):Object.defineProperty(k,"ref",{enumerable:!1,value:null}),k._store={},Object.defineProperty(k._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(k,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.freeze&&(Object.freeze(k.props),Object.freeze(k)),k}function p(k,A,P,B,ue,_){if(typeof k=="string"||typeof k=="function"||k===M||k===R||k===D||k===we||k===H||k===Cg||typeof k=="object"&&k!==null&&(k.$$typeof===Qs||k.$$typeof===Ae||k.$$typeof===G||k.$$typeof===T||k.$$typeof===ce||k.$$typeof===vg||k.getModuleId!==void 0)){var z=A.children;if(z!==void 0)if(B)if(Us(z)){for(B=0;B<z.length;B++)b(z[B],k);Object.freeze&&Object.freeze(z)}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 b(z,k)}else z="",(k===void 0||typeof k=="object"&&k!==null&&Object.keys(k).length===0)&&(z+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),k===null?B="null":Us(k)?B="array":k!==void 0&&k.$$typeof===v?(B="<"+(r(k.type)||"Unknown")+" />",z=" Did you accidentally export a JSX literal instead of a component?"):B=typeof k,console.error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",B,z);if(ec.call(A,"key")){z=r(k);var Ge=Object.keys(A).filter(function(me){return me!=="key"});B=0<Ge.length?"{key: someKey, "+Ge.join(": ..., ")+": ...}":"{key: someKey}",dc[z+B]||(Ge=0<Ge.length?"{"+Ge.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
24
24
|
let props = %s;
|
|
25
25
|
<%s {...props} />
|
|
26
26
|
React keys must be passed directly to JSX without using spread:
|
|
27
27
|
let props = %s;
|
|
28
|
-
<%s key={someKey} {...props} />`,B
|
|
28
|
+
<%s key={someKey} {...props} />`,B,z,Ge,z),dc[z+B]=!0)}if(z=null,P!==void 0&&(t(P),z=""+P),u(A)&&(t(A.key),z=""+A.key),"key"in A){P={};for(var Zt in A)Zt!=="key"&&(P[Zt]=A[Zt])}else P=A;return z&&d(P,typeof k=="function"?k.displayName||k.name||"Unknown":k),h(k,z,_,ue,c(),P)}function b(k,A){if(typeof k=="object"&&k&&k.$$typeof!==Ng){if(Us(k))for(var P=0;P<k.length;P++){var B=k[P];y(B)&&x(B,A)}else if(y(k))k._store&&(k._store.validated=1);else if(k===null||typeof k!="object"?P=null:(P=Za&&k[Za]||k["@@iterator"],P=typeof P=="function"?P:null),typeof P=="function"&&P!==k.entries&&(P=P.call(k),P!==k))for(;!(k=P.next()).done;)y(k.value)&&x(k.value,A)}}function y(k){return typeof k=="object"&&k!==null&&k.$$typeof===v}function x(k,A){if(k._store&&!k._store.validated&&k.key==null&&(k._store.validated=1,A=w(A),!fc[A])){fc[A]=!0;var P="";k&&k._owner!=null&&k._owner!==c()&&(P=null,typeof k._owner.tag=="number"?P=r(k._owner.type):typeof k._owner.name=="string"&&(P=k._owner.name),P=" It was passed a child from "+P+".");var B=Pt.getCurrentStack;Pt.getCurrentStack=function(){var ue=a(k.type);return B&&(ue+=B()||""),ue},console.error('Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',A,P),Pt.getCurrentStack=B}}function w(k){var A="",P=c();return P&&(P=r(P.type))&&(A=`
|
|
29
29
|
|
|
30
|
-
Check the render method of \``+P+"`."),A||(k=
|
|
30
|
+
Check the render method of \``+P+"`."),A||(k=r(k))&&(A=`
|
|
31
31
|
|
|
32
|
-
Check the top-level render call using <`+k+">."),A}var w=m,D=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),L=Symbol.for("react.context"),we=Symbol.for("react.forward_ref"),Et=Symbol.for("react.suspense"),Ae=Symbol.for("react.suspense_list"),ze=Symbol.for("react.memo"),Yt=Symbol.for("react.lazy"),yn=Symbol.for("react.offscreen"),ar=Symbol.iterator,lo=Symbol.for("react.client.reference"),Gt=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Qu=Object.prototype.hasOwnProperty,Xt=Object.assign,N0=Symbol.for("react.client.reference"),ii=Array.isArray,cr=0,Zu,ef,tf,nf,rf,of,sf;r.__reactDisabledLog=!0;var li,lf,ai=!1,ci=new(typeof WeakMap=="function"?WeakMap:Map),E0=Symbol.for("react.client.reference"),af,cf={},uf={},ff={};wn.Fragment=M,wn.jsx=function(k,A,P,B,ce){return h(k,A,P,!1,B,ce)},wn.jsxs=function(k,A,P,B,ce){return h(k,A,P,!0,B,ce)}}()),wn}process.env.NODE_ENV==="production"?uo.exports=xf():uo.exports=kf();var y=uo.exports;function Z(n){this.content=n}Z.prototype={constructor:Z,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),s=r.content.slice();return o==-1?s.push(t||n,e):(s[o+1]=e,t&&(s[o]=t)),new Z(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Z(t)},addToStart:function(n,e){return new Z([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Z(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),s=r.find(n);return o.splice(s==-1?o.length:s,0,e,t),new Z(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Z.from(n),n.size?new Z(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Z.from(n),n.size?new Z(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Z.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Z.from=function(n){if(n instanceof Z)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Z(e)};function mi(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),s=e.child(r);if(o==s){t+=o.nodeSize;continue}if(!o.sameMarkup(s))return t;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)t++;return t}if(o.content.size||s.content.size){let i=mi(o.content,s.content,t+1);if(i!=null)return i}t+=o.nodeSize}}function gi(n,e,t,r){for(let o=n.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:t,b:r};let i=n.child(--o),l=e.child(--s),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};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--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=gi(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class C{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,s){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,o+l,s||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let s="",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?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new C(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let s=0,i=0;i<t;s++){let l=this.content[s],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))),r.push(l),o+=l.nodeSize),i=a}return new C(r,o)}cutByIndex(e,t){return e==t?C.empty:e==0&&t==this.content.length?this:new C(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new C(o,s)}addToStart(e){return new C([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new C(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,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return mi(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return gi(this,e,t,r)}findIndex(e,t=-1){if(e==0)return dr(0,e);if(e==this.size)return dr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let s=this.child(r),i=o+s.nodeSize;if(i>=e)return i==e||t>0?dr(r+1,i):dr(r,o);o=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 C.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new C(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return C.empty;let t,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(t||(t=e.slice(0,o)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new C(t||e,r)}static from(e){if(!e)return C.empty;if(e instanceof C)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new C([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}C.empty=new C([],0);const fo={index:0,offset:0};function dr(n,e){return fo.index=n,fo.offset=e,fo}function hr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!hr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!hr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class F{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||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&&hr(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 r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return F.none;if(e instanceof F)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}}F.none=[];class pr extends Error{}class E{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=bi(this.content,e+this.openStart,t);return r&&new E(r,this.openStart,this.openEnd)}removeBetween(e,t){return new E(yi(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 r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new E(C.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)o++;return new E(e,r,o)}}E.empty=new E(C.empty,0,0);function yi(n,e,t){let{index:r,offset:o}=n.findIndex(e),s=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(o==e||s.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(yi(s.content,e-o-1,t-o-1)))}function bi(n,e,t,r){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o);if(s==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=bi(i.content,e-s-1,t);return l&&n.replaceChild(o,i.copy(l))}function Sf(n,e,t){if(t.openStart>n.depth)throw new pr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new pr("Inconsistent open depths");return xi(n,e,t,0)}function xi(n,e,t,r){let o=n.index(r),s=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let i=xi(n,e,t,r+1);return s.copy(s.content.replaceChild(o,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return Tt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Cf(t,n);return Tt(s,Si(n,i,l,e,r))}else return Tt(s,mr(n,e,r))}function ki(n,e){if(!e.type.compatibleContent(n.type))throw new pr("Cannot join "+e.type.name+" onto "+n.type.name)}function ho(n,e,t){let r=n.node(t);return ki(r,e.node(t)),r}function vt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Mn(n,e,t,r){let o=(e||n).node(t),s=0,i=e?e.index(t):o.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(vt(n.nodeAfter,r),s++));for(let l=s;l<i;l++)vt(o.child(l),r);e&&e.depth==t&&e.textOffset&&vt(e.nodeBefore,r)}function Tt(n,e){return n.type.checkContent(e),n.copy(e)}function Si(n,e,t,r,o){let s=n.depth>o&&ho(n,e,o+1),i=r.depth>o&&ho(t,r,o+1),l=[];return Mn(null,n,o,l),s&&i&&e.index(o)==t.index(o)?(ki(s,i),vt(Tt(s,Si(n,e,t,r,o+1)),l)):(s&&vt(Tt(s,mr(n,e,o+1)),l),Mn(e,t,o,l),i&&vt(Tt(i,mr(t,r,o+1)),l)),Mn(r,null,o,l),new C(l)}function mr(n,e,t){let r=[];if(Mn(null,n,t,r),n.depth>t){let o=ho(n,e,t+1);vt(Tt(o,mr(n,e,t+1)),r)}return Mn(e,null,t,r),new C(r)}function Cf(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)o=e.node(s).copy(C.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class Nn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,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 r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}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 r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)o+=r.child(s).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let s=r.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!o||!r[s].isInSet(o.marks))&&(r=r[s--].removeFromSet(r));return r}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 r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new gr(this,e,r);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 r=[],o=0,s=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(s),c=s-a;if(r.push(i,l,o+a),!c||(i=i.child(l),i.isText))break;s=c-1,o+=a+1}return new Nn(t,r,s)}static resolveCached(e,t){let r=Ci.get(e);if(r)for(let s=0;s<r.elts.length;s++){let i=r.elts[s];if(i.pos==t)return i}else Ci.set(e,r=new wf);let o=r.elts[r.i]=Nn.resolve(e,t);return r.i=(r.i+1)%Mf,o}}class wf{constructor(){this.elts=[],this.i=0}}const Mf=12,Ci=new WeakMap;class gr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}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 Nf=Object.create(null);class be{constructor(e,t,r,o=F.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||C.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,r,o=0){this.content.nodesBetween(e,t,r,o,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,r,o){return this.content.textBetween(e,t,r,o)}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,r){return this.type==e&&hr(this.attrs,t||e.defaultAttrs||Nf)&&F.sameSet(this.marks,r||F.none)}copy(e=null){return e==this.content?this:new be(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new be(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,r=!1){if(e==t)return E.empty;let o=this.resolve(e),s=this.resolve(t),i=r?0:o.sharedDepth(t),l=o.start(i),c=o.node(i).content.cut(o.pos-l,s.pos-l);return new E(c,o.depth-i,s.depth-i)}replace(e,t,r){return Sf(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return Nn.resolveCached(this,e)}resolveNoCache(e){return Nn.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(o=!0),!o)),o}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()+")"),wi(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,r=C.empty,o=0,s=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,o,s),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(e).matchType(r),i=s&&s.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=F.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!F.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 r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=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,r)}let o=C.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,o,r);return s.type.checkAttrs(s.attrs),s}}be.prototype.text=void 0;class yr extends be{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wi(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 yr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new yr(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 wi(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class At{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Ef(e,t);if(r.next==null)return At.empty;let o=Mi(r);r.next&&r.err("Unexpected trailing text");let s=If(Pf(o));return Vf(s,r),s}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,r=e.childCount){let o=this;for(let s=t;o&&s<r;s++)o=o.matchType(e.child(s).type);return o}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 r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function s(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return C.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:f}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(f)==-1){o.push(f);let d=s(f,l.concat(u));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),s=o.match;if(s.matchType(e)){let i=[];for(let l=o;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:l,next:a}=s.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),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(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let s=o+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)s+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return s}).join(`
|
|
33
|
-
`)}}At.empty=new At(!0);class Ef{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 Mi(n){let e=[];do e.push(Df(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Df(n){let e=[];do e.push(Of(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Of(n){let e=Af(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=vf(n,e);else break;return e}function Ni(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function vf(n,e){let t=Ni(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ni(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Tf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let s in t){let i=t[s];i.isInGroup(e)&&o.push(i)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Af(n){if(n.eat("(")){let e=Mi(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Tf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Pf(n){let e=[[]];return o(s(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function o(i,l){i.forEach(a=>a.to=l)}function s(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=s(i.exprs[a],l);if(a==i.exprs.length-1)return c;o(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),o(s(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return o(s(i.expr,l),a),o(s(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(s(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=t();o(s(i.expr,a),u),a=u}if(i.max==-1)o(s(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();r(a,u),o(s(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function Ei(n,e){return e-n}function Di(n,e){let t=[];return r(e),t.sort(Ei);function r(o){let s=n[o];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(o);for(let i=0;i<s.length;i++){let{term:l,to:a}=s[i];!l&&t.indexOf(a)==-1&&r(a)}}}function If(n){let e=Object.create(null);return t(Di(n,0));function t(r){let o=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);Di(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new At(r.indexOf(n.length-1)>-1);for(let i=0;i<o.length;i++){let l=o[i][1].sort(Ei);s.next.push({type:o[i][0],next:e[l.join(",")]||t(l)})}return s}}function Vf(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],s=!o.validEnd,i=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];i.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Oi(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function vi(n,e){let t=Object.create(null);for(let r in n){let o=e&&e[r];if(o===void 0){let s=n[r];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=o}return t}function Ti(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let s=n[o];s.validate&&s.validate(e[o])}}function Ai(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new zf(n,r,e[r]);return t}let Pi=class df{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Ai(e,r.attrs),this.defaultAttrs=Oi(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==At.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:vi(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new be(this,this.computeAttrs(e),C.from(t),F.setFrom(r))}createChecked(e=null,t,r){return t=C.from(t),this.checkContent(t),new be(this,this.computeAttrs(e),t,F.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=C.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let o=this.contentMatch.matchFragment(t),s=o&&o.fillBefore(C.empty,!0);return s?new be(this,e,t.append(s),F.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).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){Ti(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 r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:F.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,i)=>r[s]=new df(s,t,i));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Rf(n,e,t){let r=t.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class zf{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Rf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class br{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Ai(e,o.attrs),this.excluded=null;let s=Oi(this.attrs);this.instance=s?new F(this,s):null}create(e=null){return!e&&this.instance?this.instance:new F(this,vi(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new br(s,o++,t,i)),r}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){Ti(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class xr{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=Z.from(e.nodes),t.marks=Z.from(e.marks||{}),this.nodes=Pi.compile(this.spec.nodes,this),this.marks=br.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let s=this.nodes[o],i=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[i]||(r[i]=At.parse(i,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Ii(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let o in this.marks){let s=this.marks[o],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:Ii(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,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Pi){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,r,o)}text(e,t){let r=this.nodes.text;return new yr(r,r.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return be.fromJSON(this,e)}markFromJSON(e){return F.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ii(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],s=n.marks[o],i=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function $f(n){return n.tag!=null}function jf(n){return n.style!=null}class Pt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if($f(o))this.tags.push(o);else if(jf(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new $i(this,t,!1);return r.addAll(e,F.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new $i(this,t,!0);return r.addAll(e,F.none,t.from,t.to),E.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(Lf(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.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 r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<s)break}t.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=ji(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=ji(i)),i.node||i.ignore||i.mark||(i.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Pt(e,Pt.schemaRules(e)))}}const Vi={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},Bf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ri={ol:!0,ul:!0},En=1,po=2,kr=4;function zi(n,e,t){return e!=null?(e?En:0)|(e==="full"?po:0):n&&n.whitespace=="pre"?En|po:t&-5}class Sr{constructor(e,t,r,o,s,i){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=F.none,this.match=s||(i&kr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(C.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&En)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let t=C.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(C.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&&!Vi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class $i{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,s,i=zi(null,t.preserveWhitespace,0)|(r?kr:0);o?s=new Sr(o.type,o.attrs,F.none,!0,t.topMatch||o.type.contentMatch,i):r?s=new Sr(null,null,F.none,!0,null,i):s=new Sr(e.schema.topNodeType,null,F.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,s=o.options&po?"full":this.localPreserveWS||(o.options&En)>0;if(s==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
34
|
-
`);else if(
|
|
35
|
-
`),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 r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(s,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,r,o){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!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,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];i!=l;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,r){let o,s;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)t=this.enterInner(o[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=F.none;for(let l of o.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Bi(l.type,e.type))&&(i=l.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,r,o){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,o)),s}enterInner(e,t,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=zi(e,s,i.options);i.options&kr&&i.content.length==0&&(l|=kr);let a=F.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Bi(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Sr(e,t,a,o,null,l)),this.open++,r}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|=En)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].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,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].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("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?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>=s;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=s?r.node(a-s).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 r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Ff(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ri.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Lf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ji(n){let e={};for(let t in n)e[t]=n[t];return e}function Bi(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let s=[],i=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&i(u))return!0}};if(i(o.contentMatch))return!0}}class $e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=mo(t).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,a=0;for(;l<s.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)o=s.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(s.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=Cr(mo(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&Cr(mo(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return Cr(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $e(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Fi(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Fi(e.marks)}}function Fi(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function mo(n){return n.document||window.document}const Li=new WeakMap;function Wf(n){let e=Li.get(n);return e===void 0&&Li.set(n,e=_f(n)),e}function _f(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function Cr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Wf(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(t=o.slice(0,i),o=o.slice(i+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:h}=Cr(n,d,t,r);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}const Wi=65535,_i=Math.pow(2,16);function qf(n,e){return n+e*_i}function qi(n){return n&Wi}function Hf(n){return(n-(n&Wi))/_i}const Hi=1,Ki=2,wr=4,Ji=8;class go{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Ji)>0}get deletedBefore(){return(this.delInfo&(Hi|wr))>0}get deletedAfter(){return(this.delInfo&(Ki|wr))>0}get deletedAcross(){return(this.delInfo&wr)>0}}class xe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&xe.empty)return xe.empty}recover(e){let t=0,r=qi(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+Hf(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,s=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?o:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+i],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,p=a+o+(d<0?0:u);if(r)return p;let h=e==(t<0?a:f)?null:qf(l/3,e-a),b=e==a?Ki:e==f?Hi:wr;return(t<0?e!=a:e!=f)&&(b|=Ji),new go(p,b,h)}o+=u-c}return r?e+o:new go(e+o,0,null)}touches(e,t){let r=0,o=qi(t),s=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?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],l=i-(this.inverted?s:0),a=i+(this.inverted?0:s),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new xe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?xe.empty:new xe(e<0?[0,-e,0]:[0,0,e])}}xe.empty=new xe([]);class Dn{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Dn(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,r=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],o!=null&&o<t?r+o: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,r=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new Dn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new go(e,o,null)}}const yo=Object.create(null);class oe{getMap(){return xe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=yo[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in yo)throw new RangeError("Duplicate use of step JSON ID "+e);return yo[e]=t,t.prototype.jsonID=e,t}}class K{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new K(e,null)}static fail(e){return new K(null,e)}static fromReplace(e,t,r,o){try{return K.ok(e.replace(t,r,o))}catch(s){if(s instanceof pr)return K.fail(s.message);throw s}}}function bo(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(bo(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return C.fromArray(r)}class st extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new E(bo(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,s)}invert(){return new je(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new st(t.pos,r.pos,this.mark)}merge(e){return e instanceof st&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new st(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 st(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",st);class je extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new E(bo(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,r)}invert(){return new st(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new je(t.pos,r.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:"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 je(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",je);class it extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new E(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new it(this.pos,t.marks[o]);return new it(this.pos,this.mark)}}return new It(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new it(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 it(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",it);class It extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new E(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new it(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new It(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 It(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",It);class se extends oe{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&xo(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new xe([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new se(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof se)||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 se(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 se(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 se(t.from,t.to,E.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",se);class ee extends oe{constructor(e,t,r,o,s,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(xo(e,this.from,this.gapFrom)||xo(e,this.gapTo,this.to)))return K.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return K.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?K.fromReplace(e,this.from,this.to,r):K.fail("Content does not fit in gap")}getMap(){return new xe([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 ee(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),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||s>r.pos?null:new ee(t.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ee(t.from,t.to,t.gapFrom,t.gapTo,E.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",ee);function xo(n,e,t){let r=n.resolve(e),o=t-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function Kf(n,e,t,r){let o=[],s=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),p=Math.min(c+a.nodeSize,t),h=r.addToSet(f);for(let b=0;b<f.length;b++)f[b].isInSet(h)||(i&&i.to==d&&i.mark.eq(f[b])?i.to=p:o.push(i=new je(d,p,f[b])));l&&l.to==d?l.to=p:s.push(l=new st(d,p,r))}}),o.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Jf(n,e,t,r){let o=[],s=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;s++;let a=null;if(r instanceof br){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],d;for(let p=0;p<o.length;p++){let h=o[p];h.step==s-1&&f.eq(o[p].style)&&(d=h)}d?(d.to=c,d.step=s):o.push({style:f,from:Math.max(l,e),to:c,step:s})}}}),o.forEach(i=>n.step(new je(i.from,i.to,i.style)))}function ko(n,e,t,r=t.contentMatch,o=!0){let s=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)i.push(new se(l,u,E.empty));else{r=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||n.step(new je(l,u,c.marks[d]));if(o&&c.isText&&t.whitespace!="pre"){let d,p=/\r?\n|\r/g,h;for(;d=p.exec(c.text);)h||(h=new E(C.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new se(l+d.index,l+d.index+d[0].length,h))}}l=u}if(!r.validEnd){let a=r.fillBefore(C.empty,!0);n.replace(l,l,new E(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Yf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function On(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),s=n.$from.index(r),i=n.$to.indexAfter(r);if(r<n.depth&&o.canReplace(s,i,t))return r;if(r==0||o.type.spec.isolating||!Yf(o,s,i))break}return null}function Gf(n,e,t){let{$from:r,$to:o,depth:s}=e,i=r.before(s+1),l=o.after(s+1),a=i,c=l,u=C.empty,f=0;for(let h=s,b=!1;h>t;h--)b||r.index(h)>0?(b=!0,u=C.from(r.node(h).copy(u)),f++):a--;let d=C.empty,p=0;for(let h=s,b=!1;h>t;h--)b||o.after(h+1)<o.end(h)?(b=!0,d=C.from(o.node(h).copy(d)),p++):c++;n.step(new ee(a,c,i,l,new E(u.append(d),f,p),u.size-f,!0))}function So(n,e,t=null,r=n){let o=Xf(n,e),s=o&&Uf(r,e);return s?o.map(Yi).concat({type:e,attrs:t}).concat(s.map(Yi)):null}function Yi(n){return{type:n,attrs:null}}function Xf(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return t.canReplaceWith(r,o,i)?s:null}function Uf(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.child(r),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Qf(n,e,t){let r=C.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=C.from(t[i].type.create(t[i].attrs,r))}let o=e.start,s=e.end;n.step(new ee(o,s,o,s,new E(r,0,0),t.length,!0))}function Zf(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,a)&&ed(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!h?c=!1:!p&&h&&(c=!0)}c===!1&&Xi(n,i,l,s),ko(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),f=u.map(l,1),d=u.map(l+i.nodeSize,1);return n.step(new ee(f,d,f+1,d-1,new E(C.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Gi(n,i,l,s),!1}})}function Gi(n,e,t,r){e.forEach((o,s)=>{if(o.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+s+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Xi(n,e,t,r){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+s);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
36
|
-
`))}})}function ed(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function td(n,e,t,r,o){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let i=t.create(r,null,o||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,i);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ee(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new E(C.from(i),0,0),1,!0))}function Qt(n,e,t=1,r){let o=n.resolve(e),s=o.depth-t,i=r&&r[r.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>s;c--,u--){let f=o.node(c),d=o.index(c);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(d,f.childCount),h=r&&r[u+1];h&&(p=p.replaceChild(0,h.type.create(h.attrs)));let b=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!b.type.validContent(p))return!1}let l=o.indexAfter(s),a=r&&r[0];return o.node(s).canReplaceWith(l,l,a?a.type:o.node(s+1).type)}function nd(n,e,t=1,r){let o=n.doc.resolve(e),s=C.empty,i=C.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){s=C.from(o.node(l).copy(s));let u=r&&r[c];i=C.from(u?u.type.create(u.attrs,i):o.node(l).copy(i))}n.step(new se(e,e,new E(s.append(i),t,t),!0))}function Zt(n,e){let t=n.resolve(e),r=t.index();return Ui(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function rd(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let s=e.child(o),i=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Ui(n,e){return!!(n&&e&&!n.isLeaf&&rd(n,e))}function Qi(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let s,i,l=r.index(o);if(o==r.depth?(s=r.nodeBefore,i=r.nodeAfter):t>0?(s=r.node(o+1),l++,i=r.node(o).maybeChild(l)):(s=r.node(o).maybeChild(l-1),i=r.node(o+1)),s&&!s.isTextblock&&Ui(s,i)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function od(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,s=n.doc.resolve(e-t),i=s.node().type;if(o&&i.inlineContent){let u=i.whitespace=="pre",f=!!i.contentMatch.matchType(o);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Xi(n,u.node(),u.before(),l)}i.inlineContent&&ko(n,e+t-1,i,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),E.empty,!0)),r===!0){let u=n.doc.resolve(c);Gi(n,u.node(),u.before(),n.steps.length)}return n}function sd(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,t))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,t))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function Co(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),u=!1;if(s==1)u=c.canReplace(a,a,o);else{let f=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function wo(n,e,t=e,r=E.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),s=n.resolve(t);return Zi(o,s,r)?new se(e,t,r):new id(o,s,r).fit()}function Zi(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class id{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=C.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=C.from(e.node(o).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,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let s=this.placed,i=r.depth,l=o.depth;for(;i&&l&&s.childCount==1;)s=s.firstChild.content,i--,l--;let a=new E(s,i,l);return e>-1?new ee(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new se(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=Mo(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(i?c.matchType(i.type)||(f=c.fillBefore(C.from(i),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};if(t==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Mo(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new E(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Mo(e,t);if(o.childCount<=1&&t>0){let s=e.size-t<=t+o.size;this.unplaced=new E(vn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new E(vn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let b=0;b<s.length;b++)this.openFrontierNode(s[b]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[t];if(o){for(let b=0;b<o.childCount;b++)u.push(o.child(b));f=f.matchFragment(o)}let p=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let b=l.child(c),g=f.matchType(b.type);if(!g)break;c++,(c>1||a==0||b.content.size)&&(f=g,u.push(el(b.mark(d.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?p:-1)))}let h=c==l.childCount;h||(p=-1),this.placed=Tn(this.placed,t,C.from(u)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,g=l;b<p;b++){let x=g.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),g=x.content}this.unplaced=h?e==0?E.empty:new E(vn(i.content,e-1,1),e-1,p<0?i.openEnd:e-1):new E(vn(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||!No(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:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=No(e,t,o,r,s);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=No(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Tn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Tn(this.placed,this.depth,C.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(C.empty,!0);t.childCount&&(this.placed=Tn(this.placed,this.frontier.length,t))}}function vn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(vn(n.firstChild.content,e-1,t)))}function Tn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Tn(n.lastChild.content,e-1,t)))}function Mo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function el(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,el(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(C.empty,!0)))),n.copy(r)}function No(n,e,t,r,o){let s=n.node(e),i=o?n.indexAfter(e):n.index(e);if(i==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,i);return l&&!ld(t,s.content,i)?l:null}function ld(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function ad(n){return n.spec.defining||n.spec.definingForContent}function cd(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),s=n.doc.resolve(t);if(Zi(o,s,r))return n.step(new se(e,t,r));let i=nl(o,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(o.depth+1);i.unshift(l);for(let d=o.depth,p=o.pos-1;d>0;d--,p--){let h=o.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;i.indexOf(d)>-1?l=d:o.before(d)==p&&i.splice(1,0,-d)}let a=i.indexOf(l),c=[],u=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(c.push(h),p==r.openStart)break;d=h.content}for(let d=u-1;d>=0;d--){let p=c[d],h=ad(p.type);if(h&&!p.sameMarkup(o.node(Math.abs(l)-1)))u=d;else if(h||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+u+1)%(r.openStart+1),h=c[p];if(h)for(let b=0;b<i.length;b++){let g=i[(b+a)%i.length],x=!0;g<0&&(x=!1,g=-g);let S=o.node(g-1),w=o.index(g-1);if(S.canReplaceWith(w,w,h.type,h.marks))return n.replace(o.before(g),x?s.after(g):t,new E(tl(r.content,0,r.openStart,p),p,r.openEnd))}}let f=n.steps.length;for(let d=i.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let p=i[d];p<0||(e=o.before(p),t=s.after(p))}}function tl(n,e,t,r,o){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(tl(s.content,e+1,t,r,s)))}if(e>r){let s=o.contentMatchAt(0),i=s.fillBefore(n).append(n);n=i.append(s.matchFragment(i).fillBefore(C.empty,!0))}return n}function ud(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=sd(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new E(C.from(r),0,0))}function fd(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),s=nl(r,o);for(let i=0;i<s.length;i++){let l=s[i],a=i==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&o.end(i)-t!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function nl(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let s=n.start(o);if(s<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(s==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&t.push(o)}return t}class en extends oe{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return K.fromReplace(e,this.pos,this.pos+1,new E(C.from(o),0,t.isLeaf?0:1))}getMap(){return xe.empty}invert(e){return new en(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 en(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 en(t.pos,t.attr,t.value)}}oe.jsonID("attr",en);class An extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return K.ok(r)}getMap(){return xe.empty}invert(e){return new An(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 An(t.attr,t.value)}}oe.jsonID("docAttr",An);let tn=class extends Error{};tn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},tn.prototype=Object.create(Error.prototype),tn.prototype.constructor=tn,tn.prototype.name="TransformError";class rl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Dn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new tn(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,r=E.empty){let o=wo(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new E(C.from(r),0,0))}delete(e,t){return this.replace(e,t,E.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return cd(this,e,t,r),this}replaceRangeWith(e,t,r){return ud(this,e,t,r),this}deleteRange(e,t){return fd(this,e,t),this}lift(e,t){return Gf(this,e,t),this}join(e,t=1){return od(this,e,t),this}wrap(e,t){return Qf(this,e,t),this}setBlockType(e,t=e,r,o=null){return Zf(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return td(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new en(e,t,r)),this}setDocAttribute(e,t){return this.step(new An(e,t)),this}addNodeMark(e,t){return this.step(new it(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof F)t.isInSet(r.marks)&&this.step(new It(e,t));else{let o=r.marks,s,i=[];for(;s=t.isInSet(o);)i.push(new It(e,s)),o=s.removeFromSet(o);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,r){return nd(this,e,t,r),this}addMark(e,t,r){return Kf(this,e,t,r),this}removeMark(e,t,r){return Jf(this,e,t,r),this}clearIncompatible(e,t,r){return ko(this,e,t,r),this}}const Eo=Object.create(null);class R{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new ol(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 r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let s=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(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?E.empty:t),l==0&&ll(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:l}=o[s],a=e.mapping.slice(r),c=a.map(i.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),ll(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new V(e):nn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=t<0?nn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):nn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);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 nn(e,e,0,0,1)||new ge(e)}static atEnd(e){return nn(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 r=Eo[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Eo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Eo[e]=t,t.prototype.jsonID=e,t}getBookmark(){return V.between(this.$anchor,this.$head).getBookmark()}}R.prototype.visible=!0;class ol{constructor(e,t){this.$from=e,this.$to=t}}let sl=!1;function il(n){!sl&&!n.parent.inlineContent&&(sl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class V extends R{constructor(e,t=e){il(e),il(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return R.near(r);let o=e.resolve(t.map(this.anchor));return new V(o.parent.inlineContent?o:r,r)}replace(e,t=E.empty){if(super.replace(e,t),t==E.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof V&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Mr(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,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let s=R.findFrom(t,r,!0)||R.findFrom(t,-r,!0);if(s)t=s.$head;else return R.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(R.findFrom(e,-r,!0)||R.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new V(e,t)}}R.jsonID("text",V);class Mr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Mr(e.map(this.anchor),e.map(this.head))}resolve(e){return V.between(e.resolve(this.anchor),e.resolve(this.head))}}class O extends R{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return r?R.near(s):new O(s)}content(){return new E(C.from(this.node),0,0)}eq(e){return e instanceof O&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Do(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new O(e.resolve(t.anchor))}static create(e,t){return new O(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}O.prototype.visible=!1,R.jsonID("node",O);class Do{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Mr(r,r):new Do(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&O.isSelectable(r)?new O(t):R.near(t)}}class ge extends R{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 r=R.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}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 dd}}R.jsonID("all",ge);const dd={map(){return this},resolve(n){return new ge(n)}};function nn(n,e,t,r,o,s=!1){if(e.inlineContent)return V.create(n,t);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let l=e.child(i);if(l.isAtom){if(!s&&O.isSelectable(l))return O.create(n,t-(o<0?l.nodeSize:0))}else{let a=nn(n,l,t+o,o<0?l.childCount:0,o,s);if(a)return a}t+=l.nodeSize*o}return null}function ll(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof se||o instanceof ee))return;let s=n.mapping.maps[r],i;s.forEach((l,a,c,u)=>{i==null&&(i=u)}),n.setSelection(R.near(n.doc.resolve(i),t))}const al=1,cl=2,ul=4;class hd extends rl{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|al)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&al)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=cl,this}ensureMarks(e){return F.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&cl)>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 r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let i=this.doc.resolve(t);s=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,s)),this.selection.empty||this.setSelection(R.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|=ul,this}get scrolledIntoView(){return(this.updated&ul)>0}}function fl(n,e){return!e||!n?n:n.bind(e)}class Pn{constructor(e,t,r){this.name=e,this.init=fl(t.init,r),this.apply=fl(t.apply,r)}}const pd=[new Pn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Pn("selection",{init(n,e){return n.selection||R.atStart(e.doc)},apply(n){return n.selection}}),new Pn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Pn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Oo{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=pd.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Pn(r.key,r.spec.state,r))})}}class Ge{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 r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=o?o[i].n:0,c=o?o[i].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let f=0;f<this.config.plugins.length;f++)o.push(f<i?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),s=!0}o&&(o[i]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ge(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let s=r[o];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new hd(this)}static create(e){let t=new Oo(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ge(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new Oo(this.schema,e.plugins),r=t.fields,o=new Ge(t);for(let s=0;s<r.length;s++){let i=r[s].name;o[i]=this.hasOwnProperty(i)?this[i]:r[s].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],s=o.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Oo(e.schema,e.plugins),s=new Ge(o);return o.fields.forEach(i=>{if(i.name=="doc")s.doc=be.fromJSON(e.schema,t.doc);else if(i.name=="selection")s.selection=R.fromJSON(s.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[i.name]=c.fromJSON.call(a,e,t[l],s);return}}s[i.name]=i.init(e,s)}}),s}}function dl(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=dl(o,e,{})),t[r]=o}return t}class Be{constructor(e){this.spec=e,this.props={},e.props&&dl(e.props,this,this.props),this.key=e.key?e.key.key:hl("plugin")}getState(e){return e[this.key]}}const vo=Object.create(null);function hl(n){return n in vo?n+"$"+ ++vo[n]:(vo[n]=0,n+"$")}class lt{constructor(e="key"){this.key=hl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var Nr=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<Nr&&this.leafAppend(e)||this.length<Nr&&e.leafPrepend(this)||this.appendInner(e)):this},X.prototype.prepend=function(e){return e.length?X.from(e).append(this):this},X.prototype.appendInner=function(e){return new md(this,e)},X.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?X.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},X.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},X.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},X.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(s,i){return o.push(e(s,i))},t,r),o},X.from=function(e){return e instanceof X?e:e&&e.length?new pl(e):X.empty};var pl=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.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(o,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,i,l){for(var a=s;a<i;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,l){for(var a=s-1;a>=i;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Nr)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Nr)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(X);X.empty=new pl([]);var md=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,s,i){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(s,l),i)===!1||s>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,s)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(s,l)-l,i+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(o,l),s,i)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(r,o):r>=s?this.right.slice(r-s,o-s):this.left.slice(r,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(X);const gd=500;class Pe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;t&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){o||(o=this.remapping(r,d+1),s=o.maps.length),s--,u.push(f);return}if(o){u.push(new Fe(f.map));let p=f.step.map(o.slice(s)),h;p&&i.maybeStep(p).doc&&(h=i.mapping.maps[i.mapping.maps.length-1],c.push(new Fe(h,void 0,void 0,c.length+u.length))),s--,h&&o.appendMap(h,s)}else i.maybeStep(f.step);if(f.selection)return l=o?f.selection.map(o.slice(s)):f.selection,a=new Pe(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,o){let s=[],i=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),d=new Fe(e.mapping.maps[u],f,t),p;(p=a&&a.merge(d))&&(d=p,u?s.pop():l=l.slice(0,l.length-1)),s.push(d),t&&(i++,t=void 0),o||(a=d)}let c=i-r.depth;return c>bd&&(l=yd(l,c),i-=c),new Pe(l.append(s),i)}remapping(e,t){let r=new Dn;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Pe(this.items.append(e.map(t=>new Fe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},o);let a=t;this.items.forEach(d=>{let p=s.getMirror(--a);if(p==null)return;i=Math.min(i,p);let h=s.maps[p];if(d.step){let b=e.steps[p].invert(e.docs[p]),g=d.selection&&d.selection.map(s.slice(a+1,p));g&&l++,r.push(new Fe(h,b,g))}else r.push(new Fe(h))},o);let c=[];for(let d=t;d<i;d++)c.push(new Fe(s.maps[d]));let u=this.items.slice(0,o).append(c).append(r),f=new Pe(u,l);return f.emptyItemCount()>gd&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],s=0;return this.items.forEach((i,l)=>{if(l>=e)o.push(i),i.selection&&s++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=i.selection&&i.selection.map(t.slice(r));u&&s++;let f=new Fe(c.invert(),a,u),d,p=o.length-1;(d=o.length&&o[p].merge(f))?o[p]=d:o.push(f)}}else i.map&&r--},this.items.length,0),new Pe(X.from(o.reverse()),s)}}Pe.empty=new Pe(X.empty,0);function yd(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}class Fe{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Fe(t.getMap().invert(),t,this.selection)}}}class at{constructor(e,t,r,o,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const bd=20;function xd(n,e,t,r){let o=t.getMeta(ct),s;if(o)return o.historyState;t.getMeta(Cd)&&(n=new at(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(ct))return i.getMeta(ct).redo?new at(n.done.addTransform(t,void 0,r,Er(e)),n.undone,ml(t.mapping.maps),n.prevTime,n.prevComposition):new at(n.done,n.undone.addTransform(t,void 0,r,Er(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!kd(t,n.prevRanges)),c=i?To(n.prevRanges,t.mapping):ml(t.mapping.maps);return new at(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Er(e)),Pe.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new at(n.done.rebased(t,s),n.undone.rebased(t,s),To(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new at(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),To(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function kd(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(t=!0)}),t}function ml(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,s,i)=>e.push(s,i));return e}function To(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),s=e.map(n[r+1],-1);o<=s&&t.push(o,s)}return t}function Sd(n,e,t){let r=Er(e),o=ct.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),a=new at(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(i).setMeta(ct,{redo:t,historyState:a})}let Ao=!1,gl=null;function Er(n){let e=n.plugins;if(gl!=e){Ao=!1,gl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ao=!0;break}}return Ao}const ct=new lt("history"),Cd=new lt("closeHistory");function wd(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Be({key:ct,state:{init(){return new at(Pe.empty,Pe.empty,null,0,-1)},apply(e,t,r){return xd(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?Po:r=="historyRedo"?Dr:null;return o?(t.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function yl(n,e){return(t,r)=>{let o=ct.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let s=Sd(o,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const Po=yl(!1,!0),Dr=yl(!0,!0);function Md(n){let e=ct.getState(n);return e?e.done.eventCount:0}for(var ut={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:"'"},Or={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Nd=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ed=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),te=0;te<10;te++)ut[48+te]=ut[96+te]=String(te);for(var te=1;te<=24;te++)ut[te+111]="F"+te;for(var te=65;te<=90;te++)ut[te]=String.fromCharCode(te+32),Or[te]=String.fromCharCode(te);for(var Io in ut)Or.hasOwnProperty(Io)||(Or[Io]=ut[Io]);function Dd(n){var e=Nd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ed&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Or:ut)[n.keyCode]||n.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 Od=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function vd(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,s,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))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Od?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),i&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Td(n){let e=Object.create(null);for(let t in n)e[vd(t)]=n[t];return e}function Vo(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ro(n){return new Be({props:{handleKeyDown:zo(n)}})}function zo(n){let e=Td(n);return function(t,r){let o=Dd(r),s,i=e[Vo(o,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Vo(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||o.charCodeAt(0)>127)&&(s=ut[r.keyCode])&&s!=o){let l=e[Vo(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const bl=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Ad(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Pd=(n,e,t)=>{let r=Ad(n,t);if(!r)return!1;let o=xl(r);if(!o){let i=r.blockRange(),l=i&&On(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let s=o.nodeBefore;if(wl(n,o,e,-1))return!0;if(r.parent.content.size==0&&(rn(s,"end")||O.isSelectable(s)))for(let i=r.depth;;i--){let l=wo(n.doc,r.before(i),r.after(i),E.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(rn(s,"end")?R.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):O.create(a.doc,o.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1};function rn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Id=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=xl(r)}let i=s&&s.nodeBefore;return!i||!O.isSelectable(i)?!1:(e&&e(n.tr.setSelection(O.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function xl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Vd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Rd=(n,e,t)=>{let r=Vd(n,t);if(!r)return!1;let o=kl(r);if(!o)return!1;let s=o.nodeAfter;if(wl(n,o,e,1))return!0;if(r.parent.content.size==0&&(rn(s,"start")||O.isSelectable(s))){let i=wo(n.doc,r.before(),r.after(),E.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(rn(s,"start")?R.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):O.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},zd=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=kl(r)}let i=s&&s.nodeAfter;return!i||!O.isSelectable(i)?!1:(e&&e(n.tr.setSelection(O.create(n.doc,s.pos)).scrollIntoView()),!0)};function kl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Sl=(n,e)=>{let t=n.selection,r=t instanceof O,o;if(r){if(t.node.isTextblock||!Zt(n.doc,t.from))return!1;o=t.from}else if(o=Qi(n.doc,t.from,-1),o==null)return!1;if(e){let s=n.tr.join(o);r&&s.setSelection(O.create(s.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},$d=(n,e)=>{let t=n.selection,r;if(t instanceof O){if(t.node.isTextblock||!Zt(n.doc,t.to))return!1;r=t.to}else if(r=Qi(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},$o=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),s=o&&On(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)},jd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
37
|
-
`).scrollIntoView()),!0)};function jo(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Cl=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),s=t.indexAfter(-1),i=jo(o.contentMatchAt(s));if(!i||!o.canReplaceWith(s,s,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(R.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Bd=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof ge||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=jo(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(i,s.createAndFill());l.setSelection(V.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Fd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Qt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),o=r&&On(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function Ld(n){return(e,t)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof O&&e.selection.node.isBlock)return!r.parentOffset||!Qt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],i,l,a=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){a=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),l=jo(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),s.unshift(a&&l?{type:l}:null),i=p;break}else{if(p==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof V||e.selection instanceof ge)&&u.deleteSelection();let f=u.mapping.map(r.pos),d=Qt(u.doc,f,s.length,s);if(d||(s[0]=l?{type:l}:null,d=Qt(u.doc,f,s.length,s)),!d)return!1;if(u.split(f,s.length,s),!a&&c&&r.node(i).type!=l){let p=u.mapping.map(r.before(i)),h=u.doc.resolve(p);l&&r.node(i-1).canReplaceWith(h.index(),h.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(i)),l)}return t&&t(u.scrollIntoView()),!0}}const Wd=Ld(),Bo=(n,e)=>{let{$from:t,to:r}=n.selection,o,s=t.sharedDepth(r);return s==0?!1:(o=t.before(s),e&&e(n.tr.setSelection(O.create(n.doc,o))),!0)},_d=(n,e)=>(e&&e(n.tr.setSelection(new ge(n.doc))),!0);function qd(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,s=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||Zt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function wl(n,e,t,r){let o=e.nodeBefore,s=e.nodeAfter,i,l,a=o.type.spec.isolating||s.type.spec.isolating;if(!a&&qd(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&l.matchType(i[0]||s.type).validEnd){if(t){let p=e.pos+s.nodeSize,h=C.empty;for(let x=i.length-1;x>=0;x--)h=C.from(i[x].create(null,h));h=C.from(o.copy(h));let b=n.tr.step(new ee(e.pos-1,p,e.pos,p,new E(h,1,0),i.length,!0)),g=b.doc.resolve(p+2*i.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Zt(b.doc,g.pos)&&b.join(g.pos),t(b.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:R.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&On(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&rn(s,"start",!0)&&rn(o,"end")){let p=o,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let b=s,g=1;for(;!b.isTextblock;b=b.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,b.content)){if(t){let x=C.empty;for(let w=h.length-1;w>=0;w--)x=C.from(h[w].copy(x));let S=n.tr.step(new ee(e.pos-h.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new E(x,h.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Ml(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(t&&t(e.tr.setSelection(V.create(e.doc,n<0?o.start(s):o.end(s)))),!0):!1}}const Hd=Ml(-1),Kd=Ml(1);function Nl(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),l=i&&So(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function on(n,e=null){return function(t,r){let o=!1;for(let s=0;s<t.selection.ranges.length&&!o;s++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(i,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),f=u.index();o=u.parent.canReplaceWith(f,f+1,n)}})}if(!o)return!1;if(r){let s=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function Jd(n,e,t,r){for(let o=0;o<e.length;o++){let{$from:s,$to:i}=e[o],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,i.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function ke(n,e=null,t){return function(r,o){let{empty:s,$cursor:i,ranges:l}=r.selection;if(s&&!i||!Jd(r.doc,l,n))return!1;if(o)if(i)n.isInSet(r.storedMarks||i.marks())?o(r.tr.removeStoredMark(n)):o(r.tr.addStoredMark(n.create(e)));else{let a,c=r.tr;a=!l.some(u=>r.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<l.length;u++){let{$from:f,$to:d}=l[u];if(!a)c.removeMark(f.pos,d.pos,n);else{let p=f.pos,h=d.pos,b=f.nodeAfter,g=d.nodeBefore,x=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,S=g&&g.isText?/\s*$/.exec(g.text)[0].length:0;p+x<h&&(p+=x,h-=S),c.addMark(p,h,n.create(e))}}o(c.scrollIntoView())}return!0}}function vr(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}let Fo=vr(bl,Pd,Id),El=vr(bl,Rd,zd);const Xe={Enter:vr(jd,Bd,Fd,Wd),"Mod-Enter":Cl,Backspace:Fo,"Mod-Backspace":Fo,"Shift-Backspace":Fo,Delete:El,"Mod-Delete":El,"Mod-a":_d},Dl={"Ctrl-h":Xe.Backspace,"Alt-Backspace":Xe["Mod-Backspace"],"Ctrl-d":Xe.Delete,"Ctrl-Alt-Backspace":Xe["Mod-Delete"],"Alt-Delete":Xe["Mod-Delete"],"Alt-d":Xe["Mod-Delete"],"Ctrl-a":Hd,"Ctrl-e":Kd};for(let n in Xe)Dl[n]=Xe[n];const Yd=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?Dl:Xe;function Gd(n={}){return new Be({view(e){return new Xd(e,n)}})}class Xd{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}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,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,l=s.height/o.offsetHeight;if(t){let f=e.nodeBefore,d=e.nodeAfter;if(f||d){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let h=p.getBoundingClientRect(),b=f?h.bottom:h.top;f&&d&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:h.left,right:h.right,top:b-g,bottom:b+g}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*i;r={left:f.left-d,right:f.left+d,top:f.top,bottom:f.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 f=a.getBoundingClientRect(),d=f.width/a.offsetWidth,p=f.height/a.offsetHeight;c=f.left-a.scrollLeft*d,u=f.top-a.scrollTop*p}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.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}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,t,e):o;if(t&&!s){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Co(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 ne=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},In=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Lo=null;const Ue=function(n,e,t){let r=Lo||(Lo=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Ud=function(){Lo=null},Vt=function(n,e,t,r){return t&&(Ol(n,e,t,r,-1)||Ol(n,e,t,r,1))},Qd=/^(img|br|input|textarea|hr)$/i;function Ol(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Me(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Vn(n)||Qd.test(n.nodeName)||n.contentEditable=="false")return!1;e=ne(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Me(n):0}else return!1}}function Me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Zd(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Me(n)}else if(n.parentNode&&!Vn(n))e=ne(n),n=n.parentNode;else return null}}function eh(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Vn(n))e=ne(n)+1,n=n.parentNode;else return null}}function th(n,e,t){for(let r=e==0,o=e==Me(n);r||o;){if(n==t)return!0;let s=ne(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Me(n)}}function Vn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Tr=function(n){return n.focusNode&&Vt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Rt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function nh(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function rh(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Me(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Me(r.startContainer),r.startOffset)}}}const Le=typeof navigator<"u"?navigator:null,vl=typeof document<"u"?document:null,ft=Le&&Le.userAgent||"",Wo=/Edge\/(\d+)/.exec(ft),Tl=/MSIE \d/.exec(ft),_o=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ft),ye=!!(Tl||_o||Wo),dt=Tl?document.documentMode:_o?+_o[1]:Wo?+Wo[1]:0,Ie=!ye&&/gecko\/(\d+)/i.test(ft);Ie&&+(/Firefox\/(\d+)/.exec(ft)||[0,0])[1];const qo=!ye&&/Chrome\/(\d+)/.exec(ft),ie=!!qo,Al=qo?+qo[1]:0,ue=!ye&&!!Le&&/Apple Computer/.test(Le.vendor),sn=ue&&(/Mobile\/\w+/.test(ft)||!!Le&&Le.maxTouchPoints>2),Ne=sn||(Le?/Mac/.test(Le.platform):!1),oh=Le?/Win/.test(Le.platform):!1,Qe=/Android \d/.test(ft),Rn=!!vl&&"webkitFontSmoothing"in vl.documentElement.style,sh=Rn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ih(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ze(n,e){return typeof n=="number"?n:n[e]}function lh(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Pl(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let i=t||n.dom;i;i=In(i)){if(i.nodeType!=1)continue;let l=i,a=l==s.body,c=a?ih(s):lh(l),u=0,f=0;if(e.top<c.top+Ze(r,"top")?f=-(c.top-e.top+Ze(o,"top")):e.bottom>c.bottom-Ze(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Ze(o,"top")-c.top:e.bottom-c.bottom+Ze(o,"bottom")),e.left<c.left+Ze(r,"left")?u=-(c.left-e.left+Ze(o,"left")):e.right>c.right-Ze(r,"right")&&(u=e.right-c.right+Ze(o,"right")),u||f)if(a)s.defaultView.scrollBy(u,f);else{let d=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let h=l.scrollLeft-d,b=l.scrollTop-p;e={left:e.left-h,top:e.top-b,right:e.right-h,bottom:e.bottom-b}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function ah(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let s=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(s,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Il(n.dom)}}function Il(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=In(r));return e}function ch({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Vl(t,r==0?0:r-e)}function Vl(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:s}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let ln=null;function uh(n){if(n.setActive)return n.setActive();if(ln)return n.focus(ln);let e=Il(n);n.focus(ln==null?{get preventScroll(){return ln={preventScroll:!0},!0}}:void 0),ln||(ln=!1,Vl(e,0))}function Rl(n,e){let t,r=2e8,o,s=0,i=e.top,l=e.top,a,c;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let d;if(u.nodeType==1)d=u.getClientRects();else if(u.nodeType==3)d=Ue(u).getClientRects();else continue;for(let p=0;p<d.length;p++){let h=d[p];if(h.top<=i&&h.bottom>=l){i=Math.max(h.bottom,i),l=Math.min(h.top,l);let b=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(b<r){t=u,r=b,o=b&&t.nodeType==3?{left:h.right<e.left?h.right:h.left,top:e.top}:e,u.nodeType==1&&b&&(s=f+(e.left>=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(s=f+1)}}return!t&&a&&(t=a,o=c,r=0),t&&t.nodeType==3?fh(t,o):!t||r&&t.nodeType==1?{node:n,offset:s}:Rl(t,o)}function fh(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=ht(r,1);if(s.top!=s.bottom&&Ho(e,s))return{node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Ho(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function dh(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function hh(n,e,t){let{node:r,offset:o}=Rl(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();s=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,o,s)}function ph(n,e,t,r){let o=-1;for(let s=e,i=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!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>r.left||a.top>r.top?o=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),i=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function zl(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=o;;){let i=n.childNodes[s];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Ho(e,c))return zl(i,e,c)}}if((s=(s+1)%r)==o)break}return n}function mh(n,e){let t=n.dom.ownerDocument,r,o=0,s=rh(t,e.left,e.top);s&&({node:r,offset:o}=s);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Ho(e,c)||(i=zl(n.dom,e,c),!i))return null}if(ue)for(let c=i;r&&c;c=In(c))c.draggable&&(r=void 0);if(i=dh(i,e),r){if(Ie&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&o++}let c;Rn&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=ph(n,r,o,e))}l==null&&(l=hh(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function $l(n){return n.top<n.bottom||n.left<n.right}function ht(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if($l(r))return r}return Array.prototype.find.call(t,$l)||n.getBoundingClientRect()}const gh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function jl(n,e,t){let{node:r,offset:o,atom:s}=n.docView.domFromPos(e,t<0?-1:1),i=Rn||Ie;if(r.nodeType==3)if(i&&(gh.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=ht(Ue(r,o,o),t);if(Ie&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=ht(Ue(r,o-1,o-1),-1);if(c.top==a.top){let u=ht(Ue(r,o,o+1),-1);if(u.top!=a.top)return zn(u,u.left<c.left)}}return a}else{let a=o,c=o,u=t<0?1:-1;return t<0&&!o?(c++,u=-1):t>=0&&o==r.nodeValue.length?(a--,u=1):t<0?a--:c++,zn(ht(Ue(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Ko(a.getBoundingClientRect(),!1)}if(s==null&&o<Me(r)){let a=r.childNodes[o];if(a.nodeType==1)return Ko(a.getBoundingClientRect(),!0)}return Ko(r.getBoundingClientRect(),t>=0)}if(s==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Ue(a,Me(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return zn(ht(c,1),!1)}if(s==null&&o<Me(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ue(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return zn(ht(c,-1),!0)}return zn(ht(r.nodeType==3?Ue(r):r,-t),t>=0)}function zn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ko(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Bl(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function yh(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return Bl(n,e,()=>{let{node:s}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let i=jl(n,o.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ue(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 bh=/[\u0590-\u08ac]/;function xh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,s=!o,i=o==r.parent.content.size,l=n.domSelection();return l?!bh.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:i:Bl(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:h,focusOffset:b}=n.domSelectionRange(),g=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&c==b;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),g}):r.pos==r.start()||r.pos==r.end()}let Fl=null,Ll=null,Wl=!1;function kh(n,e,t){return Fl==e&&Ll==t?Wl:(Fl=e,Ll=t,Wl=t=="up"||t=="down"?yh(n,e,t):xh(n,e,t))}const Ee=0,_l=1,zt=2,We=3;let $n=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=Ee,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){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,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.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,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>ne(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){let i=this.children[r],l=s+i.size;if(l>e||i instanceof Jl){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof ql&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?ne(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?ne(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(o==-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 f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=ne(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=ne(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}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:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let p=0,h=0;p<this.children.length;p++){let b=this.children[p],g=h+b.size;if(s>h&&i<g)return b.setSelection(e-h-b.border,t-h-b.border,r,o);h=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((Ie||ue)&&e==t){let{node:p,offset:h}=l;if(p.nodeType==3){if(f=!!(h&&p.nodeValue[h-1]==`
|
|
38
|
-
`),f&&h==p.nodeValue.length)for(let b=p,g;b;b=b.parentNode){if(g=b.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ne(g)+1});break}let x=b.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let b=p.childNodes[h-1];f=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(Ie&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||f&&ue)&&Vt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Vt(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let h=l;l=a,a=h}let 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 r=0,o=0;o<this.children.length;o++){let s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?zt:_l,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=We:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?zt:We}r=i}this.dirty=zt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?zt:_l;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}},ql=class extends $n{constructor(e,t,r,o){let s,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!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,s=this}matchesWidget(e){return this.dirty==Ee&&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}},Sh=class extends $n{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}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}},Ar=class ui extends $n{constructor(e,t,r,o,s){super(e,[],r,o),this.mark=t,this.spec=s}static create(e,t,r,o){let s=o.nodeViews[t.type.name],i=s&&s(t,o,r);return(!i||!i.dom)&&(i=$e.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new ui(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&We||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=We&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ee){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ee}}slice(e,t,r){let o=ui.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;t<i&&(s=Yo(s,t,i,r)),e>0&&(s=Yo(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},an=class hf extends $n{constructor(e,t,r,o,s,i,l,a,c){super(e,[],s,i),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,s,i){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,f=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:f}=$e.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=Xl(u,r,t),c?a=new Ch(e,t,r,o,u,f||null,d,c,s,i+1):t.isText?new Kl(e,t,r,o,u,d,s):new hf(e,t,r,o,u,f||null,d,s,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 r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>C.empty)}return e}matchesNode(e,t,r){return this.dirty==Ee&&e.eq(this.node)&&Pr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Mh(this,i&&i.node,e);Dh(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?F.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,o)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e);let p;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(p=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,u,f,p,e)||a.updateNextNode(c,u,f,e,d,o)||a.addNode(c,u,f,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==zt)&&(i&&this.protectLocalComposition(e,i),Yl(this.contentDOM,this.children,e),sn&&Oh(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof V)||r<t||o>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,l=vh(this.node.content,i,r-t,o-t);return l<0?null:{node:s,pos:l,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new Sh(this,s,t,o);e.input.compositionNodes.push(i),this.children=Yo(this.children,r,r+o.length,e,i)}update(e,t,r,o){return this.dirty==We||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Ee}updateOuterDeco(e){if(Pr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Gl(this.dom,this.nodeDOM,Jo(this.outerDeco,this.node,t),Jo(e,this.node,t)),this.dom!=r&&(r.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 Hl(n,e,t,r,o){Xl(r,e,n);let s=new an(void 0,n,e,t,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}let Kl=class pf extends an{constructor(e,t,r,o,s,i,l){super(e,t,r,o,s,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,r,o){return this.dirty==We||this.dirty!=Ee&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ee||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Ee,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),s=document.createTextNode(o.text);return new pf(this.parent,o,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=We)}get domAtom(){return!1}isText(e){return this.node.text==e}},Jl=class extends $n{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ee&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}};class Ch extends an{constructor(e,t,r,o,s,i,l,a,c,u){super(e,t,r,o,s,i,l,c,u),this.spec=a}update(e,t,r,o){if(this.dirty==We)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}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 Yl(n,e,t){let r=n.firstChild,o=!1;for(let s=0;s<e.length;s++){let i=e[s],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=Ul(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(i instanceof Ar){let a=r?r.previousSibling:n.lastChild;Yl(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Ul(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const jn=function(n){n&&(this.nodeName=n)};jn.prototype=Object.create(null);const $t=[new jn];function Jo(n,e,t){if(n.length==0)return $t;let r=t?$t[0]:new jn,o=[r];for(let s=0;s<n.length;s++){let i=n[s].type.attrs;if(i){i.nodeName&&o.push(r=new jn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&o.length==1&&o.push(r=new jn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function Gl(n,e,t,r){if(t==$t&&r==$t)return e;let o=e;for(let s=0;s<r.length;s++){let i=r[s],l=t[s];if(s){let a;l&&l.nodeName==i.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=$t[0]),o=a}wh(o,l||$t[0],i)}return o}function wh(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.add(o[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Xl(n,e,t){return Gl(n,n,$t,Jo(e,t,n.nodeType!=1))}function Pr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Ul(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Mh{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Nh(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let o=0,s=this.stack.length>>1,i=Math.min(s,e.length);for(;o<i&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Ee,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<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[s])&&!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=Ar.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let s=-1,i;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))s=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,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,o,s){let i=this.top.children[o];return i.dirty==We&&i.dom==i.contentDOM&&(i.dirty=zt),i.update(e,t,r,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,s,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof an){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,f,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=We&&Pr(t,a.outerDeco));if(!d&&a.update(e,t,r,o))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,e,t,r,o,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=zt,f.updateChildren(o,i+1),f.dirty=Ee),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Pr(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=an.create(this.top,t,r,o,s,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,r,o,s){let i=an.create(this.top,e,t,r,o,s);i.contentDOM&&i.updateChildren(o,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let s=new ql(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ar;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Kl)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ue||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 r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Jl(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Nh(n,e){let t=e,r=t.children.length,o=n.childCount,s=new Map,i=[];e:for(;o>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Ar)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,s.set(l,o),i.push(l)}}return{index:o,matched:s,matches:i.reverse()}}function Eh(n,e){return n.type.side-e.type.side}function Dh(n,e,t,r){let o=e.locals(n),s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,o,e.forChild(s,u),c),s+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,f;for(;i<o.length&&o[i].to==s;){let g=o[i++];g.widget&&(u?(f||(f=[u])).push(g):u=g)}if(u)if(f){f.sort(Eh);for(let g=0;g<f.length;g++)t(f[g],c,!!a)}else t(u,c,!!a);let d,p;if(a)p=-1,d=a,a=null;else if(c<n.childCount)p=c,d=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let h=s+d.nodeSize;if(d.isText){let g=h;i<o.length&&o[i].from<g&&(g=o[i].from);for(let x=0;x<l.length;x++)l[x].to<g&&(g=l[x].to);g<h&&(a=d.cut(g-s),d=d.cut(0,g-s),h=g,p=-1)}else for(;i<o.length&&o[i].to<h;)i++;let b=d.isInline&&!d.isLeaf?l.filter(g=>!g.inline):l.slice();r(d,b,e.forChild(s,d),p),s=h}}function Oh(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function vh(n,e,t,r){for(let o=0,s=0;o<n.childCount&&s<=r;){let i=n.child(o++),l=s;if(s+=i.nodeSize,!i.isText)continue;let a=i.text;for(;o<n.childCount;){let c=n.child(o++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Yo(n,e,t,r,o){let s=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,u=l+=a.size;c>=t||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),o&&(s.push(o),o=void 0),u>t&&s.push(a.slice(t-c,a.size,r)))}return s}function Go(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Tr(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&O.isSelectable(f)&&o.parent&&!(f.isInline&&th(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new O(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){let h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=Uo(n,u,l,f)}return c}function Ql(n){return n.editable?n.hasFocus():sa(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function et(n,e=!1){let t=n.state.selection;if(na(n,t),!!Ql(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ie){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Vt(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Ah(n);else{let{anchor:r,head:o}=t,s,i;Zl&&!(t instanceof V)&&(t.$from.parent.inlineContent||(s=ea(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=ea(n,t.to))),n.docView.setSelection(r,o,n,e),Zl&&(s&&ta(s),i&&ta(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Th(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Zl=ue||ie&&Al<63;function ea(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ue&&o&&o.contentEditable=="false")return Xo(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return Xo(o);if(s)return Xo(s)}}function Xo(n){return n.contentEditable="true",ue&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ta(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Th(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ql(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ah(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,ne(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ye&&dt<=11&&(r.disabled=!0,r.disabled=!1)}function na(n,e){if(e instanceof O){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ra(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ra(n)}function ra(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Uo(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||V.between(e,t,r)}function oa(n){return n.editable&&!n.hasFocus()?!1:sa(n)}function sa(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ph(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Vt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Qo(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&R.findFrom(s,e)}function pt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ia(n,e,t){let r=n.state.selection;if(r instanceof V)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return pt(n,new V(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Qo(n.state,e);return o&&o instanceof O?pt(n,o):!1}else if(!(Ne&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?O.isSelectable(s)?pt(n,new O(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):Rn?pt(n,new V(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof O&&r.node.isInline)return pt(n,new V(e>0?r.$to:r.$from));{let o=Qo(n.state,e);return o?pt(n,o):!1}}}function Ir(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Bn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function cn(n,e){return e<0?Ih(n):Vh(n)}function Ih(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Ie&&t.nodeType==1&&r<Ir(t)&&Bn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Bn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(la(t))break;{let l=t.previousSibling;for(;l&&Bn(l,-1);)o=t.parentNode,s=ne(l),l=l.previousSibling;if(l)t=l,r=Ir(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Zo(n,t,r):o&&Zo(n,o,s)}function Vh(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Ir(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Bn(l,1))s=t,i=++r;else break}else{if(la(t))break;{let l=t.nextSibling;for(;l&&Bn(l,1);)s=l.parentNode,i=ne(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Ir(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Zo(n,s,i)}function la(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Rh(n,e){for(;n&&e==n.childNodes.length&&!Vn(n);)e=ne(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function zh(n,e){for(;n&&!e&&!Vn(n);)e=ne(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Zo(n,e,t){if(e.nodeType!=3){let s,i;(i=Rh(e,t))?(e=i,t=0):(s=zh(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Tr(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&et(n)},50)}function aa(n,e){let t=n.state.doc.resolve(e);if(!(ie||oh)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ca(n,e,t){let r=n.state.selection;if(r instanceof V&&!r.empty||t.indexOf("s")>-1||Ne&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Qo(n.state,e);if(i&&i instanceof O)return pt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?R.near(i,e):R.findFrom(i,e);return l?pt(n,l):!1}return!1}function ua(n,e){if(!(n.state.selection instanceof V))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function fa(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function $h(n){if(!ue||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;fa(n,r,"true"),setTimeout(()=>fa(n,r,"false"),20)}return!1}function jh(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Bh(n,e){let t=e.keyCode,r=jh(e);if(t==8||Ne&&t==72&&r=="c")return ua(n,-1)||cn(n,-1);if(t==46&&!e.shiftKey||Ne&&t==68&&r=="c")return ua(n,1)||cn(n,1);if(t==13||t==27)return!0;if(t==37||Ne&&t==66&&r=="c"){let o=t==37?aa(n,n.state.selection.from)=="ltr"?-1:1:-1;return ia(n,o,r)||cn(n,o)}else if(t==39||Ne&&t==70&&r=="c"){let o=t==39?aa(n,n.state.selection.from)=="ltr"?1:-1:1;return ia(n,o,r)||cn(n,o)}else{if(t==38||Ne&&t==80&&r=="c")return ca(n,-1,r)||cn(n,-1);if(t==40||Ne&&t==78&&r=="c")return $h(n)||ca(n,1,r)||cn(n,1);if(r==(Ne?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function da(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=ka(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=ba[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
32
|
+
Check the top-level render call using <`+k+">."),A}var C=m,v=Symbol.for("react.transitional.element"),O=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),G=Symbol.for("react.context"),ce=Symbol.for("react.forward_ref"),we=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),Ae=Symbol.for("react.memo"),Qs=Symbol.for("react.lazy"),Cg=Symbol.for("react.offscreen"),Za=Symbol.iterator,Mg=Symbol.for("react.client.reference"),Pt=C.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ec=Object.prototype.hasOwnProperty,It=Object.assign,vg=Symbol.for("react.client.reference"),Us=Array.isArray,In=0,tc,nc,rc,sc,oc,ic,lc;n.__reactDisabledLog=!0;var Zs,ac,eo=!1,to=new(typeof WeakMap=="function"?WeakMap:Map),Ng=Symbol.for("react.client.reference"),cc,uc={},dc={},fc={};rn.Fragment=M,rn.jsx=function(k,A,P,B,ue){return p(k,A,P,!1,B,ue)},rn.jsxs=function(k,A,P,B,ue){return p(k,A,P,!0,B,ue)}}()),rn}process.env.NODE_ENV==="production"?kr.exports=bc():kr.exports=xc();var g=kr.exports;function U(r){this.content=r}U.prototype={constructor:U,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 U(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 U(t)},addToStart:function(r,e){return new U([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new U(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 U(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=U.from(r),r.size?new U(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=U.from(r),r.size?new U(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=U.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}},U.from=function(r){if(r instanceof U)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new U(e)};function lo(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=lo(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function ao(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=ao(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 lo(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return ao(this,e,t,n)}findIndex(e,t=-1){if(e==0)return Rn(0,e);if(e==this.size)return Rn(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?Rn(n+1,i):Rn(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 wr={index:0,offset:0};function Rn(r,e){return wr.index=r,wr.offset=e,wr}function zn(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(!zn(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!zn(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}class F{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&&zn(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 F.none;if(e instanceof F)return[e];let t=e.slice();return t.sort((n,s)=>n.type.rank-s.type.rank),t}}F.none=[];class jn 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=uo(this.content,e+this.openStart,t);return n&&new E(n,this.openStart,this.openEnd)}removeBetween(e,t){return new E(co(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 co(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(co(o.content,e-s-1,t-s-1)))}function uo(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=uo(i.content,e-o-1,t);return l&&r.replaceChild(s,i.copy(l))}function kc(r,e,t){if(t.openStart>r.depth)throw new jn("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new jn("Inconsistent open depths");return fo(r,e,t,0)}function fo(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=fo(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 yt(i,l.cut(0,r.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=wc(t,r);return yt(o,po(r,i,l,e,n))}else return yt(o,Bn(r,e,n))}function ho(r,e){if(!e.type.compatibleContent(r.type))throw new jn("Cannot join "+e.type.name+" onto "+r.type.name)}function Sr(r,e,t){let n=r.node(t);return ho(n,e.node(t)),n}function gt(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 sn(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&&(gt(r.nodeAfter,n),o++));for(let l=o;l<i;l++)gt(s.child(l),n);e&&e.depth==t&&e.textOffset&>(e.nodeBefore,n)}function yt(r,e){return r.type.checkContent(e),r.copy(e)}function po(r,e,t,n,s){let o=r.depth>s&&Sr(r,e,s+1),i=n.depth>s&&Sr(t,n,s+1),l=[];return sn(null,r,s,l),o&&i&&e.index(s)==t.index(s)?(ho(o,i),gt(yt(o,po(r,e,t,n,s+1)),l)):(o&>(yt(o,Bn(r,e,s+1)),l),sn(e,t,s,l),i&>(yt(i,Bn(t,n,s+1)),l)),sn(n,null,s,l),new S(l)}function Bn(r,e,t){let n=[];if(sn(null,r,t,n),r.depth>t){let s=Sr(r,e,t+1);gt(yt(s,Bn(r,e,t+1)),n)}return sn(e,null,t,n),new S(n)}function wc(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 on{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 F.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 Fn(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 on(t,n,o)}static resolveCached(e,t){let n=mo.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 mo.set(e,n=new Sc);let s=n.elts[n.i]=on.resolve(e,t);return n.i=(n.i+1)%Cc,s}}class Sc{constructor(){this.elts=[],this.i=0}}const Cc=12,mo=new WeakMap;class Fn{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 Mc=Object.create(null);class ye{constructor(e,t,n,s=F.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&&zn(this.attrs,t||e.defaultAttrs||Mc)&&F.sameSet(this.marks,n||F.none)}copy(e=null){return e==this.content?this:new ye(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ye(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 kc(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 on.resolveCached(this,e)}resolveNoCache(e){return on.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()+")"),go(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=F.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(!F.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}}ye.prototype.text=void 0;class Ln extends ye{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):go(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 Ln(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ln(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 go(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}class bt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new vc(e,t);if(n.next==null)return bt.empty;let s=yo(n);n.next&&n.err("Unexpected trailing text");let o=Pc(Ac(s));return Ic(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(`
|
|
33
|
+
`)}}bt.empty=new bt(!0);class vc{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 yo(r){let e=[];do e.push(Nc(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Nc(r){let e=[];do e.push(Ec(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ec(r){let e=Tc(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=Oc(r,e);else break;return e}function bo(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function Oc(r,e){let t=bo(r),n=t;return r.eat(",")&&(r.next!="}"?n=bo(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function Dc(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 Tc(r){if(r.eat("(")){let e=yo(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=Dc(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 Ac(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 xo(r,e){return e-r}function ko(r,e){let t=[];return n(e),t.sort(xo);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 Pc(r){let e=Object.create(null);return t(ko(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]);ko(r,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[n.join(",")]=new bt(n.indexOf(r.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(xo);o.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return o}}function Ic(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 wo(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 So(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 Co(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 Mo(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new Rc(r,n,e[n]);return t}let vo=class hc{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=Mo(e,n.attrs),this.defaultAttrs=wo(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==bt.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:So(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ye(this,this.computeAttrs(e),S.from(t),F.setFrom(n))}createChecked(e=null,t,n){return t=S.from(t),this.checkContent(t),new ye(this,this.computeAttrs(e),t,F.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 ye(this,e,t.append(o),F.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){Co(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:F.none:e}static compile(e,t){let n=Object.create(null);e.forEach((o,i)=>n[o]=new hc(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 Vc(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 Rc{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Vc(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class $n{constructor(e,t,n,s){this.name=e,this.rank=t,this.schema=n,this.spec=s,this.attrs=Mo(e,s.attrs),this.excluded=null;let o=wo(this.attrs);this.instance=o?new F(this,o):null}create(e=null){return!e&&this.instance?this.instance:new F(this,So(this.attrs,e))}static compile(e,t){let n=Object.create(null),s=0;return e.forEach((o,i)=>n[o]=new $n(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){Co(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Wn{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=U.from(e.nodes),t.marks=U.from(e.marks||{}),this.nodes=vo.compile(this.spec.nodes,this),this.marks=$n.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]=bt.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?No(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==""?[]:No(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 vo){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 Ln(n,n.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return ye.fromJSON(this,e)}markFromJSON(e){return F.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function No(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 zc(r){return r.tag!=null}function jc(r){return r.style!=null}let _n=class no{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(s=>{if(zc(s))this.tags.push(s);else if(jc(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 To(this,t,!1);return n.addAll(e,F.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new To(this,t,!0);return n.addAll(e,F.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(Lc(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=Ao(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=Ao(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new no(e,no.schemaRules(e)))}};const Eo={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},Bc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Oo={ol:!0,ul:!0},ln=1,Cr=2,qn=4;function Do(r,e,t){return e!=null?(e?ln:0)|(e==="full"?Cr:0):r&&r.whitespace=="pre"?ln|Cr:t&-5}class Hn{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=F.none,this.match=o||(i&qn?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&ln)){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&&!Eo.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class To{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=Do(null,t.preserveWhitespace,0)|(n?qn:0);s?o=new Hn(s.type,s.attrs,F.none,!0,t.topMatch||s.type.contentMatch,i):n?o=new Hn(null,null,F.none,!0,null,i):o=new Hn(e.schema.topNodeType,null,F.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&Cr?"full":this.localPreserveWS||(s.options&ln)>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,`
|
|
34
|
+
`);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;Oo.hasOwnProperty(i)&&this.parser.normalizeLists&&Fc(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:Bc.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(Eo.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(`
|
|
35
|
+
`),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=F.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):Po(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=Do(e,o,i.options);i.options&qn&&i.content.length==0&&(l|=qn);let a=F.none;return n=n.filter(c=>(i.type?i.type.allowsMarkType(c.type):Po(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Hn(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|=ln)}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 Fc(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Oo.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function Lc(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function Ao(r){let e={};for(let t in r)e[t]=r[t];return e}function Po(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 $e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Mr(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}=Jn(Mr(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&&Jn(Mr(n),s(e,t),null,e.attrs)}static renderSpec(e,t,n=null,s){return Jn(e,t,n,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $e(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Io(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return Io(e.marks)}}function Io(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function Mr(r){return r.document||window.document}const Vo=new WeakMap;function $c(r){let e=Vo.get(r);return e===void 0&&Vo.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 Jn(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=$c(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}=Jn(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 Ro=65535,zo=Math.pow(2,16);function _c(r,e){return r+e*zo}function jo(r){return r&Ro}function qc(r){return(r-(r&Ro))/zo}const Bo=1,Fo=2,Kn=4,Lo=8;class vr{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Lo)>0}get deletedBefore(){return(this.delInfo&(Bo|Kn))>0}get deletedAfter(){return(this.delInfo&(Fo|Kn))>0}get deletedAcross(){return(this.delInfo&Kn)>0}}class be{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&be.empty)return be.empty}recover(e){let t=0,n=jo(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+qc(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:_c(l/3,e-a),b=e==a?Fo:e==d?Bo:Kn;return(t<0?e!=a:e!=d)&&(b|=Lo),new vr(h,b,p)}s+=u-c}return n?e+s:new vr(e+s,0,null)}touches(e,t){let n=0,s=jo(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 be(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?be.empty:new be(e<0?[0,-e,0]:[0,0,e])}}be.empty=new be([]);class an{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 an(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 an;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 vr(e,s,null)}}const Nr=Object.create(null);class oe{getMap(){return be.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Nr[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 Nr)throw new RangeError("Duplicate use of step JSON ID "+e);return Nr[e]=t,t.prototype.jsonID=e,t}}class J{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new J(e,null)}static fail(e){return new J(null,e)}static fromReplace(e,t,n,s){try{return J.ok(e.replace(t,n,s))}catch(o){if(o instanceof jn)return J.fail(o.message);throw o}}}function Er(r,e,t){let n=[];for(let s=0;s<r.childCount;s++){let o=r.child(s);o.content.size&&(o=o.copy(Er(o.content,e,o))),o.isInline&&(o=e(o,t,s)),n.push(o)}return S.fromArray(n)}class Ue extends oe{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(Er(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 J.fromReplace(e,this.from,this.to,o)}invert(){return new Pe(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 Ue(t.pos,n.pos,this.mark)}merge(e){return e instanceof Ue&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ue(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 Ue(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",Ue);class Pe extends oe{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(Er(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return J.fromReplace(e,this.from,this.to,n)}invert(){return new Ue(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 Pe(t.pos,n.pos,this.mark)}merge(e){return e instanceof Pe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Pe(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 Pe(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",Pe);class Ze extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return J.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return J.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 Ze(this.pos,t.marks[s]);return new Ze(this.pos,this.mark)}}return new xt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ze(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 Ze(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",Ze);class xt extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return J.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return J.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 Ze(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xt(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 xt(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",xt);class ie extends oe{constructor(e,t,n,s=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=s}apply(e){return this.structure&&Or(e,this.from,this.to)?J.fail("Structure replace would overwrite content"):J.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new be([this.from,this.to-this.from,this.slice.size])}invert(e){return new ie(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 ie(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ie)||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 ie(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 ie(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 ie(t.from,t.to,E.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",ie);class Z extends oe{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&&(Or(e,this.from,this.gapFrom)||Or(e,this.gapTo,this.to)))return J.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return J.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?J.fromReplace(e,this.from,this.to,n):J.fail("Content does not fit in gap")}getMap(){return new be([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 Z(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 Z(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 Z(t.from,t.to,t.gapFrom,t.gapTo,E.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",Z);function Or(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 Hc(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 Pe(f,h,d[b])));l&&l.to==f?l.to=h:o.push(l=new Ue(f,h,n))}}),s.forEach(a=>r.step(a)),o.forEach(a=>r.step(a))}function Jc(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 $n){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 Pe(i.from,i.to,i.style)))}function Dr(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 ie(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 Pe(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 ie(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 Kc(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function cn(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||!Kc(s,o,i))break}return null}function Yc(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 Z(a,c,i,l,new E(u.append(f),d,h),u.size-d,!0))}function Tr(r,e,t=null,n=r){let s=Gc(r,e),o=s&&Xc(n,e);return o?s.map($o).concat({type:e,attrs:t}).concat(o.map($o)):null}function $o(r){return{type:r,attrs:null}}function Gc(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 Xc(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 Qc(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 Z(s,o,s,o,new E(n,0,0),t.length,!0))}function Uc(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)&&Zc(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&&_o(r,i,l,o),Dr(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 Z(d,f,d+1,f-1,new E(S.from(n.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Wo(r,i,l,o),!1}})}function Wo(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 _o(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(`
|
|
36
|
+
`))}})}function Zc(r,e,t){let n=r.resolve(e),s=n.index();return n.parent.canReplaceWith(s,s+1,t)}function eu(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 Z(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new E(S.from(i),0,0),1,!0))}function Rt(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 tu(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 ie(e,e,new E(o.append(i),t,t),!0))}function zt(r,e){let t=r.resolve(e),n=t.index();return qo(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function nu(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 qo(r,e){return!!(r&&e&&!r.isLeaf&&nu(r,e))}function Ho(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&&qo(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 ru(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);_o(r,u.node(),u.before(),l)}i.inlineContent&&Dr(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 ie(c,a.map(e+t,-1),E.empty,!0)),n===!0){let u=r.doc.resolve(c);Wo(r,u.node(),u.before(),r.steps.length)}return r}function su(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 Jo(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 Ar(r,e,t=e,n=E.empty){if(e==t&&!n.size)return null;let s=r.resolve(e),o=r.resolve(t);return Ko(s,o,n)?new ie(e,t,n):new ou(s,o,n).fit()}function Ko(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class ou{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 Z(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new ie(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=Pr(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=Pr(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=Pr(e,t);if(s.childCount<=1&&t>0){let o=e.size-t<=t+s.size;this.unplaced=new E(un(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new E(un(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(Yo(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=dn(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(un(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new E(un(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||!Ir(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=Ir(e,t,s,n,o);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Ir(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=dn(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=dn(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=dn(this.placed,this.frontier.length,t))}}function un(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(un(r.firstChild.content,e-1,t)))}function dn(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(dn(r.lastChild.content,e-1,t)))}function Pr(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function Yo(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,Yo(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 Ir(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&&!iu(t,o.content,i)?l:null}function iu(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function lu(r){return r.spec.defining||r.spec.definingForContent}function au(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let s=r.doc.resolve(e),o=r.doc.resolve(t);if(Ko(s,o,n))return r.step(new ie(e,t,n));let i=Xo(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=lu(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 w=s.node(y-1),C=s.index(y-1);if(w.canReplaceWith(C,C,p.type,p.marks))return r.replace(s.before(y),x?o.after(y):t,new E(Go(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 Go(r,e,t,n,s){if(e<t){let o=r.firstChild;r=r.replaceChild(0,o.copy(Go(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 cu(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let s=su(r.doc,e,n.type);s!=null&&(e=t=s)}r.replaceRange(e,t,new E(S.from(n),0,0))}function uu(r,e,t){let n=r.doc.resolve(e),s=r.doc.resolve(t),o=Xo(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 Xo(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 jt extends oe{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 J.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 J.fromReplace(e,this.pos,this.pos+1,new E(S.from(s),0,t.isLeaf?0:1))}getMap(){return be.empty}invert(e){return new jt(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 jt(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 jt(t.pos,t.attr,t.value)}}oe.jsonID("attr",jt);class fn extends oe{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 J.ok(n)}getMap(){return be.empty}invert(e){return new fn(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 fn(t.attr,t.value)}}oe.jsonID("docAttr",fn);let Bt=class extends Error{};Bt=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t},Bt.prototype=Object.create(Error.prototype),Bt.prototype.constructor=Bt,Bt.prototype.name="TransformError";class Qo{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new an}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Bt(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=Ar(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 au(this,e,t,n),this}replaceRangeWith(e,t,n){return cu(this,e,t,n),this}deleteRange(e,t){return uu(this,e,t),this}lift(e,t){return Yc(this,e,t),this}join(e,t=1){return ru(this,e,t),this}wrap(e,t){return Qc(this,e,t),this}setBlockType(e,t=e,n,s=null){return Uc(this,e,t,n,s),this}setNodeMarkup(e,t,n=null,s){return eu(this,e,t,n,s),this}setNodeAttribute(e,t,n){return this.step(new jt(e,t,n)),this}setDocAttribute(e,t){return this.step(new fn(e,t)),this}addNodeMark(e,t){return this.step(new Ze(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof F)t.isInSet(n.marks)&&this.step(new xt(e,t));else{let s=n.marks,o,i=[];for(;o=t.isInSet(s);)i.push(new xt(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 tu(this,e,t,n),this}addMark(e,t,n){return Hc(this,e,t,n),this}removeMark(e,t,n){return Jc(this,e,t,n),this}clearIncompatible(e,t,n){return Dr(this,e,t,n),this}}const Vr=Object.create(null);class V{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Uo(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&&ti(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),ti(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let s=e.parent.inlineContent?new j(e):Ft(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?Ft(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):Ft(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 xe(e.node(0))}static atStart(e){return Ft(e,e,0,0,1)||new xe(e)}static atEnd(e){return Ft(e,e,e.content.size,e.childCount,-1)||new xe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Vr[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 Vr)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return j.between(this.$anchor,this.$head).getBookmark()}}V.prototype.visible=!0;class Uo{constructor(e,t){this.$from=e,this.$to=t}}let Zo=!1;function ei(r){!Zo&&!r.parent.inlineContent&&(Zo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class j extends V{constructor(e,t=e){ei(e),ei(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 V.near(n);let s=e.resolve(t.map(this.anchor));return new j(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 j&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Yn(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 j(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=V.findFrom(t,n,!0)||V.findFrom(t,-n,!0);if(o)t=o.$head;else return V.near(t,n)}return e.parent.inlineContent||(s==0?e=t:(e=(V.findFrom(e,-n,!0)||V.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new j(e,t)}}V.jsonID("text",j);class Yn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Yn(e.map(this.anchor),e.map(this.head))}resolve(e){return j.between(e.resolve(this.anchor),e.resolve(this.head))}}class I extends V{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?V.near(o):new I(o)}content(){return new E(S.from(this.node),0,0)}eq(e){return e instanceof I&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Rr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new I(e.resolve(t.anchor))}static create(e,t){return new I(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}I.prototype.visible=!1,V.jsonID("node",I);class Rr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Yn(n,n):new Rr(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&I.isSelectable(n)?new I(t):V.near(t)}}class xe extends V{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=V.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new xe(e)}map(e){return new xe(e)}eq(e){return e instanceof xe}getBookmark(){return du}}V.jsonID("all",xe);const du={map(){return this},resolve(r){return new xe(r)}};function Ft(r,e,t,n,s,o=!1){if(e.inlineContent)return j.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&&I.isSelectable(l))return I.create(r,t-(s<0?l.nodeSize:0))}else{let a=Ft(r,l,t+s,s<0?l.childCount:0,s,o);if(a)return a}t+=l.nodeSize*s}return null}function ti(r,e,t){let n=r.steps.length-1;if(n<e)return;let s=r.steps[n];if(!(s instanceof ie||s instanceof Z))return;let o=r.mapping.maps[n],i;o.forEach((l,a,c,u)=>{i==null&&(i=u)}),r.setSelection(V.near(r.doc.resolve(i),t))}const ni=1,ri=2,si=4;class fu extends Qo{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|ni)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&ni)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ri,this}ensureMarks(e){return F.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&ri)>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)||F.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(V.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|=si,this}get scrolledIntoView(){return(this.updated&si)>0}}function oi(r,e){return!e||!r?r:r.bind(e)}class hn{constructor(e,t,n){this.name=e,this.init=oi(t.init,n),this.apply=oi(t.apply,n)}}const hu=[new hn("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new hn("selection",{init(r,e){return r.selection||V.atStart(e.doc)},apply(r){return r.selection}}),new hn("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new hn("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class zr{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=hu.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 hn(n.key,n.spec.state,n))})}}class et{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 et(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 fu(this)}static create(e){let t=new zr(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new et(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 zr(this.schema,e.plugins),n=t.fields,s=new et(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 zr(e.schema,e.plugins),o=new et(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=ye.fromJSON(e.schema,t.doc);else if(i.name=="selection")o.selection=V.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 ii(r,e,t){for(let n in r){let s=r[n];s instanceof Function?s=s.bind(e):n=="handleDOMEvents"&&(s=ii(s,e,{})),t[n]=s}return t}class Ie{constructor(e){this.spec=e,this.props={},e.props&&ii(e.props,this,this.props),this.key=e.key?e.key.key:li("plugin")}getState(e){return e[this.key]}}const jr=Object.create(null);function li(r){return r in jr?r+"$"+ ++jr[r]:(jr[r]=0,r+"$")}class tt{constructor(e="key"){this.key=li(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var Gn=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<Gn&&this.leafAppend(e)||this.length<Gn&&e.leafPrepend(this)||this.appendInner(e)):this},X.prototype.prepend=function(e){return e.length?X.from(e).append(this):this},X.prototype.appendInner=function(e){return new pu(this,e)},X.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?X.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},X.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},X.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)},X.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},X.from=function(e){return e instanceof X?e:e&&e.length?new ai(e):X.empty};var ai=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<=Gn)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Gn)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}(X);X.empty=new ai([]);var pu=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}(X);const mu=500;class Oe{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 Ve(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 Ve(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 Oe(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 Ve(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>yu&&(l=gu(l,c),i-=c),new Oe(l.append(o),i)}remapping(e,t){let n=new an;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 Oe(this.items.append(e.map(t=>new Ve(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 Ve(p,b,y))}else n.push(new Ve(p))},s);let c=[];for(let f=t;f<i;f++)c.push(new Ve(o.maps[f]));let u=this.items.slice(0,s).append(c).append(n),d=new Oe(u,l);return d.emptyItemCount()>mu&&(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 Ve(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 Oe(X.from(s.reverse()),o)}}Oe.empty=new Oe(X.empty,0);function gu(r,e){let t;return r.forEach((n,s)=>{if(n.selection&&e--==0)return t=s,!1}),r.slice(t)}class Ve{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 Ve(t.getMap().invert(),t,this.selection)}}}class nt{constructor(e,t,n,s,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=s,this.prevComposition=o}}const yu=20;function bu(r,e,t,n){let s=t.getMeta(rt),o;if(s)return s.historyState;t.getMeta(wu)&&(r=new nt(r.done,r.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(i&&i.getMeta(rt))return i.getMeta(rt).redo?new nt(r.done.addTransform(t,void 0,n,Xn(e)),r.undone,ci(t.mapping.maps),r.prevTime,r.prevComposition):new nt(r.done,r.undone.addTransform(t,void 0,n,Xn(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||!xu(t,r.prevRanges)),c=i?Br(r.prevRanges,t.mapping):ci(t.mapping.maps);return new nt(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,Xn(e)),Oe.empty,c,t.time,l??r.prevComposition)}else return(o=t.getMeta("rebased"))?new nt(r.done.rebased(t,o),r.undone.rebased(t,o),Br(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new nt(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),Br(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function xu(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 ci(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 Br(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 ku(r,e,t){let n=Xn(e),s=rt.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 nt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(rt,{redo:t,historyState:a})}let Fr=!1,ui=null;function Xn(r){let e=r.plugins;if(ui!=e){Fr=!1,ui=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Fr=!0;break}}return Fr}const rt=new tt("history"),wu=new tt("closeHistory");function Su(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new Ie({key:rt,state:{init(){return new nt(Oe.empty,Oe.empty,null,0,-1)},apply(e,t,n){return bu(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,s=n=="historyUndo"?Lr:n=="historyRedo"?Qn:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function di(r,e){return(t,n)=>{let s=rt.getState(t);if(!s||(r?s.undone:s.done).eventCount==0)return!1;if(n){let o=ku(s,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const Lr=di(!1,!0),Qn=di(!0,!0);function Cu(r){let e=rt.getState(r);return e?e.done.eventCount:0}for(var st={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:"'"},Un={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Mu=typeof navigator<"u"&&/Mac/.test(navigator.platform),vu=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ee=0;ee<10;ee++)st[48+ee]=st[96+ee]=String(ee);for(var ee=1;ee<=24;ee++)st[ee+111]="F"+ee;for(var ee=65;ee<=90;ee++)st[ee]=String.fromCharCode(ee+32),Un[ee]=String.fromCharCode(ee);for(var $r in st)Un.hasOwnProperty($r)||(Un[$r]=st[$r]);function Nu(r){var e=Mu&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||vu&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Un:st)[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 Eu=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Ou(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))Eu?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 Du(r){let e=Object.create(null);for(let t in r)e[Ou(t)]=r[t];return e}function Wr(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 _r(r){return new Ie({props:{handleKeyDown:qr(r)}})}function qr(r){let e=Du(r);return function(t,n){let s=Nu(n),o,i=e[Wr(s,n)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(n.shiftKey){let l=e[Wr(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=st[n.keyCode])&&o!=s){let l=e[Wr(o,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const fi=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function Tu(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const Au=(r,e,t)=>{let n=Tu(r,t);if(!n)return!1;let s=hi(n);if(!s){let i=n.blockRange(),l=i&&cn(i);return l==null?!1:(e&&e(r.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(yi(r,s,e,-1))return!0;if(n.parent.content.size==0&&(Lt(o,"end")||I.isSelectable(o)))for(let i=n.depth;;i--){let l=Ar(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(Lt(o,"end")?V.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):I.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 Lt(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 Pu=(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=hi(n)}let i=o&&o.nodeBefore;return!i||!I.isSelectable(i)?!1:(e&&e(r.tr.setSelection(I.create(r.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function hi(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 Iu(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const Vu=(r,e,t)=>{let n=Iu(r,t);if(!n)return!1;let s=pi(n);if(!s)return!1;let o=s.nodeAfter;if(yi(r,s,e,1))return!0;if(n.parent.content.size==0&&(Lt(o,"start")||I.isSelectable(o))){let i=Ar(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(Lt(o,"start")?V.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):I.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},Ru=(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=pi(n)}let i=o&&o.nodeAfter;return!i||!I.isSelectable(i)?!1:(e&&e(r.tr.setSelection(I.create(r.doc,o.pos)).scrollIntoView()),!0)};function pi(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 mi=(r,e)=>{let t=r.selection,n=t instanceof I,s;if(n){if(t.node.isTextblock||!zt(r.doc,t.from))return!1;s=t.from}else if(s=Ho(r.doc,t.from,-1),s==null)return!1;if(e){let o=r.tr.join(s);n&&o.setSelection(I.create(o.doc,s-r.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},zu=(r,e)=>{let t=r.selection,n;if(t instanceof I){if(t.node.isTextblock||!zt(r.doc,t.to))return!1;n=t.to}else if(n=Ho(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},Hr=(r,e)=>{let{$from:t,$to:n}=r.selection,s=t.blockRange(n),o=s&&cn(s);return o==null?!1:(e&&e(r.tr.lift(s,o).scrollIntoView()),!0)},ju=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
37
|
+
`).scrollIntoView()),!0)};function Jr(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 gi=(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=Jr(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(V.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Bu=(r,e)=>{let t=r.selection,{$from:n,$to:s}=t;if(t instanceof xe||n.parent.inlineContent||s.parent.inlineContent)return!1;let o=Jr(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(j.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Fu=(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(Rt(r.doc,o))return e&&e(r.tr.split(o).scrollIntoView()),!0}let n=t.blockRange(),s=n&&cn(n);return s==null?!1:(e&&e(r.tr.lift(n,s).scrollIntoView()),!0)};function Lu(r){return(e,t)=>{let{$from:n,$to:s}=e.selection;if(e.selection instanceof I&&e.selection.node.isBlock)return!n.parentOffset||!Rt(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=Jr(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 j||e.selection instanceof xe)&&u.deleteSelection();let d=u.mapping.map(n.pos),f=Rt(u.doc,d,o.length,o);if(f||(o[0]=l?{type:l}:null,f=Rt(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 $u=Lu(),Kr=(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(I.create(r.doc,s))),!0)},Wu=(r,e)=>(e&&e(r.tr.setSelection(new xe(r.doc))),!0);function _u(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||zt(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function yi(r,e,t,n){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&_u(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 Z(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&&zt(b.doc,y.pos)&&b.join(y.pos),t(b.scrollIntoView())}return!0}let u=o.type.spec.isolating||n>0&&a?null:V.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&cn(d);if(f!=null&&f>=e.depth)return t&&t(r.tr.lift(d,f).scrollIntoView()),!0;if(c&&Lt(o,"start",!0)&&Lt(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 C=p.length-1;C>=0;C--)x=S.from(p[C].copy(x));let w=r.tr.step(new Z(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(w.scrollIntoView())}return!0}}return!1}function bi(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(j.create(e.doc,r<0?s.start(o):s.end(o)))),!0):!1}}const qu=bi(-1),Hu=bi(1);function xi(r,e=null){return function(t,n){let{$from:s,$to:o}=t.selection,i=s.blockRange(o),l=i&&Tr(i,r,e);return l?(n&&n(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function $t(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 Ju(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 ke(r,e=null,t){return function(n,s){let{empty:o,$cursor:i,ranges:l}=n.selection;if(o&&!i||!Ju(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,w=y&&y.isText?/\s*$/.exec(y.text)[0].length:0;h+x<p&&(h+=x,p-=w),c.addMark(h,p,r.create(e))}}s(c.scrollIntoView())}return!0}}function Zn(...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 Yr=Zn(fi,Au,Pu),ki=Zn(fi,Vu,Ru);const We={Enter:Zn(ju,Bu,Fu,$u),"Mod-Enter":gi,Backspace:Yr,"Mod-Backspace":Yr,"Shift-Backspace":Yr,Delete:ki,"Mod-Delete":ki,"Mod-a":Wu},wi={"Ctrl-h":We.Backspace,"Alt-Backspace":We["Mod-Backspace"],"Ctrl-d":We.Delete,"Ctrl-Alt-Backspace":We["Mod-Delete"],"Alt-Delete":We["Mod-Delete"],"Alt-d":We["Mod-Delete"],"Ctrl-a":qu,"Ctrl-e":Hu};for(let r in We)wi[r]=We[r];const Ku=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?wi:We;function Yu(r={}){return new Ie({view(e){return new Gu(e,r)}})}class Gu{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=Jo(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 te=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},Wt=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let Gr=null;const _e=function(r,e,t){let n=Gr||(Gr=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},Xu=function(){Gr=null},kt=function(r,e,t,n){return t&&(Si(r,e,t,n,-1)||Si(r,e,t,n,1))},Qu=/^(img|br|input|textarea|hr)$/i;function Si(r,e,t,n,s){for(;;){if(r==t&&e==n)return!0;if(e==(s<0?0:Se(r))){let o=r.parentNode;if(!o||o.nodeType!=1||pn(r)||Qu.test(r.nodeName)||r.contentEditable=="false")return!1;e=te(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?Se(r):0}else return!1}}function Se(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Uu(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=Se(r)}else if(r.parentNode&&!pn(r))e=te(r),r=r.parentNode;else return null}}function Zu(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&&!pn(r))e=te(r)+1,r=r.parentNode;else return null}}function ed(r,e,t){for(let n=e==0,s=e==Se(r);n||s;){if(r==t)return!0;let o=te(r);if(r=r.parentNode,!r)return!1;n=n&&o==0,s=s&&o==Se(r)}}function pn(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 er=function(r){return r.focusNode&&kt(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function wt(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function td(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function nd(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(Se(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(Se(n.startContainer),n.startOffset)}}}const Re=typeof navigator<"u"?navigator:null,Ci=typeof document<"u"?document:null,ot=Re&&Re.userAgent||"",Xr=/Edge\/(\d+)/.exec(ot),Mi=/MSIE \d/.exec(ot),Qr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ot),ge=!!(Mi||Qr||Xr),it=Mi?document.documentMode:Qr?+Qr[1]:Xr?+Xr[1]:0,De=!ge&&/gecko\/(\d+)/i.test(ot);De&&+(/Firefox\/(\d+)/.exec(ot)||[0,0])[1];const Ur=!ge&&/Chrome\/(\d+)/.exec(ot),le=!!Ur,vi=Ur?+Ur[1]:0,de=!ge&&!!Re&&/Apple Computer/.test(Re.vendor),_t=de&&(/Mobile\/\w+/.test(ot)||!!Re&&Re.maxTouchPoints>2),Ce=_t||(Re?/Mac/.test(Re.platform):!1),rd=Re?/Win/.test(Re.platform):!1,qe=/Android \d/.test(ot),mn=!!Ci&&"webkitFontSmoothing"in Ci.documentElement.style,sd=mn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function od(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 He(r,e){return typeof r=="number"?r:r[e]}function id(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 Ni(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=Wt(i);continue}let l=i,a=l==o.body,c=a?od(o):id(l),u=0,d=0;if(e.top<c.top+He(n,"top")?d=-(c.top-e.top+He(s,"top")):e.bottom>c.bottom-He(n,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+He(s,"top")-c.top:e.bottom-c.bottom+He(s,"bottom")),e.left<c.left+He(n,"left")?u=-(c.left-e.left+He(s,"left")):e.right>c.right-He(n,"right")&&(u=e.right-c.right+He(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:Wt(i)}}function ld(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:Ei(r.dom)}}function Ei(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=Wt(n));return e}function ad({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;Oi(t,n==0?0:n-e)}function Oi(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 qt=null;function cd(r){if(r.setActive)return r.setActive();if(qt)return r.focus(qt);let e=Ei(r);r.focus(qt==null?{get preventScroll(){return qt={preventScroll:!0},!0}}:void 0),qt||(qt=!1,Oi(e,0))}function Di(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=_e(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?ud(t,s):!t||n&&t.nodeType==1?{node:r,offset:o}:Di(t,s)}function ud(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=lt(n,1);if(o.top!=o.bottom&&Zr(e,o))return{node:r,offset:s+(e.left>=(o.left+o.right)/2?1:0)}}return{node:r,offset:0}}function Zr(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function dd(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function fd(r,e,t){let{node:n,offset:s}=Di(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 hd(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 Ti(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(Zr(e,c))return Ti(i,e,c)}}if((o=(o+1)%n)==s)break}return r}function pd(r,e){let t=r.dom.ownerDocument,n,s=0,o=nd(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(!Zr(e,c)||(i=Ti(r.dom,e,c),!i))return null}if(de)for(let c=i;n&&c;c=Wt(c))c.draggable&&(n=void 0);if(i=dd(i,e),n){if(De&&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;mn&&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=hd(r,n,s,e))}l==null&&(l=fd(r,i,e));let a=r.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ai(r){return r.top<r.bottom||r.left<r.right}function lt(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(Ai(n))return n}return Array.prototype.find.call(t,Ai)||r.getBoundingClientRect()}const md=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Pi(r,e,t){let{node:n,offset:s,atom:o}=r.docView.domFromPos(e,t<0?-1:1),i=mn||De;if(n.nodeType==3)if(i&&(md.test(n.nodeValue)||(t<0?!s:s==n.nodeValue.length))){let a=lt(_e(n,s,s),t);if(De&&s&&/\s/.test(n.nodeValue[s-1])&&s<n.nodeValue.length){let c=lt(_e(n,s-1,s-1),-1);if(c.top==a.top){let u=lt(_e(n,s,s+1),-1);if(u.top!=a.top)return gn(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++,gn(lt(_e(n,a,c),u),u<0)}if(!r.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(t<0||s==Se(n))){let a=n.childNodes[s-1];if(a.nodeType==1)return es(a.getBoundingClientRect(),!1)}if(o==null&&s<Se(n)){let a=n.childNodes[s];if(a.nodeType==1)return es(a.getBoundingClientRect(),!0)}return es(n.getBoundingClientRect(),t>=0)}if(o==null&&s&&(t<0||s==Se(n))){let a=n.childNodes[s-1],c=a.nodeType==3?_e(a,Se(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return gn(lt(c,1),!1)}if(o==null&&s<Se(n)){let a=n.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?_e(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return gn(lt(c,-1),!0)}return gn(lt(n.nodeType==3?_e(n):n,-t),t>=0)}function gn(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 es(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 Ii(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 gd(r,e,t){let n=e.selection,s=t=="up"?n.$from:n.$to;return Ii(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=Pi(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=_e(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 yd=/[\u0590-\u08ac]/;function bd(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?!yd.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:i:Ii(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 Vi=null,Ri=null,zi=!1;function xd(r,e,t){return Vi==e&&Ri==t?zi:(Vi=e,Ri=t,zi=t=="up"||t=="down"?gd(r,e,t):bd(r,e,t))}const Me=0,ji=1,St=2,ze=3;let yn=class{constructor(e,t,n,s){this.parent=e,this.children=t,this.dom=n,this.contentDOM=s,this.dirty=Me,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>te(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 $i){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 Bi&&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?te(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?te(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=te(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=te(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((De||de)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==`
|
|
38
|
+
`),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:te(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(De&&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&&de)&&kt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&kt(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?St:ji,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ze:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?St:ze}n=i}this.dirty=St}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?St:ji;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}},Bi=class extends yn{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==Me&&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}},kd=class extends yn{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}},tr=class ro extends yn{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=$e.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new ro(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&ze||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ze&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Me){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=Me}}slice(e,t,n){let s=ro.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=ns(o,t,i,n)),e>0&&(o=ns(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()}},Ht=class pc extends yn{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}=$e.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=qi(u,n,t),c?a=new wd(e,t,n,s,u,d||null,f,c,o,i+1):t.isText?new Li(e,t,n,s,u,f,o):new pc(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==Me&&e.eq(this.node)&&nr(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 Cd(this,i&&i.node,e);Nd(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?F.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==St)&&(i&&this.protectLocalComposition(e,i),Wi(this.contentDOM,this.children,e),_t&&Ed(this.dom))}localCompositionInfo(e,t){let{from:n,to:s}=e.state.selection;if(!(e.state.selection instanceof j)||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=Od(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 kd(this,o,t,s);e.input.compositionNodes.push(i),this.children=ns(this.children,n,n+s.length,e,i)}update(e,t,n,s){return this.dirty==ze||!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=Me}updateOuterDeco(e){if(nr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=_i(this.dom,this.nodeDOM,ts(this.outerDeco,this.node,t),ts(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 Fi(r,e,t,n,s){qi(n,e,r);let o=new Ht(void 0,r,e,t,n,n,n,s,0);return o.contentDOM&&o.updateChildren(s,0),o}let Li=class mc extends Ht{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==ze||this.dirty!=Me&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Me||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=Me,!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 mc(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=ze)}get domAtom(){return!1}isText(e){return this.node.text==e}},$i=class extends yn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Me&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},wd=class extends Ht{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==ze)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 Wi(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=Hi(n),s=!0;n=n.nextSibling}else s=!0,r.insertBefore(l,n);if(i instanceof tr){let a=n?n.previousSibling:r.lastChild;Wi(i.contentDOM,i.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=Hi(n),s=!0;s&&t.trackWrites==r&&(t.trackWrites=null)}const bn=function(r){r&&(this.nodeName=r)};bn.prototype=Object.create(null);const Ct=[new bn];function ts(r,e,t){if(r.length==0)return Ct;let n=t?Ct[0]:new bn,s=[n];for(let o=0;o<r.length;o++){let i=r[o].type.attrs;if(i){i.nodeName&&s.push(n=new bn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(n=new bn(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 _i(r,e,t,n){if(t==Ct&&n==Ct)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=Ct[0]),s=a}Sd(s,l||Ct[0],i)}return s}function Sd(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 qi(r,e,t){return _i(r,r,Ct,ts(e,t,r.nodeType!=1))}function nr(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 Hi(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class Cd{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Md(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=Me,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=tr.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==ze&&i.dom==i.contentDOM&&(i.dirty=St),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 Ht){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!=ze&&nr(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=St,d.updateChildren(s,i+1),d.dirty=Me),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)||!nr(n,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=Ht.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=Ht.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 Bi(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 tr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Li)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((de||le)&&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 $i(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 Md(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 tr)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 vd(r,e){return r.type.side-e.type.side}function Nd(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(vd);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 Ed(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 Od(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 ns(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 rs(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(er(t)){for(a=i;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&I.isSelectable(d)&&s.parent&&!(d.isInline&&ed(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new I(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=is(r,u,l,d)}return c}function Ji(r){return r.editable?r.hasFocus():Zi(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function Je(r,e=!1){let t=r.state.selection;if(Xi(r,t),!!Ji(r)){if(!e&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&le){let n=r.domSelectionRange(),s=r.domObserver.currentSelection;if(n.anchorNode&&s.anchorNode&&kt(n.anchorNode,n.anchorOffset,s.anchorNode,s.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)Td(r);else{let{anchor:n,head:s}=t,o,i;Ki&&!(t instanceof j)&&(t.$from.parent.inlineContent||(o=Yi(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Yi(r,t.to))),r.docView.setSelection(n,s,r,e),Ki&&(o&&Gi(o),i&&Gi(i)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Dd(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const Ki=de||le&&vi<63;function Yi(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(de&&s&&s.contentEditable=="false")return ss(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return ss(s);if(o)return ss(o)}}function ss(r){return r.contentEditable="true",de&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function Gi(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function Dd(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(()=>{(!Ji(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function Td(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,te(n)+1):t.setStart(n,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!r.state.selection.visible&&ge&&it<=11&&(n.disabled=!0,n.disabled=!1)}function Xi(r,e){if(e instanceof I){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(Qi(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else Qi(r)}function Qi(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function is(r,e,t,n){return r.someProp("createSelectionBetween",s=>s(r,e,t))||j.between(e,t,n)}function Ui(r){return r.editable&&!r.hasFocus()?!1:Zi(r)}function Zi(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 Ad(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return kt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function ls(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&&V.findFrom(o,e)}function at(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function el(r,e,t){let n=r.state.selection;if(n instanceof j)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 at(r,new j(n.$anchor,i))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let s=ls(r.state,e);return s&&s instanceof I?at(r,s):!1}else if(!(Ce&&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?I.isSelectable(o)?at(r,new I(e<0?r.state.doc.resolve(s.pos-o.nodeSize):s)):mn?at(r,new j(r.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof I&&n.node.isInline)return at(r,new j(e>0?n.$to:n.$from));{let s=ls(r.state,e);return s?at(r,s):!1}}}function rr(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function xn(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function Jt(r,e){return e<0?Pd(r):Id(r)}function Pd(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let s,o,i=!1;for(De&&t.nodeType==1&&n<rr(t)&&xn(t.childNodes[n],-1)&&(i=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(xn(l,-1))s=t,o=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if(tl(t))break;{let l=t.previousSibling;for(;l&&xn(l,-1);)s=t.parentNode,o=te(l),l=l.previousSibling;if(l)t=l,n=rr(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}i?as(r,t,n):s&&as(r,s,o)}function Id(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let s=rr(t),o,i;for(;;)if(n<s){if(t.nodeType!=1)break;let l=t.childNodes[n];if(xn(l,1))o=t,i=++n;else break}else{if(tl(t))break;{let l=t.nextSibling;for(;l&&xn(l,1);)o=l.parentNode,i=te(l)+1,l=l.nextSibling;if(l)t=l,n=0,s=rr(t);else{if(t=t.parentNode,t==r.dom)break;n=s=0}}}o&&as(r,o,i)}function tl(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function Vd(r,e){for(;r&&e==r.childNodes.length&&!pn(r);)e=te(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 Rd(r,e){for(;r&&!e&&!pn(r);)e=te(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 as(r,e,t){if(e.nodeType!=3){let o,i;(i=Vd(e,t))?(e=i,t=0):(o=Rd(e,t))&&(e=o,t=o.nodeValue.length)}let n=r.domSelection();if(!n)return;if(er(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&&Je(r)},50)}function nl(r,e){let t=r.state.doc.resolve(e);if(!(le||rd)&&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 rl(r,e,t){let n=r.state.selection;if(n instanceof j&&!n.empty||t.indexOf("s")>-1||Ce&&t.indexOf("m")>-1)return!1;let{$from:s,$to:o}=n;if(!s.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let i=ls(r.state,e);if(i&&i instanceof I)return at(r,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=n instanceof xe?V.near(i,e):V.findFrom(i,e);return l?at(r,l):!1}return!1}function sl(r,e){if(!(r.state.selection instanceof j))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 ol(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function zd(r){if(!de||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;ol(r,n,"true"),setTimeout(()=>ol(r,n,"false"),20)}return!1}function jd(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function Bd(r,e){let t=e.keyCode,n=jd(e);if(t==8||Ce&&t==72&&n=="c")return sl(r,-1)||Jt(r,-1);if(t==46&&!e.shiftKey||Ce&&t==68&&n=="c")return sl(r,1)||Jt(r,1);if(t==13||t==27)return!0;if(t==37||Ce&&t==66&&n=="c"){let s=t==37?nl(r,r.state.selection.from)=="ltr"?-1:1:-1;return el(r,s,n)||Jt(r,s)}else if(t==39||Ce&&t==70&&n=="c"){let s=t==39?nl(r,r.state.selection.from)=="ltr"?1:-1:1;return el(r,s,n)||Jt(r,s)}else{if(t==38||Ce&&t==80&&n=="c")return rl(r,-1,n)||Jt(r,-1);if(t==40||Ce&&t==78&&n=="c")return zd(r)||rl(r,1,n)||Jt(r,1);if(n==(Ce?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function cs(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")||$e.fromSchema(r.state.schema),l=hl(),a=l.createElement("div");a.appendChild(i.serializeFragment(n,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=dl[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,`
|
|
39
39
|
|
|
40
|
-
`);return{dom:a,text:
|
|
41
|
-
`))),0,0):E.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:p}=n.state,h=$e.fromSchema(p);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let g=i.appendChild(document.createElement("p"));b&&g.appendChild(h.serializeNode(p.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=_h(t),Rn&&qh(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 f=+u[3];f>0;f--){let d=i.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;i=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Fh.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Hh(ya(l,+u[1],+u[2]),u[4]);else if(l=E.maxOpen(Lh(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;d<l.openEnd&&!p.type.spec.isolating;d++,p=p.lastChild);l=ya(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const Fh=/^(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 Lh(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&ma(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=ga(i[i.length-1],s.length));let u=pa(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return C.from(i)}return n}function pa(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function ma(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=ma(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(C.from(pa(t,n,o+1))))}}function ga(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ga(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(r))}function es(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=es(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function ya(n,e,t){return e<n.openStart&&(n=new E(es(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new E(es(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ba={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 xa=null;function ka(){return xa||(xa=document.implementation.createHTMLDocument("title"))}let ts=null;function Wh(n){let e=window.trustedTypes;return e?(ts||(ts=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ts.createHTML(n)):n}function _h(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ka().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&ba[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Wh(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function qh(n){let e=n.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Hh(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=C.from(a.create(r[l+1],o)),s++,i++}return new E(o,s,i)}const fe={},de={},Kh={touchstart:!0,touchmove:!0};class Jh{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 Yh(n){for(let e in fe){let t=fe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Xh(n,r)&&!rs(n,r)&&(n.editable||!(r.type in de))&&t(n,r)},Kh[e]?{passive:!0}:void 0)}ue&&n.dom.addEventListener("input",()=>null),ns(n)}function mt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Gh(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ns(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>rs(n,r))})}function rs(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Xh(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Uh(n,e){!rs(n,e)&&fe[e.type]&&(n.editable||!(e.type in de))&&fe[e.type](n,e)}de.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Ca(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Qe&&ie&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),sn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Rt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Bh(n,t)?t.preventDefault():mt(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(Ca(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ne&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof V)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Vr(n){return{left:n.clientX,top:n.clientY}}function Qh(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ss(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function un(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Zh(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&O.isSelectable(r)?(un(n,new O(t)),!0):!1}function ep(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof O&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(O.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(un(n,O.create(n.state.doc,o)),!0):!1}function tp(n,e,t,r,o){return ss(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?ep(n,t):Zh(n,t))}function np(n,e,t,r){return ss(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function rp(n,e,t,r){return ss(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||op(n,t,r)}function op(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(un(n,V.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)un(n,V.create(r,l+1,l+1+i.content.size));else if(O.isSelectable(i))un(n,O.create(r,l));else continue;return!0}}function is(n){return Rr(n)}const Sa=Ne?"metaKey":"ctrlKey";fe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=is(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&Qh(t,n.input.lastClick)&&!t[Sa]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Vr(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new sp(n,i,t,!!r)):(s=="doubleClick"?np:rp)(n,i.pos,i.inside,t)?t.preventDefault():mt(n,"pointer"))};let sp=class{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Sa],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof O&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ie&&!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)),mt(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(()=>et(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(Vr(e))),this.updateAllowDefault(e),this.allowDefault||!t?mt(this.view,"pointer"):tp(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ue&&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)?(un(this.view,R.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):mt(this.view,"pointer")}move(e){this.updateAllowDefault(e),mt(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)}};fe.touchstart=n=>{n.input.lastTouch=Date.now(),is(n),mt(n,"pointer")},fe.touchmove=n=>{n.input.lastTouch=Date.now(),mt(n,"pointer")},fe.contextmenu=n=>is(n);function Ca(n,e){return n.composing?!0:ue&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const ip=Qe?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof V&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Rr(n,!0),n.markCursor=null;else if(Rr(n,!e.selection.empty),Ie&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}wa(n,ip)},de.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,wa(n,20))};function wa(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Rr(n),e))}function Ma(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=ap());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function lp(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Zd(e.focusNode,e.focusOffset),r=eh(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function ap(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Rr(n,e=!1){if(!(Qe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ma(n),e||n.docView&&n.docView.dirty){let t=Go(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function cp(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Fn=ye&&dt<15||sn&&sh<604;fe.copy=de.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Fn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=da(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):cp(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function up(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function fp(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ln(n,r.value,null,o,e):Ln(n,r.textContent,r.innerHTML,o,e)},50)}function Ln(n,e,t,r,o){let s=ha(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||E.empty)))return!0;if(!s)return!1;let i=up(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Na(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}de.paste=(n,e)=>{let t=e;if(n.composing&&!Qe)return;let r=Fn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ln(n,Na(r),r.getData("text/html"),o,t)?t.preventDefault():fp(n,t)};let Ea=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}};const Da=Ne?"altKey":"ctrlKey";fe.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Vr(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof O?o.to-1:o.to))){if(r&&r.mightDrag)i=O.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=O.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=da(n,l);(!t.dataTransfer.files.length||!ie||Al>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Fn||t.dataTransfer.setData("text/plain",c),n.dragging=new Ea(u,!t[Da],i)},fe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Vr(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",h=>{i=h(i,n)}):i=ha(n,Na(t.dataTransfer),Fn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[Da]);if(n.someProp("handleDrop",h=>h(n,t,i||E.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?Co(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:h}=r;h?h.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let p=c.doc.resolve(u);if(f&&O.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new O(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,g,x,S)=>h=S),c.setSelection(Uo(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},fe.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&et(n)},20))},fe.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},fe.beforeinput=(n,e)=>{if(ie&&Qe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Rt(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in de)fe[n]=de[n];function Wn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}let Oa=class mf{constructor(e,t){this.toDOM=e,this.spec=t||jt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Ve(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof mf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Wn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},_n=class fi{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new Ve(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof fi&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}static is(e){return e.type instanceof fi}destroy(){}},dp=class gf{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new Ve(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof gf&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}destroy(){}},Ve=class fr{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new fr(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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new fr(e,e,new Oa(t,r))}static inline(e,t,r,o){return new fr(e,t,new _n(r,o))}static node(e,t,r,o){return new fr(e,t,new dp(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof _n}get widget(){return this.type instanceof Oa}};const fn=[],jt={};let H=class Ot{constructor(e,t){this.local=e.length?e:fn,this.children=t.length?t:fn}static create(e,t){return t.length?zr(t,e,0,jt):le}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}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,r,o+l,s)}}map(e,t,r){return this==le||e.maps.length==0?this:this.mapInner(e,t,0,0,r||jt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?hp(this.children,i||[],e,t,r,o,s):i?new Ot(i.sort(Bt),fn):le}add(e,t){return t.length?this==le?Ot.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Aa(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,zr(u,l,c+1,jt)),s+=3}});let i=Ta(s?Pa(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new Ot(i.length?this.local.concat(i).sort(Bt):this.local,o||this.children)}remove(e){return e.length==0||this==le?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=le?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new Ot(o,r):le}forChild(e,t){if(this==le)return this;if(t.isLeaf)return Ot.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof _n){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new Ot(o.sort(Bt),fn);return r?new va([l,r]):l}return r||le}eq(e){if(this==e)return!0;if(!(e instanceof Ot)||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 fn;if(e.inlineContent||!this.local.some(_n.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof _n||t.push(this.local[r]);return t}forEachSet(e){e(this)}};H.empty=new H([],[]),H.removeOverlap=ls;const le=H.empty;let va=class xn{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,jt));return xn.from(r)}forChild(e,t){if(t.isLeaf)return H.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=le&&(s instanceof xn?r=r.concat(s.members):r.push(s))}return xn.from(r)}eq(e){if(!(e instanceof xn)||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,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?ls(r?t:t.sort(Bt)):fn}static from(e){switch(e.length){case 0:return le;case 1:return e[0];default:return new xn(e.every(t=>t instanceof H)?e:e.reduce((t,r)=>t.concat(r instanceof H?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function hp(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,p,h,b)=>{let g=b-h-(p-d);for(let x=0;x<l.length;x+=3){let S=l[x+1];if(S<0||d>S+u-f)continue;let w=l[x]+u-f;p>=w?l[x+1]=d<=w?-2:-1:d>=u&&g&&(l[x]+=g,l[x+1]+=g)}f+=g}),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(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),p=d-o,{index:h,offset:b}=r.content.findIndex(f),g=r.maybeChild(h);if(g&&b==f&&b+g.nodeSize==p){let x=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);x!=le?(l[c]=f,l[c+1]=p,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=pp(l,n,e,t,o,s,i),u=zr(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let p=u.children[f];for(;d<l.length&&l[d]<p;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new H(e.sort(Bt),l)}function Ta(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new Ve(o.from+e,o.to+e,o.type))}return t}function pp(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?t.push(f):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<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Aa(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Pa(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function zr(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Aa(n,l,a+t);if(c){s=!0;let u=zr(c,l,t+a+1,r);u!=le&&o.push(a,a+l.nodeSize,u)}});let i=Ta(s?Pa(n):n,-t).sort(Bt);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new H(i,o):le}function Bt(n,e){return n.from-e.from||n.to-e.to}function ls(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Ia(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Ia(e,o,r.copy(s.from,r.to)));break}}}return e}function Ia(n,e,t){for(;e<n.length&&Bt(t,n[e])>0;)e++;n.splice(e,0,t)}function as(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=le&&e.push(r)}),n.cursorWrapper&&e.push(H.create(n.state.doc,[n.cursorWrapper.deco])),va.from(e)}const mp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},gp=ye&&dt<=11;let yp=class{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 bp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yp,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);ye&&dt<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),gp&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,mp)),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(oa(this.view)){if(this.suppressingSelectionUpdates)return et(this.view);if(ye&&dt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Vt(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,r;for(let s=e.focusNode;s;s=In(s))t.add(s);for(let s=e.anchorNode;s;s=In(s))if(t.has(s)){r=s;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))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 r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&oa(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],a);f&&(s=s<0?f.from:Math.min(f.from,s),i=i<0?f.to:Math.max(f.to,i),f.typeOver&&(l=!0))}if(Ie&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let p=d.parentNode;p&&p.nodeName=="LI"&&(!f||Sp(e,f)!=p)&&d.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Tr(r)&&(c=Go(e))&&c.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,et(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),xp(e)),this.handleDOMChange(s,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||et(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,s=e.nextSibling;if(ye&&dt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d)}let i=o&&o.parentNode==e.target?ne(o)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=s&&s.parentNode==e.target?ne(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Va=new WeakMap,Ra=!1;function xp(n){if(!Va.has(n)&&(Va.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ie,Ra)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."),Ra=!0}}function za(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Vt(i.node,i.offset,o,s)&&([t,r,o,s]=[o,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:s}}function kp(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return za(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?za(n,t):null}function Sp(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Cp(n,e,t){let{node:r,fromOffset:o,toOffset:s,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Tr(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&n.input.lastKeyCode===8)for(let g=s;g>o;g--){let x=r.childNodes[g-1],S=x.pmViewDesc;if(x.nodeName=="BR"&&!S){s=g;break}if(!S||S.size)break}let f=n.state.doc,d=n.someProp("domParser")||Pt.fromSchema(n.state.schema),p=f.resolve(i),h=null,b=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:wp,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=g),h={anchor:g+i,head:x+i}}return{doc:b,sel:h,from:i,to:l}}function wp(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ue&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||ue&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Mp=/^(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 Np(n,e,t,r,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let v=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,L=Go(n,v);if(L&&!n.state.selection.eq(L)){if(ie&&Qe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Et=>Et(n,Rt(13,"Enter"))))return;let we=n.state.tr.setSelection(L);v=="pointer"?we.setMeta("pointer",!0):v=="key"&&we.scrollIntoView(),s&&we.setMeta("composition",s),n.dispatch(we)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Cp(n,e,t),u=n.state.doc,f=u.slice(c.from,c.to),d,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,p="end"):(d=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let h=Op(f.content,c.doc.content,c.from,d,p);if(h&&n.input.domChangeCount++,(sn&&n.input.lastIOSEnter>Date.now()-225||Qe)&&o.some(v=>v.nodeType==1&&!Mp.test(v.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",v=>v(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof V&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let v=$a(n,n.state.doc,c.sel);if(v&&!v.eq(n.state.selection)){let L=n.state.tr.setSelection(v);s&&L.setMeta("composition",s),n.dispatch(L)}}return}n.state.selection.from<n.state.selection.to&&h.start==h.endB&&n.state.selection instanceof V&&(h.start>n.state.selection.from&&h.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?h.start=n.state.selection.from:h.endA<n.state.selection.to&&h.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(h.endB+=n.state.selection.to-h.endA,h.endA=n.state.selection.to)),ye&&dt<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" "&&(h.start--,h.endA--,h.endB--);let b=c.doc.resolveNoCache(h.start-c.from),g=c.doc.resolveNoCache(h.endB-c.from),x=u.resolve(h.start),S=b.sameParent(g)&&b.parent.inlineContent&&x.end()>=h.endA,w;if((sn&&n.input.lastIOSEnter>Date.now()-225&&(!S||o.some(v=>v.nodeName=="DIV"||v.nodeName=="P"))||!S&&b.pos<c.doc.content.size&&!b.sameParent(g)&&(w=R.findFrom(c.doc.resolve(b.pos+1),1,!0))&&w.head==g.pos)&&n.someProp("handleKeyDown",v=>v(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&Dp(u,h.start,h.endA,b,g)&&n.someProp("handleKeyDown",v=>v(n,Rt(8,"Backspace")))){Qe&&ie&&n.domObserver.suppressSelectionUpdates();return}ie&&h.endB==h.start&&(n.input.lastChromeDelete=Date.now()),Qe&&!S&&b.start()!=g.start()&&g.parentOffset==0&&b.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,g=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(v){return v(n,Rt(13,"Enter"))})},20));let D=h.start,T=h.endA,M,I,z;if(S){if(b.pos==g.pos)ye&&dt<=11&&b.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>et(n),20)),M=n.state.tr.delete(D,T),I=u.resolve(h.start).marksAcross(u.resolve(h.endA));else if(h.endA==h.endB&&(z=Ep(b.parent.content.cut(b.parentOffset,g.parentOffset),x.parent.content.cut(x.parentOffset,h.endA-x.start()))))M=n.state.tr,z.type=="add"?M.addMark(D,T,z.mark):M.removeMark(D,T,z.mark);else if(b.parent.child(b.index()).isText&&b.index()==g.index()-(g.textOffset?0:1)){let v=b.parent.textBetween(b.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",L=>L(n,D,T,v)))return;M=n.state.tr.insertText(v,D,T)}}if(M||(M=n.state.tr.replace(D,T,c.doc.slice(h.start-c.from,h.endB-c.from))),c.sel){let v=$a(n,M.doc,c.sel);v&&!(ie&&n.composing&&v.empty&&(h.start!=h.endB||n.input.lastChromeDelete<Date.now()-100)&&(v.head==D||v.head==M.mapping.map(T)-1)||ye&&v.empty&&v.head==D)&&M.setSelection(v)}I&&M.ensureMarks(I),s&&M.setMeta("composition",s),n.dispatch(M.scrollIntoView())}function $a(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Uo(n,e.resolve(t.anchor),e.resolve(t.head))}function Ep(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,s=r,i,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&s.length==1)l=s[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(C.from(c).eq(n))return{mark:l,type:i}}function Dp(n,e,t,r,o){if(t-e<=o.pos-r.pos||cs(r,!0,!1)<o.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=n.resolve(cs(s,!0,!0));return!i.parent.isTextblock||i.pos>t||cs(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function cs(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function Op(n,e,t,r,o){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,s-Math.min(i,l));r-=i+a-s}if(i<s&&n.size<e.size){let a=r<=s&&r>=i?s-r:0;s-=a,s&&s<e.size&&ja(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-i),i=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&ja(n.textBetween(s-1,s+1))&&(s+=a?1:-1),i=s+(i-l),l=s}return{start:s,endA:i,endB:l}}function ja(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class vp{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 Jh,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(_a),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=La(this),Fa(this),this.nodeViews=Wa(this),this.docView=Hl(this.state.doc,Ba(this),as(this),this.dom,this),this.domObserver=new bp(this,(r,o,s,i)=>Np(this,r,o,s,i)),this.domObserver.start(),Yh(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&&ns(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(_a),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(Ma(this),i=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Wa(this);Ap(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ns(this),this.editable=La(this),Fa(this);let a=as(this),c=Ba(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(o.selection))&&(i=!0);let d=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&ah(this);if(i){this.domObserver.stop();let p=f&&(ye||ie)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Tp(o.selection,e.selection);if(f){let h=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=lp(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Hl(e.doc,c,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ph(this))?et(this,p):(na(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&ch(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof O){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Pl(this,t.getBoundingClientRect(),e)}else Pl(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 r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new Ea(e.slice,e.move,o<0?void 0:O.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(o=t?t(l):l))return o}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let l=s[i].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(ye){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&&uh(this.dom),et(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 mh(this,e)}coordsAtPos(e,t=1){return jl(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,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return kh(this,t||this.state,e)}pasteHTML(e,t){return Ln(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ln(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Gh(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,Ud())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Uh(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?ue&&this.root.nodeType===11&&nh(this.dom.ownerDocument)==this.dom&&kp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ba(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ve.node(0,n.state.doc.content.size,e)]}function Fa(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ve.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function La(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Tp(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Wa(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Ap(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function _a(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class q extends R{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return q.valid(r)?new q(r):R.near(r)}content(){return E.empty}eq(e){return e instanceof q&&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 q(e.resolve(t.pos))}getBookmark(){return new us(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Pp(e)||!Ip(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&q.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){s=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=t;let a=e.doc.resolve(o);if(q.valid(a))return a}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!O.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*t),r=!1;continue e}break}s=i,o+=t;let l=e.doc.resolve(o);if(q.valid(l))return l}return null}}}q.prototype.visible=!1,q.findFrom=q.findGapCursorFrom,R.jsonID("gapcursor",q);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 q.valid(t)?new q(t):R.near(t)}}function Pp(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function Ip(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function Vp(){return new Be({props:{decorations:jp,createSelectionBetween(n,e,t){return e.pos==t.pos&&q.valid(t)?new q(t):null},handleClick:zp,handleKeyDown:Rp,handleDOMEvents:{beforeinput:$p}}})}const Rp=zo({ArrowLeft:$r("horiz",-1),ArrowRight:$r("horiz",1),ArrowUp:$r("vert",-1),ArrowDown:$r("vert",1)});function $r(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof V){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=q.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new q(c))),!0):!1}}function zp(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!q.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&O.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new q(r))),!0)}function $p(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof q))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=C.empty;for(let i=r.length-1;i>=0;i--)o=C.from(r[i].createAndFill(null,o));let s=n.state.tr.replace(t.pos,t.pos,new E(o,0,0));return s.setSelection(V.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function jp(n){if(!(n.selection instanceof q))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",H.create(n.doc,[Ve.widget(n.selection.head,e,{key:"gapcursor"})])}const Bp=["ol",0],Fp=["ul",0],Lp=["li",0],Wp={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(n){return{order:n.hasAttribute("start")?+n.getAttribute("start"):1}}}],toDOM(n){return n.attrs.order==1?Bp:["ol",{start:n.attrs.order},0]}},_p={parseDOM:[{tag:"ul"}],toDOM(){return Fp}},qp={parseDOM:[{tag:"li"}],toDOM(){return Lp},defining:!0};function fs(n,e){let t={};for(let r in n)t[r]=n[r];for(let r in e)t[r]=e[r];return t}function Hp(n,e,t){return n.append({ordered_list:fs(Wp,{content:"list_item+",group:t}),bullet_list:fs(_p,{content:"list_item+",group:t}),list_item:fs(qp,{content:e})})}function jr(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s);if(!i)return!1;let l=r?t.tr:null;return Kp(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Kp(n,e,t,r=null){let o=!1,s=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);s=new gr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new gr(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=So(s,t,r,e);return l?(n&&Jp(n,e,l,o,t),!0):!1}function Jp(n,e,t,r,o){let s=C.empty;for(let u=t.length-1;u>=0;u--)s=C.from(t[u].type.create(t[u].attrs,s));n.step(new ee(e.start-(r?2:0),e.end,e.start,e.end,new E(s,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==o&&(i=u+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,d=!0;u<f;u++,d=!1)!d&&Qt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Yp(n,e){return function(t,r){let{$from:o,$to:s,node:i}=t.selection;if(i&&i.isBlock||o.depth<2||!o.sameParent(s))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let f=C.empty,d=o.index(-1)?1:o.index(-2)?2:3;for(let x=o.depth-d;x>=o.depth-3;x--)f=C.from(o.node(x).copy(f));let p=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;f=f.append(C.from(n.createAndFill()));let h=o.before(o.depth-(d-1)),b=t.tr.replace(h,o.after(-p),new E(f,4-d,0)),g=-1;b.doc.nodesBetween(h,b.doc.content.size,(x,S)=>{if(g>-1)return!1;x.isTextblock&&x.content.size==0&&(g=S+1)}),g>-1&&b.setSelection(R.near(b.doc.resolve(g))),r(b.scrollIntoView())}return!0}let a=s.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,s.pos),u=a?[null,{type:a}]:void 0;return Qt(c.doc,o.pos,2,u)?(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0):!1}}function Gp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,i=>i.childCount>0&&i.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Xp(e,t,n,s):Up(e,t,s):!0:!1}}function Xp(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new ee(s-1,i,s,i,new E(C.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new gr(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const l=On(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(s,-1)-1);return Zt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function Up(n,e,t){let r=n.tr,o=t.parent;for(let p=t.end,h=t.endIndex-1,b=t.startIndex;h>b;h--)p-=o.child(h).nodeSize,r.delete(p-1,p+1);let s=r.doc.resolve(t.start),i=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?C.empty:C.from(o))))return!1;let f=s.pos,d=f+i.nodeSize;return r.step(new ee(f-(l?1:0),d+(a?1:0),f+1,d-1,new E((l?C.empty:C.from(o.copy(C.empty))).append(a?C.empty:C.from(o.copy(C.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Qp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=C.from(c?n.create():null),f=new E(C.from(n.create(null,C.from(l.type.create(null,u)))),c?3:1,0),d=s.start,p=s.end;t(e.tr.step(new ee(d-(c?3:1),p,d,p,f,1,!0)).scrollIntoView())}return!0}}class gt{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Zp(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function Zp(n){return function(e,t,r,o){let s=n;if(t[1]){let i=t[0].lastIndexOf(t[1]);s+=t[0].slice(i+t[1].length),r+=i;let l=r-o;l>0&&(s=t[0].slice(i-l,i)+s,r=o)}return e.tr.insertText(s,r,o)}}const em=500;function tm({rules:n}){let e=new Be({state:{init(){return null},apply(t,r){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,o,s){return qa(t,r,o,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&qa(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function qa(n,e,t,r,o,s){if(n.composing)return!1;let i=n.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-em),l.parentOffset,null,"")+r;for(let c=0;c<o.length;c++){let u=o[c];if(!u.inCodeMark&&l.marks().some(p=>p.type.spec.code))continue;if(l.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let f=u.match.exec(a),d=f&&f[0].length>=r.length&&u.handler(i,f,e-(f[0].length-r.length),t);if(d)return u.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}const nm=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let o=t[r],s;if(o.spec.isInputRules&&(s=o.getState(n))){if(e){let i=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)i.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else i.delete(s.from,s.to);e(i)}return!0}}return!1},rm=new gt(/--$/,"—",{inCodeMark:!1}),om=new gt(/\.\.\.$/,"…",{inCodeMark:!1}),sm=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),im=new gt(/"$/,"”",{inCodeMark:!1}),lm=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),am=new gt(/'$/,"’",{inCodeMark:!1}),cm=[sm,im,lm,am];function ds(n,e,t=null,r){return new gt(n,(o,s,i,l)=>{let a=t instanceof Function?t(s):t,c=o.tr.delete(i,l),u=c.doc.resolve(i),f=u.blockRange(),d=f&&So(f,e,a);if(!d)return null;c.wrap(f,d);let p=c.doc.resolve(i-1).nodeBefore;return p&&p.type==e&&Zt(c.doc,i-1)&&(!r||r(s,p))&&c.join(i-1),c})}function Ha(n,e,t=null){return new gt(n,(r,o,s,i)=>{let l=r.doc.resolve(s),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(s,i).setBlockType(s,s,e,a):null})}const Ka=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function um(n,e){let t={},r;function o(s,i){t[s]=i}if(o("Mod-z",Po),o("Shift-Mod-z",Dr),o("Backspace",nm),Ka||o("Mod-y",Dr),o("Alt-ArrowUp",Sl),o("Alt-ArrowDown",$d),o("Mod-BracketLeft",$o),o("Escape",Bo),(r=n.marks.strong)&&(o("Mod-b",ke(r)),o("Mod-B",ke(r))),(r=n.marks.em)&&(o("Mod-i",ke(r)),o("Mod-I",ke(r))),(r=n.marks.code)&&o("Mod-`",ke(r)),(r=n.nodes.bullet_list)&&o("Shift-Ctrl-8",jr(r)),(r=n.nodes.ordered_list)&&o("Shift-Ctrl-9",jr(r)),(r=n.nodes.blockquote)&&o("Ctrl->",Nl(r)),r=n.nodes.hard_break){let s=r,i=vr(Cl,(l,a)=>(a&&a(l.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0));o("Mod-Enter",i),o("Shift-Enter",i),Ka&&o("Ctrl-Enter",i)}if((r=n.nodes.list_item)&&(o("Enter",Yp(r)),o("Mod-[",Gp(r)),o("Mod-]",Qp(r))),(r=n.nodes.paragraph)&&o("Shift-Ctrl-0",on(r)),(r=n.nodes.code_block)&&o("Shift-Ctrl-\\",on(r)),r=n.nodes.heading)for(let s=1;s<=6;s++)o("Shift-Ctrl-"+s,on(r,{level:s}));if(r=n.nodes.horizontal_rule){let s=r;o("Mod-_",(i,l)=>(l&&l(i.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0))}return t}function fm(n){return ds(/^\s*>\s$/,n)}function dm(n){return ds(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function hm(n){return ds(/^\s*([-+*])\s$/,n)}function pm(n){return Ha(/^```$/,n)}function mm(n,e){return Ha(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function gm(n){let e=cm.concat(om,rm),t;return(t=n.nodes.blockquote)&&e.push(fm(t)),(t=n.nodes.ordered_list)&&e.push(dm(t)),(t=n.nodes.bullet_list)&&e.push(hm(t)),(t=n.nodes.code_block)&&e.push(pm(t)),(t=n.nodes.heading)&&e.push(mm(t,6)),tm({rules:e})}const tt=new lt("ImagePluginKey"),ym=n=>new Be({key:tt,state:{init(){return{set:H.empty,schema:n.schema,upload:n.upload}},apply(t,r){let o=r.set.map(t.mapping,t.doc);const s=t.getMeta(tt);if(s&&s.add){const i=document.createElement("placeholder"),l=Ve.widget(s.add.pos,i,{id:s.add.id,key:`imgphd${s.add.id}`});o=o.add(t.doc,[l])}else s&&s.remove&&(o=o.remove(o.find(void 0,void 0,i=>i.id==s.remove.id)));return{...r,set:o}}},props:{decorations(t){var r;return(r=this.getState(t))==null?void 0:r.set}}}),bm=(n,e)=>{const t=tt.getState(n).set,r=t==null?void 0:t.find(void 0,void 0,o=>o.id==e);return r!=null&&r.length?r[0].from:null},xm=async(n,e,t,r)=>{if(!e)return;const o=Date.now(),s=n.state.tr;r===void 0&&(s.selection.empty||s.deleteSelection(),r=s.selection.from),s.setMeta(tt,{add:{id:o,pos:r}}),n.dispatch(s);try{const i=tt.getState(n.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=bm(n.state,o);if(u===null){console.warn("uploadImage: The image was removed from the document during upload");return}n.dispatch(n.state.tr.replaceWith(u,u,l.nodes.image.create({fid:c,title:t})).setMeta(tt,{remove:{id:o}}))}catch(i){n.dispatch(n.state.tr.setMeta(tt,{remove:{id:o}})),console.error(`uploadImage: ${i}`)}},km=(n,e,t,r)=>{if(!e)return;const o=n.state.tr;r===void 0&&(o.selection.empty||o.deleteSelection(),r=o.selection.from);const s=tt.getState(n.state).schema;n.dispatch(n.state.tr.replaceWith(r,r,s.nodes.image.create({src:e,title:t})))},Ft=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ja=function(n,e,t,r){return t&&(Ya(n,e,t,r,-1)||Ya(n,e,t,r,1))},Sm=/^(img|br|input|textarea|hr)$/i;function Ya(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Br(n))){let s=n.parentNode;if(!s||s.nodeType!=1||hs(n)||Sm.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ft(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Br(n):0}else return!1}}function Br(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Cm(n,e,t){for(let r=e==0,o=e==Br(n);r||o;){if(n==t)return!0;let s=Ft(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Br(n)}}function hs(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Ga=function(n){return n.focusNode&&Ja(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Xa(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const _e=typeof navigator<"u"?navigator:null,Ua=typeof document<"u"?document:null,yt=_e&&_e.userAgent||"",ps=/Edge\/(\d+)/.exec(yt),Qa=/MSIE \d/.exec(yt),ms=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yt),qn=!!(Qa||ms||ps),Za=Qa?document.documentMode:ms?+ms[1]:ps?+ps[1]:0,Fr=!qn&&/gecko\/(\d+)/i.test(yt);Fr&&+(/Firefox\/(\d+)/.exec(yt)||[0,0])[1];const gs=!qn&&/Chrome\/(\d+)/.exec(yt),bt=!!gs,ec=gs?+gs[1]:0,Lt=!qn&&!!_e&&/Apple Computer/.test(_e.vendor),ys=Lt&&(/Mobile\/\w+/.test(yt)||!!_e&&_e.maxTouchPoints>2),De=ys||(_e?/Mac/.test(_e.platform):!1),wm=_e?/Win/.test(_e.platform):!1,Hn=/Android \d/.test(yt),bs=!!Ua&&"webkitFontSmoothing"in Ua.documentElement.style,Mm=bs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Nm(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Ga(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&O.isSelectable(f)&&o.parent&&!(f.isInline&&Cm(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new O(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){let h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=ic(n,u,l,f)}return c}function tc(n){return n.editable?n.hasFocus():vm(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function xs(n,e=!1){let t=n.state.selection;if(Om(n,t),!!tc(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&bt){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Ja(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Dm(n);else{let{anchor:r,head:o}=t,s,i;nc&&!(t instanceof V)&&(t.$from.parent.inlineContent||(s=rc(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=rc(n,t.to))),n.docView.setSelection(r,o,n,e),nc&&(s&&oc(s),i&&oc(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Em(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const nc=Lt||bt&&ec<63;function rc(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Lt&&o&&o.contentEditable=="false")return ks(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return ks(o);if(s)return ks(s)}}function ks(n){return n.contentEditable="true",Lt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function oc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Em(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!tc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Dm(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,Ft(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&qn&&Za<=11&&(r.disabled=!0,r.disabled=!1)}function Om(n,e){if(e instanceof O){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(sc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else sc(n)}function sc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ic(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||V.between(e,t,r)}function vm(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ss(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&R.findFrom(s,e)}function xt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function lc(n,e,t){let r=n.state.selection;if(r instanceof V)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return xt(n,new V(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Ss(n.state,e);return o&&o instanceof O?xt(n,o):!1}else if(!(De&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?O.isSelectable(s)?xt(n,new O(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):bs?xt(n,new V(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof O&&r.node.isInline)return xt(n,new V(e>0?r.$to:r.$from));{let o=Ss(n.state,e);return o?xt(n,o):!1}}}function Lr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Kn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function dn(n,e){return e<0?Tm(n):Am(n)}function Tm(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Fr&&t.nodeType==1&&r<Lr(t)&&Kn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Kn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(ac(t))break;{let l=t.previousSibling;for(;l&&Kn(l,-1);)o=t.parentNode,s=Ft(l),l=l.previousSibling;if(l)t=l,r=Lr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Cs(n,t,r):o&&Cs(n,o,s)}function Am(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Lr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Kn(l,1))s=t,i=++r;else break}else{if(ac(t))break;{let l=t.nextSibling;for(;l&&Kn(l,1);)s=l.parentNode,i=Ft(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Lr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Cs(n,s,i)}function ac(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Pm(n,e){for(;n&&e==n.childNodes.length&&!hs(n);)e=Ft(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Im(n,e){for(;n&&!e&&!hs(n);)e=Ft(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Cs(n,e,t){if(e.nodeType!=3){let s,i;(i=Pm(e,t))?(e=i,t=0):(s=Im(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ga(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&xs(n)},50)}function cc(n,e){let t=n.state.doc.resolve(e);if(!(bt||wm)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function uc(n,e,t){let r=n.state.selection;if(r instanceof V&&!r.empty||t.indexOf("s")>-1||De&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Ss(n.state,e);if(i&&i instanceof O)return xt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?R.near(i,e):R.findFrom(i,e);return l?xt(n,l):!1}return!1}function fc(n,e){if(!(n.state.selection instanceof V))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function dc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Vm(n){if(!Lt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;dc(n,r,"true"),setTimeout(()=>dc(n,r,"false"),20)}return!1}function Rm(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function zm(n,e){let t=e.keyCode,r=Rm(e);if(t==8||De&&t==72&&r=="c")return fc(n,-1)||dn(n,-1);if(t==46&&!e.shiftKey||De&&t==68&&r=="c")return fc(n,1)||dn(n,1);if(t==13||t==27)return!0;if(t==37||De&&t==66&&r=="c"){let o=t==37?cc(n,n.state.selection.from)=="ltr"?-1:1:-1;return lc(n,o,r)||dn(n,o)}else if(t==39||De&&t==70&&r=="c"){let o=t==39?cc(n,n.state.selection.from)=="ltr"?1:-1:1;return lc(n,o,r)||dn(n,o)}else{if(t==38||De&&t==80&&r=="c")return uc(n,-1,r)||dn(n,-1);if(t==40||De&&t==78&&r=="c")return Vm(n)||uc(n,1,r)||dn(n,1);if(r==(De?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function hc(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=Sc(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=xc[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
42
|
-
|
|
43
|
-
`);return{dom:a,text:d,slice:e}}function pc(n,e,t,r,o){let s=o.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,s||r,n)}),s)return e?new E(C.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
44
|
-
`))),0,0):E.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:p}=n.state,h=$e.fromSchema(p);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let g=i.appendChild(document.createElement("p"));b&&g.appendChild(h.serializeNode(p.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=Fm(t),bs&&Lm(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 f=+u[3];f>0;f--){let d=i.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;i=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!$m.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Wm(bc(l,+u[1],+u[2]),u[4]);else if(l=E.maxOpen(jm(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;d<l.openEnd&&!p.type.spec.isolating;d++,p=p.lastChild);l=bc(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const $m=/^(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 jm(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&gc(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=yc(i[i.length-1],s.length));let u=mc(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return C.from(i)}return n}function mc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function gc(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=gc(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(C.from(mc(t,n,o+1))))}}function yc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,yc(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(r))}function ws(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=ws(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function bc(n,e,t){return e<n.openStart&&(n=new E(ws(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new E(ws(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const xc={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 kc=null;function Sc(){return kc||(kc=document.implementation.createHTMLDocument("title"))}let Ms=null;function Bm(n){let e=window.trustedTypes;return e?(Ms||(Ms=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ms.createHTML(n)):n}function Fm(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Sc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&xc[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Bm(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function Lm(n){let e=n.querySelectorAll(bt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Wm(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=C.from(a.create(r[l+1],o)),s++,i++}return new E(o,s,i)}const Re={},Se={};function kt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}Se.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!wc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Hn&&bt&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ys&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Xa(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||zm(n,t)?t.preventDefault():kt(n,"key")},Se.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},Se.keypress=(n,e)=>{let t=e;if(wc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||De&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof V)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Wr(n){return{left:n.clientX,top:n.clientY}}function _m(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ns(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function hn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function qm(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&O.isSelectable(r)?(hn(n,new O(t)),!0):!1}function Hm(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof O&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(O.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(hn(n,O.create(n.state.doc,o)),!0):!1}function Km(n,e,t,r,o){return Ns(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Hm(n,t):qm(n,t))}function Jm(n,e,t,r){return Ns(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Ym(n,e,t,r){return Ns(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||Gm(n,t,r)}function Gm(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(hn(n,V.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)hn(n,V.create(r,l+1,l+1+i.content.size));else if(O.isSelectable(i))hn(n,O.create(r,l));else continue;return!0}}function Es(n){return _r(n)}const Cc=De?"metaKey":"ctrlKey";Re.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Es(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&_m(t,n.input.lastClick)&&!t[Cc]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Wr(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Xm(n,i,t,!!r)):(s=="doubleClick"?Jm:Ym)(n,i.pos,i.inside,t)?t.preventDefault():kt(n,"pointer"))};class Xm{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Cc],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof O&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Fr&&!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)),kt(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(()=>xs(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(Wr(e))),this.updateAllowDefault(e),this.allowDefault||!t?kt(this.view,"pointer"):Km(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Lt&&this.mightDrag&&!this.mightDrag.node.isAtom||bt&&!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)?(hn(this.view,R.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):kt(this.view,"pointer")}move(e){this.updateAllowDefault(e),kt(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)}}Re.touchstart=n=>{n.input.lastTouch=Date.now(),Es(n),kt(n,"pointer")},Re.touchmove=n=>{n.input.lastTouch=Date.now(),kt(n,"pointer")},Re.contextmenu=n=>Es(n);function wc(n,e){return n.composing?!0:Lt&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Um=Hn?5e3:-1;Se.compositionstart=Se.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof V&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),_r(n,!0),n.markCursor=null;else if(_r(n,!e.selection.empty),Fr&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}Mc(n,Um)},Se.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Mc(n,20))};function Mc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>_r(n),e))}function Qm(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Zm());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Zm(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function _r(n,e=!1){if(!(Hn&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Qm(n),e||n.docView&&n.docView.dirty){let t=Nm(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function eg(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Jn=qn&&Za<15||ys&&Mm<604;Re.copy=Se.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Jn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=hc(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):eg(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function tg(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ng(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ds(n,r.value,null,o,e):Ds(n,r.textContent,r.innerHTML,o,e)},50)}function Ds(n,e,t,r,o){let s=pc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||E.empty)))return!0;if(!s)return!1;let i=tg(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Nc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Se.paste=(n,e)=>{let t=e;if(n.composing&&!Hn)return;let r=Jn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ds(n,Nc(r),r.getData("text/html"),o,t)?t.preventDefault():ng(n,t)};class rg{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const og=De?"altKey":"ctrlKey";function Ec(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[og]}Re.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Wr(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof O?o.to-1:o.to))){if(r&&r.mightDrag)i=O.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=O.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=hc(n,l);(!t.dataTransfer.files.length||!bt||ec>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Jn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Jn||t.dataTransfer.setData("text/plain",c),n.dragging=new rg(u,Ec(n,t),i)},Re.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},Se.dragover=Se.dragenter=(n,e)=>e.preventDefault(),Se.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Wr(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",h=>{i=h(i,n)}):i=pc(n,Nc(t.dataTransfer),Jn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&Ec(n,t));if(n.someProp("handleDrop",h=>h(n,t,i||E.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?Co(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:h}=r;h?h.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let p=c.doc.resolve(u);if(f&&O.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new O(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,g,x,S)=>h=S),c.setSelection(ic(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},Re.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&xs(n)},20))},Re.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},Re.beforeinput=(n,e)=>{if(bt&&Hn&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Xa(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in Se)Re[n]=Se[n];function Yn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class qr{constructor(e,t){this.toDOM=e,this.spec=t||Wt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new qe(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof qr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Yn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class St{constructor(e,t){this.attrs=e,this.spec=t||Wt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new qe(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof St&&Yn(this.attrs,e.attrs)&&Yn(this.spec,e.spec)}static is(e){return e.type instanceof St}destroy(){}}class Os{constructor(e,t){this.attrs=e,this.spec=t||Wt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new qe(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof Os&&Yn(this.attrs,e.attrs)&&Yn(this.spec,e.spec)}destroy(){}}class qe{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new qe(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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new qe(e,e,new qr(t,r))}static inline(e,t,r,o){return new qe(e,t,new St(r,o))}static node(e,t,r,o){return new qe(e,t,new Os(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof St}get widget(){return this.type instanceof qr}}const pn=[],Wt={};class U{constructor(e,t){this.local=e.length?e:pn,this.children=t.length?t:pn}static create(e,t){return t.length?Hr(t,e,0,Wt):he}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}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,r,o+l,s)}}map(e,t,r){return this==he||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Wt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?ig(this.children,i||[],e,t,r,o,s):i?new U(i.sort(_t),pn):he}add(e,t){return t.length?this==he?U.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Oc(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,Hr(u,l,c+1,Wt)),s+=3}});let i=Dc(s?vc(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new U(i.length?this.local.concat(i).sort(_t):this.local,o||this.children)}remove(e){return e.length==0||this==he?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=he?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new U(o,r):he}forChild(e,t){if(this==he)return this;if(t.isLeaf)return U.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof St){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new U(o.sort(_t),pn);return r?new sg([l,r]):l}return r||he}eq(e){if(this==e)return!0;if(!(e instanceof U)||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 vs(this.localsInner(e))}localsInner(e){if(this==he)return pn;if(e.inlineContent||!this.local.some(St.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof St||t.push(this.local[r]);return t}forEachSet(e){e(this)}}U.empty=new U([],[]),U.removeOverlap=vs;const he=U.empty;let sg=class kn{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,Wt));return kn.from(r)}forChild(e,t){if(t.isLeaf)return U.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=he&&(s instanceof kn?r=r.concat(s.members):r.push(s))}return kn.from(r)}eq(e){if(!(e instanceof kn)||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,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?vs(r?t:t.sort(_t)):pn}static from(e){switch(e.length){case 0:return he;case 1:return e[0];default:return new kn(e.every(t=>t instanceof U)?e:e.reduce((t,r)=>t.concat(r instanceof U?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function ig(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,p,h,b)=>{let g=b-h-(p-d);for(let x=0;x<l.length;x+=3){let S=l[x+1];if(S<0||d>S+u-f)continue;let w=l[x]+u-f;p>=w?l[x+1]=d<=w?-2:-1:d>=u&&g&&(l[x]+=g,l[x+1]+=g)}f+=g}),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(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),p=d-o,{index:h,offset:b}=r.content.findIndex(f),g=r.maybeChild(h);if(g&&b==f&&b+g.nodeSize==p){let x=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);x!=he?(l[c]=f,l[c+1]=p,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=lg(l,n,e,t,o,s,i),u=Hr(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let p=u.children[f];for(;d<l.length&&l[d]<p;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new U(e.sort(_t),l)}function Dc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new qe(o.from+e,o.to+e,o.type))}return t}function lg(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?t.push(f):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<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Oc(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function vc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Hr(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Oc(n,l,a+t);if(c){s=!0;let u=Hr(c,l,t+a+1,r);u!=he&&o.push(a,a+l.nodeSize,u)}});let i=Dc(s?vc(n):n,-t).sort(_t);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new U(i,o):he}function _t(n,e){return n.from-e.from||n.to-e.to}function vs(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Tc(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Tc(e,o,r.copy(s.from,r.to)));break}}}return e}function Tc(n,e,t){for(;e<n.length&&_t(t,n[e])>0;)e++;n.splice(e,0,t)}var Ts,As;if(typeof WeakMap<"u"){let n=new WeakMap;Ts=e=>n.get(e),As=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Ts=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},As=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}var Q=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,o=e/this.width|0;let s=r+1,i=o+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:o,top:s,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[s*this.width+(t<0?r-1:o)]:(t<0?s==0:i==this.height)?null:this.map[r+this.width*(t<0?s-1:i)]}rectBetween(n,e){const{left:t,right:r,top:o,bottom:s}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){const s=r*this.width+o,i=this.map[s];t[i]||(t[i]=!0,!(o==n.left&&o&&this.map[s-1]==i||r==n.top&&r&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){const s=o+t.child(r).nodeSize;if(r==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<o;)i++;return i==l?s-1:this.map[i]}o=s}}static get(n){return Ts(n)||As(n,ag(n))}};function ag(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=cg(n),t=n.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const f=n.child(c);u++;for(let h=0;;h++){for(;o<r.length&&r[o]!=0;)o++;if(h==f.childCount)break;const b=f.child(h),{colspan:g,rowspan:x,colwidth:S}=b.attrs;for(let w=0;w<x;w++){if(w+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:x-w});break}const D=o+w*e;for(let T=0;T<g;T++){r[D+T]==0?r[D+T]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:g-T});const M=S&&S[T];if(M){const I=(D+T)%e*2,z=i[I];z==null||z!=M&&i[I+1]==1?(i[I]=M,i[I+1]=1):z==M&&i[I+1]++}}}o+=g,u+=b.nodeSize}const d=(c+1)*e;let p=0;for(;o<d;)r[o++]==0&&p++;p&&(s||(s=[])).push({type:"missing",row:c,n:p}),u++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new Q(e,t,r,s);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&ug(l,i,n),l}function cg(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const o=n.child(r);let s=0;if(t)for(let i=0;i<r;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){const l=o.child(i);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function ug(n,e,t){n.problems||(n.problems=[]);const r={};for(let o=0;o<n.map.length;o++){const s=n.map[o];if(r[s])continue;r[s]=!0;const i=t.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const u=(o+c)%n.width,f=e[u*2];f!=null&&(!a.colwidth||a.colwidth[c]!=f)&&((l||(l=fg(a)))[c]=f)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function fg(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Ac(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,o=Number(n.getAttribute("colspan")||1),s={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(n);a!=null&&(s[i]=a)}return s}function Pc(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const r in e){const o=e[r].setDOMAttr;o&&o(n.attrs[r],t)}return t}function dg(n){if(n!==null){if(!Array.isArray(n))throw new TypeError("colwidth must be null or an array");for(const e of n)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function hg(n){const e=n.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:dg}};for(const r in e)t[r]={default:e[r].default,validate:e[r].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.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:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>Ac(r,e)}],toDOM(r){return["td",Pc(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Ac(r,e)}],toDOM(r){return["th",Pc(r,e),0]}}}}function pe(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var Ct=new lt("selectingCells");function Gn(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function pg(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Oe(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Kr(n){const e=n.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=Gn(e.$head)||mg(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function mg(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Ic(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function gg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Ps(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Vc(n,e,t){const r=n.node(-1),o=Q.get(r),s=n.start(-1),i=o.nextCell(n.pos-s,e,t);return i==null?null:n.node(0).resolve(s+i)}function qt(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Rc(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function yg(n,e,t){const r=pe(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var W=class ot extends R{constructor(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=o.cellsInRect(i).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);const c=a.map(u=>{const f=r.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const d=s+u+1;return new ol(l.resolve(d),l.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(Ic(r)&&Ic(o)&&Ps(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?ot.rowSelection(r,o):s&&this.isColSelection()?ot.colSelection(r,o):new ot(r,o)}return V.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=Q.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let u=a*t.width+o.left,f=o.left;f<o.right;f++,u++){const d=t.map[u];if(s[d])continue;s[d]=!0;const p=t.findCell(d);let h=e.nodeAt(d);if(!h)throw RangeError(`No cell with offset ${d} found`);const b=o.left-p.left,g=p.right-o.right;if(b>0||g>0){let x=h.attrs;if(b>0&&(x=qt(x,0,b)),g>0&&(x=qt(x,x.colspan-g,g)),p.left<o.left){if(h=h.type.createAndFill(x),!h)throw RangeError(`Could not create cell with attrs ${JSON.stringify(x)}`)}else h=h.type.create(x,h.content)}if(p.top<o.top||p.bottom>o.bottom){const x={...h.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?h=h.type.createAndFill(x):h=h.type.create(x,h.content)}c.push(h)}i.push(e.child(a).copy(C.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new E(C.from(l),1,1)}replace(e,t=E.empty){const r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){const{$from:l,$to:a}=o[i],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),i?E.empty:t)}const s=R.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new E(C.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Q.get(t),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)e(t.nodeAt(s[i]),o+s[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(s+o.map[i.left])),l.bottom<o.height&&(t=a.resolve(s+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+o.map[l.left])),i.bottom<o.height&&(e=a.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new ot(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Q.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof ot&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(s+o.map[i.top*o.width])),l.right<o.width&&(t=a.resolve(s+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+o.map[l.top*o.width])),i.right<o.width&&(e=a.resolve(s+o.map[o.width*(i.top+1)-1]))),new ot(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ot(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ot(e.resolve(t),e.resolve(r))}getBookmark(){return new bg(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1,R.jsonID("cell",W);var bg=class yf{constructor(e,t){this.anchor=e,this.head=t}map(e){return new yf(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Ps(t,r)?new W(t,r):R.near(r,1)}};function xg(n){if(!(n.selection instanceof W))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(qe.node(r,r+t.nodeSize,{class:"selectedCell"}))}),U.create(n.doc,e)}function kg({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function Sg({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){const s=n.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function Cg(n,e,t){const r=(e||n).selection,o=(e||n).doc;let s,i;if(r instanceof O&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=W.create(o,r.from);else if(i=="row"){const l=o.resolve(r.from+1);s=W.rowSelection(l,l)}else if(!t){const l=Q.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=W.create(o,a+1,c)}}else r instanceof V&&kg(r)?s=V.create(o,r.from):r instanceof V&&Sg(r)&&(s=V.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var wg=new lt("fix-tables");function zc(n,e,t,r){const o=n.childCount,s=e.childCount;e:for(let i=0,l=0;i<s;i++){const a=e.child(i);for(let c=l,u=Math.min(o,i+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?zc(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Is(n,e){let t;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(t=Mg(n,o,s,t))};return e?e.doc!=n.doc&&zc(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Mg(n,e,t,r){const o=Q.get(e);if(!o.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a<o.height;a++)s.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const f=u.attrs;for(let d=0;d<f.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,qt(f,f.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.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;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(t);r.delete(u,u+e.nodeSize)}}let i,l;for(let a=0;a<s.length;a++)s[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const u=e.child(a),f=c+u.nodeSize,d=s[a];if(d>0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);const h=[];for(let g=0;g<d;g++){const x=pe(n.schema)[p].createAndFill();x&&h.push(x)}const b=(a==0||i==a-1)&&l==a?c+1:f-1;r.insert(r.mapping.map(b),h)}c=f}return r.setMeta(wg,{fixTables:!0})}function He(n){const e=n.selection,t=Kr(n),r=t.node(-1),o=t.start(-1),s=Q.get(r);return{...e instanceof W?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(t.pos-o),tableStart:o,map:s,table:r}}function $c(n,{map:e,tableStart:t,table:r},o){let s=o>0?-1:0;yg(e,r,o+s)&&(s=o==0||o==e.width?null:0);for(let i=0;i<e.height;i++){const l=i*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,Rc(c.attrs,o-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=s==null?pe(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(i,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function Ng(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e($c(n.tr,t,t.left))}return!0}function Eg(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e($c(n.tr,t,t.right))}return!0}function Dg(n,{map:e,table:t,tableStart:r},o){const s=n.mapping.maps.length;for(let i=0;i<e.height;){const l=i*e.width+o,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,qt(u,o-e.colCount(a)));else{const f=n.mapping.slice(s).map(r+a);n.delete(f,f+c.nodeSize)}i+=u.rowspan}}function Og(n,e){if(!Oe(n))return!1;if(e){const t=He(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;Dg(r,t,o),o!=t.left;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=Q.get(s)}e(r)}return!0}function vg(n,e,t){var r;const o=pe(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(((r=e.nodeAt(n.map[s+t*n.width]))==null?void 0:r.type)!=o)return!1;return!0}function jc(n,{map:e,tableStart:t,table:r},o){var s;let i=t;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;const l=[];let a=o>0?-1:0;vg(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){const f=e.map[u],d=r.nodeAt(f).attrs;n.setNodeMarkup(t+f,null,{...d,rowspan:d.rowspan+1}),c+=d.colspan-1}else{const f=a==null?pe(r.type.schema).cell:(s=r.nodeAt(e.map[u+a*e.width]))==null?void 0:s.type,d=f==null?void 0:f.createAndFill();d&&l.push(d)}return n.insert(i,pe(r.type.schema).row.create(null,l)),n}function Tg(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(jc(n.tr,t,t.top))}return!0}function Ag(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(jc(n.tr,t,t.bottom))}return!0}function Pg(n,{map:e,table:t,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=t.child(c).nodeSize;const i=s+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(s+r,i+r);const a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){const f=e.map[u];if(!a.has(f)){if(a.add(f),o>0&&f==e.map[u-e.width]){const d=t.nodeAt(f).attrs;n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d,rowspan:d.rowspan-1}),c+=d.colspan-1}else if(o<e.height&&f==e.map[u+e.width]){const d=t.nodeAt(f),p=d.attrs,h=d.type.create({...p,rowspan:d.attrs.rowspan-1},d.content),b=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+b),h),c+=p.colspan-1}}}}function Ig(n,e){if(!Oe(n))return!1;if(e){const t=He(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;Pg(r,t,o),o!=t.top;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=Q.get(t.table)}e(r)}return!0}function Bc(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Vg({width:n,height:e,map:t},r){let o=r.top*n+r.left,s=o,i=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[i]==t[i+n])return!0;o++,i++}return!1}function Rg(n,e){const t=n.selection;if(!(t instanceof W)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=He(n),{map:o}=r;if(Vg(o,r))return!1;if(e){const s=n.tr,i={};let l=C.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){const d=o.map[u*o.width+f],p=r.table.nodeAt(d);if(!(i[d]||!p))if(i[d]=!0,a==null)a=d,c=p;else{Bc(p)||(l=l.append(p.content));const h=s.mapping.map(d+r.tableStart);s.delete(h,h+p.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...Rc(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const u=a+1+c.content.size,f=Bc(c)?a+1:u;s.replaceWith(f+r.tableStart,u+r.tableStart,l)}s.setSelection(new W(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function zg(n,e){const t=pe(n.schema);return $g(({node:r})=>t[r.type.spec.tableRole])(n,e)}function $g(n){return(e,t)=>{var r;const o=e.selection;let s,i;if(o instanceof W){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;s=o.$anchorCell.nodeAfter,i=o.$anchorCell.pos}else{if(s=pg(o.$from),!s)return!1;i=(r=Gn(o.$from))==null?void 0:r.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=He(e),f=e.tr;for(let p=0;p<u.right-u.left;p++)a.push(c?{...l,colwidth:c&&c[p]?[c[p]]:null}:l);let d;for(let p=u.top;p<u.bottom;p++){let h=u.map.positionAt(p,u.left,u.table);p==u.top&&(h+=s.nodeSize);for(let b=u.left,g=0;b<u.right;b++,g++)b==u.left&&p==u.top||f.insert(d=f.mapping.map(h+u.tableStart,1),n({node:s,row:p,col:b}).createAndFill(a[g]))}f.setNodeMarkup(i,n({node:s,row:u.top,col:u.left}),a[0]),o instanceof W&&f.setSelection(new W(f.doc.resolve(o.$anchorCell.pos),d?f.doc.resolve(d):void 0)),t(f)}return!0}}function mn(n,e){return function(t,r){if(!Oe(t))return!1;const o=Kr(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){const s=t.tr;t.selection instanceof W?t.selection.forEachCell((i,l)=>{i.attrs[n]!==e&&s.setNodeMarkup(l,null,{...i.attrs,[n]:e})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function jg(n){return function(e,t){if(!Oe(e))return!1;if(t){const r=pe(e.schema),o=He(e),s=e.tr,i=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=i.map(a=>o.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<i.length;a++)s.setNodeMarkup(o.tableStart+i[a],r.header_cell,l[a].attrs);t(s)}return!0}}function Fc(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const s=e.table.nodeAt(r[o]);if(s&&s.type!==t.header_cell)return!1}return!0}function Vs(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?jg(n):function(t,r){if(!Oe(t))return!1;if(r){const o=pe(t.schema),s=He(t),i=t.tr,l=Fc("row",s,o),a=Fc("column",s,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,f=n=="column"?{left:0,top:u,right:1,bottom:s.map.height}:n=="row"?{left:u,top:0,right:s.map.width,bottom:1}:s,d=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(f).forEach(p=>{const h=p+s.tableStart,b=i.doc.nodeAt(h);b&&i.setNodeMarkup(h,d,b.attrs)}),r(i)}return!0}}var Bg=Vs("row",{useDeprecatedLogic:!0}),Fg=Vs("column",{useDeprecatedLogic:!0}),Lg=Vs("cell",{useDeprecatedLogic:!0});function Wg(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){const s=n.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function Lc(n){return function(e,t){if(!Oe(e))return!1;const r=Wg(Kr(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(V.between(o,gg(o))).scrollIntoView())}return!0}}function _g(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Jr(n,e){const t=n.selection;if(!(t instanceof W))return!1;if(e){const r=n.tr,o=pe(n.schema).cell.createAndFill().content;t.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new E(o,0,0))}),r.docChanged&&e(r)}return!0}function qg(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const o=e.child(0),s=o.type.spec.tableRole,i=o.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,t-1),f=a<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=Rs(pe(i).row,new E(c,u,f)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?Rs(pe(i).row,new E(e,t,r)).content:e);else return null;return Hg(i,l)}function Hg(n,e){const t=[];for(let o=0;o<e.length;o++){const s=e[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=s.child(i).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(C.empty),t[o]<r){const s=pe(n).cell.createAndFill(),i=[];for(let l=t[o];l<r;l++)i.push(s);e[o]=e[o].append(C.from(i))}return{height:e.length,width:r,rows:e}}function Rs(n,e){const t=n.createAndFill();return new rl(t).replace(0,t.content.size,e).doc}function Kg({width:n,height:e,rows:t},r,o){if(n!=r){const s=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=s[l]||0,f=0;u<r;f++){let d=a.child(f%a.childCount);u+d.attrs.colspan>r&&(d=d.type.createChecked(qt(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let p=1;p<d.attrs.rowspan;p++)s[l+p]=(s[l+p]||0)+d.attrs.colspan}i.push(C.from(c))}t=i,n=r}if(e!=o){const s=[];for(let i=0,l=0;i<o;i++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);i+f.attrs.rowspan>o&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,o-f.attrs.rowspan)},f.content)),a.push(f)}s.push(C.from(a))}t=s,e=o}return{width:n,height:e,rows:t}}function Jg(n,e,t,r,o,s,i){const l=n.doc.type.schema,a=pe(l);let c,u;if(o>e.width)for(let f=0,d=0;f<e.height;f++){const p=t.child(f);d+=p.nodeSize;const h=[];let b;p.lastChild==null||p.lastChild.type==a.cell?b=c||(c=a.cell.createAndFill()):b=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)h.push(b);n.insert(n.mapping.slice(i).map(d-1+r),h)}if(s>e.height){const f=[];for(let h=0,b=(e.height-1)*e.width;h<Math.max(e.width,o);h++){const g=h>=e.width?!1:t.nodeAt(e.map[b+h]).type==a.header_cell;f.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const d=a.row.create(null,C.from(f)),p=[];for(let h=e.height;h<s;h++)p.push(d);n.insert(n.mapping.slice(i).map(r+t.nodeSize-2),p)}return!!(c||u)}function Wc(n,e,t,r,o,s,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=o;c<s;c++){const u=i*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){a=!0;const d=t.nodeAt(f),{top:p,left:h}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d.attrs,rowspan:i-p}),n.insert(n.mapping.slice(l).map(e.positionAt(i,h,t)),d.type.createAndFill({...d.attrs,rowspan:p+d.attrs.rowspan-i})),c+=d.attrs.colspan-1}}return a}function _c(n,e,t,r,o,s,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=o;c<s;c++){const u=c*e.width+i,f=e.map[u];if(e.map[u-1]==f){a=!0;const d=t.nodeAt(f),p=e.colCount(f),h=n.mapping.slice(l).map(f+r);n.setNodeMarkup(h,null,qt(d.attrs,i-p,d.attrs.colspan-(i-p))),n.insert(h+d.nodeSize,d.type.createAndFill(qt(d.attrs,0,i-p))),c+=d.attrs.rowspan-1}}return a}function qc(n,e,t,r,o){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let i=Q.get(s);const{top:l,left:a}=r,c=a+o.width,u=l+o.height,f=n.tr;let d=0;function p(){if(s=t?f.doc.nodeAt(t-1):f.doc,!s)throw new Error("No table found");i=Q.get(s),d=f.mapping.maps.length}Jg(f,i,s,t,c,u,d)&&p(),Wc(f,i,s,t,a,c,l,d)&&p(),Wc(f,i,s,t,a,c,u,d)&&p(),_c(f,i,s,t,l,u,a,d)&&p(),_c(f,i,s,t,l,u,c,d)&&p();for(let h=l;h<u;h++){const b=i.positionAt(h,a,s),g=i.positionAt(h,c,s);f.replace(f.mapping.slice(d).map(b+t),f.mapping.slice(d).map(g+t),new E(o.rows[h-l],0,0))}p(),f.setSelection(new W(f.doc.resolve(t+i.positionAt(l,a,s)),f.doc.resolve(t+i.positionAt(u-1,c-1,s)))),e(f)}var Yg=zo({ArrowLeft:Gr("horiz",-1),ArrowRight:Gr("horiz",1),ArrowUp:Gr("vert",-1),ArrowDown:Gr("vert",1),"Shift-ArrowLeft":Xr("horiz",-1),"Shift-ArrowRight":Xr("horiz",1),"Shift-ArrowUp":Xr("vert",-1),"Shift-ArrowDown":Xr("vert",1),Backspace:Jr,"Mod-Backspace":Jr,Delete:Jr,"Mod-Delete":Jr});function Yr(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Gr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof W)return Yr(t,r,R.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const i=Hc(o,n,e);if(i==null)return!1;if(n=="horiz")return Yr(t,r,R.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(i),a=Vc(l,n,e);let c;return a?c=R.near(a,1):e<0?c=R.near(t.doc.resolve(l.before(-1)),-1):c=R.near(t.doc.resolve(l.after(-1)),1),Yr(t,r,c)}}}function Xr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;let i;if(s instanceof W)i=s;else{const a=Hc(o,n,e);if(a==null)return!1;i=new W(t.doc.resolve(a))}const l=Vc(i.$headCell,n,e);return l?Yr(t,r,new W(i.$anchorCell,l)):!1}}function Gg(n,e){const t=n.state.doc,r=Gn(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new W(r))),!0):!1}function Xg(n,e,t){if(!Oe(n.state))return!1;let r=qg(t);const o=n.state.selection;if(o instanceof W){r||(r={width:1,height:1,rows:[C.from(Rs(pe(n.state.schema).cell,t))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),l=Q.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=Kg(r,l.right-l.left,l.bottom-l.top),qc(n.state,n.dispatch,i,l,r),!0}else if(r){const s=Kr(n.state),i=s.start(-1);return qc(n.state,n.dispatch,i,Q.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function Ug(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Kc(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof W)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Gn(n.state.selection.$anchor))!=null&&((t=zs(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(a,c){let u=zs(n,c);const f=Ct.getState(n.state)==null;if(!u||!Ps(a,u))if(f)u=a;else return;const d=new W(a,u);if(f||!n.state.selection.eq(d)){const p=n.state.tr.setSelection(d);f&&p.setMeta(Ct,a.pos),n.dispatch(p)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),Ct.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ct,-1))}function l(a){const c=a,u=Ct.getState(n.state);let f;if(u!=null)f=n.state.doc.resolve(u);else if(Kc(n,c.target)!=r&&(f=zs(n,e),!f))return i();f&&s(f,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function Hc(n,e,t){if(!(n.state.selection instanceof V))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Kc(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function zs(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Gn(n.state.doc.resolve(t.pos)):null}new lt("tableColumnResizing");function Qg({allowTableNodeSelection:n=!1}={}){return new Be({key:Ct,state:{init(){return null},apply(e,t){const r=e.getMeta(Ct);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:o,pos:s}=e.mapping.mapResult(t);return o?null:s}},props:{decorations:xg,handleDOMEvents:{mousedown:Ug},createSelectionBetween(e){return Ct.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Gg,handleKeyDown:Yg,handlePaste:Xg},appendTransaction(e,t,r){return Cg(r,Is(r,t),n)}})}const wt=m.createContext(null),Zg=m.createContext(null),Jc=m.createContext(null),Ur=new WeakMap;function ey(n){const e=Object.create(null);e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",o=>{if(typeof o=="function"&&(o=o(n.state)),o)for(const s in o)s=="class"?e.class+=" "+o[s]:s=="style"?e.style=(e.style?e.style+";":"")+o[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(o[s]))}),e.translate||(e.translate="no");const t=[Ve.node(0,n.state.doc.content.size,e)],r=Ur.get(n);return!r||r[0].to!==n.state.doc.content.size||!r[0].type.eq(t[0].type)?(Ur.set(n,t),t):r}const ty=[],ny={},$s=H.empty;let Yc=class Sn{constructor(e){j(this,"members");this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,ny));return Sn.from(r)}forChild(e,t){if(t.isLeaf)return H.empty;let r=[];for(let o=0;o<this.members.length;o++){const s=this.members[o].forChild(e,t);s!=$s&&(s instanceof Sn?r=r.concat(s.members):r.push(s))}return Sn.from(r)}eq(e){if(!(e instanceof Sn)||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,r=!0;for(let o=0;o<this.members.length;o++){const s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?ry(r?t:t.sort(Gc)):ty}static from(e){switch(e.length){case 0:return $s;case 1:return e[0];default:return new Sn(e.every(t=>t instanceof H)?e:e.reduce((t,r)=>t.concat(r instanceof H?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Gc(n,e){return n.from-e.from||n.to-e.to}function ry(n){let e=n;for(let t=0;t<e.length-1;t++){const r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){const s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Xc(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Xc(e,o,r.copy(s.from,r.to)));break}}}return e}function Xc(n,e,t){for(;e<n.length&&Gc(t,n[e])>0;)e++;n.splice(e,0,t)}const js=new WeakMap;function oy(n,e){const t=[];n.someProp("decorations",i=>{const l=i(n.state);l&&l!=$s&&t.push(l)}),e&&t.push(H.create(n.state.doc,[e]));const r=js.get(n);if(!r){const i=Yc.from(t);return js.set(n,i),i}let o=0,s=!0;if(r.forEachSet(i=>{t[o++]!==i&&(s=!1)}),o!==t.length&&(s=!1),!s){const i=Yc.from(t);return js.set(n,i),i}return r}const Bs=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},Uc=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},sy=function(n,e,t,r){return t&&(Qc(n,e,t,r,-1)||Qc(n,e,t,r,1))},iy=/^(img|br|input|textarea|hr)$/i;function Qc(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Qr(n))){const s=n.parentNode;if(!s||s.nodeType!=1||ay(n)||iy.test(n.nodeName)||n.contentEditable=="false")return!1;e=Bs(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Qr(n):0}else return!1}}function Qr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ly(n,e,t){for(let r=e==0,o=e==Qr(n);r||o;){if(n==t)return!0;const s=Bs(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Qr(n)}return!1}function ay(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Zc=function(n){return n.focusNode&&sy(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},eu=m.createContext(null);function J(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];typeof document>"u"||m.useLayoutEffect(...e)}function cy(n,e){const t=m.useContext(eu);J(()=>t(n),e)}function Ke(n,e){const{view:t,flushSyncRef:r}=m.useContext(wt);cy(()=>{if(t!=null&&t.docView){r.current=!1;const o=n(t);return r.current=!0,o}},e&&[t,...e])}const uy=m.forwardRef(function(e,t){let{widget:r,getPos:o,...s}=e;const[i,l]=m.useState(!0),a=m.useRef(null);return m.useImperativeHandle(t,()=>a.current,[]),Ke(c=>{if(!c||!a.current)return;c.domObserver.disconnectSelection();const u=c.domSelection(),f=document.createRange(),d=a.current;d.nodeName=="IMG"&&d.parentNode?f.setEnd(d.parentNode,Bs(d)+1):f.setEnd(d,0),f.collapse(!1),u.removeAllRanges(),u.addRange(f),l(!1),c.domObserver.connectSelection()},[]),i?m.createElement("img",{ref:a,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...s}):null});function fy(n,e){if(n==e)return!0;for(const t in n)if(n[t]!==e[t])return!1;for(const t in e)if(!(t in n))return!1;return!0}const dy={side:0};class Xn{constructor(e,t){j(this,"Component");j(this,"side");j(this,"spec");this.Component=e,this.spec=t??dy,this.side=this.spec.side??0}map(e,t,r,o){const{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Ve(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Xn&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&fy(this.spec,e.spec))}destroy(){}}function hy(n,e,t){return new Ve(n,n,new Xn(e,t))}function Fs(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const Un=new lt("@handlewithcare/react-prosemirror/reactKeys");function py(){let n=!1;return new Be({key:Un,state:{init(e,t){const r={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((o,s)=>{const i=Fs();return r.posToKey.set(s,i),r.keyToPos.set(i,s),!0}),r},apply(e,t,r,o){if(!e.docChanged||n)return t;const s=e.getMeta(Un),i=(s==null?void 0:s.type)==="bustKey"&&s.payload.key,l={posToKey:new Map,keyToPos:new Map},a=Array.from(t.posToKey.entries()).sort((c,u)=>{let[f]=c,[d]=u;return f-d});for(const[c,u]of a){const{pos:f,deleted:d}=e.mapping.mapResult(c);if(d)continue;let p=u;i===u&&(p=Fs()),l.posToKey.set(f,p),l.keyToPos.set(p,f)}return o.doc.descendants((c,u)=>{if(l.posToKey.has(u))return!0;const f=Fs();return l.posToKey.set(u,f),l.keyToPos.set(f,u),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{n=!0},compositionend:()=>{n=!1}}}})}function Ls(n,e){var i;let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(e===null)return!1;const r=t.from??n.state.selection.from,o=t.to??n.state.selection.to;if(n.someProp("handleTextInput",l=>l(n,r,o,e)))return!0;const{tr:s}=n.state;if(t.marks&&s.ensureMarks(t.marks),s.insertText(e,r,o),t.bust){const l=n.state.doc.resolve(r),a=l.sharedDepth(o),c=l.start(a),u=(i=Un.getState(n.state))==null?void 0:i.posToKey.get(c-1);s.setMeta(Un,{type:"bustKey",payload:{key:u}})}return n.dispatch(s),!0}function my(n){let e=null,t=null;return new Be({props:{handleDOMEvents:{compositionstart(r){var i;const{state:o}=r;r.dispatch(o.tr.deleteSelection());const s=o.selection.$from;return o.selection.empty&&(o.storedMarks||!s.textOffset&&s.parentOffset&&((i=s.nodeBefore)!=null&&i.marks.some(l=>l.type.spec.inclusive===!1)))&&n(hy(o.selection.from,uy,{key:"cursor-wrapper",marks:o.storedMarks??s.marks()})),t=o.storedMarks??s.marks(),r.input.composing=!0,!0},compositionupdate(){return!0},compositionend(r){if(r.input.composing=!1,e!==null)return Ls(r,e,{bust:!0,marks:t}),e=null,t=null,n(null),!0},beforeinput(r,o){var s,i;switch(o.preventDefault(),o.inputType){case"insertCompositionText":{if(o.data===null)break;e=o.data;break}case"insertReplacementText":{const l=o.getTargetRanges();(i=(s=o.dataTransfer)==null?void 0:s.items[0])==null||i.getAsString(a=>{for(const c of l){const u=r.posAtDOM(c.startContainer,c.startOffset,1),f=r.posAtDOM(c.endContainer,c.endOffset,1);Ls(r,a,{from:u,to:f})}});break}case"insertText":{Ls(r,o.data);break}case"deleteWordBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteContentForward":case"deleteContent":{const l=o.getTargetRanges(),{tr:a}=r.state;for(const c of l){const u=r.posAtDOM(c.startContainer,c.startOffset),f=r.posAtDOM(c.endContainer,c.endOffset),{doc:d}=r.state,p=d.resolve(u).marksAcross(d.resolve(f));a.delete(u,f).setStoredMarks(p)}r.dispatch(a);break}}return!0}}}})}const Je=typeof navigator<"u"?navigator:null,tu=typeof document<"u"?document:null,Ht=Je&&Je.userAgent||"",Ws=/Edge\/(\d+)/.exec(Ht),nu=/MSIE \d/.exec(Ht),_s=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ht),Zr=!!(nu||_s||Ws),gy=nu?document.documentMode:_s?+_s[1]:Ws?+Ws[1]:0,ru=!Zr&&/gecko\/(\d+)/i.test(Ht);ru&&+(/Firefox\/(\d+)/.exec(Ht)||[0,0])[1];const qs=!Zr&&/Chrome\/(\d+)/.exec(Ht),yy=!!qs,by=qs?+qs[1]:0,ou=!Zr&&!!Je&&/Apple Computer/.test(Je.vendor);ou&&(/Mobile\/\w+/.test(Ht)||!!Je&&Je.maxTouchPoints>2)||Je&&/Mac/.test(Je.platform),Je&&/Win/.test(Je.platform),!!tu&&"webkitFontSmoothing"in tu.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];const ae={ie:Zr,ie_version:gy,gecko:ru,chrome:yy,chrome_version:by,safari:ou};function su(n){return n.editable&&!n.hasFocus()?!1:xy(n)}function xy(n){var t,r;const e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(((t=e.focusNode)==null?void 0:t.nodeType)==3?(r=e.focusNode)==null?void 0:r.parentNode:e.focusNode))}catch{return!1}}function ky(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||V.between(e,t,r)}function iu(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;const t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode);const s=o&&o.size==0;let i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Zc(t)){for(a=i;o&&!o.node;)o=o.parent;const f=o.node;if(o&&f.isAtom&&O.isSelectable(f)&&o.parent&&!(f.isInline&&ly(t.focusNode,t.focusOffset,o.dom))){const d=o.posBefore;c=new O(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){const h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}const u=r.resolve(a);if(!c){const f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=ky(n,u,l,f)}return c}const eo=function(n,e,t,r){return t&&(lu(n,e,t,r,-1)||lu(n,e,t,r,1))};function Sy(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Cy=/^(img|br|input|textarea|hr)$/i;function lu(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:au(n))){const s=n.parentNode;if(!s||s.nodeType!=1||Sy(n)||Cy.test(n.nodeName)||n.contentEditable=="false")return!1;e=Mt(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?au(n):0}else return!1}}const Mt=function(n){let e=n;for(let t=0;;t++)if(e=e.previousSibling,!e)return t};function au(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function wy(n,e){const t=n;if(e instanceof O){const r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(cu(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else cu(t)}function cu(n){const e=n;e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function My(n){const e=n,t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function uu(n){return n.editable?n.hasFocus():My(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ny(n){const e=n,t=e.domSelection(),r=document.createRange();if(!t)return;const o=e.cursorWrapper.dom,s=o.nodeName=="IMG";s?r.setStart(o.parentNode,Mt(o)+1):r.setStart(o,0),r.collapse(!0),t.removeAllRanges(),t.addRange(r),!s&&!e.state.selection.visible&&ae.ie&&ae.ie_version<=11&&(o.disabled=!0,o.disabled=!1)}function fu(n,e){const t=n,{node:r,offset:o}=t.docView.domFromPos(e,0),s=o<r.childNodes.length?r.childNodes[o]:null,i=o?r.childNodes[o-1]:null;if(ae.safari&&s&&s.contentEditable=="false")return Hs(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Hs(s);if(i)return Hs(i)}}function Hs(n){return n.contentEditable="true",ae.safari&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function du(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Ey(n){const e=n,t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);const r=e.domSelectionRange(),o=r.anchorNode,s=r.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(r.anchorNode!=o||r.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!uu(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const hu=ae.safari||ae.chrome&&ae.chrome_version<63;function to(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const t=n,r=t.state.selection;if(wy(t,r),!!uu(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ae.chrome){const o=t.domSelectionRange(),s=t.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&eo(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Ny(t);else{const{anchor:o,head:s}=r;let i,l;hu&&!(r instanceof V)&&(r.$from.parent.inlineContent||(i=fu(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=fu(t,r.to))),t.docView.setSelection(o,s,t,e),hu&&(i&&du(i),l&&du(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ey(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}let Dy=class{constructor(){j(this,"anchorNode",null);j(this,"anchorOffset",0);j(this,"focusNode",null);j(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 Oy{constructor(e){j(this,"view");j(this,"flushingSoon");j(this,"currentSelection");j(this,"suppressingSelectionUpdates");this.view=e,this.flushingSoon=-1,this.currentSelection=new Dy,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const t=new Set;let r;for(let s=e.focusNode;s;s=Uc(s))t.add(s);for(let s=e.anchorNode;s;s=Uc(s))if(t.has(s)){r=s;break}const o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,t=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,o=iu(e,r);if(o&&!e.state.selection.eq(o)){const s=e.state.tr.setSelection(o);r=="pointer"?s.setMeta("pointer",!0):r=="key"&&s.scrollIntoView(),t&&s.setMeta("composition",t),e.dispatch(s)}}selectionToDOM(){const{view:e}=this;to(e);const t=e.domSelectionRange();this.currentSelection.set(t)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const t=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&su(e)&&!this.ignoreSelectionChange(t);let o=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Zc(t)&&(o=iu(e))&&o.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,to(e),this.currentSelection.set(t),e.scrollToSelection()):r&&(this.updateSelection(),this.currentSelection.eq(t)||to(e),this.currentSelection.set(t))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(su(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return to(this.view);if(ae.ie&&ae.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&eo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}let vy=class{add(){}remove(){}},pu=class co{constructor(){j(this,"nodeName","div");j(this,"style",{})}get parent(){return new co}get parentNode(){return new co}appendChild(){return new co}setAttribute(){}hasAttribute(){return!1}insertBefore(){}get classList(){return new vy}get ownerDocument(){return new mu}addEventListener(){}removeEventListener(){}replaceChildren(){}},mu=class{createElement(){return new pu}addEventListener(){}removeEventListener(){}get documentElement(){return new pu}};function gu(){const n=globalThis.window;globalThis.window??(globalThis.window={visualViewport:null});const e=globalThis.document;return globalThis.document??(globalThis.document=new mu),function(){globalThis.window!==n&&(globalThis.window=n),globalThis.document!==e&&(globalThis.document=e)}}function Kt(n,e){return n instanceof er?1:e instanceof er?-1:n.getPos()-e.getPos()}const gn=0,yu=1,no=2,Qn=3;class Zn{constructor(e,t,r,o,s){j(this,"parent");j(this,"children");j(this,"getPos");j(this,"dom");j(this,"contentDOM");j(this,"dirty");j(this,"node");this.parent=e,this.children=t,this.getPos=r,this.dom=o,this.contentDOM=s,this.dirty=gn,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){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(){}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){const o=this.children[t];if(o==e)return r;r+=o.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,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Mt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;for(let r=!0,o=e;o;o=o.parentNode){const s=this.getDesc(o);let i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){const t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){const s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t];const s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){const i=this.children[r],l=s+i.size;if(l>e||i instanceof er){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Ks&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Mt(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Mt(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t){let r=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 o=-1,s=-1;for(let i=r,l=0;;l++){const a=this.children[l],c=i+a.size;if(o==-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 f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=Mt(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){const f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Mt(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}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:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r){var p;let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const s=Math.min(e,t),i=Math.max(e,t);for(let h=0,b=0;h<this.children.length;h++){const g=this.children[h],x=b+g.size;if(s>b&&i<x)return g.setSelection(e-b-g.border,t-b-g.border,r,o);b=x}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1);const c=r.root.getSelection(),u=r.domSelectionRange();let f=!1;if((ae.gecko||ae.safari)&&e==t){const{node:h,offset:b}=l;if(h.nodeType==3){if(f=!!(b&&((p=h.nodeValue)==null?void 0:p[b-1])==`
|
|
45
|
-
`),f&&b==h.nodeValue.length)for(let g=h,x;g;g=g.parentNode){if(x=g.nextSibling){x.nodeName=="BR"&&(l=a={node:x.parentNode,offset:Mt(x)+1});break}const S=g.pmViewDesc;if(S&&S.node&&S.node.isBlock)break}}else{const g=h.childNodes[b-1];f=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(ae.gecko&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){const h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||f&&ae.safari)&&eo(l.node,l.offset,u.anchorNode,u.anchorOffset)&&eo(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){const b=l;l=a,a=b}const 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 r=0,o=0;o<this.children.length;o++){const s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){const l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?no:yu,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Qn:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?no:Qn}r=i}this.dirty=no}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const r=e==1?no:yu;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class Ks extends Zn{constructor(t,r,o,s){super(t,[],r,s,null);j(this,"widget");this.widget=o,this.widget=o}matchesWidget(t){return this.dirty==gn&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){const r=this.widget.spec.stopEvent;return r?r(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}get domAtom(){return!0}get side(){return this.widget.type.side}}class ro extends Zn{constructor(t,r,o,s,i){super(t,[],r,o,null);j(this,"textDOM");j(this,"text");this.textDOM=s,this.text=i}get size(){return this.text.length}localPosFromDOM(t,r){return t!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class Ty extends Zn{constructor(t,r,o,s,i,l,a){super(t,r,o,i,l);j(this,"mark");j(this,"spec");this.mark=s,this.spec=a}parseRule(){return this.dirty&Qn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Qn&&this.mark.eq(t)}markDirty(t,r){if(super.markDirty(t,r),this.dirty!=gn){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=gn}}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Js extends Zn{constructor(t,r,o,s,i,l,a,c,u,f,d,p,h){super(t,r,o,a,c);j(this,"node");j(this,"outerDeco");j(this,"innerDeco");j(this,"nodeDOM");j(this,"stopEvent");j(this,"selectNode");j(this,"deselectNode");j(this,"ignoreMutation");this.node=s,this.outerDeco=i,this.innerDeco=l,this.nodeDOM=u,this.stopEvent=f,this.selectNode=d,this.deselectNode=p,this.ignoreMutation=h}updateOuterDeco(){}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 r=this.children.length-1;r>=0;r--){const o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}t.contentElement||(t.getContent=()=>C.empty)}return t}matchesNode(t,r,o){return this.dirty==gn&&t.eq(this.node)&&Py(r,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}update(t,r,o,s){return!0}get domAtom(){return this.node.isAtom}}class Ay extends Js{constructor(e,t,r,o,s,i,l,a){super(e,t,r,o,s,i,l,null,a,()=>!1,()=>{},()=>{},c=>c.type!="characterData"&&c.type!="selection")}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Qn)}get domAtom(){return!1}}class er extends Zn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==gn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function Py(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Iy(n){const e={};for(const[r,o]of n.entries()){let s=function(i,l){for(const a of o){let c=!1;if(Ye.unstable_batchedUpdates(()=>{c=!!a.call(this,i,l)}),c||l.defaultPrevented)return!0}return!1};e[r]=s}return new Be({key:new lt("@handlewithcare/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function Vy(){const[n,e]=m.useState(new Map),t=m.useCallback((s,i)=>{const l=n.get(s)??[];l.unshift(i),n.has(s)||(n.set(s,l),e(new Map(n)))},[n]),r=m.useCallback((s,i)=>{const l=n.get(s);l==null||l.splice(l.indexOf(i),1)},[n]),o=m.useMemo(()=>Iy(n),[n]);return{registerEventListener:t,unregisterEventListener:r,componentEventListenersPlugin:o}}function Ys(){const[,n]=m.useReducer(e=>e+1,0);return n}function Ry(n){const e=Object.create(null);function t(r){for(const o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function zy(n,e){let t=0,r=0;for(const o in n){if(n[o]!=e[o])return!0;t++}for(const o in e)r++;return t!=r}function $y(n,e){for(const t of Object.keys(n))if(n[t]!==e[t])return!0;return!1}function bu(n){return!n.someProp("editable",e=>e(n.state)===!1)}class xu extends vp{constructor(t,r){const o=gu();super(t,{state:Ge.create({schema:r.state.schema,plugins:r.state.plugins}),plugins:r.plugins});j(this,"shouldUpdatePluginViews",!1);j(this,"oldProps");j(this,"_props");o(),this.shouldUpdatePluginViews=!0,this._props=r,this.oldProps={state:r.state},this.state=r.state,this.domObserver.stop(),this.domObserver=new Oy(this),this.domObserver.start(),this.editable=bu(this),this.docView.dom.replaceChildren(),this.docView=r.docView}get needsRedraw(){if(this.oldProps.state.plugins===this._props.state.plugins&&this._props.plugins===this.oldProps.plugins)return!1;const t=Ry(this);return zy(this.nodeViews,t)}pureSetProps(t){this._props={...this._props,...t},this.state=this._props.state,this.editable=bu(this)}runPendingEffects(){if($y(this.props,this.oldProps)){const t=this.props;this._props=this.oldProps,this.state=this._props.state,this.update(t)}}update(t){super.update(t),this.oldProps=t}updatePluginViews(t){this.shouldUpdatePluginViews&&super.updatePluginViews(t)}destroy(){this.dom=document.createElement("div"),super.destroy()}}const jy=new xr({nodes:{doc:{content:"text*"},text:{inline:!0}}}),By=Ge.create({schema:jy});let ku=!1;function Fy(n,e){process.env.NODE_ENV!=="production"&&e.defaultState!==void 0&&e.state!==void 0&&!ku&&(console.error("A component contains a ProseMirror editor with both value and defaultValue 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"),ku=!0);const t=m.useRef(!0),[r,o]=m.useState(null),s=Ys(),i=e.defaultState??By,[l,a]=m.useState(i),c=e.state??l,{componentEventListenersPlugin:u,registerEventListener:f,unregisterEventListener:d}=Vy(),p=m.useCallback(I=>{Ye.flushSync(()=>{o(I)})},[]),h=m.useMemo(()=>[...e.plugins??[],u,my(p)],[e.plugins,u,p]),b=m.useCallback(function(z){t.current?Ye.flushSync(()=>{e.state||a(v=>v.apply(z)),e.dispatchTransaction&&e.dispatchTransaction.call(this,z)}):(e.state||a(v=>v.apply(z)),e.dispatchTransaction&&e.dispatchTransaction.call(this,z))},[e.dispatchTransaction,e.state]),g=gu(),x=document.createElement("div");g();const S=m.useRef(new Js(void 0,[],()=>-1,c.doc,[],H.empty,x,null,x,()=>!1,()=>{},()=>{},()=>!1)),w={...e,state:c,plugins:h,dispatchTransaction:b,docView:S.current},[D,T]=m.useState(()=>new xu(null,w));return J(()=>()=>{D==null||D.destroy()},[D]),J(()=>{if(!n){T(null);return}if(!D||D.dom!==n){const I=new xu({mount:n},w);T(I),I.dom.addEventListener("compositionend",s);return}if(D.needsRedraw){T(null);return}D==null||D.domObserver.selectionToDOM(),D==null||D.runPendingEffects()}),D==null||D.pureSetProps(w),{editor:m.useMemo(()=>({view:D,registerEventListener:f,unregisterEventListener:d,cursorWrapper:r,docViewDescRef:S,flushSyncRef:t}),[D,f,d,r]),state:c}}function Ly(n){let{children:e}=n;const t=m.useRef(new Set).current,r=m.useRef(new Set).current,o=m.useRef(!1),s=Ys(),i=m.useRef(!0),l=m.useCallback(()=>{i.current||(s(),i.current=!0)},[s]),a=m.useCallback(c=>{let u;const f=()=>{u=c()};return t.add(f),l(),()=>{t.delete(f),u&&(o.current?(r.add(u),l()):u())}},[t,r,l]);return J(()=>(i.current=!1,t.forEach(c=>c()),t.clear(),()=>{r.forEach(c=>c()),r.clear()})),J(()=>(o.current=!0,()=>{o.current=!1}),[]),m.createElement(eu.Provider,{value:a},e)}const Ce=m.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}});function Gs(n,e,t,r,o,s,i,l){const{view:a}=m.useContext(wt),[c,u]=m.useState(!0),f=m.useRef(i),d=m.useRef(()=>!1),p=m.useCallback(M=>{d.current=M},[]),h=m.useRef(()=>!1),b=m.useCallback(M=>{h.current=M},[]),g=m.useRef(()=>{!r.current||!n||(r.current.nodeType==1&&r.current.classList.add("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&(((t==null?void 0:t.current)??r.current).draggable=!0))}),x=m.useRef(()=>{!r.current||!n||r.current.nodeType==1&&(r.current.classList.remove("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&((t==null?void 0:t.current)??r.current).removeAttribute("draggable"))}),S=m.useCallback((M,I)=>{g.current=M,x.current=I},[]),{siblingsRef:w,parentRef:D}=m.useContext(Ce),T=m.useRef([]);return J(()=>{const M=w.current;return()=>{if(f.current&&M.includes(f.current)){const I=M.indexOf(f.current);M.splice(I,1)}}},[w]),J(()=>{var I;if(!n||!r.current)return;const M=T.current[0];f.current?(f.current.parent=D.current,f.current.children=T.current,f.current.node=n,f.current.getPos=e,f.current.outerDeco=s,f.current.innerDeco=o,f.current.dom=(t==null?void 0:t.current)??r.current,f.current.dom.pmViewDesc=f.current,f.current.contentDOM=(l==null?void 0:l.current)??f.current.contentDOM??(M==null?void 0:M.dom.parentElement)??null,f.current.nodeDOM=r.current):f.current=new Js(D.current,T.current,e,n,s,o,(t==null?void 0:t.current)??r.current,(M==null?void 0:M.dom.parentElement)??null,r.current,z=>!!d.current(z),()=>g.current(),()=>x.current(),z=>h.current(z)),u(f.current.contentDOM!==null),w.current.includes(f.current)||w.current.push(f.current),w.current.sort(Kt);for(const z of T.current)if(z.parent=f.current,z instanceof ro){const v=(I=f.current.contentDOM)==null?void 0:I.firstChild;if(!v)throw new Error("Started a composition but couldn't find the text node it belongs to.");let L=v;for(;L.firstChild;)L=L.firstChild;if(!L||!(L instanceof Text))throw new Error("Started a composition but couldn't find the text node it belongs to.");z.dom=v,z.textDOM=L,z.text=L.data,z.textDOM.pmViewDesc=z,a==null||a.input.compositionNodes.push(z)}return()=>{var z,v,L,we;((z=f.current)==null?void 0:z.children[0])instanceof ro&&!(a!=null&&a.composing)&&((we=(v=f.current)==null?void 0:v.children[0].dom.parentNode)==null||we.removeChild((L=f.current)==null?void 0:L.children[0].dom))}}),{hasContentDOM:c,childDescriptors:T,nodeViewDescRef:f,setStopEvent:p,setSelectNode:S,setIgnoreMutation:b}}function Wy(n,e){return n.type.side-e.type.side}function _y(n,e,t,r){const o=e.locals(n);let s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){const u=n.child(c);r(u,o,e.forChild(s,u),s,c),s+=u.nodeSize}return}let i=0;const l=[];let a=null;for(let c=0;;){if(i<o.length&&o[i].to==s){const h=o[i++];let b;for(;i<o.length&&o[i].to==s;)(b||(b=[h])).push(o[i++]);if(b){b.sort(Wy);for(let g=0;g<b.length;g++)t(b[g],!(b[g].type instanceof Xn),s,c+g,!!a)}else t(h,!(h.type instanceof Xn),s,c,!!a)}let u,f;if(a)f=-1,u=a,a=null;else if(c<n.childCount)f=c,u=n.child(c++);else break;for(let h=0;h<l.length;h++)l[h].to<=s&&l.splice(h--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let d=s+u.nodeSize;if(u.isText){let h=d;i<o.length&&o[i].from<h&&(h=o[i].from);for(let b=0;b<l.length;b++)l[b].to<h&&(h=l[b].to);h<d&&(a=u.cut(h-s),u=u.cut(0,h-s),d=h,f=-1)}const p=u.isInline&&!u.isLeaf?l.filter(h=>!h.inline):l.slice();r(u,p,e.forChild(s,u),s,f),s=d}}function qy(){const{view:n}=m.useContext(wt);return n&&Un.getState(n.state)}var Su={exports:{}};/*!
|
|
40
|
+
`);return{dom:a,text:f,slice:e}}function il(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,`
|
|
41
|
+
`))),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=$e.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=Wd(t),mn&&_d(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")||_n.fromSchema(r.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Fd.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=qd(ul(l,+u[1],+u[2]),u[4]);else if(l=E.maxOpen(Ld(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=ul(l,d,f)}return r.someProp("transformPasted",d=>{l=d(l,r)}),l}const Fd=/^(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 Ld(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&&al(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=cl(i[i.length-1],o.length));let u=ll(l,a);i.push(u),s=s.matchType(u.type),o=a}}),i)return S.from(i)}return r}function ll(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,S.from(r));return r}function al(r,e,t,n,s){if(s<r.length&&s<e.length&&r[s]==e[s]){let o=al(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(ll(t,r,s+1))))}}function cl(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,cl(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(S.empty,!0);return r.copy(t.append(n))}function us(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=us(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 ul(r,e,t){return e<r.openStart&&(r=new E(us(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new E(us(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const dl={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 fl=null;function hl(){return fl||(fl=document.implementation.createHTMLDocument("title"))}let ds=null;function $d(r){let e=window.trustedTypes;return e?(ds||(ds=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ds.createHTML(r)):r}function Wd(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=hl().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),s;if((s=n&&dl[n[1].toLowerCase()])&&(r=s.map(o=>"<"+o+">").join("")+r+s.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=$d(r),s)for(let o=0;o<s.length;o++)t=t.querySelector(s[o])||t;return t}function _d(r){let e=r.querySelectorAll(le?"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 qd(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 fe={},he={},Hd={touchstart:!0,touchmove:!0};class Jd{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 Kd(r){for(let e in fe){let t=fe[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Gd(r,n)&&!hs(r,n)&&(r.editable||!(n.type in he))&&t(r,n)},Hd[e]?{passive:!0}:void 0)}de&&r.dom.addEventListener("input",()=>null),fs(r)}function ct(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Yd(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 fs(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>hs(r,n))})}function hs(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Gd(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 Xd(r,e){!hs(r,e)&&fe[e.type]&&(r.editable||!(e.type in he))&&fe[e.type](r,e)}he.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!ml(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(qe&&le&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),_t&&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,wt(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||Bd(r,t)?t.preventDefault():ct(r,"key")},he.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)},he.keypress=(r,e)=>{let t=e;if(ml(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ce&&t.metaKey)return;if(r.someProp("handleKeyPress",s=>s(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof j)||!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 sr(r){return{left:r.clientX,top:r.clientY}}function Qd(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function ps(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 Kt(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 Ud(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&I.isSelectable(n)?(Kt(r,new I(t)),!0):!1}function Zd(r,e){if(e==-1)return!1;let t=r.state.selection,n,s;t instanceof I&&(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(I.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?(Kt(r,I.create(r.state.doc,s)),!0):!1}function ef(r,e,t,n,s){return ps(r,"handleClickOn",e,t,n)||r.someProp("handleClick",o=>o(r,e,n))||(s?Zd(r,t):Ud(r,t))}function tf(r,e,t,n){return ps(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",s=>s(r,e,n))}function nf(r,e,t,n){return ps(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",s=>s(r,e,n))||rf(r,t,n)}function rf(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(Kt(r,j.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)Kt(r,j.create(n,l+1,l+1+i.content.size));else if(I.isSelectable(i))Kt(r,I.create(n,l));else continue;return!0}}function ms(r){return or(r)}const pl=Ce?"metaKey":"ctrlKey";fe.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=ms(r),s=Date.now(),o="singleClick";s-r.input.lastClick.time<500&&Qd(t,r.input.lastClick)&&!t[pl]&&(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(sr(t));i&&(o=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new sf(r,i,t,!!n)):(o=="doubleClick"?tf:nf)(r,i.pos,i.inside,t)?t.preventDefault():ct(r,"pointer"))};class sf{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[pl],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 I&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&De&&!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)),ct(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(()=>Je(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(sr(e))),this.updateAllowDefault(e),this.allowDefault||!t?ct(this.view,"pointer"):ef(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||de&&this.mightDrag&&!this.mightDrag.node.isAtom||le&&!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)?(Kt(this.view,V.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ct(this.view,"pointer")}move(e){this.updateAllowDefault(e),ct(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)}}fe.touchstart=r=>{r.input.lastTouch=Date.now(),ms(r),ct(r,"pointer")},fe.touchmove=r=>{r.input.lastTouch=Date.now(),ct(r,"pointer")},fe.contextmenu=r=>ms(r);function ml(r,e){return r.composing?!0:de&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const of=qe?5e3:-1;he.compositionstart=he.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof j&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))r.markCursor=r.state.storedMarks||t.marks(),or(r,!0),r.markCursor=null;else if(or(r,!e.selection.empty),De&&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}gl(r,of)},he.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++,gl(r,20))};function gl(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>or(r),e))}function yl(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=af());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function lf(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=Uu(e.focusNode,e.focusOffset),n=Zu(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 af(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function or(r,e=!1){if(!(qe&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),yl(r),e||r.docView&&r.docView.dirty){let t=rs(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 cf(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 kn=ge&&it<15||_t&&sd<604;fe.copy=he.cut=(r,e)=>{let t=e,n=r.state.selection,s=t.type=="cut";if(n.empty)return;let o=kn?null:t.clipboardData,i=n.content(),{dom:l,text:a}=cs(r,i);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):cf(r,l),s&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function uf(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function df(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?wn(r,n.value,null,s,e):wn(r,n.textContent,n.innerHTML,s,e)},50)}function wn(r,e,t,n,s){let o=il(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=uf(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 bl(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," "):""}he.paste=(r,e)=>{let t=e;if(r.composing&&!qe)return;let n=kn?null:t.clipboardData,s=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&wn(r,bl(n),n.getData("text/html"),s,t)?t.preventDefault():df(r,t)};class xl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const ff=Ce?"altKey":"ctrlKey";function kl(r,e){let t=r.someProp("dragCopies",n=>!n(e));return t??!e[ff]}fe.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(sr(t)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof I?s.to-1:s.to))){if(n&&n.mightDrag)i=I.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=I.create(r.state.doc,d.posBefore))}}let l=(i||r.state.selection).content(),{dom:a,text:c,slice:u}=cs(r,l);(!t.dataTransfer.files.length||!le||vi>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(kn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",kn||t.dataTransfer.setData("text/plain",c),r.dragging=new xl(u,kl(r,t),i)},fe.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)},he.dragover=he.dragenter=(r,e)=>e.preventDefault(),he.drop=(r,e)=>{let t=e,n=r.dragging;if(r.dragging=null,!t.dataTransfer)return;let s=r.posAtCoords(sr(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=il(r,bl(t.dataTransfer),kn?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(n&&kl(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?Jo(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&&I.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new I(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,y,x,w)=>p=w),c.setSelection(is(r,h,c.doc.resolve(p)))}r.focus(),r.dispatch(c.setMeta("uiEvent","drop"))},fe.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())&&Je(r)},20))},fe.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)},fe.beforeinput=(r,e)=>{if(le&&qe&&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,wt(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 he)fe[r]=he[r];function Sn(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 ir{constructor(e,t){this.toDOM=e,this.spec=t||Mt,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 ne(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof ir&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Sn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ut{constructor(e,t){this.attrs=e,this.spec=t||Mt}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 ne(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ut&&Sn(this.attrs,e.attrs)&&Sn(this.spec,e.spec)}static is(e){return e.type instanceof ut}destroy(){}}class gs{constructor(e,t){this.attrs=e,this.spec=t||Mt}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 ne(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 gs&&Sn(this.attrs,e.attrs)&&Sn(this.spec,e.spec)}destroy(){}}class ne{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new ne(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 ne(e,e,new ir(t,n))}static inline(e,t,n,s){return new ne(e,t,new ut(n,s))}static node(e,t,n,s){return new ne(e,t,new gs(n,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof ut}get widget(){return this.type instanceof ir}}const Yt=[],Mt={};class L{constructor(e,t){this.local=e.length?e:Yt,this.children=t.length?t:Yt}static create(e,t){return t.length?lr(t,e,0,Mt):ae}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==ae||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Mt)}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?hf(this.children,i||[],e,t,n,s,o):i?new L(i.sort(vt),Yt):ae}add(e,t){return t.length?this==ae?L.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,lr(u,l,c+1,Mt)),o+=3}});let i=Sl(o?Ml(t):t,-n);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new L(i.length?this.local.concat(i).sort(vt):this.local,s||this.children)}remove(e){return e.length==0||this==ae?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!=ae?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 L(s,n):ae}forChild(e,t){if(this==ae)return this;if(t.isLeaf)return L.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 ut){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 L(s.sort(vt),Yt);return n?new wl([l,n]):l}return n||ae}eq(e){if(this==e)return!0;if(!(e instanceof L)||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 ys(this.localsInner(e))}localsInner(e){if(this==ae)return Yt;if(e.inlineContent||!this.local.some(ut.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof ut||t.push(this.local[n]);return t}forEachSet(e){e(this)}}L.empty=new L([],[]),L.removeOverlap=ys;const ae=L.empty;let wl=class en{constructor(e){this.members=e}map(e,t){const n=this.members.map(s=>s.map(e,t,Mt));return en.from(n)}forChild(e,t){if(t.isLeaf)return L.empty;let n=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,t);o!=ae&&(o instanceof en?n=n.concat(o.members):n.push(o))}return en.from(n)}eq(e){if(!(e instanceof en)||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?ys(n?t:t.sort(vt)):Yt}static from(e){switch(e.length){case 0:return ae;case 1:return e[0];default:return new en(e.every(t=>t instanceof L)?e:e.reduce((t,n)=>t.concat(n instanceof L?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function hf(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 w=l[x+1];if(w<0||f>w+u-d)continue;let C=l[x]+u-d;h>=C?l[x+1]=f<=C?-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!=ae?(l[c]=d,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=pf(l,r,e,t,s,o,i),u=lr(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 L(e.sort(vt),l)}function Sl(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 ne(s.from+e,s.to+e,s.type))}return t}function pf(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 Ml(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function lr(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=lr(c,l,t+a+1,n);u!=ae&&s.push(a,a+l.nodeSize,u)}});let i=Sl(o?Ml(r):r,-t).sort(vt);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 L(i,s):ae}function vt(r,e){return r.from-e.from||r.to-e.to}function ys(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),vl(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),vl(e,s,n.copy(o.from,n.to)));break}}}return e}function vl(r,e,t){for(;e<r.length&&vt(t,r[e])>0;)e++;r.splice(e,0,t)}function bs(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=ae&&e.push(n)}),r.cursorWrapper&&e.push(L.create(r.state.doc,[r.cursorWrapper.deco])),wl.from(e)}const mf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},gf=ge&&it<=11;class yf{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 bf{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yf,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]);ge&&it<=11&&n.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),gf&&(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,mf)),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(Ui(this.view)){if(this.suppressingSelectionUpdates)return Je(this.view);if(ge&&it<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&kt(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=Wt(o))t.add(o);for(let o=e.anchorNode;o;o=Wt(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)&&Ui(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(De&&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||wf(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&&er(n)&&(c=rs(e))&&c.eq(V.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Je(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),xf(e)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Je(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(ge&&it<=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?te(s)+1:0,l=n.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?te(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 Nl=new WeakMap,El=!1;function xf(r){if(!Nl.has(r)&&(Nl.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=De,El)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."),El=!0}}function Ol(r,e){let t=e.startContainer,n=e.startOffset,s=e.endContainer,o=e.endOffset,i=r.domAtPos(r.state.selection.anchor);return kt(i.node,i.offset,s,o)&&([t,n,s,o]=[s,o,t,n]),{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:o}}function kf(r,e){if(e.getComposedRanges){let s=e.getComposedRanges(r.root)[0];if(s)return Ol(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?Ol(r,t):null}function wf(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 Sf(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}],er(a)||c.push({node:a.focusNode,offset:a.focusOffset})),le&&r.input.lastKeyCode===8)for(let y=o;y>s;y--){let x=n.childNodes[y-1],w=x.pmViewDesc;if(x.nodeName=="BR"&&!w){o=y;break}if(!w||w.size)break}let d=r.state.doc,f=r.someProp("domParser")||_n.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:Cf,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 Cf(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(de&&/^(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||de&&/^(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 Mf=/^(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 vf(r,e,t,n,s){let o=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let T=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,G=rs(r,T);if(G&&!r.state.selection.eq(G)){if(le&&qe&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",we=>we(r,wt(13,"Enter"))))return;let ce=r.state.tr.setSelection(G);T=="pointer"?ce.setMeta("pointer",!0):T=="key"&&ce.scrollIntoView(),o&&ce.setMeta("composition",o),r.dispatch(ce)}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=Sf(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++,(_t&&r.input.lastIOSEnter>Date.now()-225||qe)&&s.some(T=>T.nodeType==1&&!Mf.test(T.nodeName))&&(!p||p.endA>=p.endB)&&r.someProp("handleKeyDown",T=>T(r,wt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!p)if(n&&a instanceof j&&!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 T=Dl(r,r.state.doc,c.sel);if(T&&!T.eq(r.state.selection)){let G=r.state.tr.setSelection(T);o&&G.setMeta("composition",o),r.dispatch(G)}}return}r.state.selection.from<r.state.selection.to&&p.start==p.endB&&r.state.selection instanceof j&&(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)),ge&&it<=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),w=b.sameParent(y)&&b.parent.inlineContent&&x.end()>=p.endA,C;if((_t&&r.input.lastIOSEnter>Date.now()-225&&(!w||s.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!w&&b.pos<c.doc.content.size&&(!b.sameParent(y)||!b.parent.inlineContent)&&!/\S/.test(c.doc.textBetween(b.pos,y.pos,"",""))&&(C=V.findFrom(c.doc.resolve(b.pos+1),1,!0))&&C.head>b.pos)&&r.someProp("handleKeyDown",T=>T(r,wt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>p.start&&Ef(u,p.start,p.endA,b,y)&&r.someProp("handleKeyDown",T=>T(r,wt(8,"Backspace")))){qe&&le&&r.domObserver.suppressSelectionUpdates();return}le&&p.endB==p.start&&(r.input.lastChromeDelete=Date.now()),qe&&!w&&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(T){return T(r,wt(13,"Enter"))})},20));let v=p.start,O=p.endA,M,D,R;if(w){if(b.pos==y.pos)ge&&it<=11&&b.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>Je(r),20)),M=r.state.tr.delete(v,O),D=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&(R=Nf(b.parent.content.cut(b.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start()))))M=r.state.tr,R.type=="add"?M.addMark(v,O,R.mark):M.removeMark(v,O,R.mark);else if(b.parent.child(b.index()).isText&&b.index()==y.index()-(y.textOffset?0:1)){let T=b.parent.textBetween(b.parentOffset,y.parentOffset);if(r.someProp("handleTextInput",G=>G(r,v,O,T)))return;M=r.state.tr.insertText(T,v,O)}}if(M||(M=r.state.tr.replace(v,O,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let T=Dl(r,M.doc,c.sel);T&&!(le&&r.composing&&T.empty&&(p.start!=p.endB||r.input.lastChromeDelete<Date.now()-100)&&(T.head==v||T.head==M.mapping.map(O)-1)||ge&&T.empty&&T.head==v)&&M.setSelection(T)}D&&M.ensureMarks(D),o&&M.setMeta("composition",o),r.dispatch(M.scrollIntoView())}function Dl(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:is(r,e.resolve(t.anchor),e.resolve(t.head))}function Nf(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 Ef(r,e,t,n,s){if(t-e<=s.pos-n.pos||xs(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(xs(o,!0,!0));return!i.parent.isTextblock||i.pos>t||xs(i,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(i.parent.content)}function xs(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&&Tl(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&&Tl(r.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function Tl(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 Df{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 Jd,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Rl),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=Il(this),Pl(this),this.nodeViews=Vl(this),this.docView=Fi(this.state.doc,Al(this),bs(this),this.dom,this),this.domObserver=new bf(this,(n,s,o,i)=>vf(this,n,s,o,i)),this.domObserver.start(),Kd(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&&fs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Rl),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&&(yl(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=Vl(this);Af(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&fs(this),this.editable=Il(this),Pl(this);let a=bs(this),c=Al(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&&ld(this);if(i){this.domObserver.stop();let h=d&&(ge||le)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Tf(s.selection,e.selection);if(d){let p=le?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=lf(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Fi(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ad(this))?Je(this,h):(Xi(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&&ad(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 I){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Ni(this,t.getBoundingClientRect(),e)}else Ni(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 xl(e.slice,e.move,s<0?void 0:I.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(ge){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&&cd(this.dom),Je(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 pd(this,e)}coordsAtPos(e,t=1){return Pi(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 xd(this,t||this.state,e)}pasteHTML(e,t){return wn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return wn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return cs(this,e)}destroy(){this.docView&&(Yd(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],bs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Xu())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Xd(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?de&&this.root.nodeType===11&&td(this.dom.ownerDocument)==this.dom&&kf(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Al(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"),[ne.node(0,r.state.doc.content.size,e)]}function Pl(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:ne.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function Il(r){return!r.someProp("editable",e=>e(r.state)===!1)}function Tf(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 Vl(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 Af(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 Rl(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 q extends V{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return q.valid(n)?new q(n):V.near(n)}content(){return E.empty}eq(e){return e instanceof q&&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 q(e.resolve(t.pos))}getBookmark(){return new ks(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Pf(e)||!If(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&&q.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(q.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!I.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(q.valid(l))return l}return null}}}q.prototype.visible=!1,q.findFrom=q.findGapCursorFrom,V.jsonID("gapcursor",q);class ks{constructor(e){this.pos=e}map(e){return new ks(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return q.valid(t)?new q(t):V.near(t)}}function Pf(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 If(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 Vf(){return new Ie({props:{decorations:Bf,createSelectionBetween(r,e,t){return e.pos==t.pos&&q.valid(t)?new q(t):null},handleClick:zf,handleKeyDown:Rf,handleDOMEvents:{beforeinput:jf}}})}const Rf=qr({ArrowLeft:ar("horiz",-1),ArrowRight:ar("horiz",1),ArrowUp:ar("vert",-1),ArrowDown:ar("vert",1)});function ar(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 j){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let c=q.findGapCursorFrom(l,e,a);return c?(s&&s(n.tr.setSelection(new q(c))),!0):!1}}function zf(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!q.valid(n))return!1;let s=r.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&I.isSelectable(r.state.doc.nodeAt(s.inside))?!1:(r.dispatch(r.state.tr.setSelection(new q(n))),!0)}function jf(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof q))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(j.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function Bf(r){if(!(r.selection instanceof q))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",L.create(r.doc,[ne.widget(r.selection.head,e,{key:"gapcursor"})])}const Ff=["ol",0],Lf=["ul",0],$f=["li",0],Wf={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?Ff:["ol",{start:r.attrs.order},0]}},_f={parseDOM:[{tag:"ul"}],toDOM(){return Lf}},qf={parseDOM:[{tag:"li"}],toDOM(){return $f},defining:!0};function ws(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 Hf(r,e,t){return r.append({ordered_list:ws(Wf,{content:"list_item+",group:t}),bullet_list:ws(_f,{content:"list_item+",group:t}),list_item:ws(qf,{content:e})})}function cr(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 Jf(l,i,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function Jf(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 Fn(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Fn(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Tr(o,t,n,e);return l?(r&&Kf(r,e,l,s,t),!0):!1}function Kf(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 Z(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&&Rt(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return r}function Yf(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,w)=>{if(y>-1)return!1;x.isTextblock&&x.content.size==0&&(y=w+1)}),y>-1&&b.setSelection(V.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 Rt(c.doc,s.pos,2,u)?(n&&n(c.split(s.pos,2,u).scrollIntoView()),!0):!1}}function Gf(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?Xf(e,t,r,o):Qf(e,t,o):!0:!1}}function Xf(r,e,t,n){let s=r.tr,o=n.end,i=n.$to.end(n.depth);o<i&&(s.step(new Z(o-1,i,o,i,new E(S.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new Fn(s.doc.resolve(n.$from.pos),s.doc.resolve(i),n.depth));const l=cn(n);if(l==null)return!1;s.lift(n,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return zt(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function Qf(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 Z(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 Uf(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 Z(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}class dt{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Zf(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}}function Zf(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 eh=500;function th({rules:r}){let e=new Ie({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 zl(t,n,s,o,r,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:n}=t.state.selection;n&&zl(t,n.pos,n.pos,"",r,e)})}}},isInputRules:!0});return e}function zl(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-eh),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 nh=(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},rh=new dt(/--$/,"—",{inCodeMark:!1}),sh=new dt(/\.\.\.$/,"…",{inCodeMark:!1}),oh=new dt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),ih=new dt(/"$/,"”",{inCodeMark:!1}),lh=new dt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),ah=new dt(/'$/,"’",{inCodeMark:!1}),ch=[oh,ih,lh,ah];function Ss(r,e,t=null,n){return new dt(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&&Tr(d,e,a);if(!f)return null;c.wrap(d,f);let h=c.doc.resolve(i-1).nodeBefore;return h&&h.type==e&&zt(c.doc,i-1)&&(!n||n(o,h))&&c.join(i-1),c})}function jl(r,e,t=null){return new dt(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 Bl=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function uh(r,e){let t={},n;function s(o,i){t[o]=i}if(s("Mod-z",Lr),s("Shift-Mod-z",Qn),s("Backspace",nh),Bl||s("Mod-y",Qn),s("Alt-ArrowUp",mi),s("Alt-ArrowDown",zu),s("Mod-BracketLeft",Hr),s("Escape",Kr),(n=r.marks.strong)&&(s("Mod-b",ke(n)),s("Mod-B",ke(n))),(n=r.marks.em)&&(s("Mod-i",ke(n)),s("Mod-I",ke(n))),(n=r.marks.code)&&s("Mod-`",ke(n)),(n=r.nodes.bullet_list)&&s("Shift-Ctrl-8",cr(n)),(n=r.nodes.ordered_list)&&s("Shift-Ctrl-9",cr(n)),(n=r.nodes.blockquote)&&s("Ctrl->",xi(n)),n=r.nodes.hard_break){let o=n,i=Zn(gi,(l,a)=>(a&&a(l.tr.replaceSelectionWith(o.create()).scrollIntoView()),!0));s("Mod-Enter",i),s("Shift-Enter",i),Bl&&s("Ctrl-Enter",i)}if((n=r.nodes.list_item)&&(s("Enter",Yf(n)),s("Mod-[",Gf(n)),s("Mod-]",Uf(n))),(n=r.nodes.paragraph)&&s("Shift-Ctrl-0",$t(n)),(n=r.nodes.code_block)&&s("Shift-Ctrl-\\",$t(n)),n=r.nodes.heading)for(let o=1;o<=6;o++)s("Shift-Ctrl-"+o,$t(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 dh(r){return Ss(/^\s*>\s$/,r)}function fh(r){return Ss(/^(\d+)\.\s$/,r,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function hh(r){return Ss(/^\s*([-+*])\s$/,r)}function ph(r){return jl(/^```$/,r)}function mh(r,e){return jl(new RegExp("^(#{1,"+e+"})\\s$"),r,t=>({level:t[1].length}))}function gh(r){let e=ch.concat(sh,rh),t;return(t=r.nodes.blockquote)&&e.push(dh(t)),(t=r.nodes.ordered_list)&&e.push(fh(t)),(t=r.nodes.bullet_list)&&e.push(hh(t)),(t=r.nodes.code_block)&&e.push(ph(t)),(t=r.nodes.heading)&&e.push(mh(t,6)),th({rules:e})}const Ke=new tt("ImagePluginKey"),yh=r=>new Ie({key:Ke,state:{init(){return{set:L.empty,schema:r.schema,upload:r.upload}},apply(t,n){let s=n.set.map(t.mapping,t.doc);const o=t.getMeta(Ke);if(o&&o.add){const i=document.createElement("placeholder"),l=ne.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}}}),bh=(r,e)=>{const t=Ke.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},xh=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(Ke,{add:{id:s,pos:n}}),r.dispatch(o);try{const i=Ke.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=bh(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(Ke,{remove:{id:s}}))}catch(i){r.dispatch(r.state.tr.setMeta(Ke,{remove:{id:s}})),console.error(`uploadImage: ${i}`)}},kh=(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=Ke.getState(r.state).schema;r.dispatch(r.state.tr.replaceWith(n,n,o.nodes.image.create({src:e,title:t})))};var Cs,Ms;if(typeof WeakMap<"u"){let r=new WeakMap;Cs=e=>r.get(e),Ms=(e,t)=>(r.set(e,t),t)}else{const r=[];let t=0;Cs=n=>{for(let s=0;s<r.length;s+=2)if(r[s]==n)return r[s+1]},Ms=(n,s)=>(t==10&&(t=0),r[t++]=n,r[t++]=s)}var Q=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 Cs(r)||Ms(r,wh(r))}};function wh(r){if(r.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+r.type.name);const e=Sh(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:w}=b.attrs;for(let C=0;C<x;C++){if(C+c>=t){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:x-C});break}const v=s+C*e;for(let O=0;O<y;O++){n[v+O]==0?n[v+O]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:y-O});const M=w&&w[O];if(M){const D=(v+O)%e*2,R=i[D];R==null||R!=M&&i[D+1]==1?(i[D]=M,i[D+1]=1):R==M&&i[D+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 Q(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&&Ch(l,i,r),l}function Sh(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 Ch(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=Mh(a)))[c]=d)}l&&r.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:l})}}function Mh(r){if(r.colwidth)return r.colwidth.slice();const e=[];for(let t=0;t<r.colspan;t++)e.push(0);return e}function Fl(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 Ll(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 vh(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 Nh(r){const e=r.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:vh}};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=>Fl(n,e)}],toDOM(n){return["td",Ll(n,e),0]}},table_header:{content:r.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:n=>Fl(n,e)}],toDOM(n){return["th",Ll(n,e),0]}}}}function pe(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 ft=new tt("selectingCells");function Cn(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 Eh(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 ve(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 ur(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=Cn(e.$head)||Oh(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Oh(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 $l(r){return r.parent.type.spec.tableRole=="row"&&!!r.nodeAfter}function Dh(r){return r.node(0).resolve(r.pos+r.nodeAfter.nodeSize)}function vs(r,e){return r.depth==e.depth&&r.pos>=e.start(-1)&&r.pos<=e.end(-1)}function Wl(r,e,t){const n=r.node(-1),s=Q.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 Nt(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 _l(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 Th(r,e,t){const n=pe(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 W=class Qe extends V{constructor(e,t=e){const n=e.node(-1),s=Q.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 Uo(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($l(n)&&$l(s)&&vs(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 j.between(n,s)}content(){const e=this.$anchorCell.node(-1),t=Q.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=Nt(x,0,b)),y>0&&(x=Nt(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=V.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=Q.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=Q.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=Q.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=Q.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 Ah(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1,V.jsonID("cell",W);var Ah=class gc{constructor(e,t){this.anchor=e,this.head=t}map(e){return new gc(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&&vs(t,n)?new W(t,n):V.near(n,1)}};function Ph(r){if(!(r.selection instanceof W))return null;const e=[];return r.selection.forEachCell((t,n)=>{e.push(ne.node(n,n+t.nodeSize,{class:"selectedCell"}))}),L.create(r.doc,e)}function Ih({$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 Vh({$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 Rh(r,e,t){const n=(e||r).selection,s=(e||r).doc;let o,i;if(n instanceof I&&(i=n.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")o=W.create(s,n.from);else if(i=="row"){const l=s.resolve(n.from+1);o=W.rowSelection(l,l)}else if(!t){const l=Q.get(n.node),a=n.from+1,c=a+l.map[l.width*l.height-1];o=W.create(s,a+1,c)}}else n instanceof j&&Ih(n)?o=j.create(s,n.from):n instanceof j&&Vh(n)&&(o=j.create(s,n.$from.start(),n.$from.end()));return o&&(e||(e=r.tr)).setSelection(o),e}var zh=new tt("fix-tables");function ql(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)?ql(r.child(l),a,t+1,n):a.nodesBetween(0,a.content.size,n,t+1),t+=a.nodeSize}}function Ns(r,e){let t;const n=(s,o)=>{s.type.spec.tableRole=="table"&&(t=jh(r,s,o,t))};return e?e.doc!=r.doc&&ql(e.doc,r.doc,0,n):r.doc.descendants(n),t}function jh(r,e,t,n){const s=Q.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,Nt(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=pe(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(zh,{fixTables:!0})}function je(r){const e=r.selection,t=ur(r),n=t.node(-1),s=t.start(-1),o=Q.get(n);return{...e instanceof W?o.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o.findCell(t.pos-s),tableStart:s,map:o,table:n}}function Hl(r,{map:e,tableStart:t,table:n},s){let o=s>0?-1:0;Th(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,_l(c.attrs,s-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=o==null?pe(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 Bh(r,e){if(!ve(r))return!1;if(e){const t=je(r);e(Hl(r.tr,t,t.left))}return!0}function Fh(r,e){if(!ve(r))return!1;if(e){const t=je(r);e(Hl(r.tr,t,t.right))}return!0}function Lh(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,Nt(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 $h(r,e){if(!ve(r))return!1;if(e){const t=je(r),n=r.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;Lh(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=Q.get(o)}e(n)}return!0}function Wh(r,e,t){var n;const s=pe(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 Jl(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;Wh(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?pe(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,pe(n.type.schema).row.create(null,l)),r}function _h(r,e){if(!ve(r))return!1;if(e){const t=je(r);e(Jl(r.tr,t,t.top))}return!0}function qh(r,e){if(!ve(r))return!1;if(e){const t=je(r);e(Jl(r.tr,t,t.bottom))}return!0}function Hh(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 Jh(r,e){if(!ve(r))return!1;if(e){const t=je(r),n=r.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;Hh(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=Q.get(t.table)}e(n)}return!0}function Kl(r){const e=r.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Kh({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 Yh(r,e){const t=r.selection;if(!(t instanceof W)||t.$anchorCell.pos==t.$headCell.pos)return!1;const n=je(r),{map:s}=n;if(Kh(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{Kl(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,{..._l(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=Kl(c)?a+1:u;o.replaceWith(d+n.tableStart,u+n.tableStart,l)}o.setSelection(new W(o.doc.resolve(a+n.tableStart))),e(o)}return!0}function Gh(r,e){const t=pe(r.schema);return Xh(({node:n})=>t[n.type.spec.tableRole])(r,e)}function Xh(r){return(e,t)=>{var n;const s=e.selection;let o,i;if(s instanceof W){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;o=s.$anchorCell.nodeAfter,i=s.$anchorCell.pos}else{if(o=Eh(s.$from),!o)return!1;i=(n=Cn(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=je(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 W&&d.setSelection(new W(d.doc.resolve(s.$anchorCell.pos),f?d.doc.resolve(f):void 0)),t(d)}return!0}}function Gt(r,e){return function(t,n){if(!ve(t))return!1;const s=ur(t);if(s.nodeAfter.attrs[r]===e)return!1;if(n){const o=t.tr;t.selection instanceof W?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 Qh(r){return function(e,t){if(!ve(e))return!1;if(t){const n=pe(e.schema),s=je(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 Yl(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 Es(r,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Qh(r):function(t,n){if(!ve(t))return!1;if(n){const s=pe(t.schema),o=je(t),i=t.tr,l=Yl("row",o,s),a=Yl("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 Uh=Es("row",{useDeprecatedLogic:!0}),Zh=Es("column",{useDeprecatedLogic:!0}),ep=Es("cell",{useDeprecatedLogic:!0});function tp(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 Gl(r){return function(e,t){if(!ve(e))return!1;const n=tp(ur(e),r);if(n==null)return!1;if(t){const s=e.doc.resolve(n);t(e.tr.setSelection(j.between(s,Dh(s))).scrollIntoView())}return!0}}function np(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 dr(r,e){const t=r.selection;if(!(t instanceof W))return!1;if(e){const n=r.tr,s=pe(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 rp(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=Os(pe(i).row,new E(c,u,d)).content),l.push(c)}else if(o=="cell"||o=="header_cell")l.push(t||n?Os(pe(i).row,new E(e,t,n)).content:e);else return null;return sp(i,l)}function sp(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=pe(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 Os(r,e){const t=r.createAndFill();return new Qo(t).replace(0,t.content.size,e).doc}function op({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(Nt(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 ip(r,e,t,n,s,o,i){const l=r.doc.type.schema,a=pe(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 Xl(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 Ql(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,Nt(f.attrs,i-h,f.attrs.colspan-(i-h))),r.insert(p+f.nodeSize,f.type.createAndFill(Nt(f.attrs,0,i-h))),c+=f.attrs.rowspan-1}}return a}function Ul(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=Q.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=Q.get(o),f=d.mapping.maps.length}ip(d,i,o,t,c,u,f)&&h(),Xl(d,i,o,t,a,c,l,f)&&h(),Xl(d,i,o,t,a,c,u,f)&&h(),Ql(d,i,o,t,l,u,a,f)&&h(),Ql(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 W(d.doc.resolve(t+i.positionAt(l,a,o)),d.doc.resolve(t+i.positionAt(u-1,c-1,o)))),e(d)}var lp=qr({ArrowLeft:hr("horiz",-1),ArrowRight:hr("horiz",1),ArrowUp:hr("vert",-1),ArrowDown:hr("vert",1),"Shift-ArrowLeft":pr("horiz",-1),"Shift-ArrowRight":pr("horiz",1),"Shift-ArrowUp":pr("vert",-1),"Shift-ArrowDown":pr("vert",1),Backspace:dr,"Mod-Backspace":dr,Delete:dr,"Mod-Delete":dr});function fr(r,e,t){return t.eq(r.selection)?!1:(e&&e(r.tr.setSelection(t).scrollIntoView()),!0)}function hr(r,e){return(t,n,s)=>{if(!s)return!1;const o=t.selection;if(o instanceof W)return fr(t,n,V.near(o.$headCell,e));if(r!="horiz"&&!o.empty)return!1;const i=Zl(s,r,e);if(i==null)return!1;if(r=="horiz")return fr(t,n,V.near(t.doc.resolve(o.head+e),e));{const l=t.doc.resolve(i),a=Wl(l,r,e);let c;return a?c=V.near(a,1):e<0?c=V.near(t.doc.resolve(l.before(-1)),-1):c=V.near(t.doc.resolve(l.after(-1)),1),fr(t,n,c)}}}function pr(r,e){return(t,n,s)=>{if(!s)return!1;const o=t.selection;let i;if(o instanceof W)i=o;else{const a=Zl(s,r,e);if(a==null)return!1;i=new W(t.doc.resolve(a))}const l=Wl(i.$headCell,r,e);return l?fr(t,n,new W(i.$anchorCell,l)):!1}}function ap(r,e){const t=r.state.doc,n=Cn(t.resolve(e));return n?(r.dispatch(r.state.tr.setSelection(new W(n))),!0):!1}function cp(r,e,t){if(!ve(r.state))return!1;let n=rp(t);const s=r.state.selection;if(s instanceof W){n||(n={width:1,height:1,rows:[S.from(Os(pe(r.state.schema).cell,t))]});const o=s.$anchorCell.node(-1),i=s.$anchorCell.start(-1),l=Q.get(o).rectBetween(s.$anchorCell.pos-i,s.$headCell.pos-i);return n=op(n,l.right-l.left,l.bottom-l.top),Ul(r.state,r.dispatch,i,l,n),!0}else if(n){const o=ur(r.state),i=o.start(-1);return Ul(r.state,r.dispatch,i,Q.get(o.node(-1)).findCell(o.pos-i),n),!0}else return!1}function up(r,e){var t;if(e.ctrlKey||e.metaKey)return;const n=ea(r,e.target);let s;if(e.shiftKey&&r.state.selection instanceof W)o(r.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&n&&(s=Cn(r.state.selection.$anchor))!=null&&((t=Ds(r,e))==null?void 0:t.pos)!=s.pos)o(s,e),e.preventDefault();else if(!n)return;function o(a,c){let u=Ds(r,c);const d=ft.getState(r.state)==null;if(!u||!vs(a,u))if(d)u=a;else return;const f=new W(a,u);if(d||!r.state.selection.eq(f)){const h=r.state.tr.setSelection(f);d&&h.setMeta(ft,a.pos),r.dispatch(h)}}function i(){r.root.removeEventListener("mouseup",i),r.root.removeEventListener("dragstart",i),r.root.removeEventListener("mousemove",l),ft.getState(r.state)!=null&&r.dispatch(r.state.tr.setMeta(ft,-1))}function l(a){const c=a,u=ft.getState(r.state);let d;if(u!=null)d=r.state.doc.resolve(u);else if(ea(r,c.target)!=n&&(d=Ds(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 Zl(r,e,t){if(!(r.state.selection instanceof j))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 ea(r,e){for(;e&&e!=r.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ds(r,e){const t=r.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Cn(r.state.doc.resolve(t.pos)):null}new tt("tableColumnResizing");function dp({allowTableNodeSelection:r=!1}={}){return new Ie({key:ft,state:{init(){return null},apply(e,t){const n=e.getMeta(ft);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:Ph,handleDOMEvents:{mousedown:up},createSelectionBetween(e){return ft.getState(e.state)!=null?e.state.selection:null},handleTripleClick:ap,handleKeyDown:lp,handlePaste:cp},appendTransaction(e,t,n){return Rh(n,Ns(n,t),r)}})}const Xt=m.createContext(null),fp=m.createContext(null),ta=m.createContext(null),mr=new WeakMap;function hp(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=[ne.node(0,r.state.doc.content.size,e)],n=mr.get(r);return!n||n[0].to!==r.state.doc.content.size||!n[0].type.eq(t[0].type)?(mr.set(r,t),t):n}const pp=[],mp={},Ts=L.empty;let na=class tn{constructor(e){$(this,"members");this.members=e}map(e,t){const n=this.members.map(s=>s.map(e,t,mp));return tn.from(n)}forChild(e,t){if(t.isLeaf)return L.empty;let n=[];for(let s=0;s<this.members.length;s++){const o=this.members[s].forChild(e,t);o!=Ts&&(o instanceof tn?n=n.concat(o.members):n.push(o))}return tn.from(n)}eq(e){if(!(e instanceof tn)||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?gp(n?t:t.sort(ra)):pp}static from(e){switch(e.length){case 0:return Ts;case 1:return e[0];default:return new tn(e.every(t=>t instanceof L)?e:e.reduce((t,n)=>t.concat(n instanceof L?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function ra(r,e){return r.from-e.from||r.to-e.to}function gp(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),sa(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),sa(e,s,n.copy(o.from,n.to)));break}}}return e}function sa(r,e,t){for(;e<r.length&&ra(t,r[e])>0;)e++;r.splice(e,0,t)}const As=new WeakMap;function yp(r,e){const t=[];r.someProp("decorations",i=>{const l=i(r.state);l&&l!=Ts&&t.push(l)}),e&&t.push(L.create(r.state.doc,[e]));const n=As.get(r);if(!n){const i=na.from(t);return As.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=na.from(t);return As.set(r,i),i}return n}const bp=new Wn({nodes:{doc:{content:"text*"},text:{inline:!0}}}),Ps=et.create({schema:bp});function oa(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 xp(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 Et extends Df{constructor(t,n){var e=(...Ig)=>(super(...Ig),$(this,"nextProps"),$(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:Ps}),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=Ps,this.nextProps=n,this.state=n.state,this.nodeViews=oa(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=oa(this);xp(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}}}commitPendingEffects(){this.state=this.prevState,this.docView.markDirty(-1,-1),super.update(this.nextProps),this.prevState=this.state}}class ia{constructor(e){$(this,"props");$(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 ht=function(r){for(let e=0;;e++)if(r=r.previousSibling,!r)return e},la=function(r,e,t,n){return t&&(aa(r,e,t,n,-1)||aa(r,e,t,n,1))},kp=/^(img|br|input|textarea|hr)$/i;function aa(r,e,t,n,s){for(;;){if(r==t&&e==n)return!0;if(e==(s<0?0:ca(r))){const o=r.parentNode;if(!o||o.nodeType!=1||wp(r)||kp.test(r.nodeName)||r.contentEditable=="false")return!1;e=ht(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?ca(r):0}else return!1}}function ca(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function wp(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 ua=m.createContext(null);function re(){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 Sp(r,e){const t=m.useContext(ua);re(()=>t(r),e)}function Be(r,e){const{view:t,flushSyncRef:n}=m.useContext(Xt);Sp(()=>{if(t instanceof Et){n.current=!1;const s=r(t);return n.current=!0,s}},e&&[t,...e])}const Cp=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,[]),Be(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,ht(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 Mp(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 vp={side:0};class Qt{constructor(e,t){$(this,"Component");$(this,"side");$(this,"spec");this.Component=e,this.spec=t??vp,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 ne(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Qt&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&Mp(this.spec,e.spec))}destroy(){}}function Np(r,e,t){return new ne(r,r,new Qt(e,t))}function Is(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 Ep(r){let e=null,t=null;return new Ie({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(Np(s.selection.from,Cp,{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&&Is(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);Is(n,a,{from:u,to:d})}});break}case"insertText":{Is(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 Op(r){const e={};for(const[n,s]of r.entries()){let o=function(i,l){for(const a of s){let c=!1;if(Le.unstable_batchedUpdates(()=>{c=!!a.call(this,i,l)}),c||l.defaultPrevented)return!0}return!1};e[n]=o}return new Ie({key:new tt("@handlewithcare/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function Dp(){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(()=>Op(r),[r]);return{registerEventListener:t,unregisterEventListener:n,componentEventListenersPlugin:s}}function da(){const[,r]=m.useReducer(e=>e+1,0);return r}let fa=!1;function Tp(r,e){process.env.NODE_ENV!=="production"&&e.defaultState!==void 0&&e.state!==void 0&&!fa&&(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"),fa=!0);const t=m.useRef(!0),[n,s]=m.useState(null),o=da(),i=e.defaultState??Ps,[l,a]=m.useState(i),c=e.state??l,{componentEventListenersPlugin:u,registerEventListener:d,unregisterEventListener:f}=Dp(),h=m.useCallback(v=>{Le.flushSync(()=>{s(v)})},[]),p=m.useMemo(()=>[...e.plugins??[],u,Ep(h)],[e.plugins,u,h]),b=m.useCallback(function(O){t.current?Le.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,w]=m.useState(()=>new ia(y));return re(()=>()=>{x.destroy()},[x]),re(()=>{if(r!==x.dom)if(r){const v=new Et({mount:r},y);v.dom.addEventListener("compositionend",o),w(v)}else{const v=new ia(y);w(v)}else x instanceof Et&&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 Ap(r){let{children:e}=r;const t=m.useRef(new Set).current,n=m.useRef(new Set).current,s=m.useRef(!1),o=da(),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 re(()=>(i.current=!1,t.forEach(c=>c()),t.clear(),()=>{n.forEach(c=>c()),n.clear()})),re(()=>(s.current=!0,()=>{s.current=!1}),[]),m.createElement(ua.Provider,{value:a},e)}const Te=m.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}}),Fe=typeof navigator<"u"?navigator:null,ha=typeof document<"u"?document:null,Ot=Fe&&Fe.userAgent||"",Vs=/Edge\/(\d+)/.exec(Ot),pa=/MSIE \d/.exec(Ot),Rs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ot),zs=!!(pa||Rs||Vs);pa?document.documentMode:Rs?+Rs[1]:Vs&&+Vs[1];const ma=!zs&&/gecko\/(\d+)/i.test(Ot);ma&&+(/Firefox\/(\d+)/.exec(Ot)||[0,0])[1];const js=!zs&&/Chrome\/(\d+)/.exec(Ot),Pp=!!js;js&&+js[1];const ga=!zs&&!!Fe&&/Apple Computer/.test(Fe.vendor);ga&&(/Mobile\/\w+/.test(Ot)||!!Fe&&Fe.maxTouchPoints>2)||Fe&&/Mac/.test(Fe.platform),Fe&&/Win/.test(Fe.platform),!!ha&&"webkitFontSmoothing"in ha.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];const Ut={gecko:ma,chrome:Pp,safari:ga};function Dt(r,e){return r instanceof vn?1:e instanceof vn?-1:r.getPos()-e.getPos()}const pt=0,ya=1,gr=2,Tt=3;class Mn{constructor(e,t,n,s,o){$(this,"parent");$(this,"children");$(this,"getPos");$(this,"dom");$(this,"contentDOM");$(this,"dirty");$(this,"node");this.parent=e,this.children=t,this.getPos=n,this.dom=s,this.contentDOM=o,this.dirty=pt,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>ht(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 vn){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 Bs&&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?ht(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?ht(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=ht(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=ht(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((Ut.gecko||Ut.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])==`
|
|
42
|
+
`),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:ht(x)+1});break}const w=y.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{const y=p.childNodes[b-1];d=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Ut.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&&Ut.safari)&&la(l.node,l.offset,u.anchorNode,u.anchorOffset)&&la(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?gr:ya,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Tt:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?gr:Tt}n=i}this.dirty=gr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const n=e==1?gr:ya;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class Bs extends Mn{constructor(t,n,s,o){super(t,[],n,o,null);$(this,"widget");this.widget=s,this.widget=s}matchesWidget(t){return this.dirty==pt&&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 Fs extends Mn{constructor(t,n,s,o,i){super(t,[],n,s,null);$(this,"textDOM");$(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 Ip extends Mn{constructor(t,n,s,o,i,l,a){super(t,n,s,i,l);$(this,"mark");$(this,"spec");this.mark=o,this.spec=a}parseRule(){return this.dirty&Tt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Tt&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=pt){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty<this.dirty&&(s.dirty=this.dirty),this.dirty=pt}}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ba extends Mn{constructor(t,n,s,o,i,l,a,c,u){super(t,n,s,a,c);$(this,"node");$(this,"outerDeco");$(this,"innerDeco");$(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==pt&&t.eq(this.node)&&jp(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==Tt||!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=pt}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 Vp extends ba{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=pt,!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=Tt)}get domAtom(){return!1}}class vn extends Mn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==pt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}let Rp=class extends ba{constructor(t,n,s,o,i,l,a,c,u,d){super(t,n,s,o,i,l,a,c,u);$(this,"spec");this.spec=d}update(t,n,s,o){if(this.dirty==Tt)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 zp extends Rp{updateChildren(e,t){}updateOuterDeco(e){this.outerDeco=e}destroy(){this.children=[],super.destroy()}}function jp(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 xa(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 Ls(r,e,t){const{view:n}=m.useContext(Xt),{parentRef:s,siblingsRef:o}=m.useContext(Te),[i,l]=m.useState(null),[a,c]=m.useState(null),[u,d]=m.useState(null),f=m.useRef(),h=m.useRef([]),p=m.useCallback(w=>{if(!(n instanceof Et))return;const C=r.current;if(!C)return;const{node:v,getPos:O,decorations:M,innerDecorations:D}=w,R=e(v,n,O,M,D);if(!R)return;const T=s.current,G=h.current,ce=xa(R,G),we=R.dom,H=new zp(T,G,O,v,M,D,C,ce,we,R);return l(C),d(ce),c(we),H},[r,s,e,n]),b=m.useCallback(w=>{if(!(n instanceof Et))return!1;const C=f.current;if(!C)return!1;const v=r.current;if(!v||v!==C.dom||xa(C,C.children)!==C.contentDOM||!v.contains(C.nodeDOM))return!1;const{node:M,decorations:D,innerDecorations:R}=w;return C.matchesNode(M,D,R)||C.update(M,D,R,n)},[r,n]),y=m.useCallback(()=>{const w=f.current;if(!w)return;w.destroy();const C=o.current;if(C.includes(w)){const v=C.indexOf(w);C.splice(v,1)}l(null),d(null),c(null)},[o]);return re(()=>{var M;b(t)||(y(),f.current=p(t));const w=f.current;if(!w)return;n.dom===w.dom&&n instanceof Et&&(n.docView=w);const C=s.current,v=o.current,O=h.current;w.parent=C,v.includes(w)||v.push(w),v.sort(Dt);for(const D of O)if(D.parent=w,D instanceof Fs){const R=(M=w==null?void 0:w.contentDOM)==null?void 0:M.firstChild;if(!R)throw new Error("Started a composition but couldn't find the text node it belongs to.");let T=R;for(;T.firstChild;)T=T.firstChild;if(!T||!(T instanceof Text))throw new Error("Started a composition but couldn't find the text node it belongs to.");D.dom=R,D.textDOM=T,D.text=T.data,D.textDOM.pmViewDesc=D,n.input.compositionNodes.push(D)}}),re(()=>()=>{y(),f.current=void 0},[y]),{childContextValue:m.useMemo(()=>({parentRef:f,siblingsRef:h}),[h,f]),dom:i,contentDOM:u,nodeDOM:a,ref:r}}function Bp(r,e){return r.type.side-e.type.side}function Fp(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 Qt)&&(p?(b||(b=[p])).push(y):p=y)}if(p)if(b){b.sort(Bp);for(let y=0;y<b.length;y++)t(b[y],!(b[y].type instanceof Qt),o,c+y,!!a)}else t(p,!(p.type instanceof Qt),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 ka(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const wa=new tt("@handlewithcare/react-prosemirror/reactKeys");function Lp(){let r=!1;return new Ie({key:wa,state:{init(e,t){const n={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((s,o)=>{const i=ka();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=ka();return o.posToKey.set(a,c),o.keyToPos.set(c,a),!0}),o}},props:{handleDOMEvents:{compositionstart:()=>{r=!0},compositionend:()=>{r=!1}}}})}function $p(){const{view:r}=m.useContext(Xt);return wa.getState(r.state)}var Sa={exports:{}};/*!
|
|
46
43
|
Copyright (c) 2018 Jed Watson.
|
|
47
44
|
Licensed under the MIT License (MIT), see
|
|
48
45
|
http://jedwatson.github.io/classnames
|
|
49
|
-
*/(function(n){(function(){var e={}.hasOwnProperty;function t(){for(var s="",i=0;i<arguments.length;i++){var l=arguments[i];l&&(s=o(s,r(l)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return t.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var i="";for(var l in s)e.call(s,l)&&s[l]&&(i=o(i,l));return i}function o(s,i){return i?s?s+" "+i:s+i:s}n.exports?(t.default=t,n.exports=t):window.classNames=t})()})(Su);var Hy=Su.exports;const Ky=bf(Hy);let Cu=!1;function Jy(){if(Cu)return;const n=console.error;console.error=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];const[o,s,i]=t;typeof o=="string"&&o.includes("Invalid DOM property `%s`. Did you mean `%s`?")&&s==="STYLE"&&i==="style"||n(...t)},Cu=!0}function Yy(n,e){return"STYLE"in n?"STYLE"in e?`${n.STYLE.match(/;\s*$/)?n.STYLE:`${n.STYLE}`} ${e.STYLE}`:n.STYLE:"STYLE"in e?e.STYLE:void 0}function wu(n,e){return{...n,...e,className:Ky(n.className,e.className),STYLE:Yy(n,e),style:{...n.style,...e.style}}}function Mu(n){Jy();const e={};for(const[t,r]of Object.entries(n))switch(t.toLowerCase()){case"class":{e.className=r;break}case"style":{e.STYLE=r;break}case"autocapitalize":{e.autoCapitalize=r;break}case"contenteditable":{if(r===""||r==="true"){e.contentEditable=!0;break}if(r==="false"){e.contentEditable=!1;break}if(r==="plaintext-only"){e.contentEditable="plaintext-only";break}e.contentEditable=null;break}case"draggable":{e.draggable=r!=null;break}case"enterkeyhint":{e.enterKeyHint=r;break}case"for":{e.htmlFor=r;break}case"hidden":{e.hidden=r;break}case"inputmode":{e.inputMode=r;break}case"itemprop":{e.itemProp=r;break}case"spellcheck":{if(r===""||r==="true"){e.spellCheck=!0;break}if(r==="false"){e.spellCheck=!1;break}e.spellCheck=null;break}case"tabindex":{const o=parseInt(r,10);Number.isNaN(o)||(e.tabIndex=o);break}case"autocomplete":{e.autoComplete=r;break}case"autofocus":{e.autoFocus=r!=null;break}case"formaction":{e.formAction=r;break}case"formenctype":{e.formEnctype=r;break}case"formmethod":{e.formMethod=r;break}case"formnovalidate":{e.formNoValidate=r;break}case"formtarget":{e.formTarget=r;break}case"maxlength":{const o=parseInt(r,10);Number.isNaN(o)||(e.maxLength=r);break}case"minlength":{const o=parseInt(r,10);Number.isNaN(o)||(e.minLength=r);break}case"max":{const o=parseInt(r,10);Number.isNaN(o)||(e.max=r);break}case"min":{const o=parseInt(r,10);Number.isNaN(o)||(e.min=r);break}case"multiple":{e.multiple=r!=null;break}case"readonly":{e.readOnly=r!=null;break}case"required":{e.required=r!=null;break}case"size":{const o=parseInt(r,10);Number.isNaN(o)||(e.size=r);break}case"step":{if(r==="any"){e.step=r;break}const o=parseInt(r,10);!Number.isNaN(o)&&o>0&&(e.step=r);break}case"disabled":{e.disabled=r!=null;break}case"rows":{const o=parseInt(r,10);Number.isNaN(o)||(e.rows=r);break}default:{e[t]=r;break}}return e}function Nu(n){if(!Array.isArray(n))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const e=n[1];let t=1;e&&typeof e=="object"&&e.nodeType==null&&!Array.isArray(e)&&(t=2);for(let r=t;r<n.length;r++){const o=n[r];if(o===0||Nu(o))return!0}return!1}const Xs=m.memo(m.forwardRef(function(e,t){let{outputSpec:r,isMark:o,children:s,...i}=e;if(typeof r=="string")return m.createElement(m.Fragment,null,r);if(!Array.isArray(r))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const a=r[0].replace(" ",":"),c=r[1];let u={ref:t,...i},f=1;c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)&&(f=2,u=wu(Mu(c),u));const d=[];for(let p=f;p<r.length;p++){const h=r[p];if(h===0){if(p<r.length-1||p>f)throw new RangeError("Content hole must be the only child of its parent node");return m.createElement(a,u,s)}d.push(m.createElement(Xs,{outputSpec:h},s))}return o&&!Nu(r)&&d.push(s),m.createElement(a,u,...d)})),Eu=m.memo(m.forwardRef(function(e,t){let{mark:r,getPos:o,children:s}=e;const{siblingsRef:i,parentRef:l}=m.useContext(Ce),a=m.useRef(void 0),c=m.useRef([]),u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const f=m.useMemo(()=>{var p,h;return(h=(p=r.type.spec).toDOM)==null?void 0:h.call(p,r,!0)},[r]);if(!f)throw new Error(`Mark spec for ${r.type.name} is missing toDOM`);J(()=>{const p=i.current;return()=>{if(a.current&&p.includes(a.current)){const h=p.indexOf(a.current);p.splice(h,1)}}},[i]),J(()=>{if(!u.current)return;const p=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=(p==null?void 0:p.dom.parentElement)??u.current,a.current.mark=r,a.current.getPos=()=>o.current()):a.current=new Ty(l.current,c.current,()=>o.current(),r,u.current,(p==null?void 0:p.dom.parentElement)??u.current,{dom:u.current,contentDOM:(p==null?void 0:p.dom.parentElement)??u.current}),i.current.includes(a.current)||i.current.push(a.current),i.current.sort(Kt);for(const h of c.current)h.parent=a.current});const d=m.useMemo(()=>({parentRef:a,siblingsRef:c}),[c,a]);return m.createElement(Xs,{ref:u,outputSpec:f,isMark:!0},m.createElement(Ce.Provider,{value:d},s))}));function Gy(n){let{widget:e,getPos:t}=n;const{siblingsRef:r,parentRef:o}=m.useContext(Ce),s=m.useRef(null),i=m.useRef(null);return J(()=>{const l=r.current;return()=>{if(s.current&&l.includes(s.current)){const a=l.indexOf(s.current);l.splice(a,1)}}},[r]),Ke(l=>{if(!i.current)return;const a=e.type.toDOM;let c=typeof a=="function"?a(l,()=>t.current()):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)}),J(()=>{i.current&&(s.current?(s.current.parent=o.current,s.current.widget=e,s.current.getPos=()=>t.current(),s.current.dom=i.current):s.current=new Ks(o.current,()=>t.current(),e,i.current),r.current.includes(s.current)||r.current.push(s.current),r.current.sort(Kt))}),m.createElement("span",{ref:i})}function Xy(){}function Uy(){return Xy}function Qy(){return m.useSyncExternalStore(Uy,()=>!0,()=>!1)}const Zy=m.memo(function(e){var Et;let{customNodeView:t,node:r,getPos:o,innerDeco:s,outerDeco:i}=e;const{view:l}=m.useContext(wt),a=m.useRef(null),c=m.useRef(null),u=m.useRef(null),f=m.useRef(()=>o.current()).current,d=m.useRef(r);d.current=r;const p=m.useRef(i);p.current=i;const h=m.useRef(s);h.current=s;const b=m.useRef(null),g=m.useRef(null),x=Ys(),S=Qy();J(()=>{var Yt,yn,ar;if(g.current||(g.current=t(d.current,l,f,p.current,h.current),g.current.stopEvent&&T(g.current.stopEvent.bind(g.current)),g.current.selectNode&&M(g.current.selectNode.bind(g.current),((Yt=g.current.deselectNode)==null?void 0:Yt.bind(g.current))??(()=>{})),g.current.ignoreMutation&&I(g.current.ignoreMutation.bind(g.current)),x()),!b.current)return;const{dom:Ae}=g.current;if(b.current.firstChild===Ae)return;c.current=b.current,b.current.appendChild(Ae),(l==null?void 0:l.state.selection)instanceof O&&l.state.selection.node===d.current&&((ar=(yn=g.current).selectNode)==null||ar.call(yn));const ze=g.current;return()=>{var lo;(lo=ze.destroy)==null||lo.call(ze),g.current=null}},[t,f,l]),J(()=>{if(!t||!g.current)return;const{destroy:Ae,update:ze}=g.current;if(((ze==null?void 0:ze.call(g.current,r,i,s))??!0)||(Ae==null||Ae.call(g.current),!b.current))return;g.current=t(d.current,l,f,p.current,h.current);const{dom:yn}=g.current;c.current=b.current,b.current.appendChild(yn)},[t,l,s,r,i,o,f]);const{childDescriptors:w,nodeViewDescRef:D,setStopEvent:T,setSelectNode:M,setIgnoreMutation:I}=Gs(r,f,a,c,s,i,void 0,u),z=m.useMemo(()=>({parentRef:D,siblingsRef:w}),[w,D]);if(!S)return null;g.current||(g.current=t(d.current,l,()=>o.current(),p.current,h.current),g.current.stopEvent&&T(g.current.stopEvent.bind(g.current)),g.current.selectNode&&M(g.current.selectNode.bind(g.current),((Et=g.current.deselectNode)==null?void 0:Et.bind(g.current))??(()=>{})),g.current.ignoreMutation&&I(g.current.ignoreMutation.bind(g.current)));const{contentDOM:v}=g.current;u.current=v??null;const L=m.createElement(r.isInline?"span":"div",{ref:b,contentEditable:!!v,suppressContentEditableWarning:!0},v&&Ye.createPortal(m.createElement(tr,{getPos:o,node:r,innerDecorations:s}),v)),we=m.cloneElement(i.reduce(oo,L),i.some(Ae=>Ae.type.attrs.nodeName)?{ref:a}:void 0);return m.createElement(Ce.Provider,{value:z},we)}),eb=m.createContext(null),tb=m.createContext(null),Du=m.createContext(null),nb=m.memo(function(e){let{outerDeco:t,getPos:r,node:o,innerDeco:s,...i}=e;const l=m.useRef(null),a=m.useRef(null),c=m.useRef(null),u=m.useRef(()=>r.current()).current,{nodeViews:f}=m.useContext(Jc);let d=null;const p=f[o.type.name],h=m.useMemo(()=>{var v,L;return(L=(v=o.type.spec).toDOM)==null?void 0:L.call(v,o)},[o]),{hasContentDOM:b,childDescriptors:g,setStopEvent:x,setSelectNode:S,setIgnoreMutation:w,nodeViewDescRef:D}=Gs(o,()=>r.current(),l,a,s,t,void 0,c),T={...i,...!b&&{contentEditable:!1}},M=m.useMemo(()=>({node:o,getPos:u,decorations:t,innerDecorations:s}),[u,s,o,t]);if(p?d=m.createElement(p,{...T,ref:a,nodeProps:M},m.createElement(tr,{getPos:r,node:o,innerDecorations:s})):h&&(d=m.createElement(Xs,{...T,ref:a,outputSpec:h},m.createElement(tr,{getPos:r,node:o,innerDecorations:s}))),!d)throw new Error(`Node spec for ${o.type.name} is missing toDOM`);const I=m.cloneElement(t.reduce(oo,d),t.some(v=>v.type.attrs.nodeName)?{ref:l}:void 0),z=m.useMemo(()=>({parentRef:D,siblingsRef:g}),[g,D]);return m.createElement(tb.Provider,{value:S},m.createElement(Du.Provider,{value:x},m.createElement(eb.Provider,{value:w},m.createElement(Ce.Provider,{value:z},I))))}),Ou=m.memo(function(e){let{outerDeco:t,getPos:r,node:o,innerDeco:s,...i}=e;const{view:l}=m.useContext(wt),a=l==null?void 0:l.someProp("nodeViews",c=>c==null?void 0:c[o.type.name]);return a?m.createElement(Zy,{customNodeView:a,node:o,innerDeco:s,outerDeco:t,getPos:r}):m.createElement(nb,{node:o,innerDeco:s,outerDeco:t,getPos:r,...i})});function rb(n){let{getPos:e}=n;const{siblingsRef:t,parentRef:r}=m.useContext(Ce),o=m.useRef(null),s=m.useRef(null),[i,l]=m.useState(!1);return J(()=>{const a=t.current;return()=>{if(o.current&&a.includes(o.current)){const c=a.indexOf(o.current);a.splice(c,1)}}},[t]),J(()=>{var c;const a=t.current[t.current.length-1];if((ae.safari||ae.chrome)&&((c=a==null?void 0:a.dom)==null?void 0:c.contentEditable)=="false"){l(!0);return}s.current&&(o.current?(o.current.parent=r.current,o.current.dom=s.current,o.current.getPos=()=>e.current()):o.current=new er(r.current,[],()=>e.current(),s.current,null),t.current.includes(o.current)||t.current.push(o.current),t.current.sort(Kt))}),i?m.createElement("img",{ref:s,className:"ProseMirror-separator"}):null}var Us={exports:{}},ve={};/**
|
|
46
|
+
*/(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})()})(Sa);var Wp=Sa.exports;const _p=yc(Wp);let Ca=!1;function qp(){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 Hp(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 Ma(r,e){return{...r,...e,className:_p(r.className,e.className),STYLE:Hp(r,e),style:{...r.style,...e.style}}}function va(r){qp();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 Na(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||Na(s))return!0}return!1}const $s=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=Ma(va(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($s,{outputSpec:p},o))}return s&&!Na(n)&&f.push(o),m.createElement(a,u,...f)})),Ea=m.memo(m.forwardRef(function(e,t){let{mark:n,getPos:s,children:o}=e;const{siblingsRef:i,parentRef:l}=m.useContext(Te),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`);re(()=>{const h=i.current;return()=>{if(a.current&&h.includes(a.current)){const p=h.indexOf(a.current);h.splice(p,1)}}},[i]),re(()=>{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 Ip(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(Dt);for(const p of c.current)p.parent=a.current});const f=m.useMemo(()=>({parentRef:a,siblingsRef:c}),[c,a]);return m.createElement($s,{ref:u,outputSpec:d,isMark:!0},m.createElement(Te.Provider,{value:f},o))}));function Jp(r){let{widget:e,getPos:t}=r;const{siblingsRef:n,parentRef:s}=m.useContext(Te),o=m.useRef(null),i=m.useRef(null);return re(()=>{const l=n.current;return()=>{if(o.current&&l.includes(o.current)){const a=l.indexOf(o.current);l.splice(a,1)}}},[n]),Be(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)}),re(()=>{i.current&&(o.current?(o.current.parent=s.current,o.current.widget=e,o.current.dom=i.current):o.current=new Bs(s.current,t,e,i.current),n.current.includes(o.current)||n.current.push(o.current),n.current.sort(Dt))}),m.createElement("span",{ref:i})}const Kp=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,u]=m.useState(!1),d=m.useMemo(()=>({node:n,getPos:s,decorations:i,innerDecorations:o}),[n,s,i,o]),f=function(){var M,D;for(var w=arguments.length,C=new Array(w),v=0;v<w;v++)C[v]=arguments[v];const O=t(...C);if(!O||!O.dom){const R=(D=(M=n.type.spec).toDOM)==null?void 0:D.call(M,n);if(!R)throw new Error(`Node spec for ${n.type.name} is missing toDOM`);return $e.renderSpec(document,R,null)}return O},{childContextValue:h,contentDOM:p}=Ls(l,function(){var T,G,ce,we;for(var w=arguments.length,C=new Array(w),v=0;v<w;v++)C[v]=arguments[v];u(!1);const O=f(...C),M=O.contentDOM,D=O.dom,R=a.current??l.current;return R.appendChild(D),!M&&D instanceof HTMLElement&&D.tagName!=="BR"&&(D.hasAttribute("contenteditable")||(D.contentEditable="false")),{...O,destroy(){O.destroy&&O.destroy(),R.removeChild(D)},selectNode:((T=O.selectNode)==null?void 0:T.bind(O))??(()=>{D instanceof HTMLElement&&D.classList.add("ProseMirror-selectednode"),u(!0)}),deselectNode:((G=O.deselectNode)==null?void 0:G.bind(O))??(()=>{D instanceof HTMLElement&&D.classList.remove("ProseMirror-selectednode"),u(!1)}),stopEvent:(ce=O.stopEvent)==null?void 0:ce.bind(O),ignoreMutation:(we=O.ignoreMutation)==null?void 0:we.bind(O)}},d),b=!n.isLeaf&&p?Le.createPortal(m.createElement(Te.Provider,{value:h},m.createElement(Js,{getPos:s,node:n,innerDecorations:o})),p):null,y=m.createElement(n.isInline?"span":"div",{ref:a},b),x={...c||n.type.spec.draggable?{draggable:!0}:null,ref:l};return m.cloneElement(i.reduce(yr,y),x)}),Yp=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($s,{...o,outputSpec:i,ref:t},s)}),Gp=m.createContext(null),Xp=m.createContext(null),Oa=m.createContext(null),Qp=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((H,Ae)=>(h.current=H,p.current=Ae,a(!0),()=>{h.current=null,p.current=null,a(!1)}),[]),w=m.useCallback(H=>(b.current=H,()=>{b.current=null}),[]),C=m.useCallback(H=>(y.current=H,()=>(y.current=null,()=>{y.current=null})),[]),v=m.useMemo(()=>({node:o,getPos:s,decorations:n,innerDecorations:i}),[s,i,o,n]),{childContextValue:O,contentDOM:M,nodeDOM:D}=Ls(d,()=>(u(!1),{dom:f.current??d.current,update(){return!0},multiType:!0,selectNode(){const H=h.current;H&&H(),u(!0)},deselectNode(){const H=p.current;H&&H(),u(!1)},stopEvent(H){const Ae=b.current;return Ae?Ae(H):!1},ignoreMutation(H){const Ae=y.current;return Ae?Ae(H):!1}}),v),R=o.isLeaf?null:m.createElement(Js,{getPos:s,node:o,innerDecorations:i}),T={nodeProps:v,...!M&&!v.node.isText&&(D==null?void 0:D.nodeName)!=="BR"?{contentEditable:!1,suppressContentEditableWarning:!0}:null,...l&&c?{className:"ProseMirror-selectednode"}:null,ref:f},G=m.createElement(t,T,R),ce={...l&&c||o.type.spec.draggable?{draggable:!0}:null,ref:d},we=m.cloneElement(n.reduce(yr,G),ce);return m.createElement(Xp.Provider,{value:x},m.createElement(Oa.Provider,{value:w},m.createElement(Gp.Provider,{value:C},m.createElement(Te.Provider,{value:O},we))))}),Da=m.memo(function(e){const{components:t,constructors:n}=m.useContext(ta),s=t[e.node.type.name]??Yp,o=n[e.node.type.name],i=m.useMemo(()=>o?function(a){return m.createElement(Kp,{constructor:o,...a})}:function(a){return m.createElement(Qp,{component:s,...a})},[o,s]);return m.createElement(i,e)});function Up(r){let{getPos:e}=r;const{siblingsRef:t,parentRef:n}=m.useContext(Te),s=m.useRef(null),o=m.useRef(null),[i,l]=m.useState(!1);return re(()=>{const a=t.current;return()=>{if(s.current&&a.includes(s.current)){const c=a.indexOf(s.current);a.splice(c,1)}}},[t]),re(()=>{var c;const a=t.current[t.current.length-1];if((Ut.safari||Ut.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 vn(n.current,[],e,o.current,null),t.current.includes(s.current)||t.current.push(s.current),t.current.sort(Dt))}),i?m.createElement("img",{ref:o,className:"ProseMirror-separator"}):null}var Ws={exports:{}},Ne={};/**
|
|
50
47
|
* @license React
|
|
51
48
|
* react-reconciler-reflection.production.js
|
|
52
49
|
*
|
|
@@ -54,7 +51,7 @@ Check the top-level render call using <`+k+">."),A}var w=m,D=Symbol.for("react.t
|
|
|
54
51
|
*
|
|
55
52
|
* This source code is licensed under the MIT license found in the
|
|
56
53
|
* LICENSE file in the root directory of this source tree.
|
|
57
|
-
*/var
|
|
54
|
+
*/var Ta;function Zp(){if(Ta)return Ne;Ta=1;function r(i){var l="https://react.dev/errors/"+i;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)l+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function e(i){var l=i,a=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,l.flags&4098&&(a=l.return),i=l.return;while(i)}return l.tag===3?a:null}function t(i){if(e(i)!==i)throw Error(r(188))}function n(i){var l=i.alternate;if(!l){if(l=e(i),l===null)throw Error(r(188));return l!==i?null:i}for(var a=i,c=l;;){var u=a.return;if(u===null)break;var d=u.alternate;if(d===null){if(c=u.return,c!==null){a=c;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===a)return t(u),i;if(d===c)return t(u),l;d=d.sibling}throw Error(r(188))}if(a.return!==c.return)a=u,c=d;else{for(var f=!1,h=u.child;h;){if(h===a){f=!0,a=u,c=d;break}if(h===c){f=!0,c=u,a=d;break}h=h.sibling}if(!f){for(h=d.child;h;){if(h===a){f=!0,a=d,c=u;break}if(h===c){f=!0,c=d,a=u;break}h=h.sibling}if(!f)throw Error(r(189))}}if(a.alternate!==c)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:l}function s(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(l=s(i),l!==null)return l;i=i.sibling}return null}function o(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(i.tag!==4&&(l=o(i),l!==null))return l;i=i.sibling}return null}return Ne.doesFiberContain=function(i,l){for(var a=i.alternate;l!==null;){if(l===i||l===a)return!0;l=l.return}return!1},Ne.findCurrentFiberUsingSlowPath=n,Ne.findCurrentHostFiber=function(i){return i=n(i),i!==null?s(i):null},Ne.findCurrentHostFiberWithNoPortals=function(i){return i=n(i),i!==null?o(i):null},Ne.getContainerFromFiber=function(i){return i.tag===3?i.stateNode.containerInfo:null},Ne.getNearestMountedFiber=e,Ne.getSuspenseInstanceFromFiber=function(i){if(i.tag===13){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null},Ne.isFiberMounted=function(i){return e(i)===i},Ne.isFiberSuspenseAndTimedOut=function(i){var l=i.memoizedState;return i.tag===13&&l!==null&&l.dehydrated===null},Ne.isMounted=function(i){return(i=i._reactInternals)?e(i)===i:!1},Ne}var Ee={};/**
|
|
58
55
|
* @license React
|
|
59
56
|
* react-reconciler-reflection.development.js
|
|
60
57
|
*
|
|
@@ -62,5 +59,5 @@ Check the top-level render call using <`+k+">."),A}var w=m,D=Symbol.for("react.t
|
|
|
62
59
|
*
|
|
63
60
|
* This source code is licensed under the MIT license found in the
|
|
64
61
|
* LICENSE file in the root directory of this source tree.
|
|
65
|
-
*/var Tu;function sb(){return Tu||(Tu=1,process.env.NODE_ENV!=="production"&&function(){function n(s){var i=s,l=s;if(s.alternate)for(;i.return;)i=i.return;else{s=i;do i=s,i.flags&4098&&(l=i.return),s=i.return;while(s)}return i.tag===3?l:null}function e(s){if(n(s)!==s)throw Error("Unable to find node on an unmounted component.")}function t(s){var i=s.alternate;if(!i){if(i=n(s),i===null)throw Error("Unable to find node on an unmounted component.");return i!==s?null:s}for(var l=s,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),s;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 f=!1,d=c.child;d;){if(d===l){f=!0,l=c,a=u;break}if(d===a){f=!0,a=c,l=u;break}d=d.sibling}if(!f){for(d=u.child;d;){if(d===l){f=!0,l=u,a=c;break}if(d===a){f=!0,a=u,l=c;break}d=d.sibling}if(!f)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?s:i}function r(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(i=r(s),i!==null)return i;s=s.sibling}return null}function o(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(s.tag!==4&&(i=o(s),i!==null))return i;s=s.sibling}return null}Te.doesFiberContain=function(s,i){for(var l=s.alternate;i!==null;){if(i===s||i===l)return!0;i=i.return}return!1},Te.findCurrentFiberUsingSlowPath=t,Te.findCurrentHostFiber=function(s){return s=t(s),s!==null?r(s):null},Te.findCurrentHostFiberWithNoPortals=function(s){return s=t(s),s!==null?o(s):null},Te.getContainerFromFiber=function(s){return s.tag===3?s.stateNode.containerInfo:null},Te.getNearestMountedFiber=n,Te.getSuspenseInstanceFromFiber=function(s){if(s.tag===13){var i=s.memoizedState;if(i===null&&(s=s.alternate,s!==null&&(i=s.memoizedState)),i!==null)return i.dehydrated}return null},Te.isFiberMounted=function(s){return n(s)===s},Te.isFiberSuspenseAndTimedOut=function(s){var i=s.memoizedState;return s.tag===13&&i!==null&&i.dehydrated===null},Te.isMounted=function(s){return(s=s._reactInternals)?n(s)===s:!1}}()),Te}process.env.NODE_ENV==="production"?Us.exports=ob():Us.exports=sb();var ib=Us.exports;function lb(n){return n._reactInternals}function P0(n){return n}function ab(n){const e=lb(n);if(e===void 0){if(typeof n.render=="function")throw new Error("Unable to find node on an unmounted component.");{const r=Object.keys(n).join(",");throw new Error(`Argument appears to not be a ReactComponent. Keys: ${r}`)}}const t=ib.findCurrentHostFiber(e);return t===null?null:t.stateNode}function cb(n){return ab(n)}function ub(n,e){if(n===e)return!0;if(!n||!e)return!1;const t=Object.keys(n),r=Object.keys(e),o=t.length;if(r.length!==o)return!1;for(let s=0;s<o;s++){const i=t[s];if(n[i]!==e[i]||!Object.prototype.hasOwnProperty.call(e,i))return!1}return!0}class fb extends m.Component{constructor(){super(...arguments);j(this,"viewDescRef",null);j(this,"renderRef",null)}updateEffect(){const{view:t,decorations:r,siblingsRef:o,parentRef:s,getPos:i,node:l}=this.props,a=cb(this);if(!a){if(!(t!=null&&t.composing))return;this.viewDescRef=new ro(s.current,()=>i.current(),document.createElement("div"),document.createTextNode(l.text??""),l.text??"");return}let c=a;for(;c.firstChild;)c=c.firstChild;!this.viewDescRef||this.viewDescRef instanceof ro?this.viewDescRef=new Ay(void 0,[],()=>i.current(),l,r,H.empty,a,c):(this.viewDescRef.parent=s.current,this.viewDescRef.children=[],this.viewDescRef.node=l,this.viewDescRef.getPos=()=>i.current(),this.viewDescRef.outerDeco=r,this.viewDescRef.innerDeco=H.empty,this.viewDescRef.dom=a,this.viewDescRef.dom.pmViewDesc=this.viewDescRef,this.viewDescRef.nodeDOM=c),o.current.includes(this.viewDescRef)||o.current.push(this.viewDescRef),o.current.sort(Kt)}shouldComponentUpdate(t){return!ub(this.props,t)}componentDidMount(){this.updateEffect()}componentDidUpdate(){this.updateEffect()}componentWillUnmount(){const{siblingsRef:t}=this.props;if(this.viewDescRef&&t.current.includes(this.viewDescRef)){const r=t.current.indexOf(this.viewDescRef);t.current.splice(r,1)}}render(){const{view:t,getPos:r,node:o,decorations:s}=this.props;return t!=null&&t.composing&&t.state.selection.from>=r.current()&&t.state.selection.from<=r.current()+o.nodeSize?this.renderRef:(this.renderRef=s.reduce(oo,o.text),this.renderRef)}}function db(n){let{getPos:e}=n;const{siblingsRef:t,parentRef:r}=m.useContext(Ce),o=m.useRef(null),s=m.useRef(null);return J(()=>{const i=t.current;return()=>{if(o.current&&i.includes(o.current)){const l=i.indexOf(o.current);i.splice(l,1)}}},[t]),J(()=>{s.current&&(o.current?(o.current.parent=r.current,o.current.dom=s.current,o.current.getPos=()=>e.current()):o.current=new er(r.current,[],()=>e.current(),s.current,null),t.current.includes(o.current)||t.current.push(o.current),t.current.sort(Kt))}),m.createElement("br",{ref:s,className:"ProseMirror-trailingBreak"})}function hb(n){let{widget:e,getPos:t}=n;const{siblingsRef:r,parentRef:o}=m.useContext(Ce),s=m.useRef(null),i=m.useRef(()=>t.current()).current,l=m.useRef(null);J(()=>{const c=r.current;return()=>{if(s.current&&c.includes(s.current)){const u=c.indexOf(s.current);c.splice(u,1)}}},[r]),J(()=>{l.current&&(s.current?(s.current.parent=o.current,s.current.widget=e,s.current.getPos=()=>t.current(),s.current.dom=l.current):s.current=new Ks(o.current,()=>t.current(),e,l.current),r.current.includes(s.current)||r.current.push(s.current),r.current.sort(Kt))});const{Component:a}=e.type;return a&&m.createElement(a,{ref:l,widget:e,getPos:i,contentEditable:!1})}function oo(n,e){const{nodeName:t,...r}=e.type.attrs,o=Mu(r);return t||typeof n=="string"?m.createElement(t??"span",o,n):m.cloneElement(n,wu(n.props,o))}function Qs(n,e){var t,r,o;return n.type===e.type&&n.marks.every(s=>s.isInSet(e.marks))&&e.marks.every(s=>s.isInSet(n.marks))&&n.key===e.key&&(n.type==="node"?((t=n.outerDeco)==null?void 0:t.length)===((r=e.outerDeco)==null?void 0:r.length)&&((o=n.outerDeco)==null?void 0:o.every(s=>{var i;return(i=e.outerDeco)==null?void 0:i.some(l=>s.from===l.from&&s.to&&l.to&&s.type.eq(l.type))}))&&n.innerDeco.eq(e.innerDeco):!0)&&n.node===e.node&&n.widget===e.widget}const pb=m.memo(function(e){let{child:t,getInnerPos:r}=e;const{view:o}=m.useContext(wt),s=m.useRef(()=>r.current()+t.offset);return s.current=()=>r.current()+t.offset,t.type==="widget"?m.createElement(hb,{key:t.key,widget:t.widget,getPos:s}):t.type==="native-widget"?m.createElement(Gy,{key:t.key,widget:t.widget,getPos:s}):t.node.isText?m.createElement(Ce.Consumer,{key:t.key},i=>{let{siblingsRef:l,parentRef:a}=i;return m.createElement(fb,{view:o,node:t.node,getPos:s,siblingsRef:l,parentRef:a,decorations:t.outerDeco})}):m.createElement(Ou,{key:t.key,node:t.node,getPos:s,outerDeco:t.outerDeco,innerDeco:t.innerDeco})}),mb=m.memo(function(e){let{childViews:t,getInnerPos:r}=e;const o=t[0],s=m.useRef(()=>r.current()+o.offset);s.current=()=>r.current()+o.offset;const i=o.marks[0];return i?m.createElement(Eu,{getPos:s,key:o.key,mark:i},m.createElement(Zs,{key:o.key,getInnerPos:r,childViews:t.map(l=>({...l,marks:l.marks.slice(1)}))})):m.createElement(m.Fragment,null,t.map(l=>m.createElement(pb,{key:l.key,child:l,getInnerPos:r})))}),Zs=m.memo(function(e){let{getInnerPos:t,childViews:r}=e;const o=r.reduce((s,i)=>{var c;const l=s[s.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]))?[...s.slice(0,s.length-1),[...l.slice(0,l.length),i]]:[...s,[i]]:[...s.slice(0,s.length),[i]]},[]);return m.createElement(m.Fragment,null,o.map(s=>{const i=s[0];return i?m.createElement(mb,{key:i.key,childViews:s,getInnerPos:t}):null}))});function ei(n,e,t,r,o,s){const i=n+e,l=r==null?void 0:r.get(i);if(t==="widget"||t==="native-widget")return o.type.spec.key?o.type.spec.key:(console.warn(`Widget at position ${i} doesn't have a key specified. This may cause issues.`),`${l}-${s}`);if(l)return l;const a=n-1,c=r==null?void 0:r.get(a);return c?`${c}-${e}`:i}function gb(n,e){if(!e||e.widget.type.side>=0||!n||!n.node.isInline)return;const t=n.marks;e.marks=e.marks.reduce((r,o)=>o.addToSet(r),t)}function yb(n,e){if(!e.node.isInline)return;const t=e.marks;for(let r=n.length-1;r>=0;r--){const o=n[r];o.widget.type.side<0||(o.marks=o.marks.reduce((s,i)=>i.addToSet(s),t))}}const bb=m.memo(function(e){let{child:t,getInnerPos:r}=e;const o=m.useRef(()=>r.current()+t.offset);return o.current=()=>r.current()+t.offset,t.type==="node"?t.marks.reduce((s,i)=>m.createElement(Eu,{getPos:o,mark:i},s),m.createElement(Ou,{key:t.key,outerDeco:t.outerDeco,node:t.node,innerDeco:t.innerDeco,getPos:o})):m.createElement(Zs,{key:t.key,childViews:[t],getInnerPos:r})});function xb(n,e){return n.length?n.every(t=>t.type!=="node"||t.node.isInline)?[m.createElement(Zs,{key:n[0].key,childViews:n,getInnerPos:e})]:n.map(t=>m.createElement(bb,{key:t.key,child:t,getInnerPos:e})):[]}const tr=m.memo(function(e){let{getPos:t,node:r,innerDecorations:o}=e;const s=qy(),i=m.useRef(()=>t.current()+1),l=m.useRef(new Map).current;if(!r)return null;const a=new Set;let c=[],u=null;_y(r,o,(h,b,g,x)=>{const S=h.type.spec.marks??[];let w;if(b){w=ei(i.current(),g,"native-widget",s==null?void 0:s.posToKey,h,x);const T={type:"native-widget",widget:h,marks:S,offset:g,index:x,key:w},M=l.get(w);M&&Qs(M,T)?M.offset=g:l.set(w,T),a.add(w)}else{w=ei(i.current(),g,"widget",s==null?void 0:s.posToKey,h,x);const T={type:"widget",widget:h,marks:S,offset:g,index:x,key:w},M=l.get(w);M&&Qs(M,T)?M.offset=g:l.set(w,T),a.add(w)}const D=l.get(w);c.push(D),gb(u,l.get(w))},(h,b,g,x)=>{const S=ei(i.current(),x,"node",s==null?void 0:s.posToKey),w={type:"node",node:h,marks:h.marks,innerDeco:g,outerDeco:b,offset:x,key:S},D=l.get(S);D&&Qs(D,w)?(D.offset=x,u=D):(l.set(S,w),u=w),a.add(S),yb(c,u),c=[]});for(const h of l.keys())a.has(h)||l.delete(h);const f=Array.from(l.values()).sort((h,b)=>h.offset-b.offset),d=xb(f,i),p=f[f.length-1];return(!p||p.type!=="node"||p.node.isInline&&!p.node.isText||/\n$/.test(p.node.text))&&d.push(m.createElement(rb,{getPos:i,key:"trailing-hack-img"}),m.createElement(db,{getPos:i,key:"trailing-hack-br"})),m.createElement(m.Fragment,null,d)}),ti={current(){return-1}},kb=m.memo(m.forwardRef(function(e,t){let{className:r,node:o,innerDeco:s,outerDeco:i,as:l,viewDesc:a,...c}=e;const u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const{childDescriptors:f,nodeViewDescRef:d}=Gs(o,()=>ti.current(),u,u,s,i,a),p=m.useMemo(()=>({parentRef:d,siblingsRef:f}),[f,d]),h={...c,ref:u,className:r,suppressContentEditableWarning:!0},b=l?m.cloneElement(l,h,m.createElement(Ce.Provider,{value:p},m.createElement(tr,{getPos:ti,node:o,innerDecorations:s}))):m.createElement("div",h,m.createElement(Ce.Provider,{value:p},m.createElement(tr,{getPos:ti,node:o,innerDecorations:s})));if(!o)return b;const g=i.filter(S=>!S.inline);return g.length?g.reduce(oo,b):b})),Au=m.createContext(null);function Sb(n,e){let{as:t,...r}=n;const o=m.useRef([]),s=m.useRef(null),{setMount:i,...l}=m.useContext(Au),a=m.useRef(void 0);m.useImperativeHandle(e,()=>s.current,[]);const c=m.useMemo(()=>({parentRef:a,siblingsRef:o}),[o,a]);return m.createElement(Ce.Provider,{value:c},m.createElement(kb,{ref:u=>{s.current=u,i(u)},...r,...l,as:t}))}const Pu=m.forwardRef(Sb),Cb=[];function wb(n){var h;let{className:e,children:t,nodeViews:r,customNodeViews:o,...s}=n;const[i,l]=m.useState(null),{editor:a,state:c}=Fy(i,{...s,nodeViews:o}),u=a.view?oy(a.view,a.cursorWrapper):H.empty,f=a.view?ey(a.view):Cb,d=m.useMemo(()=>({nodeViews:r??{}}),[r]),p=m.useMemo(()=>{var b;return{className:e,setMount:l,node:(b=a.view)==null?void 0:b.state.doc,innerDeco:u,outerDeco:f,viewDesc:a.docViewDescRef.current}},[e,a.docViewDescRef,(h=a.view)==null?void 0:h.state.doc,u,f]);return m.createElement(wt.Provider,{value:a},m.createElement(Zg.Provider,{value:c},m.createElement(Jc.Provider,{value:d},m.createElement(Au.Provider,{value:p},t))))}function Iu(n){return m.createElement(Ly,null,m.createElement(wb,n))}function re(n){const e=m.useRef(n),{view:t}=m.useContext(wt);return Ke(()=>{e.current=n},[n]),m.useCallback(function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return e.current(t,...o)},[t])}function Vu(n){const e=m.useContext(Du),t=re(n);Ke(()=>{e(t)},[e,t])}const Ru=n=>[Qg(),Ro({Tab:Lc(1),"Shift-Tab":Lc(-1)}),gm(n.schema),Ro(um(n.schema)),Ro(Yd),Gd({color:"#F00",width:2}),Vp(),wd(),ym(n),py()],Mb=["p",0],Nb=["blockquote",0],Eb=["hr"],Db=["pre",["code",0]],Ob=["br"],vb={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Mb}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return Nb}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Eb}},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(n){return["h"+n.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Db}},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(n){return{src:n.getAttribute("src"),title:n.getAttribute("title"),alt:n.getAttribute("alt")}}}],toDOM(n){let{src:e,alt:t,title:r}=n.attrs;return["img",{src:e,alt:t,title:r}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return Ob}}},Tb=["em",0],Ab=["strong",0],Pb=["code",0],Ib={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(n){return{href:n.getAttribute("href"),title:n.getAttribute("title")}}}],toDOM(n){let{href:e,title:t}=n.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:n=>n.type.name=="em"}],toDOM(){return Tb}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name=="strong"},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}],toDOM(){return Ab}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return Pb}}},zu=new xr({nodes:vb,marks:Ib}),$u=zu.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]}}}),so="https://dailytelefrag.ru/api",ni="https://dailytelefrag.ru/error_image.png",ri="https://dailytelefrag.ru/error_embed.png",nr=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="vkvideo.ru"&&t.hostname!=="vk.com")throw new Error;let r,o;if(t.pathname==="/video_ext.php")r=t.searchParams.get("id"),o=t.searchParams.get("oid");else if(t.pathname.startsWith("/video"))[o,r]=t.pathname.slice(6).split("_");else throw new Error;if(!r||!o)throw new Error;return e?`https://vkvideo.ru/video_ext.php?oid=${o}&id=${r}&hd=2`:!0}catch{return e?"":!1}},rr=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="rutube.ru")throw new Error;let r;if(t.pathname.startsWith("/video/"))r=t.pathname.split("/")[2];else if(t.pathname.startsWith("/play/embed/"))r=t.pathname.split("/")[3];else throw new Error;if(!r)throw new Error;return e?`https://rutube.ru/play/embed/${r}`:!0}catch{return e?"":!1}},or=(n,e)=>{try{const t=new URL(n);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 r;if(t.pathname==="/watch")r=t.searchParams.get("v");else if(t.pathname.startsWith("/live/"))r=t.pathname.split("/")[2];else if(t.pathname.startsWith("/embed/"))r=t.pathname.split("/")[2];else throw new Error;if(!r)throw new Error;return e?`https://youtube.com/embed/${r}`:!0}catch{return e?"":!1}},oi=n=>{try{const e=new URL(n);switch(e.hostname){case"vkvideo.ru":case"vk.com":return nr(e,!0)+"";case"rutube.ru":return rr(e,!0)+"";case"youtube.com":case"www.youtube.com":case"youtu.be":return or(e,!0)+"";default:throw new Error}}catch{return""}},Vb={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(n){return{fid:n.getAttribute("fid"),src:n.getAttribute("src"),alt:n.getAttribute("alt"),title:n.getAttribute("title")}}}],toDOM(n){let{fid:e,src:t,alt:r,title:o}=n.attrs;return e&&(t=`${so}/files/${e}`),t||(t=ni),["div",{title:o,class:"image"},["img",{fid:e,src:t,alt:r,title:o}]]}},Rb={atom:!0,attrs:{title:{default:null,validate:"string|null"},src:{validate:n=>{if(typeof n!="string"){if(Array.isArray(n)){n.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(n){return{src:n.getAttribute("src"),title:n.getAttribute("title")}}}],toDOM(n){const{src:e,title:t}=n.attrs,r="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",o=Array.isArray(e)?e[0]:e;return oi(o)?["div",{title:t,class:"video"},["iframe",{src:o,title:t,allow:r}]]:["div",{title:t,class:"image"},["img",{src:ri}]]}},zb={content:"inline*",group:"block",attrs:{align:{default:null,validate:"string|null"}},parseDOM:[{tag:"p",getAttrs(n){let e=n.getAttribute("align");return e!=="right"&&e!=="center"&&e!=="justify"&&(e=null),{align:e}}}],toDOM(n){const{align:e}=n.attrs;return["p",{align:e},0]}},$b={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(n){return["h"+n.attrs.level,0]}},jb={atom:!0,content:"image*",group:"block",toDOM(){return["div",{class:"carousel"},0]}},ju=zu.spec.nodes.remove("image").append({image:Vb,video:Rb}),io=new xr({nodes:ju.remove("horizontal_rule").remove("heading"),marks:$u}),Bb=ju.remove("heading").remove("paragraph").prepend({paragraph:zb}).append({heading:$b}).append({carousel:jb}).append(hg({tableGroup:"block",cellContent:"(paragraph | ordered_list | bullet_list)+",cellAttributes:{halign:{default:null,getFromDOM(n){const e=n.getAttribute("align")||null;return e==="left"||e==="right"||e==="center"?e:null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`text-align: ${n};`)}},valign:{default:null,getFromDOM(n){const e=n.style.verticalAlign||null;return e==="top"||e==="bottom"||e==="middle"?e:null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`vertical-align: ${n};`)}}}})),Nt=new xr({nodes:Hp(Bb,"(paragraph | ordered_list | bullet_list)+","block"),marks:$u}),Fb=n=>{if(n)try{const e=be.fromJSON(Nt,JSON.parse(n)),t=$e.fromSchema(Nt).serializeFragment(e.content);return Pt.fromSchema(io).parse(t)}catch(e){console.error(`Can not convert content to simple schema: ${e}`)}},sr=({ref:n,item:e})=>{const[t,r]=m.useState(!0),[o,s]=m.useState(!1),[i,l]=m.useState(!1);Ke(c=>{c&&(r(e.isActive&&e.isActive(c.state)),l(e.isSelected&&!e.isSelected(c.state)),e.isDisabled?s(e.isDisabled(c.state)):s(!e.command(c.state)))});const a=re(c=>{c&&(o||e.command(c.state,c.dispatch,c),c.focus())});return i?null:y.jsx("div",{ref:n,className:`MenuItem ${t?"active":""} ${o?"disabled":""}`,onClick:c=>{c.stopPropagation(),c.preventDefault(),a()},children:e.icon})},Bu=({schema:n})=>{const[e,t]=m.useState(void 0),[r,o]=m.useState(void 0);return m.useEffect(()=>{if(t(void 0),o(void 0),n.nodes.paragraph){const s=n.nodes.paragraph;t({icon:y.jsx(N.Icons.Type,{}),command:on(s)})}if(n.nodes.code_block){const s=n.nodes.code_block;o({icon:y.jsx(N.Icons.CodeXml,{}),command:on(s)})}},[n]),y.jsxs(y.Fragment,{children:[e&&y.jsx(sr,{item:e}),r&&y.jsx(sr,{item:r})]})},ir=({items:n})=>y.jsx("div",{className:"MenuBlock",children:n.map((e,t)=>y.jsx(sr,{item:e},t))}),Lb=({schema:n,isOpen:e,onClose:t})=>{const r=re((o,s)=>{o&&(ke(n.marks.link,{href:s})(o.state,o.dispatch),t(),o.focus())});return y.jsx(N.Prompt,{title:"Введите URL для ссылки",isOpen:e,onCancel:t,onSubmit:r})},Fu=({schema:n})=>{const[e,t]=m.useState([]),[r,o]=m.useState(!1);return m.useEffect(()=>{const s=[];if(n.marks.strong){const i=n.marks.strong;s.push({icon:y.jsx(N.Icons.Bold,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.em){const i=n.marks.em;s.push({icon:y.jsx(N.Icons.Italic,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.underline){const i=n.marks.underline;s.push({icon:y.jsx(N.Icons.Underline,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.strikethrough){const i=n.marks.strikethrough;s.push({icon:y.jsx(N.Icons.Strikethrough,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.code){const i=n.marks.code;s.push({icon:y.jsx(N.Icons.Code,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.link){const i=n.marks.link;s.push({icon:y.jsx(N.Icons.Link,{}),isActive:l=>Jt(l,i),isDisabled:l=>l.selection.empty?!0:!ke(i)(l),command:(l,a,c)=>(Jt(l,i)?(ke(i)(l,a),c==null||c.focus()):o(!0),!0)})}t(s)},[n]),e.length<1?null:y.jsxs(y.Fragment,{children:[y.jsx(ir,{items:e}),y.jsx(Lb,{isOpen:r,schema:n,onClose:()=>o(!1)})]})};function Jt(n,e){let{from:t,$from:r,to:o,empty:s}=n.selection;return s?!!e.isInSet(n.storedMarks||r.marks()):n.doc.rangeHasMark(t,o,e)}const Lu=()=>y.jsxs("div",{className:"MenuBlock",children:[y.jsx(sr,{item:{icon:y.jsx(N.Icons.Undo,{}),command:Po}}),y.jsx(sr,{item:{icon:y.jsx(N.Icons.Redo,{}),command:Dr}})]}),Wu=({schema:n})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{const r=[];if(n.nodes.bullet_list){const o=n.nodes.bullet_list;r.push({icon:y.jsx(N.Icons.List,{}),command:(s,i)=>jr(o)(s,i)})}if(n.nodes.ordered_list){const o=n.nodes.ordered_list;r.push({icon:y.jsx(N.Icons.ListOrdered,{}),command:(s,i)=>jr(o)(s,i)})}if(n.nodes.blockquote){const o=n.nodes.blockquote;r.push({icon:y.jsx(N.Icons.Quote,{}),command:(s,i)=>Nl(o)(s,i)})}t(r)},[n]),e.length<1?null:y.jsx(ir,{items:e})},_u=({pos:n,isOpen:e,onClose:t})=>{const[r,o]=m.useState(""),[s,i]=m.useState(),[l,a]=m.useState(""),[c,u]=m.useState(!1);m.useEffect(()=>{o(""),a(""),i(void 0)},[e]),Ke(d=>{if(!d||!e)return;const p=tt.getState(d.state);u(p.upload!==void 0)},[e]);const f=re(d=>{d&&(c?xm(d,s,l,n):km(d,r,l,n),d.focus(),t())});return y.jsxs(N.Modal,{isOpen:e,onClose:t,children:[y.jsx("h1",{children:"Вставка картинки"}),y.jsxs(N.Form,{submit:"Вставить",submitType:"Success",onSubmit:f,onCancel:t,children:[c?y.jsx(N.Image,{id:"image",value:s,onChange:i,text:y.jsxs("span",{children:[y.jsx(N.Icons.Image,{}),y.jsx("br",{}),"Выберите файл"]}),required:!0,label:"Картинка"}):y.jsx(N.Input,{id:"href",value:r,onChange:o,required:!0,label:"Ссылка на картинку"}),y.jsx(N.Input,{id:"value",value:l,onChange:a,label:"Подпись"})]})]})},Wb=({schema:n,isOpen:e,onClose:t})=>{const[r,o]=m.useState(""),[s,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[f,d]=m.useState(""),[p,h]=m.useState(!0);m.useEffect(()=>{o(""),i(""),a(""),u(""),d(""),n.nodes.table?h(!1):h(!0)},[e]);const b=re(x=>{const S=n.nodes.video;if(!x||!S)return;let w=[];if(p){if(w=oi(r),!w)return}else{if(!s&&!l&&!c)return;const D=rr(l,!0)+"",T=or(c,!0)+"",M=nr(s,!0)+"";D&&w.push(D),T&&w.push(T),M&&w.push(M)}x.dispatch(x.state.tr.replaceSelectionWith(S.create({src:w,title:f}))),x.focus(),t()}),g=()=>p?!!oi(r):l&&!rr(l)||c&&!or(c)||s&&!nr(s)?!1:!!(l||c||s);return n.nodes.video?y.jsxs(N.Modal,{isOpen:e,onClose:t,children:[y.jsx("h1",{children:"Вставка видео"}),y.jsxs(N.Form,{submit:"Вставить",submitType:"Success",onSubmit:b,onCancel:t,children:[p?y.jsx(N.Input,{id:"url",value:r,onChange:o,label:"Ссылка на видео",bottom:"Поддерживаются VK Video, RuTube и YouTube",required:!g()}):y.jsxs(y.Fragment,{children:[y.jsx(N.Input,{id:"vkvideo",value:s,onChange:i,label:"Ссылка на VK Video",required:!g()}),y.jsx(N.Input,{id:"rutube",value:l,onChange:a,label:"Ссылка на RuTube",required:!g()}),y.jsx(N.Input,{id:"youtube",value:c,onChange:u,label:"Ссылка на YouTube",required:!g()})]}),y.jsx(N.Input,{id:"value",value:f,onChange:d,label:"Подпись"})]})]}):null},qu=({schema:n})=>{const[e,t]=m.useState([]),[r,o]=m.useState(!1),[s,i]=m.useState(!1);return m.useEffect(()=>{const l=[];if(n.nodes.image){const a=n.nodes.image;l.push({icon:y.jsx(N.Icons.Image,{}),isDisabled:c=>!si(c,a),command:()=>(o(!0),!0)})}if(n.nodes.video){const a=n.nodes.video;l.push({icon:y.jsx(N.Icons.Film,{}),isDisabled:c=>!si(c,a),command:()=>(i(!0),!0)})}if(n.nodes.horizontal_rule){const a=n.nodes.horizontal_rule;l.push({icon:y.jsx(N.Icons.FlipVertical,{}),isDisabled:c=>!si(c,a),command:(c,u)=>u?(u(c.tr.replaceSelectionWith(a.create())),!0):!1})}n.nodes.table&&l.push({icon:y.jsx(N.Icons.Table,{}),isDisabled:Oe,command:_b()}),t(l)},[n]),e.length<1?null:y.jsxs(y.Fragment,{children:[y.jsx(ir,{items:e}),y.jsx(_u,{isOpen:r,onClose:()=>o(!1)}),y.jsx(Wb,{isOpen:s,schema:n,onClose:()=>i(!1)})]})},si=(n,e)=>{let t=n.selection.$from;for(let r=t.depth;r>=0;r--){let o=t.index(r);if(t.node(r).canReplaceWith(o,o,e))return!0}return!1};function _b(){return(n,e)=>{const t=n.tr.selection.anchor+1,r=n.tr,o=n.schema.nodes.table_cell.createAndFill(),s=n.schema.nodes.table.create(null,C.fromArray([n.schema.nodes.table_row.create(null,C.fromArray([o,o,o])),n.schema.nodes.table_row.create(null,C.fromArray([o,o,o]))]));return e&&e(r.replaceSelectionWith(s).scrollIntoView().setSelection(V.near(r.doc.resolve(t)))),!0}}const Hu=({schema:n})=>n.nodes.carousel?y.jsx(ir,{items:[{icon:y.jsx(N.Icons.JoinUp,{}),command:Sl},{icon:y.jsx(N.Icons.IndentDecrease,{}),command:$o},{icon:y.jsx(N.Icons.SquareDashed,{}),command:Bo}]}):y.jsx(ir,{items:[{icon:y.jsx(N.Icons.IndentDecrease,{}),command:$o},{icon:y.jsx(N.Icons.SquareDashed,{}),command:Bo}]}),qb=({schema:n})=>y.jsxs("div",{className:"SimpleMenuBar",children:[y.jsx("div",{className:"MenuBlock",children:y.jsx(Bu,{schema:n})}),y.jsx(Fu,{schema:n}),y.jsx(qu,{schema:n}),y.jsx(Wu,{schema:n}),y.jsx(Hu,{schema:n}),y.jsx(Lu,{})]}),Ku=m.forwardRef(function({children:e,nodeProps:t,...r},o){const[s,i]=m.useState(t.node.attrs.alt??""),[l,a]=m.useState(t.node.attrs.title??""),[c,u]=m.useState(!1),[f,d]=m.useState("");Vu((x,S)=>x?!(S instanceof MouseEvent):!1),Ke(x=>{if(d(""),u(!1),!x||!x.state.schema.nodes.carousel)return;const S=t.getPos(),w=x.state.doc.resolve(S).parent;if(u(w.type.name!=="carousel"),w.type.name==="carousel"){let D=0;w.forEach((T,M)=>{T===t.node&&(D=M+1)}),d(D?`${D} / ${w.childCount}`:"")}});const p=re((x,S)=>{if(!x)return;i(S);const w=x.state.tr,D=t.getPos();x.dispatch(w.setNodeMarkup(D,null,{...t.node.attrs,alt:S})),x.focus()}),h=re((x,S)=>{if(!x)return;a(S);const w=x.state.tr,D=t.getPos();x.dispatch(w.setNodeMarkup(D,null,{...t.node.attrs,title:S})),x.focus()}),b=re(x=>{if(!x)return;const S=t.getPos(),w=t.node.nodeSize,D=t.node.attrs,T=x.state.schema,M=T.nodes.carousel.create(null,T.nodes.image.create(D));x.dispatch(x.state.tr.replaceWith(S,S+w,M))}),g=re(x=>{if(!x)return;const S=x.state.tr,w=t.getPos(),D=t.node.nodeSize;x.dispatch(S.delete(w,w+D))});return y.jsxs("div",{...r,ref:o,className:"image",title:t.node.attrs.title,children:[y.jsxs("div",{className:"image-buttons",children:[c&&y.jsx("div",{onClick:b,className:"text-button",children:"Сделать карусель"}),f&&y.jsx("div",{className:"text-button",children:f}),y.jsx("div",{onClick:g,children:y.jsx(N.Icons.Trash,{})})]}),y.jsx("div",{className:"image-title",children:y.jsx(N.Editable,{value:s,placeholder:"Alt: описание изображения (не обязательно)",onChange:p,empty:!0,style:{textAlign:"center",cursor:"text"}})}),y.jsx("img",{title:t.node.attrs.title,alt:t.node.attrs.alt,src:t.node.attrs.fid?`${so}/files/${t.node.attrs.fid}`:t.node.attrs.src}),y.jsx("div",{className:"image-title",children:y.jsx(N.Editable,{value:l,placeholder:"Title: подпись под изображением (не обязательно)",onChange:h,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Ju=m.forwardRef(function({children:e,nodeProps:t,...r},o){const[s,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[f,d]=m.useState(""),[p,h]=m.useState(t.node.attrs.title??""),b="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";Vu(()=>!0),m.useEffect(()=>{let x=t.node.attrs.src;typeof x=="string"&&(x=[x]),x.forEach(S=>{rr(S)?(i(S),a(S)):or(S)?(i(S),u(S)):nr(S)&&(i(S),d(S))})},[t]);const g=re((x,S)=>{if(!x)return;h(S);const{$from:w,$to:D}=x.state.selection,T=w.blockRange(D);if(T){const M=x.state.doc;let I=x.state.tr;M.nodesBetween(T.start,T.end,(z,v)=>{z.type.name==="video"&&(I=I.setNodeMarkup(v,null,{...t.node.attrs,title:S}))}),x.dispatch(I)}x.focus()});return y.jsxs("div",{...r,ref:o,className:"video",title:t.node.attrs.title,children:[y.jsxs("div",{className:"video-switcher",children:[l&&y.jsx("div",{onClick:()=>i(l),className:s===l?"active":"",children:"RuTube"}),c&&y.jsx("div",{onClick:()=>i(c),className:s===c?"active":"",children:"YouTube"}),f&&y.jsx("div",{onClick:()=>i(f),className:s===f?"active":"",children:"VK Video"})]}),s?y.jsx("iframe",{src:s,allow:b}):y.jsx("img",{src:ri}),y.jsx("div",{className:"video-title",children:y.jsx(N.Editable,{value:p,placeholder:"Подпись под видео (не обязательно)",onChange:g,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Yu=({onSave:n,disabled:e=!1,notEmpty:t=!0})=>{const[r,o]=m.useState(!0),[s,i]=m.useState(!1);Ke(a=>{let c=!0;if(t){const u=a.state.doc;c=!!u.textBetween(0,u.content.size,void 0," ").length}o(c)});const l=re(async a=>{i(!0);try{let c;const u=Is(a.state);if(u){const d=a.state.apply(u.setMeta("addToHistory",!1));c=JSON.stringify(d.doc.toJSON())}else c=JSON.stringify(a.state.doc.toJSON());const f=await n({content:c,format:"prose"});if(f)throw new Error(f)}catch(c){console.error(`Can not save doc: ${c}`)}i(!1),a.focus()});return y.jsx(N.Button,{type:"Accent",disabled:e||!r||s,label:s?"Сохраняю":"Сохранить",size:"Small",onClick:l})},Hb=({title:n=!1,content:e,onSave:t,onCancel:r,onChange:o,onUpload:s})=>{const[i,l]=m.useState(""),[a,c]=m.useState();m.useEffect(()=>{const p=Ge.create({doc:Fb(e),schema:io,plugins:Ru({schema:io,upload:s})});c(p),n!==!1&&l(typeof n=="string"?n:"")},[n,e]);const u=()=>n!==!1?i.trim().length>0:!0,f=p=>{!t||!u()||t({...p,name:i})},d=()=>{r&&r()};return a?y.jsxs("div",{className:"ProseNotes",children:[n!==!1&&y.jsx("input",{className:"ProseNotesTitle",onChange:p=>l(p.currentTarget.value),value:i,placeholder:"Укажите заголовок"}),y.jsxs(Iu,{state:a,dispatchTransaction:p=>c(h=>{const b=h==null?void 0:h.apply(p);return b&&o&&o(!!Md(b)),b}),nodeViews:{image:Ku,video:Ju},children:[y.jsxs("div",{className:"ProseNotesContent",children:[y.jsx(qb,{schema:io}),y.jsx(Pu,{})]}),(t||r)&&y.jsxs("div",{className:"ProseNotesButtons",children:[r&&y.jsx("span",{className:"a small",onClick:d,children:"Отменить"}),t&&y.jsx(Yu,{onSave:f,disabled:!u()})]})]})]}):null},Kb=({schema:n})=>{const e=m.useRef(null),[t,r]=m.useState([]),[o,s]=m.useState([]),[i,l]=m.useState(!1);Ke(c=>{const u=n.nodes.heading;if(!c||!u||!i)return;const f=[],d=[];for(let p=2;p<7;p++){const b=on(u,{level:p});d[p]=b,f[p]={id:p,icon:y.jsx(Jb,{level:p}),text:`уровень ${p}`,disabled:!b(c.state)}}r(f),s(d)},[i]);const a=re((c,u)=>{!c||!u.id||(o[u.id](c.state,c.dispatch,c),l(!1),c.focus())});return n.nodes.heading?y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:e,className:"MenuItem",onClick:()=>l(!0),children:y.jsx(N.Icons.Heading,{})}),e.current&&y.jsx(N.Menu,{parent:e.current,items:t,isOpen:i,onClose:()=>l(!1),onClick:a,horizontal:"inner-left"})]}):null},Jb=({level:n})=>{switch(n){case 2:return y.jsx(N.Icons.Heading2,{});case 3:return y.jsx(N.Icons.Heading3,{});case 4:return y.jsx(N.Icons.Heading4,{});case 5:return y.jsx(N.Icons.Heading5,{});case 6:return y.jsx(N.Icons.Heading6,{});default:return y.jsx(N.Icons.Heading,{})}},Yb=[{id:"left",icon:y.jsx(N.Icons.AlignLeft,{}),text:"Прижать влево"},{id:"right",icon:y.jsx(N.Icons.AlignRight,{}),text:"Прижать вправо"},{id:"center",icon:y.jsx(N.Icons.AlignCenter,{}),text:"Отцентровать"},{id:"justify",icon:y.jsx(N.Icons.AlignJustify,{}),text:"Выровнять по краям"}],Gb=({schema:n})=>{const e=m.useRef(null),[t,r]=m.useState(!1),o=re((s,i)=>{if(!s||!i.id)return;const l=i.id==="left"?null:i.id,{$from:a,$to:c}=s.state.selection,u=a.blockRange(c);if(u){const f=s.state.doc;let d=s.state.tr;f.nodesBetween(u.start,u.end,(p,h)=>{p.type.name==="paragraph"&&(d=d.setNodeMarkup(h,null,{align:l}))}),s.dispatch(d)}s.focus(),r(!1)});return n.nodes.paragraph?y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:e,className:"MenuItem",onClick:()=>r(!0),children:y.jsx(N.Icons.AlignLeft,{})}),e.current&&y.jsx(N.Menu,{parent:e.current,items:Yb,isOpen:t,onClose:()=>r(!1),onClick:o,horizontal:"inner-left"})]}):null},Xb=({schema:n,onSave:e,onView:t})=>y.jsxs("div",{className:"MenuBar",children:[y.jsxs("div",{className:"MenuBlock",children:[y.jsx(Kb,{schema:n}),y.jsx(Bu,{schema:n})]}),y.jsx(Fu,{schema:n}),y.jsx(qu,{schema:n}),y.jsx(Wu,{schema:n}),y.jsx(Gb,{schema:n}),y.jsx(Hu,{schema:n}),y.jsx(Lu,{}),t&&y.jsx("div",{className:"MenuItem",onClick:()=>t(),children:y.jsx(N.Icons.Eye,{})}),y.jsx("div",{className:"MenuBlock",children:y.jsx(Yu,{onSave:e})})]}),Ub=7,Gu=1,lr=50,Qb=({width:n,onChange:e,onWidth:t})=>{const[r,o]=m.useState(!1),[s,i]=m.useState(0),[l,a]=m.useState(0),[c,u]=m.useState(n),f=h=>{const b=n[l],g=n[l+1],x=[...c];return b+h<lr&&(h=lr-b),g-h<lr&&(h=g-lr),x[l]=b+h,x[l+1]=g-h,x};m.useEffect(()=>{u(n)},[n]),m.useEffect(()=>{const h=g=>{if(!r)return;o(!1),g.preventDefault(),g.stopPropagation();const x=g.clientX-s,S=f(x);t(S)},b=g=>{if(!r)return;g.preventDefault(),g.stopPropagation();const x=g.clientX-s,S=f(x);u(S),e(S)};return document.addEventListener("mouseup",h),document.addEventListener("mousemove",b),()=>{document.removeEventListener("mouseup",h),document.removeEventListener("mousemove",b)}},[r,l]);const d=(h,b)=>{b!==n.length-1&&(h.preventDefault(),h.stopPropagation(),o(!0),i(h.clientX),a(b))},p=h=>c.slice(0,h+1).reduce((b,g)=>b+g,0)+h+Gu-Math.floor(Ub/2);return y.jsx("div",{className:"table-resizer",children:c.map((h,b)=>y.jsx("div",{style:{left:p(b)+"px"},onMouseDown:g=>d(g,b)},b))})},Zb=m.forwardRef(function({children:e,nodeProps:t,...r},o){var f;const s=m.useRef(null),i=m.useRef(null),[l,a]=m.useState([]),c=re((d,p)=>{if(!d)return;const h=t.node,b=t.getPos()+1,g=Q.get(h),x=d.state.tr;for(let S=0;S<g.height;S++)for(let w=0;w<g.width;){const D=S*g.width+w,T=g.map[D],M=h.nodeAt(T).attrs,I=p.slice(w,w+M.colspan);S&&g.map[D]==g.map[D-g.width]||x.setNodeMarkup(b+T,null,{...M,colwidth:I}),w+=M.colspan}x.docChanged&&d.dispatch(x)});m.useEffect(()=>{if(!s.current||!i.current)return;const p=t.node.firstChild;if(!p)return;let h=[];for(let M=0;M<p.childCount;M++){const I=p.child(M),{colspan:z,colwidth:v}=I.attrs;h=h.concat(Array.isArray(v)?v:Array(z).fill(0))}const b=h.filter(M=>!M).length,g=h.reduce((M,I)=>M+I,0),x=(h.length+1)*Gu,S=Math.max(b?(s.current.offsetWidth-g-x)/b:0,lr);h=h.map(M=>M||S);const w=h.reduce((M,I)=>M+I,0),D=i.current.offsetWidth-x-16,T=D/w;h=h.map(M=>Math.round(M*T)),h[h.length-1]+=D-h.reduce((M,I)=>M+I,0),a(h)},[t,s,i,(f=i.current)==null?void 0:f.offsetWidth]);const u=re(d=>{_g(d.state,d.dispatch)});return y.jsxs("div",{...r,className:"table-wrapper",ref:d=>{i.current=d,o&&(typeof o=="function"?o(d):o.current=d)},children:[y.jsx(Qb,{width:l,onChange:a,onWidth:c}),y.jsxs("table",{ref:s,children:[y.jsx("colgroup",{children:l.map((d,p)=>y.jsx("col",{width:d},p))}),y.jsx("caption",{onClick:u,children:y.jsx(N.Icons.Trash,{})}),y.jsx("tbody",{children:e})]})]})}),e0=[{id:"toggleHeaderRow",text:"Toggle header row",icon:y.jsx(N.Icons.Heading,{})},{id:"addRowBefore",text:"Insert row before",icon:y.jsx(N.Icons.RowInsertBefore,{})},{id:"addRowAfter",text:"Insert row after",icon:y.jsx(N.Icons.RowInsertAfter,{})},{id:"deleteRow",text:"Delete row",icon:y.jsx(N.Icons.Trash,{})}],t0=[{id:"toggleHeaderColumn",text:"Toggle header column",icon:y.jsx(N.Icons.Heading,{})},{id:"addColumnBefore",text:"Insert column before",icon:y.jsx(N.Icons.ColumnInsertBefore,{})},{id:"addColumnAfter",text:"Insert column after",icon:y.jsx(N.Icons.ColumnInsertAfter,{})},{id:"deleteColumn",text:"Delete column",icon:y.jsx(N.Icons.Trash,{})}],n0=[{id:"toggleHeaderCell",text:"Toggle header",icon:y.jsx(N.Icons.Heading,{})},{id:"alignLeft",text:"Horizontal align left",icon:y.jsx(N.Icons.AlignLeft,{})},{id:"alignCenter",text:"Horizontal align center",icon:y.jsx(N.Icons.AlignCenter,{})},{id:"alignRight",text:"Horizontal align Right",icon:y.jsx(N.Icons.AlignRight,{})},{id:"alignTop",text:"Vertical align top",icon:y.jsx(N.Icons.AlignTop,{})},{id:"alignMiddle",text:"Vertical align middle",icon:y.jsx(N.Icons.AlignMiddle,{})},{id:"alignBottom",text:"Vertical align bottom",icon:y.jsx(N.Icons.AlignBottom,{})},{id:"mergeCells",text:"Merge cells",icon:y.jsx(N.Icons.CellsMerge,{})},{id:"splitCell",text:"Split cell",icon:y.jsx(N.Icons.CellsSplit,{})}],Xu=({x:n,y:e,isRowMenuOpen:t,isCellMenuOpen:r,isColumnMenuOpen:o,onRowMenuClose:s,onCellMenuClose:i,onColumnMenuClose:l})=>{const a=re((c,u)=>{if(c){switch(u.id){case"toggleHeaderRow":Bg(c.state,c.dispatch);break;case"addRowBefore":Tg(c.state,c.dispatch);break;case"addRowAfter":Ag(c.state,c.dispatch);break;case"deleteRow":Ig(c.state,c.dispatch);break;case"toggleHeaderColumn":Fg(c.state,c.dispatch);break;case"addColumnBefore":Ng(c.state,c.dispatch);break;case"addColumnAfter":Eg(c.state,c.dispatch);break;case"deleteColumn":Og(c.state,c.dispatch);break;case"mergeCells":Rg(c.state,c.dispatch);break;case"splitCell":zg(c.state,c.dispatch);break;case"toggleHeaderCell":Lg(c.state,c.dispatch);break;case"alignLeft":mn("halign","left")(c.state,c.dispatch);break;case"alignCenter":mn("halign","center")(c.state,c.dispatch);break;case"alignRight":mn("halign","right")(c.state,c.dispatch);break;case"alignTop":mn("valign","top")(c.state,c.dispatch);break;case"alignMiddle":mn("valign","middle")(c.state,c.dispatch);break;case"alignBottom":mn("valign","bottom")(c.state,c.dispatch);break}s(),i(),l(),c.focus()}});return y.jsxs(y.Fragment,{children:[y.jsx(N.Menu,{x:n,y:e,items:e0,isOpen:t,onClose:s,onClick:a}),y.jsx(N.Menu,{x:n,y:e,items:n0,isOpen:r,onClose:i,onClick:a}),y.jsx(N.Menu,{x:n,y:e,items:t0,isOpen:o,onClose:l,onClick:a})]})},Uu=m.forwardRef(function({children:e,nodeProps:t,...r},o){const s=m.useRef(null),[i,l]=m.useState(0),[a,c]=m.useState(0),[u,f]=m.useState(!1),[d,p]=m.useState(!1),[h,b]=m.useState(!1);m.useEffect(()=>{const S=w=>{s.current!==w.target&&(f(!1),p(!1),b(!1))};return document.addEventListener("contextmenu",S,!0),()=>document.removeEventListener("contextmenu",S,!0)},[]);const g=S=>{S.preventDefault(),S.stopPropagation(),f(!1),p(!1),b(!1),l(S.clientX),c(S.clientY);const w=S.currentTarget.getBoundingClientRect();S.clientY<w.y?b(!0):S.clientX<w.x?f(!0):p(!0)},x=S=>{f(!1),p(!1),b(!1),l(S.clientX),c(S.clientY);const w=S.currentTarget.getBoundingClientRect();if(S.clientY<w.y)b(!0);else if(S.clientX<w.x)f(!0);else return;S.preventDefault(),S.stopPropagation()};return t.node.type.spec.tableRole==="header_cell"?y.jsxs("th",{...r,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:g,ref:S=>{s.current=S,o&&(typeof o=="function"?o(S):o.current=S)},children:[e,y.jsx(Xu,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>f(!1),isCellMenuOpen:d,onCellMenuClose:()=>p(!1),isColumnMenuOpen:h,onColumnMenuClose:()=>b(!1)})]}):y.jsxs("td",{...r,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:g,ref:S=>{s.current=S,o&&(typeof o=="function"?o(S):o.current=S)},children:[e,y.jsx(Xu,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>f(!1),isCellMenuOpen:d,onCellMenuClose:()=>p(!1),isColumnMenuOpen:h,onColumnMenuClose:()=>b(!1)})]})}),r0=m.forwardRef(function({children:e,nodeProps:t,...r},o){var T;const s=m.useRef(null),[i,l]=m.useState(!1),[a,c]=m.useState(!1),[u,f]=m.useState(!1),[d,p]=m.useState(),[h,b]=m.useState(),g=M=>{const I=M.scrollLeft,z=M.clientWidth,v=M.scrollWidth;c(I>0),f(I<v-z*1.5)};m.useEffect(()=>{s.current&&(h&&s.current.scrollWidth>h&&(s.current.scrollLeft=s.current.scrollWidth-s.current.clientWidth),b(s.current.scrollWidth))},[(T=s.current)==null?void 0:T.scrollWidth]),m.useEffect(()=>{p(t.getPos()+t.node.nodeSize-1),s.current&&t.node.childCount>1&&g(s.current)},[t,s]),Ke(M=>{if(!M||t.node.childCount>0)return;const I=M.state.tr,z=t.getPos(),v=t.node.nodeSize;M.dispatch(I.delete(z,z+v))},[t]);const x=re(M=>{if(!M)return;const I=t.getPos(),z=t.node.nodeSize;M.dispatch(M.state.tr.delete(I,I+z))}),S=()=>{l(!0)},w=M=>{g(M.currentTarget)},D=(M,I)=>{if(M.stopPropagation(),!s.current)return;const z=s.current.clientWidth;let v=s.current.scrollLeft+I*z;s.current.scrollLeft=v};return y.jsxs("div",{ref:o,...r,className:"carousel",children:[y.jsx("div",{className:"carousel-list",ref:s,onScroll:w,children:e}),y.jsxs("div",{className:"carousel-buttons",children:[y.jsx("div",{onClick:x,className:"text-button",children:"Удалить карусель"}),y.jsx("div",{onClick:S,children:y.jsx(N.Icons.Plus,{})})]}),a&&y.jsx("div",{className:"carousel-prev",onClick:M=>D(M,-1),children:y.jsx(N.Icons.ChevronLeft,{})}),u&&y.jsx("div",{className:"carousel-next",onClick:M=>D(M,1),children:y.jsx(N.Icons.ChevronRight,{})}),y.jsx(_u,{pos:d,isOpen:i,onClose:()=>l(!1)})]})}),o0=({content:n,onSave:e,onView:t,onChange:r,onUpload:o})=>{const[s,i]=m.useState();m.useEffect(()=>{let a;if(n)try{a=be.fromJSON(Nt,JSON.parse(n))}catch(f){console.error(`Can not parse Prose format: ${f}`)}let c=Ge.create({doc:a,schema:Nt,plugins:Ru({schema:Nt,upload:o})});const u=Is(c);u&&(c=c.apply(u.setMeta("addToHistory",!1))),i(c)},[n]);const l=async a=>{const c=await e(a);return r&&r(!1),c};return s?y.jsx("div",{className:"ProseEditor",children:y.jsxs(Iu,{state:s,dispatchTransaction:a=>i(c=>{const u=c==null?void 0:c.apply(a);return u&&r&&r(!0),u}),nodeViews:{image:Ku,video:Ju,table:Zb,table_header:Uu,table_cell:Uu,carousel:r0},children:[y.jsx(Xb,{schema:Nt,onSave:l,onView:t}),y.jsx(Pu,{})]})}):null},s0=({node:n})=>{const[e,t]=m.useState();return m.useEffect(()=>{var o;const r=(o=n.attrs)==null?void 0:o.align;t(r!=="right"&&r!=="center"&&r!=="justify"?void 0:{textAlign:r})},[n]),y.jsx("p",{style:e,children:Array.isArray(n.content)&&n.content.map((r,o)=>y.jsx(Y,{node:r},o))})},i0=({node:n})=>{if(!n.text)return null;const e=(t,r)=>{var i;if(!Array.isArray(n.marks))return y.jsx(y.Fragment,{children:r});if(!t.length)return y.jsx(y.Fragment,{children:r});const o=t[0].type,s=(i=t[0].attrs)==null?void 0:i.href;switch(o){case"em":return y.jsx("em",{children:e(t.slice(1),r)});case"code":return y.jsx("code",{children:e(t.slice(1),r)});case"strong":return y.jsx("strong",{children:e(t.slice(1),r)});case"underline":return y.jsx("u",{children:e(t.slice(1),r)});case"strikethrough":return y.jsx("s",{children:e(t.slice(1),r)});case"link":return s?y.jsx("a",{target:"_blank",href:s,children:e(t.slice(1),r)}):y.jsx(y.Fragment,{children:e(t.slice(1),r)});default:return y.jsx(y.Fragment,{children:e(t.slice(1),r)})}};return e(n.marks,n.text)},l0=({node:n,className:e})=>y.jsx("div",{className:e,children:Array.isArray(n.content)&&n.content.map((t,r)=>y.jsx(Y,{node:t},r))}),a0=({node:n})=>{const e=m.useRef(null),[t,r]=m.useState(""),[o,s]=m.useState(""),[i,l]=m.useState(""),[a,c]=m.useState(!1);m.useEffect(()=>{const f=()=>{c(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",f),()=>document.removeEventListener("fullscreenchange",f)},[]),m.useEffect(()=>{var p,h,b,g,x,S,w;let f=(p=n.attrs)==null?void 0:p.fid,d=(h=n.attrs)!=null&&h.src?`${(b=n.attrs)==null?void 0:b.src}`:"";f&&(d=`${so}/files/${f}`),d||(d=ni),r(d),s((g=n.attrs)!=null&&g.alt?`${(x=n.attrs)==null?void 0:x.alt}`:""),l((S=n.attrs)!=null&&S.title?`${(w=n.attrs)==null?void 0:w.title}`:"")},[n]);const u=f=>{var d;f.stopPropagation(),a?document.exitFullscreen():(d=e.current)==null||d.requestFullscreen()};return t?y.jsxs("div",{ref:e,className:"image",children:[y.jsx("img",{src:t,onClick:u,alt:o,title:i}),i&&y.jsx("div",{className:"image-title",children:i}),y.jsx("div",{className:"image-full",onClick:u,children:a?y.jsx(N.Icons.Minimize,{}):y.jsx(N.Icons.Maximize,{})})]}):null},c0=({node:n})=>y.jsx("blockquote",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),u0=50,f0=({node:n})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{if(t([]),!Array.isArray(n.content))return;const r=n.content[0];if(!Array.isArray(r.content))return;let o=[];for(let i=0;i<r.content.length;i++){const l=r.content[i].attrs;if(!l)return;const{colspan:a,colwidth:c}=l;o=o.concat(Array.isArray(c)?c:Array(a).fill(u0))}const s=o.reduce((i,l)=>i+l,0);o=o.map(i=>Math.round(i*100/s)),o[o.length-1]+=100-o.reduce((i,l)=>i+l,0),t(o)},[n]),y.jsxs("table",{children:[e.length>0&&y.jsx("colgroup",{children:e.map((r,o)=>y.jsx("col",{width:`${r}%`},o))}),y.jsx("tbody",{children:Array.isArray(n.content)&&n.content.map((r,o)=>y.jsx(Y,{node:r},o))})]})},d0=({node:n})=>y.jsx("tr",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),h0=({node:n})=>{const[e,t]=m.useState(),[r,o]=m.useState(),[s,i]=m.useState(),[l,a]=m.useState();return m.useEffect(()=>{var c,u,f,d;t((c=n.attrs)==null?void 0:c.halign),o((u=n.attrs)==null?void 0:u.valign),i((f=n.attrs)!=null&&f.rowspan?parseInt(n.attrs.rowspan+""):1),a((d=n.attrs)!=null&&d.colspan?parseInt(n.attrs.colspan+""):1)},[n]),n.type==="table_header"?y.jsx("th",{colSpan:l,rowSpan:s,style:{textAlign:e,verticalAlign:r},children:Array.isArray(n.content)&&n.content.map((c,u)=>y.jsx(Y,{node:c},u))}):y.jsx("td",{colSpan:l,rowSpan:s,style:{textAlign:e,verticalAlign:r},children:Array.isArray(n.content)&&n.content.map((c,u)=>y.jsx(Y,{node:c},u))})},p0=({node:n})=>{var e;if(!Array.isArray(n.content))return null;switch((e=n.attrs)==null?void 0:e.level){case 1:return y.jsx("h1",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 2:return y.jsx("h2",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 3:return y.jsx("h3",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 4:return y.jsx("h4",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 5:return y.jsx("h5",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 6:return y.jsx("h6",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});default:return y.jsx("h2",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))})}},m0=({node:n})=>Array.isArray(n.content)?n.type==="bullet_list"?y.jsx("ul",{children:n.content.map((e,t)=>y.jsx(Y,{node:e},t))}):y.jsx("ol",{children:n.content.map((e,t)=>y.jsx(Y,{node:e},t))}):null,g0=({node:n})=>y.jsx("li",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),y0=({node:n})=>y.jsx("pre",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),b0=()=>y.jsx("hr",{}),x0=({node:n})=>{const[e,t]=m.useState(""),[r,o]=m.useState(""),[s,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[f,d]=m.useState(0),p="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";return m.useEffect(()=>{var b,g;u((b=n.attrs)!=null&&b.title?`${n.attrs.title}`:"");let h=(g=n.attrs)==null?void 0:g.src;typeof h=="string"&&(h=[h]),h.forEach(x=>{rr(x)?(t(x),o(x)):or(x)?(t(x),i(x)):nr(x)&&(t(x),a(x))})},[n]),m.useEffect(()=>{let h=0;r&&h++,s&&h++,l&&h++,d(h)},[r,s,l]),f?y.jsxs("div",{className:"video",children:[f>1&&y.jsxs("div",{className:"video-switcher",children:[r&&y.jsx("div",{onClick:()=>t(r),className:e===r?"active":"",children:"RuTube"}),s&&y.jsx("div",{onClick:()=>t(s),className:e===s?"active":"",children:"YouTube"}),l&&y.jsx("div",{onClick:()=>t(l),className:e===l?"active":"",children:"VK Video"})]}),y.jsx("iframe",{src:e,allow:p}),c&&y.jsx("div",{className:"video-title",children:c})]}):y.jsxs("div",{className:"image",children:[y.jsx("img",{src:ri}),c&&y.jsx("div",{className:"image-title",children:c})]})},k0=()=>y.jsx("br",{}),S0=({node:n})=>{const e=m.useRef(null),t=m.useRef(null),[r,o]=m.useState(!1),[s,i]=m.useState(!1),[l,a]=m.useState(!1),[c,u]=m.useState(1),[f,d]=m.useState(1),p=g=>{const x=g.scrollLeft,S=g.clientWidth,w=g.scrollWidth;i(x>S/2),a(x<w-S*1.5),u(Math.round(x/S+1))};m.useEffect(()=>{var g;a(Array.isArray(n.content)&&n.content.length>1),d(((g=n.content)==null?void 0:g.length)??1),u(1)},[n]),m.useEffect(()=>{const g=()=>{o(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]),m.useEffect(()=>{if(!r)return;const g=x=>{x.key==="ArrowLeft"&&b(null,-1),x.key==="ArrowRight"&&b(null,1)};return document.body.addEventListener("keydown",g),()=>document.body.removeEventListener("keydown",g)},[r]);const h=g=>{var x;g.stopPropagation(),r?document.exitFullscreen():(x=t.current)==null||x.requestFullscreen()},b=(g,x)=>{if(g==null||g.stopPropagation(),!e.current)return;const S=e.current.clientWidth;let w=e.current.scrollLeft+x*S;e.current.scrollLeft=w};return Array.isArray(n.content)?y.jsxs("div",{className:"carousel",ref:t,children:[y.jsx("div",{className:"carousel-list",ref:e,onScroll:g=>p(g.currentTarget),children:n.content.map((g,x)=>y.jsx(C0,{node:g,onClick:h},x))}),y.jsxs("div",{className:"carousel-numb",children:[c," / ",f]}),y.jsx("div",{className:"carousel-full",onClick:h,children:r?y.jsx(N.Icons.Minimize,{}):y.jsx(N.Icons.Maximize,{})}),s&&y.jsx("div",{className:"carousel-prev",onClick:g=>b(g,-1),children:y.jsx(N.Icons.ChevronLeft,{})}),l&&y.jsx("div",{className:"carousel-next",onClick:g=>b(g,1),children:y.jsx(N.Icons.ChevronRight,{})})]}):null},C0=({node:n,onClick:e})=>{const[t,r]=m.useState(""),[o,s]=m.useState(""),[i,l]=m.useState("");return m.useEffect(()=>{var d,p,h,b;let a=(d=n.attrs)==null?void 0:d.fid,c=(p=n.attrs)!=null&&p.src?`${n.attrs.src}`:"",u=(h=n.attrs)!=null&&h.alt?`${n.attrs.alt}`:"",f=(b=n.attrs)!=null&&b.title?`${n.attrs.title}`:"";a&&(c=`${so}/files/${a}`),c||(c=ni),r(c),s(u),l(f)},[n]),n.type!=="image"?null:y.jsxs("div",{className:"image",children:[t&&y.jsx("img",{src:t,onClick:e,alt:o,title:i}),i&&y.jsx("div",{className:"image-title",children:i})]})},Y=({node:n,className:e})=>n?(r=>{switch(r.type){case"doc":return y.jsx(l0,{node:r,className:e});case"list_item":return y.jsx(g0,{node:r});case"bullet_list":case"ordered_list":return y.jsx(m0,{node:r});case"image":return y.jsx(a0,{node:r});case"video":return y.jsx(x0,{node:r});case"text":return y.jsx(i0,{node:r});case"table":return y.jsx(f0,{node:r});case"table_row":return y.jsx(d0,{node:r});case"table_cell":case"table_header":return y.jsx(h0,{node:r});case"heading":return y.jsx(p0,{node:r});case"code_block":return y.jsx(y0,{node:r});case"paragraph":return y.jsx(s0,{node:r});case"blockquote":return y.jsx(c0,{node:r});case"carousel":return y.jsx(S0,{node:r});case"horizontal_rule":return y.jsx(b0,{});case"hard_break":return y.jsx(k0,{});default:return y.jsx("span",{className:"unknown_node_type",children:r.type})}})(n):null,w0=({content:n})=>{const[e,t]=m.useState(),[r,o]=m.useState(!1);return m.useEffect(()=>{try{o(!1);const s=JSON.parse(n);t(s)}catch(s){o(!0),console.error(`Can not parse Prose format: ${s}`)}},[n]),r?y.jsx("div",{className:"error",children:"ОШИБКА"}):y.jsx(Y,{node:e,className:"ProseViewer"})},M0=({content:n})=>{const e=m.useRef(null),[t,r]=m.useState(!1);return m.useEffect(()=>{var o;try{r(!1);const s=be.fromJSON(Nt,JSON.parse(n)),i=$e.fromSchema(Nt).serializeFragment(s.content);(o=e.current)==null||o.appendChild(i)}catch(s){r(!0),console.error(`Can not parse Prose format: ${s}`)}},[e,n]),y.jsx("div",{ref:e,className:"ProseViewer",children:t&&y.jsx("div",{className:"error",children:"ОШИБКА"})})};G.DOM=M0,G.Editor=o0,G.Notes=Hb,G.Viewer=w0,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
|
|
62
|
+
*/var Aa;function em(){return Aa||(Aa=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}Ee.doesFiberContain=function(o,i){for(var l=o.alternate;i!==null;){if(i===o||i===l)return!0;i=i.return}return!1},Ee.findCurrentFiberUsingSlowPath=t,Ee.findCurrentHostFiber=function(o){return o=t(o),o!==null?n(o):null},Ee.findCurrentHostFiberWithNoPortals=function(o){return o=t(o),o!==null?s(o):null},Ee.getContainerFromFiber=function(o){return o.tag===3?o.stateNode.containerInfo:null},Ee.getNearestMountedFiber=r,Ee.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},Ee.isFiberMounted=function(o){return r(o)===o},Ee.isFiberSuspenseAndTimedOut=function(o){var i=o.memoizedState;return o.tag===13&&i!==null&&i.dehydrated===null},Ee.isMounted=function(o){return(o=o._reactInternals)?r(o)===o:!1}}()),Ee}process.env.NODE_ENV==="production"?Ws.exports=Zp():Ws.exports=em();var tm=Ws.exports;function nm(r){return r._reactInternals}function Pg(r){return r}function rm(r){const e=nm(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=tm.findCurrentHostFiber(e);return t===null?null:t.stateNode}function sm(r){return rm(r)}function om(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 im extends m.Component{constructor(){super(...arguments);$(this,"viewDescRef",null);$(this,"renderRef",null)}updateEffect(){const{view:t,decorations:n,siblingsRef:s,parentRef:o,getPos:i,node:l}=this.props,a=sm(this);if(!a){if(!t.composing)return;this.viewDescRef=new Fs(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 Fs?this.viewDescRef=new Vp(void 0,[],i,l,n,L.empty,a,c):(this.viewDescRef.parent=o.current,this.viewDescRef.children=[],this.viewDescRef.node=l,this.viewDescRef.outerDeco=n,this.viewDescRef.innerDeco=L.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(Dt)}shouldComponentUpdate(t){return!om(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(yr,s.text),this.renderRef)}}function lm(r){let{getPos:e}=r;const{siblingsRef:t,parentRef:n}=m.useContext(Te),s=m.useRef(null),o=m.useRef(null);return re(()=>{const i=t.current;return()=>{if(s.current&&i.includes(s.current)){const l=i.indexOf(s.current);i.splice(l,1)}}},[t]),re(()=>{o.current&&(s.current?(s.current.parent=n.current,s.current.dom=o.current):s.current=new vn(n.current,[],e,o.current,null),t.current.includes(s.current)||t.current.push(s.current),t.current.sort(Dt))}),m.createElement("br",{ref:o,className:"ProseMirror-trailingBreak"})}function am(r){let{widget:e,getPos:t}=r;const{siblingsRef:n,parentRef:s}=m.useContext(Te),o=m.useRef(null),i=m.useRef(null);re(()=>{const a=n.current;return()=>{if(o.current&&a.includes(o.current)){const c=a.indexOf(o.current);a.splice(c,1)}}},[n]),re(()=>{i.current&&(o.current?(o.current.parent=s.current,o.current.widget=e,o.current.dom=i.current):o.current=new Bs(s.current,t,e,i.current),n.current.includes(o.current)||n.current.push(o.current),n.current.sort(Dt))});const{Component:l}=e.type;return l&&m.createElement(l,{ref:i,widget:e,getPos:t,contentEditable:!1})}function yr(r,e){const{nodeName:t,...n}=e.type.attrs,s=va(n);return t||typeof r=="string"?m.createElement(t??"span",s,r):m.cloneElement(r,Ma(r.props,s))}function _s(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 cm=m.memo(function(e){let{child:t,getInnerPos:n}=e;const{view:s}=m.useContext(Xt),o=m.useRef(t);o.current=t;const i=m.useCallback(()=>n()+o.current.offset,[n]);return t.type==="widget"?m.createElement(am,{key:t.key,widget:t.widget,getPos:i}):t.type==="native-widget"?m.createElement(Jp,{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(Te.Consumer,{key:t.key},l=>{let{siblingsRef:a,parentRef:c}=l;return m.createElement(im,{view:s,node:t.node,getPos:i,siblingsRef:a,parentRef:c,decorations:t.outerDeco})}):m.createElement(Da,{key:t.key,node:t.node,getPos:i,outerDeco:t.outerDeco,innerDeco:t.innerDeco})}),um=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(Ea,{key:s.key,mark:l,getPos:i},m.createElement(qs,{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(cm,{key:a.key,child:a,getInnerPos:n})))}),qs=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(um,{key:i.key,childViews:o,getInnerPos:t}):null}))});function Hs(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 dm(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 fm(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 hm=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(Ea,{mark:l,getPos:o},i),m.createElement(Da,{key:t.key,outerDeco:t.outerDeco,node:t.node,innerDeco:t.innerDeco,getPos:o})):m.createElement(qs,{key:t.key,childViews:[t],getInnerPos:n})});function pm(r,e){return r.length?r.every(t=>t.type!=="node"||t.node.isInline)?[m.createElement(qs,{key:r[0].key,childViews:r,getInnerPos:e})]:r.map(t=>m.createElement(hm,{key:t.key,child:t,getInnerPos:e})):[]}const Js=m.memo(function(e){let{getPos:t,node:n,innerDecorations:s}=e;const o=$p(),i=m.useCallback(()=>t()+1,[t]),l=m.useRef(new Map).current;if(!n)return null;const a=new Map;let c=[],u=null;Fp(n,s,(h,p,b,y)=>{const x=h.type.spec.marks??[];let w;if(p){w=Hs(i(),b,y,"native-widget",o==null?void 0:o.posToKey,h);const v={type:"native-widget",widget:h,marks:x,offset:b,index:y,key:w},O=l.get(w);O&&_s(O,v)?O.offset=b:l.set(w,v),a.set(w,a.size)}else{w=Hs(i(),b,y,"widget",o==null?void 0:o.posToKey,h);const v={type:"widget",widget:h,marks:x,offset:b,index:y,key:w},O=l.get(w);O&&_s(O,v)?O.offset=b:l.set(w,v),a.set(w,a.size)}const C=l.get(w);c.push(C),dm(u,l.get(w))},(h,p,b,y,x)=>{const w=Hs(i(),y,x,"node",o==null?void 0:o.posToKey),C={type:"node",node:h,marks:h.marks,innerDeco:b,outerDeco:p,offset:y,index:x,key:w},v=l.get(w);v&&_s(v,C)?(v.offset=y,u=v):(l.set(w,C),u=C),a.set(w,a.size),fm(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:Up,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:lm,marks:[],offset:(h==null?void 0:h.offset)??0,index:((h==null?void 0:h.index)??0)+1,key:"trailing-hack-br"})}const f=pm(d,i);return m.createElement(m.Fragment,null,f)}),mm=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}=Ls(u,()=>{const y=u.current;return{dom:y,contentDOM:y,update(){return!0}}},d),h=m.createElement(Te.Provider,{value:f},m.createElement(Js,{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(yr,b)})),Pa=m.createContext(null),Ia=m.forwardRef(function(e,t){let{as:n,...s}=e;const o=m.useContext(Pa);return m.createElement(mm,{ref:t,...s,...o,as:n})});function gm(){return-1}function ym(r){let{className:e,children:t,nodeViews:n,customNodeViews:s,...o}=r;const[i,l]=m.useState(null),{editor:a,state:c}=Tp(i,{...o,nodeViews:s}),u=a.view.nodeViews,d=m.useMemo(()=>({components:{...n},constructors:u}),[u,n]),f=c.doc,h=hp(a.view),p=yp(a.view,a.cursorWrapper),b=m.useMemo(()=>({className:e,setMount:l,node:f,getPos:gm,decorations:h,innerDecorations:p}),[e,f,h,p]);return m.createElement(Xt.Provider,{value:a},m.createElement(fp.Provider,{value:c},m.createElement(ta.Provider,{value:d},m.createElement(Pa.Provider,{value:b},t))))}function Va(r){return m.createElement(Ap,null,m.createElement(ym,r))}function bm(r){if(!(r instanceof Et))throw new DOMException("ProseMirror document is not mounted","InvalidStateError")}function se(r){const e=m.useRef(r),{view:t}=m.useContext(Xt);return Be(()=>{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 bm(t),e.current(t,...s)},[t])}function Ra(r){const e=m.useContext(Oa),t=se(r);Be(()=>e(t),[e,t])}const za=r=>[dp(),_r({Tab:Gl(1),"Shift-Tab":Gl(-1)}),gh(r.schema),_r(uh(r.schema)),_r(Ku),Yu({color:"#F00",width:2}),Vf(),Su(),yh(r),Lp()],xm=["p",0],km=["blockquote",0],wm=["hr"],Sm=["pre",["code",0]],Cm=["br"],Mm={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return xm}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return km}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return wm}},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 Sm}},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 Cm}}},vm=["em",0],Nm=["strong",0],Em=["code",0],Om={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 vm}},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 Nm}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return Em}}},ja=new Wn({nodes:Mm,marks:Om}),Ba=ja.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]}}}),br="https://dailytelefrag.ru/api",Ks="https://dailytelefrag.ru/error_image.png",Ys="https://dailytelefrag.ru/error_embed.png",Nn=(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}},En=(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}},On=(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}},Gs=r=>{try{const e=new URL(r);switch(e.hostname){case"vkvideo.ru":case"vk.com":case"vk.ru":return Nn(e,!0)+"";case"rutube.ru":return En(e,!0)+"";case"youtube.com":case"www.youtube.com":case"youtu.be":return On(e,!0)+"";default:throw new Error}}catch{return""}},Dm={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){return{fid:r.getAttribute("fid"),src:r.getAttribute("src"),alt:r.getAttribute("alt"),title:r.getAttribute("title")}}}],toDOM(r){let{fid:e,src:t,alt:n,title:s}=r.attrs;return e&&(t=`${br}/files/${e}`),t||(t=Ks),["div",{title:s,class:"image"},["img",{fid:e,src:t,alt:n,title:s}]]}},Tm={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 Gs(s)?["div",{title:t,class:"video"},["iframe",{src:s,title:t,allow:n}]]:["div",{title:t,class:"image"},["img",{src:Ys}]]}},Am={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]}},Pm={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]}},Im={atom:!0,content:"image*",group:"block",toDOM(){return["div",{class:"carousel"},0]}},Fa=ja.spec.nodes.remove("image").append({image:Dm,video:Tm}),Dn=new Wn({nodes:Fa.remove("horizontal_rule").remove("heading"),marks:Ba}),Vm=Fa.remove("heading").remove("paragraph").prepend({paragraph:Am}).append({heading:Pm}).append({carousel:Im}).append(Nh({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};`)}}}})),Ye=new Wn({nodes:Hf(Vm,"(paragraph | ordered_list | bullet_list)+","block"),marks:Ba}),Rm=r=>{if(r)try{const e=ye.fromJSON(Ye,JSON.parse(r)),t=$e.fromSchema(Ye).serializeFragment(e.content);return _n.fromSchema(Dn).parse(t)}catch(e){console.error(`Can not convert content to simple schema: ${e}`)}},Tn=({ref:r,item:e})=>{const[t,n]=m.useState(!0),[s,o]=m.useState(!1),[i,l]=m.useState(!1);Be(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=se(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})},La=({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(N.Icons.Type,{}),command:$t(o)})}if(r.nodes.code_block){const o=r.nodes.code_block;s({icon:g.jsx(N.Icons.CodeXml,{}),command:$t(o)})}},[r]),g.jsxs(g.Fragment,{children:[e&&g.jsx(Tn,{item:e}),n&&g.jsx(Tn,{item:n})]})},An=({items:r})=>g.jsx("div",{className:"MenuBlock",children:r.map((e,t)=>g.jsx(Tn,{item:e},t))}),zm=({schema:r,isOpen:e,onClose:t})=>{const n=se((s,o)=>{s&&(ke(r.marks.link,{href:o})(s.state,s.dispatch),t(),s.focus())});return g.jsx(N.Prompt,{title:"Введите URL для ссылки",isOpen:e,onCancel:t,onSubmit:n})},$a=({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(N.Icons.Bold,{}),command:ke(i),isActive:l=>At(l,i)})}if(r.marks.em){const i=r.marks.em;o.push({icon:g.jsx(N.Icons.Italic,{}),command:ke(i),isActive:l=>At(l,i)})}if(r.marks.underline){const i=r.marks.underline;o.push({icon:g.jsx(N.Icons.Underline,{}),command:ke(i),isActive:l=>At(l,i)})}if(r.marks.strikethrough){const i=r.marks.strikethrough;o.push({icon:g.jsx(N.Icons.Strikethrough,{}),command:ke(i),isActive:l=>At(l,i)})}if(r.marks.code){const i=r.marks.code;o.push({icon:g.jsx(N.Icons.Code,{}),command:ke(i),isActive:l=>At(l,i)})}if(r.marks.link){const i=r.marks.link;o.push({icon:g.jsx(N.Icons.Link,{}),isActive:l=>At(l,i),isDisabled:l=>l.selection.empty?!0:!ke(i)(l),command:(l,a,c)=>(At(l,i)?(ke(i)(l,a),c==null||c.focus()):s(!0),!0)})}t(o)},[r]),e.length<1?null:g.jsxs(g.Fragment,{children:[g.jsx(An,{items:e}),g.jsx(zm,{isOpen:n,schema:r,onClose:()=>s(!1)})]})};function At(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 Wa=()=>g.jsxs("div",{className:"MenuBlock",children:[g.jsx(Tn,{item:{icon:g.jsx(N.Icons.Undo,{}),command:Lr}}),g.jsx(Tn,{item:{icon:g.jsx(N.Icons.Redo,{}),command:Qn}})]}),_a=({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(N.Icons.List,{}),command:(o,i)=>cr(s)(o,i)})}if(r.nodes.ordered_list){const s=r.nodes.ordered_list;n.push({icon:g.jsx(N.Icons.ListOrdered,{}),command:(o,i)=>cr(s)(o,i)})}if(r.nodes.blockquote){const s=r.nodes.blockquote;n.push({icon:g.jsx(N.Icons.Quote,{}),command:(o,i)=>xi(s)(o,i)})}t(n)},[r]),e.length<1?null:g.jsx(An,{items:e})},qa=({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]),Be(f=>{if(!f||!e)return;const h=Ke.getState(f.state);u(h.upload!==void 0)},[e]);const d=se(f=>{f&&(c?xh(f,o,l,r):kh(f,n,l,r),f.focus(),t())});return g.jsxs(N.Modal,{isOpen:e,onClose:t,children:[g.jsx("h1",{children:"Вставка картинки"}),g.jsxs(N.Form,{submit:"Вставить",submitType:"Success",onSubmit:d,onCancel:t,children:[c?g.jsx(N.Image,{id:"image",value:o,onChange:i,text:g.jsxs("span",{children:[g.jsx(N.Icons.Image,{}),g.jsx("br",{}),"Выберите файл"]}),required:!0,label:"Картинка"}):g.jsx(N.Input,{id:"href",value:n,onChange:s,required:!0,label:"Ссылка на картинку"}),g.jsx(N.Input,{id:"value",value:l,onChange:a,label:"Подпись"})]})]})},jm=({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=se(x=>{const w=r.nodes.video;if(!x||!w)return;let C=[];if(h){if(C=Gs(n),!C)return}else{if(!o&&!l&&!c)return;const v=En(l,!0)+"",O=On(c,!0)+"",M=Nn(o,!0)+"";v&&C.push(v),O&&C.push(O),M&&C.push(M)}x.dispatch(x.state.tr.replaceSelectionWith(w.create({src:C,title:d}))),x.focus(),t()}),y=()=>h?!!Gs(n):l&&!En(l)||c&&!On(c)||o&&!Nn(o)?!1:!!(l||c||o);return r.nodes.video?g.jsxs(N.Modal,{isOpen:e,onClose:t,children:[g.jsx("h1",{children:"Вставка видео"}),g.jsxs(N.Form,{submit:"Вставить",submitType:"Success",onSubmit:b,onCancel:t,children:[h?g.jsx(N.Input,{id:"url",value:n,onChange:s,label:"Ссылка на видео",bottom:"Поддерживаются VK Video, RuTube и YouTube",required:!y()}):g.jsxs(g.Fragment,{children:[g.jsx(N.Input,{id:"vkvideo",value:o,onChange:i,label:"Ссылка на VK Video",required:!y()}),g.jsx(N.Input,{id:"rutube",value:l,onChange:a,label:"Ссылка на RuTube",required:!y()}),g.jsx(N.Input,{id:"youtube",value:c,onChange:u,label:"Ссылка на YouTube",required:!y()})]}),g.jsx(N.Input,{id:"value",value:d,onChange:f,label:"Подпись"})]})]}):null},Ha=({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(N.Icons.Image,{}),isDisabled:c=>!Xs(c,a),command:()=>(s(!0),!0)})}if(r.nodes.video){const a=r.nodes.video;l.push({icon:g.jsx(N.Icons.Film,{}),isDisabled:c=>!Xs(c,a),command:()=>(i(!0),!0)})}if(r.nodes.horizontal_rule){const a=r.nodes.horizontal_rule;l.push({icon:g.jsx(N.Icons.FlipVertical,{}),isDisabled:c=>!Xs(c,a),command:(c,u)=>u?(u(c.tr.replaceSelectionWith(a.create())),!0):!1})}r.nodes.table&&l.push({icon:g.jsx(N.Icons.Table,{}),isDisabled:ve,command:Bm()}),t(l)},[r]),e.length<1?null:g.jsxs(g.Fragment,{children:[g.jsx(An,{items:e}),g.jsx(qa,{isOpen:n,onClose:()=>s(!1)}),g.jsx(jm,{isOpen:o,schema:r,onClose:()=>i(!1)})]})},Xs=(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 Bm(){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(j.near(n.doc.resolve(t)))),!0}}const Ja=({schema:r})=>r.nodes.carousel?g.jsx(An,{items:[{icon:g.jsx(N.Icons.JoinUp,{}),command:mi},{icon:g.jsx(N.Icons.IndentDecrease,{}),command:Hr},{icon:g.jsx(N.Icons.SquareDashed,{}),command:Kr}]}):g.jsx(An,{items:[{icon:g.jsx(N.Icons.IndentDecrease,{}),command:Hr},{icon:g.jsx(N.Icons.SquareDashed,{}),command:Kr}]}),Fm=({schema:r})=>g.jsxs("div",{className:"SimpleMenuBar",children:[g.jsx("div",{className:"MenuBlock",children:g.jsx(La,{schema:r})}),g.jsx($a,{schema:r}),g.jsx(Ha,{schema:r}),g.jsx(_a,{schema:r}),g.jsx(Ja,{schema:r}),g.jsx(Wa,{})]}),Ka=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("");Ra((x,w)=>x?!(w instanceof MouseEvent):!1),Be(x=>{if(f(""),u(!1),!x||!x.state.schema.nodes.carousel)return;const w=t.getPos(),C=x.state.doc.resolve(w).parent;if(u(C.type.name!=="carousel"),C.type.name==="carousel"){let v=0;C.forEach((O,M)=>{O===t.node&&(v=M+1)}),f(v?`${v} / ${C.childCount}`:"")}});const h=se((x,w)=>{if(!x)return;i(w);const C=x.state.tr,v=t.getPos();x.dispatch(C.setNodeMarkup(v,null,{...t.node.attrs,alt:w})),x.focus()}),p=se((x,w)=>{if(!x)return;a(w);const C=x.state.tr,v=t.getPos();x.dispatch(C.setNodeMarkup(v,null,{...t.node.attrs,title:w})),x.focus()}),b=se(x=>{if(!x)return;const w=t.getPos(),C=t.node.nodeSize,v=t.node.attrs,O=x.state.schema,M=O.nodes.carousel.create(null,O.nodes.image.create(v));x.dispatch(x.state.tr.replaceWith(w,w+C,M))}),y=se(x=>{if(!x)return;const w=x.state.tr,C=t.getPos(),v=t.node.nodeSize;x.dispatch(w.delete(C,C+v))});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(N.Icons.Trash,{})})]}),g.jsx("div",{className:"image-title",children:g.jsx(N.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?`${br}/files/${t.node.attrs.fid}`:t.node.attrs.src}),g.jsx("div",{className:"image-title",children:g.jsx(N.Editable,{value:l,placeholder:"Title: подпись под изображением (не обязательно)",onChange:p,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Ya=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";Ra(()=>!0),m.useEffect(()=>{let x=t.node.attrs.src;typeof x=="string"&&(x=[x]),x.forEach(w=>{En(w)?(i(w),a(w)):On(w)?(i(w),u(w)):Nn(w)&&(i(w),f(w))})},[t]);const y=se((x,w)=>{if(!x)return;p(w);const{$from:C,$to:v}=x.state.selection,O=C.blockRange(v);if(O){const M=x.state.doc;let D=x.state.tr;M.nodesBetween(O.start,O.end,(R,T)=>{R.type.name==="video"&&(D=D.setNodeMarkup(T,null,{...t.node.attrs,title:w}))}),x.dispatch(D)}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:Ys}),g.jsx("div",{className:"video-title",children:g.jsx(N.Editable,{value:h,placeholder:"Подпись под видео (не обязательно)",onChange:y,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Ga=({onSave:r,disabled:e=!1,notEmpty:t=!0})=>{const[n,s]=m.useState(!0),[o,i]=m.useState(!1);Be(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=se(async a=>{i(!0);try{let c;const u=Ns(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(N.Button,{type:"Accent",disabled:e||!n||o,label:o?"Сохраняю":"Сохранить",size:"Small",onClick:l})},Lm=({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=et.create({doc:Rm(e),schema:Dn,plugins:za({schema:Dn,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(Va,{state:a,dispatchTransaction:h=>c(p=>{const b=p==null?void 0:p.apply(h);return b&&s&&s(!!Cu(b)),b}),nodeViews:{image:Ka,video:Ya},children:[g.jsxs("div",{className:"ProseNotesContent",children:[g.jsx(Fm,{schema:Dn}),g.jsx(Ia,{})]}),(t||n)&&g.jsxs("div",{className:"ProseNotesButtons",children:[n&&g.jsx("span",{className:"a small",onClick:f,children:"Отменить"}),t&&g.jsx(Ga,{onSave:d,disabled:!u()})]})]})]}):null},$m=({schema:r})=>{const e=m.useRef(null),[t,n]=m.useState([]),[s,o]=m.useState([]),[i,l]=m.useState(!1);Be(c=>{const u=r.nodes.heading;if(!c||!u||!i)return;const d=[],f=[];for(let h=2;h<7;h++){const b=$t(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=se((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(N.Icons.Heading,{})}),e.current&&g.jsx(N.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(N.Icons.Heading2,{});case 3:return g.jsx(N.Icons.Heading3,{});case 4:return g.jsx(N.Icons.Heading4,{});case 5:return g.jsx(N.Icons.Heading5,{});case 6:return g.jsx(N.Icons.Heading6,{});default:return g.jsx(N.Icons.Heading,{})}},_m=[{id:"left",icon:g.jsx(N.Icons.AlignLeft,{}),text:"Прижать влево"},{id:"right",icon:g.jsx(N.Icons.AlignRight,{}),text:"Прижать вправо"},{id:"center",icon:g.jsx(N.Icons.AlignCenter,{}),text:"Отцентровать"},{id:"justify",icon:g.jsx(N.Icons.AlignJustify,{}),text:"Выровнять по краям"}],qm=({schema:r})=>{const e=m.useRef(null),[t,n]=m.useState(!1),s=se((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(N.Icons.AlignLeft,{})}),e.current&&g.jsx(N.Menu,{parent:e.current,items:_m,isOpen:t,onClose:()=>n(!1),onClick:s,horizontal:"inner-left"})]}):null},Hm=({schema:r,onSave:e,onView:t})=>g.jsxs("div",{className:"MenuBar",children:[g.jsxs("div",{className:"MenuBlock",children:[g.jsx($m,{schema:r}),g.jsx(La,{schema:r})]}),g.jsx($a,{schema:r}),g.jsx(Ha,{schema:r}),g.jsx(_a,{schema:r}),g.jsx(qm,{schema:r}),g.jsx(Ja,{schema:r}),g.jsx(Wa,{}),t&&g.jsx("div",{className:"MenuItem",onClick:()=>t(),children:g.jsx(N.Icons.Eye,{})}),g.jsx("div",{className:"MenuBlock",children:g.jsx(Ga,{onSave:e})})]}),Jm=7,Xa=1,Pn=50,Km=({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<Pn&&(p=Pn-b),y-p<Pn&&(p=y-Pn),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,w=d(x);t(w)},b=y=>{if(!n)return;y.preventDefault(),y.stopPropagation();const x=y.clientX-o,w=d(x);u(w),e(w)};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+Xa-Math.floor(Jm/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))})},Ym=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=se((f,h)=>{if(!f)return;const p=t.node,b=t.getPos()+1,y=Q.get(p),x=f.state.tr;for(let w=0;w<y.height;w++)for(let C=0;C<y.width;){const v=w*y.width+C,O=y.map[v],M=p.nodeAt(O).attrs,D=h.slice(C,C+M.colspan);w&&y.map[v]==y.map[v-y.width]||x.setNodeMarkup(b+O,null,{...M,colwidth:D}),C+=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 D=h.child(M),{colspan:R,colwidth:T}=D.attrs;p=p.concat(Array.isArray(T)?T:Array(R).fill(0))}const b=p.filter(M=>!M).length,y=p.reduce((M,D)=>M+D,0),x=(p.length+1)*Xa,w=Math.max(b?(o.current.offsetWidth-y-x)/b:0,Pn);p=p.map(M=>M||w);const C=p.reduce((M,D)=>M+D,0),v=i.current.offsetWidth-x-16,O=v/C;p=p.map(M=>Math.round(M*O)),p[p.length-1]+=v-p.reduce((M,D)=>M+D,0),a(p)},[t,o,i,(d=i.current)==null?void 0:d.offsetWidth]);const u=se(f=>{np(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(Km,{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(N.Icons.Trash,{})}),g.jsx("tbody",{children:e})]})]})}),Gm=[{id:"toggleHeaderRow",text:"Toggle header row",icon:g.jsx(N.Icons.Heading,{})},{id:"addRowBefore",text:"Insert row before",icon:g.jsx(N.Icons.RowInsertBefore,{})},{id:"addRowAfter",text:"Insert row after",icon:g.jsx(N.Icons.RowInsertAfter,{})},{id:"deleteRow",text:"Delete row",icon:g.jsx(N.Icons.Trash,{})}],Xm=[{id:"toggleHeaderColumn",text:"Toggle header column",icon:g.jsx(N.Icons.Heading,{})},{id:"addColumnBefore",text:"Insert column before",icon:g.jsx(N.Icons.ColumnInsertBefore,{})},{id:"addColumnAfter",text:"Insert column after",icon:g.jsx(N.Icons.ColumnInsertAfter,{})},{id:"deleteColumn",text:"Delete column",icon:g.jsx(N.Icons.Trash,{})}],Qm=[{id:"toggleHeaderCell",text:"Toggle header",icon:g.jsx(N.Icons.Heading,{})},{id:"alignLeft",text:"Horizontal align left",icon:g.jsx(N.Icons.AlignLeft,{})},{id:"alignCenter",text:"Horizontal align center",icon:g.jsx(N.Icons.AlignCenter,{})},{id:"alignRight",text:"Horizontal align Right",icon:g.jsx(N.Icons.AlignRight,{})},{id:"alignTop",text:"Vertical align top",icon:g.jsx(N.Icons.AlignTop,{})},{id:"alignMiddle",text:"Vertical align middle",icon:g.jsx(N.Icons.AlignMiddle,{})},{id:"alignBottom",text:"Vertical align bottom",icon:g.jsx(N.Icons.AlignBottom,{})},{id:"mergeCells",text:"Merge cells",icon:g.jsx(N.Icons.CellsMerge,{})},{id:"splitCell",text:"Split cell",icon:g.jsx(N.Icons.CellsSplit,{})}],Qa=({x:r,y:e,isRowMenuOpen:t,isCellMenuOpen:n,isColumnMenuOpen:s,onRowMenuClose:o,onCellMenuClose:i,onColumnMenuClose:l})=>{const a=se((c,u)=>{if(c){switch(u.id){case"toggleHeaderRow":Uh(c.state,c.dispatch);break;case"addRowBefore":_h(c.state,c.dispatch);break;case"addRowAfter":qh(c.state,c.dispatch);break;case"deleteRow":Jh(c.state,c.dispatch);break;case"toggleHeaderColumn":Zh(c.state,c.dispatch);break;case"addColumnBefore":Bh(c.state,c.dispatch);break;case"addColumnAfter":Fh(c.state,c.dispatch);break;case"deleteColumn":$h(c.state,c.dispatch);break;case"mergeCells":Yh(c.state,c.dispatch);break;case"splitCell":Gh(c.state,c.dispatch);break;case"toggleHeaderCell":ep(c.state,c.dispatch);break;case"alignLeft":Gt("halign","left")(c.state,c.dispatch);break;case"alignCenter":Gt("halign","center")(c.state,c.dispatch);break;case"alignRight":Gt("halign","right")(c.state,c.dispatch);break;case"alignTop":Gt("valign","top")(c.state,c.dispatch);break;case"alignMiddle":Gt("valign","middle")(c.state,c.dispatch);break;case"alignBottom":Gt("valign","bottom")(c.state,c.dispatch);break}o(),i(),l(),c.focus()}});return g.jsxs(g.Fragment,{children:[g.jsx(N.Menu,{x:r,y:e,items:Gm,isOpen:t,onClose:o,onClick:a}),g.jsx(N.Menu,{x:r,y:e,items:Qm,isOpen:n,onClose:i,onClick:a}),g.jsx(N.Menu,{x:r,y:e,items:Xm,isOpen:s,onClose:l,onClick:a})]})},Ua=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 w=C=>{o.current!==C.target&&(d(!1),h(!1),b(!1))};return document.addEventListener("contextmenu",w,!0),()=>document.removeEventListener("contextmenu",w,!0)},[]);const y=w=>{w.preventDefault(),w.stopPropagation(),d(!1),h(!1),b(!1),l(w.clientX),c(w.clientY);const C=w.currentTarget.getBoundingClientRect();w.clientY<C.y?b(!0):w.clientX<C.x?d(!0):h(!0)},x=w=>{d(!1),h(!1),b(!1),l(w.clientX),c(w.clientY);const C=w.currentTarget.getBoundingClientRect();if(w.clientY<C.y)b(!0);else if(w.clientX<C.x)d(!0);else return;w.preventDefault(),w.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:w=>{o.current=w,s&&(typeof s=="function"?s(w):s.current=w)},children:[e,g.jsx(Qa,{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:w=>{o.current=w,s&&(typeof s=="function"?s(w):s.current=w)},children:[e,g.jsx(Qa,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>d(!1),isCellMenuOpen:f,onCellMenuClose:()=>h(!1),isColumnMenuOpen:p,onColumnMenuClose:()=>b(!1)})]})}),Um=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 D=M.scrollLeft,R=M.clientWidth,T=M.scrollWidth;c(D>0),d(D<T-R*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]),Be(M=>{if(!M||t.node.childCount>0)return;const D=M.state.tr,R=t.getPos(),T=t.node.nodeSize;M.dispatch(D.delete(R,R+T))},[t]);const x=se(M=>{if(!M)return;const D=t.getPos(),R=t.node.nodeSize;M.dispatch(M.state.tr.delete(D,D+R))}),w=()=>{l(!0)},C=M=>{y(M.currentTarget)},v=(M,D)=>{if(M.stopPropagation(),!o.current)return;const R=o.current.clientWidth;let T=o.current.scrollLeft+D*R;o.current.scrollLeft=T};return g.jsxs("div",{ref:s,...n,className:"carousel",children:[g.jsx("div",{className:"carousel-list",ref:o,onScroll:C,children:e}),g.jsxs("div",{className:"carousel-buttons",children:[g.jsx("div",{onClick:x,className:"text-button",children:"Удалить карусель"}),g.jsx("div",{onClick:w,children:g.jsx(N.Icons.Plus,{})})]}),a&&g.jsx("div",{className:"carousel-prev",onClick:M=>v(M,-1),children:g.jsx(N.Icons.ChevronLeft,{})}),u&&g.jsx("div",{className:"carousel-next",onClick:M=>v(M,1),children:g.jsx(N.Icons.ChevronRight,{})}),g.jsx(qa,{pos:f,isOpen:i,onClose:()=>l(!1)})]})}),Zm=({content:r,onSave:e,onView:t,onChange:n,onUpload:s})=>{const[o,i]=m.useState();m.useEffect(()=>{let a;if(r)try{a=ye.fromJSON(Ye,JSON.parse(r))}catch(d){console.error(`Can not parse Prose format: ${d}`)}let c=et.create({doc:a,schema:Ye,plugins:za({schema:Ye,upload:s})});const u=Ns(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(Va,{state:o,dispatchTransaction:a=>i(c=>{const u=c==null?void 0:c.apply(a);return u&&n&&n(!0),u}),nodeViews:{image:Ka,video:Ya,table:Ym,table_header:Ua,table_cell:Ua,carousel:Um},children:[g.jsx(Hm,{schema:Ye,onSave:l,onView:t}),g.jsx(Ia,{})]})}):null},eg=({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(Y,{node:n},s))})},tg=({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)},ng=({node:r,className:e})=>g.jsx("div",{className:e,children:Array.isArray(r.content)&&r.content.map((t,n)=>g.jsx(Y,{node:t},n))}),rg=({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,w,C;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=`${br}/files/${d}`),f||(f=Ks),n(f),o((y=r.attrs)!=null&&y.alt?`${(x=r.attrs)==null?void 0:x.alt}`:""),l((w=r.attrs)!=null&&w.title?`${(C=r.attrs)==null?void 0:C.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(N.Icons.Minimize,{}):g.jsx(N.Icons.Maximize,{})})]}):null},sg=({node:r})=>g.jsx("blockquote",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(Y,{node:e},t))}),og=50,ig=({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(og))}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(Y,{node:n},s))})]})},lg=({node:r})=>g.jsx("tr",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(Y,{node:e},t))}),ag=({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(Y,{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(Y,{node:c},u))})},cg=({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(Y,{node:t},n))});case 2:return g.jsx("h2",{children:r.content.map((t,n)=>g.jsx(Y,{node:t},n))});case 3:return g.jsx("h3",{children:r.content.map((t,n)=>g.jsx(Y,{node:t},n))});case 4:return g.jsx("h4",{children:r.content.map((t,n)=>g.jsx(Y,{node:t},n))});case 5:return g.jsx("h5",{children:r.content.map((t,n)=>g.jsx(Y,{node:t},n))});case 6:return g.jsx("h6",{children:r.content.map((t,n)=>g.jsx(Y,{node:t},n))});default:return g.jsx("h2",{children:r.content.map((t,n)=>g.jsx(Y,{node:t},n))})}},ug=({node:r})=>Array.isArray(r.content)?r.type==="bullet_list"?g.jsx("ul",{children:r.content.map((e,t)=>g.jsx(Y,{node:e},t))}):g.jsx("ol",{children:r.content.map((e,t)=>g.jsx(Y,{node:e},t))}):null,dg=({node:r})=>g.jsx("li",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(Y,{node:e},t))}),fg=({node:r})=>g.jsx("pre",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(Y,{node:e},t))}),hg=()=>g.jsx("hr",{}),pg=({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=>{En(x)?(t(x),s(x)):On(x)?(t(x),i(x)):Nn(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:Ys}),c&&g.jsx("div",{className:"image-title",children:c})]})},mg=()=>g.jsx("br",{}),gg=({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,w=y.clientWidth,C=y.scrollWidth;i(x>w/2),a(x<C-w*1.5),u(Math.round(x/w+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 w=e.current.clientWidth;let C=e.current.scrollLeft+x*w;e.current.scrollLeft=C};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(yg,{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(N.Icons.Minimize,{}):g.jsx(N.Icons.Maximize,{})}),o&&g.jsx("div",{className:"carousel-prev",onClick:y=>b(y,-1),children:g.jsx(N.Icons.ChevronLeft,{})}),l&&g.jsx("div",{className:"carousel-next",onClick:y=>b(y,1),children:g.jsx(N.Icons.ChevronRight,{})})]}):null},yg=({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=`${br}/files/${a}`),c||(c=Ks),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})]})},Y=({node:r,className:e})=>r?(n=>{switch(n.type){case"doc":return g.jsx(ng,{node:n,className:e});case"list_item":return g.jsx(dg,{node:n});case"bullet_list":case"ordered_list":return g.jsx(ug,{node:n});case"image":return g.jsx(rg,{node:n});case"video":return g.jsx(pg,{node:n});case"text":return g.jsx(tg,{node:n});case"table":return g.jsx(ig,{node:n});case"table_row":return g.jsx(lg,{node:n});case"table_cell":case"table_header":return g.jsx(ag,{node:n});case"heading":return g.jsx(cg,{node:n});case"code_block":return g.jsx(fg,{node:n});case"paragraph":return g.jsx(eg,{node:n});case"blockquote":return g.jsx(sg,{node:n});case"carousel":return g.jsx(gg,{node:n});case"horizontal_rule":return g.jsx(hg,{});case"hard_break":return g.jsx(mg,{});default:return g.jsx("span",{className:"unknown_node_type",children:n.type})}})(r):null,bg=({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(Y,{node:e,className:"ProseViewer"})},xg=({content:r})=>{const e=m.useRef(null),[t,n]=m.useState(!1);return m.useEffect(()=>{var s;try{n(!1);const o=ye.fromJSON(Ye,JSON.parse(r)),i=$e.fromSchema(Ye).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:"ОШИБКА"})})},kg='{"type":"doc","content":[{"type":"paragraph","attrs":{"align":null},"content":[{"type":"text","text":"@"}]}]}',wg='{"type":"doc","content":[{"type":"paragraph","attrs":{"align":null},"content":[{"type":"text","text":"При парсинге документа произошла ошибка"}]}]}',Sg=(r,e)=>{if(!r)return kg;try{const t=new DOMParser().parseFromString(r,"text/html"),n=_n.fromSchema(e?Dn:Ye).parse(t).toJSON();return JSON.stringify(n)}catch(t){return console.error(`Can not convert html content to prose format: ${t}`),wg}};K.DOM=xg,K.Editor=Zm,K.Notes=Lm,K.Viewer=bg,K.htmlToProse=Sg,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})});
|
|
66
63
|
//# sourceMappingURL=prose-editor.umd.js.map
|