@alxgrn/prose-editor 0.0.43 → 0.0.45

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.
@@ -1,5 +1,5 @@
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={};/**
1
+ (function(J,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):(J=typeof globalThis<"u"?globalThis:J||self,m(J.ProseEditor={},J.React,J.ReactDOM,J["@alxgrn/telefrag-ui"]))})(this,function(J,m,Le,N){"use strict";var Tg=Object.defineProperty;var Ag=(J,m,Le)=>m in J?Tg(J,m,{enumerable:!0,configurable:!0,writable:!0,value:Le}):J[m]=Le;var $=(J,m,Le)=>Ag(J,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 xc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Sr={exports:{}},rn={};/**
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 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={};/**
10
+ */var oo;function kc(){if(oo)return rn;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 rn.Fragment=e,rn.jsx=t,rn.jsxs=t,rn}var sn={};/**
11
11
  * @license React
12
12
  * react-jsx-runtime.development.js
13
13
  *
@@ -15,35 +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 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(`
18
+ */var io;function wc(){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===Eg?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(zn===0){rc=console.log,sc=console.info,oc=console.warn,ic=console.error,lc=console.group,ac=console.groupCollapsed,cc=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})}zn++}function o(){if(zn--,zn===0){var k={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:It({},k,{value:rc}),info:It({},k,{value:sc}),warn:It({},k,{value:oc}),error:It({},k,{value:ic}),group:It({},k,{value:lc}),groupCollapsed:It({},k,{value:ac}),groupEnd:It({},k,{value:cc})})}0>zn&&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]||"",uc=-1<P.stack.indexOf(`
19
19
  at`)?" (<anonymous>)":-1<P.stack.indexOf("@")?"@unknown:0:0":""}return`
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:
20
+ `+Zs+k+uc}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 wr=Xe}Reflect.construct(k,[],mt)}else{try{mt.call()}catch(Xe){wr=Xe}k.call(mt.prototype)}}else{try{throw Error()}catch(Xe){wr=Xe}(mt=k())&&typeof mt.catch=="function"&&mt.catch(function(){})}}catch(Xe){if(Xe&&wr&&typeof Xe.stack=="string")return[Xe.stack,wr.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],en=z[1];if(Ge&&en){var me=Ge.split(`
21
+ `),Vt=en.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 jn=`
23
+ `+me[_].replace(" at new "," at ");return k.displayName&&jn.includes("<anonymous>")&&(jn=jn.replace("<anonymous>",k.displayName)),typeof k=="function"&&to.set(k,jn),jn}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(nc.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(){dc||(dc=!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 fc[k]||(fc[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===Ng||typeof k=="object"&&k!==null&&(k.$$typeof===Qs||k.$$typeof===Ae||k.$$typeof===G||k.$$typeof===T||k.$$typeof===ce||k.$$typeof===Og||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(nc.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}",hc[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,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=`
28
+ <%s key={someKey} {...props} />`,B,z,Ge,z),hc[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 en in A)en!=="key"&&(P[en]=A[en])}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!==Dg){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=tc&&k[tc]||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),!pc[A])){pc[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
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 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&&gt(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&&gt(yt(o,Bn(r,e,s+1)),l),sn(e,t,s,l),i&&gt(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,`
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"),Ng=Symbol.for("react.offscreen"),tc=Symbol.iterator,Eg=Symbol.for("react.client.reference"),Pt=C.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,nc=Object.prototype.hasOwnProperty,It=Object.assign,Og=Symbol.for("react.client.reference"),Us=Array.isArray,zn=0,rc,sc,oc,ic,lc,ac,cc;n.__reactDisabledLog=!0;var Zs,uc,eo=!1,to=new(typeof WeakMap=="function"?WeakMap:Map),Dg=Symbol.for("react.client.reference"),dc,fc={},hc={},pc={};sn.Fragment=M,sn.jsx=function(k,A,P,B,ue){return p(k,A,P,!1,B,ue)},sn.jsxs=function(k,A,P,B,ue){return p(k,A,P,!0,B,ue)}}()),sn}process.env.NODE_ENV==="production"?Sr.exports=kc():Sr.exports=wc();var g=Sr.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 Bn(0,e);if(e==this.size)return Bn(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?Bn(n+1,i):Bn(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 Cr={index:0,offset:0};function Bn(r,e){return Cr.index=r,Cr.offset=e,Cr}function Fn(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(!Fn(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!Fn(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&&Fn(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 Ln 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 Sc(r,e,t){if(t.openStart>r.depth)throw new Ln("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new Ln("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}=Cc(t,r);return yt(o,po(r,i,l,e,n))}else return yt(o,$n(r,e,n))}function ho(r,e){if(!e.type.compatibleContent(r.type))throw new Ln("Cannot join "+e.type.name+" onto "+r.type.name)}function Mr(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 on(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&&gt(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&&Mr(r,e,s+1),i=n.depth>s&&Mr(t,n,s+1),l=[];return on(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&&gt(yt(o,$n(r,e,s+1)),l),on(e,t,s,l),i&&gt(yt(i,$n(t,n,s+1)),l)),on(n,null,s,l),new S(l)}function $n(r,e,t){let n=[];if(on(null,r,t,n),r.depth>t){let s=Mr(r,e,t+1);gt(yt(s,$n(r,e,t+1)),n)}return on(e,null,t,n),new S(n)}function Cc(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 ln{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 Wn(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 ln(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 Mc);let s=n.elts[n.i]=ln.resolve(e,t);return n.i=(n.i+1)%vc,s}}class Mc{constructor(){this.elts=[],this.i=0}}const vc=12,mo=new WeakMap;class Wn{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 Nc=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&&Fn(this.attrs,t||e.defaultAttrs||Nc)&&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 Sc(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 ln.resolveCached(this,e)}resolveNoCache(e){return ln.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 _n 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 _n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new _n(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 Ec(e,t);if(n.next==null)return bt.empty;let s=yo(n);n.next&&n.err("Unexpected trailing text");let o=Vc(Ic(s));return Rc(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 Ec{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(Oc(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Oc(r){let e=[];do e.push(Dc(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Dc(r){let e=Pc(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=Tc(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 Tc(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 Ac(r,e){let t=r.nodeTypes,n=t[e];if(n)return[n];let s=[];for(let o in t){let i=t[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&r.err("No node type or group '"+e+"' found"),s}function Pc(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=Ac(r,r.next).map(t=>(r.inline==null?r.inline=t.isInline:r.inline!=t.isInline&&r.err("Mixing inline and block content"),{type:"name",value:t}));return r.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Ic(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 Vc(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 Rc(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 jc(r,n,e[n]);return t}let vo=class mc{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 mc(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 zc(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 jc{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?zc(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class qn{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 qn(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 Hn{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=qn.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 _n(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 Bc(r){return r.tag!=null}function Fc(r){return r.style!=null}let Jn=class no{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(s=>{if(Bc(s))this.tags.push(s);else if(Fc(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(Wc(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},Lc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Oo={ol:!0,ul:!0},an=1,vr=2,Kn=4;function Do(r,e,t){return e!=null?(e?an:0)|(e==="full"?vr:0):r&&r.whitespace=="pre"?an|vr:t&-5}class Yn{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&Kn?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&an)){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?Kn:0);s?o=new Yn(s.type,s.attrs,F.none,!0,t.topMatch||s.type.contentMatch,i):n?o=new Yn(null,null,F.none,!0,null,i):o=new Yn(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&vr?"full":this.localPreserveWS||(s.options&an)>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&&$c(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:Lc.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&Kn&&i.content.length==0&&(l|=Kn);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 Yn(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|=an)}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 $c(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 Wc(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=Nr(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}=Gn(Nr(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&&Gn(Nr(n),s(e,t),null,e.attrs)}static renderSpec(e,t,n=null,s){return Gn(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 Nr(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=qc(r)),e}function qc(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 Gn(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}=Gn(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 Hc(r,e){return r+e*zo}function jo(r){return r&Ro}function Jc(r){return(r-(r&Ro))/zo}const Bo=1,Fo=2,Xn=4,Lo=8;class Er{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|Xn))>0}get deletedAfter(){return(this.delInfo&(Fo|Xn))>0}get deletedAcross(){return(this.delInfo&Xn)>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+Jc(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:Hc(l/3,e-a),b=e==a?Fo:e==d?Bo:Xn;return(t<0?e!=a:e!=d)&&(b|=Lo),new Er(h,b,p)}s+=u-c}return n?e+s:new Er(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 cn{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 cn(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 cn;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 Er(e,s,null)}}const Or=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=Or[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 Or)throw new RangeError("Duplicate use of step JSON ID "+e);return Or[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,n,s){try{return K.ok(e.replace(t,n,s))}catch(o){if(o instanceof Ln)return K.fail(o.message);throw o}}}function Dr(r,e,t){let n=[];for(let s=0;s<r.childCount;s++){let o=r.child(s);o.content.size&&(o=o.copy(Dr(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(Dr(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 K.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(Dr(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return K.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 K.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return K.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 K.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return K.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&&Tr(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.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&&(Tr(e,this.from,this.gapFrom)||Tr(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 n=this.slice.insertAt(this.insert,t.content);return n?K.fromReplace(e,this.from,this.to,n):K.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 Tr(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 Kc(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 Yc(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 qn){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 Ar(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 Gc(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function un(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||!Gc(s,o,i))break}return null}function Xc(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 Pr(r,e,t=null,n=r){let s=Qc(r,e),o=s&&Uc(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 Qc(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 Uc(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 Zc(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 eu(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)&&tu(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),Ar(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 tu(r,e,t){let n=r.resolve(e),s=n.index();return n.parent.canReplaceWith(s,s+1,t)}function nu(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 ru(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 su(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&&su(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 ou(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&&Ar(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 iu(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 Ir(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 lu(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 lu{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=Vr(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=Vr(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=Vr(e,t);if(s.childCount<=1&&t>0){let o=e.size-t<=t+s.size;this.unplaced=new E(dn(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new E(dn(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=fn(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(dn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new E(dn(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||!Rr(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=Rr(e,t,s,n,o);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Rr(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=fn(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=fn(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=fn(this.placed,this.frontier.length,t))}}function dn(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(dn(r.firstChild.content,e-1,t)))}function fn(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(fn(r.lastChild.content,e-1,t)))}function Vr(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 Rr(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&&!au(t,o.content,i)?l:null}function au(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function cu(r){return r.spec.defining||r.spec.definingForContent}function uu(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=cu(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 du(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let s=iu(r.doc,e,n.type);s!=null&&(e=t=s)}r.replaceRange(e,t,new E(S.from(n),0,0))}function fu(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 K.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 K.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 hn 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 K.ok(n)}getMap(){return be.empty}invert(e){return new hn(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 hn(t.attr,t.value)}}oe.jsonID("docAttr",hn);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 cn}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=Ir(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 uu(this,e,t,n),this}replaceRangeWith(e,t,n){return du(this,e,t,n),this}deleteRange(e,t){return fu(this,e,t),this}lift(e,t){return Xc(this,e,t),this}join(e,t=1){return ou(this,e,t),this}wrap(e,t){return Zc(this,e,t),this}setBlockType(e,t=e,n,s=null){return eu(this,e,t,n,s),this}setNodeMarkup(e,t,n=null,s){return nu(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 hn(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 ru(this,e,t,n),this}addMark(e,t,n){return Kc(this,e,t,n),this}removeMark(e,t,n){return Yc(this,e,t,n),this}clearIncompatible(e,t,n){return Ar(this,e,t,n),this}}const zr=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=zr[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 zr)throw new RangeError("Duplicate use of selection JSON ID "+e);return zr[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 Qn(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 Qn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Qn(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 jr(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 jr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Qn(n,n):new jr(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 hu}}V.jsonID("all",xe);const hu={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 pu 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 pn{constructor(e,t,n){this.name=e,this.init=oi(t.init,n),this.apply=oi(t.apply,n)}}const mu=[new pn("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new pn("selection",{init(r,e){return r.selection||V.atStart(e.doc)},apply(r){return r.selection}}),new pn("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new pn("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class Br{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=mu.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 pn(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 pu(this)}static create(e){let t=new Br(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 Br(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 Br(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 Fr=Object.create(null);function li(r){return r in Fr?r+"$"+ ++Fr[r]:(Fr[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 Un=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<Un&&this.leafAppend(e)||this.length<Un&&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 gu(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<=Un)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Un)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 gu=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 yu=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>xu&&(l=bu(l,c),i-=c),new Oe(l.append(o),i)}remapping(e,t){let n=new cn;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()>yu&&(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 bu(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 xu=20;function ku(r,e,t,n){let s=t.getMeta(rt),o;if(s)return s.historyState;t.getMeta(Cu)&&(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,Zn(e)),r.undone,ci(t.mapping.maps),r.prevTime,r.prevComposition):new nt(r.done,r.undone.addTransform(t,void 0,n,Zn(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||!wu(t,r.prevRanges)),c=i?Lr(r.prevRanges,t.mapping):ci(t.mapping.maps);return new nt(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,Zn(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),Lr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new nt(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),Lr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function wu(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 Lr(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 Su(r,e,t){let n=Zn(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 $r=!1,ui=null;function Zn(r){let e=r.plugins;if(ui!=e){$r=!1,ui=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){$r=!0;break}}return $r}const rt=new tt("history"),Cu=new tt("closeHistory");function Mu(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 ku(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,s=n=="historyUndo"?Wr:n=="historyRedo"?er: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=Su(s,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const Wr=di(!1,!0),er=di(!0,!0);function vu(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:"'"},tr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Nu=typeof navigator<"u"&&/Mac/.test(navigator.platform),Eu=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),tr[ee]=String.fromCharCode(ee);for(var _r in st)tr.hasOwnProperty(_r)||(tr[_r]=st[_r]);function Ou(r){var e=Nu&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||Eu&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?tr: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 Du=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Tu(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))Du?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 Au(r){let e=Object.create(null);for(let t in r)e[Tu(t)]=r[t];return e}function qr(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 Hr(r){return new Ie({props:{handleKeyDown:Jr(r)}})}function Jr(r){let e=Au(r);return function(t,n){let s=Ou(n),o,i=e[qr(s,n)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(n.shiftKey){let l=e[qr(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[qr(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 Pu(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const Iu=(r,e,t)=>{let n=Pu(r,t);if(!n)return!1;let s=hi(n);if(!s){let i=n.blockRange(),l=i&&un(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=Ir(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 Vu=(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 Ru(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const zu=(r,e,t)=>{let n=Ru(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=Ir(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},ju=(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},Bu=(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},Kr=(r,e)=>{let{$from:t,$to:n}=r.selection,s=t.blockRange(n),o=s&&un(s);return o==null?!1:(e&&e(r.tr.lift(s,o).scrollIntoView()),!0)},Fu=(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 Yr(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=Yr(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},Lu=(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=Yr(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},$u=(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&&un(n);return s==null?!1:(e&&e(r.tr.lift(n,s).scrollIntoView()),!0)};function Wu(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=Yr(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=Wu(),Gr=(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)},qu=(r,e)=>(e&&e(r.tr.setSelection(new xe(r.doc))),!0);function Hu(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&&Hu(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&&un(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 Ju=bi(-1),Ku=bi(1);function xi(r,e=null){return function(t,n){let{$from:s,$to:o}=t.selection,i=s.blockRange(o),l=i&&Pr(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 Yu(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||!Yu(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 nr(...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 Xr=nr(fi,Iu,Vu),ki=nr(fi,zu,ju);const We={Enter:nr(Fu,Lu,$u,_u),"Mod-Enter":gi,Backspace:Xr,"Mod-Backspace":Xr,"Shift-Backspace":Xr,Delete:ki,"Mod-Delete":ki,"Mod-a":qu},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":Ju,"Ctrl-e":Ku};for(let r in We)wi[r]=We[r];const Gu=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?wi:We;function Xu(r={}){return new Ie({view(e){return new Qu(e,r)}})}class Qu{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 Qr=null;const _e=function(r,e,t){let n=Qr||(Qr=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},Uu=function(){Qr=null},kt=function(r,e,t,n){return t&&(Si(r,e,t,n,-1)||Si(r,e,t,n,1))},Zu=/^(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||mn(r)||Zu.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 ed(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&&!mn(r))e=te(r),r=r.parentNode;else return null}}function td(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&&!mn(r))e=te(r)+1,r=r.parentNode;else return null}}function nd(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 mn(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 rr=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 rd(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function sd(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||"",Ur=/Edge\/(\d+)/.exec(ot),Mi=/MSIE \d/.exec(ot),Zr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ot),ge=!!(Mi||Zr||Ur),it=Mi?document.documentMode:Zr?+Zr[1]:Ur?+Ur[1]:0,De=!ge&&/gecko\/(\d+)/i.test(ot);De&&+(/Firefox\/(\d+)/.exec(ot)||[0,0])[1];const es=!ge&&/Chrome\/(\d+)/.exec(ot),le=!!es,vi=es?+es[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),od=Re?/Win/.test(Re.platform):!1,qe=/Android \d/.test(ot),gn=!!Ci&&"webkitFontSmoothing"in Ci.documentElement.style,id=gn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ld(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 ad(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?ld(o):ad(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 cd(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 ud({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 dd(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?fd(t,s):!t||n&&t.nodeType==1?{node:r,offset:o}:Di(t,s)}function fd(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&&ts(e,o))return{node:r,offset:s+(e.left>=(o.left+o.right)/2?1:0)}}return{node:r,offset:0}}function ts(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function hd(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function pd(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 md(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(ts(e,c))return Ti(i,e,c)}}if((o=(o+1)%n)==s)break}return r}function gd(r,e){let t=r.dom.ownerDocument,n,s=0,o=sd(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(!ts(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=hd(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;gn&&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=md(r,n,s,e))}l==null&&(l=pd(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 yd=/[\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=gn||De;if(n.nodeType==3)if(i&&(yd.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 yn(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++,yn(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 ns(a.getBoundingClientRect(),!1)}if(o==null&&s<Se(n)){let a=n.childNodes[s];if(a.nodeType==1)return ns(a.getBoundingClientRect(),!0)}return ns(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 yn(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 yn(lt(c,-1),!0)}return yn(lt(n.nodeType==3?_e(n):n,-t),t>=0)}function yn(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 ns(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 bd(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 xd=/[\u0590-\u08ac]/;function kd(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?!xd.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 wd(r,e,t){return Vi==e&&Ri==t?zi:(Vi=e,Ri=t,zi=t=="up"||t=="down"?bd(r,e,t):kd(r,e,t))}const Me=0,ji=1,St=2,ze=3;let bn=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 bn{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}},Sd=class extends bn{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}},sr=class ro extends bn{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=ss(o,t,i,n)),e>0&&(o=ss(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 gc extends bn{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 Cd(e,t,n,s,u,d||null,f,c,o,i+1):t.isText?new Li(e,t,n,s,u,f,o):new gc(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)&&or(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 vd(this,i&&i.node,e);Od(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&&Dd(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=Td(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 Sd(this,o,t,s);e.input.compositionNodes.push(i),this.children=ss(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(or(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=_i(this.dom,this.nodeDOM,rs(this.outerDeco,this.node,t),rs(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 yc 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 yc(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 bn{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"}},Cd=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 sr){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 xn=function(r){r&&(this.nodeName=r)};xn.prototype=Object.create(null);const Ct=[new xn];function rs(r,e,t){if(r.length==0)return Ct;let n=t?Ct[0]:new xn,s=[n];for(let o=0;o<r.length;o++){let i=r[o].type.attrs;if(i){i.nodeName&&s.push(n=new xn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(n=new xn(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}Md(s,l||Ct[0],i)}return s}function Md(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,rs(e,t,r.nodeType!=1))}function or(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 vd{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Nd(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let s=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;s<i&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=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=sr.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&&or(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)||!or(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 sr;)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 Nd(r,e){let t=e,n=t.children.length,s=r.childCount,o=new Map,i=[];e:for(;s>0;){let l;for(;;)if(n){let c=t.children[n-1];if(c instanceof sr)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 Ed(r,e){return r.type.side-e.type.side}function Od(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(Ed);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 Dd(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 Td(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 ss(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 is(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(rr(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&&nd(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=as(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)Pd(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&&Ad(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 ls(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return ls(s);if(o)return ls(o)}}function ls(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 Ad(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 Pd(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 as(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 Id(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 cs(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=cs(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)):gn?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=cs(r.state,e);return s?at(r,s):!1}}}function ir(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function kn(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?Vd(r):Rd(r)}function Vd(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<ir(t)&&kn(t.childNodes[n],-1)&&(i=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(kn(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&&kn(l,-1);)s=t.parentNode,o=te(l),l=l.previousSibling;if(l)t=l,n=ir(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}i?us(r,t,n):s&&us(r,s,o)}function Rd(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let s=ir(t),o,i;for(;;)if(n<s){if(t.nodeType!=1)break;let l=t.childNodes[n];if(kn(l,1))o=t,i=++n;else break}else{if(tl(t))break;{let l=t.nextSibling;for(;l&&kn(l,1);)o=l.parentNode,i=te(l)+1,l=l.nextSibling;if(l)t=l,n=0,s=ir(t);else{if(t=t.parentNode,t==r.dom)break;n=s=0}}}o&&us(r,o,i)}function tl(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function zd(r,e){for(;r&&e==r.childNodes.length&&!mn(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 jd(r,e){for(;r&&!e&&!mn(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 us(r,e,t){if(e.nodeType!=3){let o,i;(i=zd(e,t))?(e=i,t=0):(o=jd(e,t))&&(e=o,t=o.nodeValue.length)}let n=r.domSelection();if(!n)return;if(rr(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||od)&&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=cs(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 Bd(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 Fd(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function Ld(r,e){let t=e.keyCode,n=Fd(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 Bd(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 ds(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
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:{}};/*!
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=qd(t),gn&&Hd(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")||Jn.fromSchema(r.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!$d.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Jd(ul(l,+u[1],+u[2]),u[4]);else if(l=E.maxOpen(Wd(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 $d=/^(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 Wd(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 fs(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=fs(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(fs(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new E(fs(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 hs=null;function _d(r){let e=window.trustedTypes;return e?(hs||(hs=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),hs.createHTML(r)):r}function qd(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 Hd(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 Jd(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={},Kd={touchstart:!0,touchmove:!0};class Yd{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 Gd(r){for(let e in fe){let t=fe[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Qd(r,n)&&!ms(r,n)&&(r.editable||!(n.type in he))&&t(r,n)},Kd[e]?{passive:!0}:void 0)}de&&r.dom.addEventListener("input",()=>null),ps(r)}function ct(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Xd(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 ps(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>ms(r,n))})}function ms(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Qd(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 Ud(r,e){!ms(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))||Ld(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 lr(r){return{left:r.clientX,top:r.clientY}}function Zd(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function gs(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 ef(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 tf(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 nf(r,e,t,n,s){return gs(r,"handleClickOn",e,t,n)||r.someProp("handleClick",o=>o(r,e,n))||(s?tf(r,t):ef(r,t))}function rf(r,e,t,n){return gs(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",s=>s(r,e,n))}function sf(r,e,t,n){return gs(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",s=>s(r,e,n))||of(r,t,n)}function of(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 ys(r){return ar(r)}const pl=Ce?"metaKey":"ctrlKey";fe.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=ys(r),s=Date.now(),o="singleClick";s-r.input.lastClick.time<500&&Zd(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(lr(t));i&&(o=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new lf(r,i,t,!!n)):(o=="doubleClick"?rf:sf)(r,i.pos,i.inside,t)?t.preventDefault():ct(r,"pointer"))};class lf{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(lr(e))),this.updateAllowDefault(e),this.allowDefault||!t?ct(this.view,"pointer"):nf(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(),ys(r),ct(r,"pointer")},fe.touchmove=r=>{r.input.lastTouch=Date.now(),ct(r,"pointer")},fe.contextmenu=r=>ys(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 af=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(),ar(r,!0),r.markCursor=null;else if(ar(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,af)},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(()=>ar(r),e))}function yl(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=uf());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function cf(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=ed(e.focusNode,e.focusOffset),n=td(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 uf(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function ar(r,e=!1){if(!(qe&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),yl(r),e||r.docView&&r.docView.dirty){let t=is(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 df(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 wn=ge&&it<15||_t&&id<604;fe.copy=he.cut=(r,e)=>{let t=e,n=r.state.selection,s=t.type=="cut";if(n.empty)return;let o=wn?null:t.clipboardData,i=n.content(),{dom:l,text:a}=ds(r,i);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):df(r,l),s&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ff(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function hf(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?Sn(r,n.value,null,s,e):Sn(r,n.textContent,n.innerHTML,s,e)},50)}function Sn(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=ff(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=wn?null:t.clipboardData,s=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&Sn(r,bl(n),n.getData("text/html"),s,t)?t.preventDefault():hf(r,t)};class xl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const pf=Ce?"altKey":"ctrlKey";function kl(r,e){let t=r.someProp("dragCopies",n=>!n(e));return t??!e[pf]}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(lr(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}=ds(r,l);(!t.dataTransfer.files.length||!le||vi>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(wn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",wn||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(lr(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),wn?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(as(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 Cn(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 cr{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 cr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Cn(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&&Cn(this.attrs,e.attrs)&&Cn(this.spec,e.spec)}static is(e){return e.type instanceof ut}destroy(){}}class bs{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 bs&&Cn(this.attrs,e.attrs)&&Cn(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 cr(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 bs(n,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof ut}get widget(){return this.type instanceof cr}}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?ur(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?mf(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,ur(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 xs(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=xs;const ae=L.empty;let wl=class tn{constructor(e){this.members=e}map(e,t){const n=this.members.map(s=>s.map(e,t,Mt));return tn.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 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++){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?xs(n?t:t.sort(vt)):Yt}static from(e){switch(e.length){case 0:return ae;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 mf(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=gf(l,r,e,t,s,o,i),u=ur(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 gf(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 ur(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=ur(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 xs(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 ks(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 yf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},bf=ge&&it<=11;class xf{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 kf{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new xf,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()}),bf&&(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,yf)),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||Cf(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&&rr(n)&&(c=is(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),wf(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 wf(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 Sf(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 Cf(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 Mf(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}],rr(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")||Jn.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:vf,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 vf(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 Nf=/^(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 Ef(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=is(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=Mf(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=Tf(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&&!Nf.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&&Df(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=Of(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:as(r,e.resolve(t.anchor),e.resolve(t.head))}function Of(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 Df(r,e,t,n,s){if(t-e<=s.pos-n.pos||ws(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(ws(o,!0,!0));return!i.parent.isTextblock||i.pos>t||ws(i,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(i.parent.content)}function ws(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 Tf(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 Af{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 Yd,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),ks(this),this.dom,this),this.domObserver=new kf(this,(n,s,o,i)=>Ef(this,n,s,o,i)),this.domObserver.start(),Gd(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&&ps(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);If(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ps(this),this.editable=Il(this),Pl(this);let a=ks(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&&cd(this);if(i){this.domObserver.stop();let h=d&&(ge||le)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Pf(s.selection,e.selection);if(d){let p=le?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=cf(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())&&Id(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&&ud(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&&dd(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 gd(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 wd(this,t||this.state,e)}pasteHTML(e,t){return Sn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Sn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return ds(this,e)}destroy(){this.docView&&(Xd(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ks(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Uu())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ud(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&&rd(this.dom.ownerDocument)==this.dom&&Sf(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 Pf(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 If(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 Ss(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Vf(e)||!Rf(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 Ss{constructor(e){this.pos=e}map(e){return new Ss(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return q.valid(t)?new q(t):V.near(t)}}function Vf(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 Rf(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 zf(){return new Ie({props:{decorations:Lf,createSelectionBetween(r,e,t){return e.pos==t.pos&&q.valid(t)?new q(t):null},handleClick:Bf,handleKeyDown:jf,handleDOMEvents:{beforeinput:Ff}}})}const jf=Jr({ArrowLeft:dr("horiz",-1),ArrowRight:dr("horiz",1),ArrowUp:dr("vert",-1),ArrowDown:dr("vert",1)});function dr(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 Bf(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 Ff(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 Lf(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 $f=["ol",0],Wf=["ul",0],_f=["li",0],qf={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?$f:["ol",{start:r.attrs.order},0]}},Hf={parseDOM:[{tag:"ul"}],toDOM(){return Wf}},Jf={parseDOM:[{tag:"li"}],toDOM(){return _f},defining:!0};function Cs(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 Kf(r,e,t){return r.append({ordered_list:Cs(qf,{content:"list_item+",group:t}),bullet_list:Cs(Hf,{content:"list_item+",group:t}),list_item:Cs(Jf,{content:e})})}function fr(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 Yf(l,i,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function Yf(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 Wn(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Wn(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Pr(o,t,n,e);return l?(r&&Gf(r,e,l,s,t),!0):!1}function Gf(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 Xf(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 Qf(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?Uf(e,t,r,o):Zf(e,t,o):!0:!1}}function Uf(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 Wn(s.doc.resolve(n.$from.pos),s.doc.resolve(i),n.depth));const l=un(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 Zf(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 eh(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"?th(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}}function th(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 nh=500;function rh({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-nh),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 sh=(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},oh=new dt(/--$/,"—",{inCodeMark:!1}),ih=new dt(/\.\.\.$/,"…",{inCodeMark:!1}),lh=new dt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),ah=new dt(/"$/,"”",{inCodeMark:!1}),ch=new dt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),uh=new dt(/'$/,"’",{inCodeMark:!1}),dh=[lh,ah,ch,uh];function Ms(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&&Pr(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 fh(r,e){let t={},n;function s(o,i){t[o]=i}if(s("Mod-z",Wr),s("Shift-Mod-z",er),s("Backspace",sh),Bl||s("Mod-y",er),s("Alt-ArrowUp",mi),s("Alt-ArrowDown",Bu),s("Mod-BracketLeft",Kr),s("Escape",Gr),(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",fr(n)),(n=r.nodes.ordered_list)&&s("Shift-Ctrl-9",fr(n)),(n=r.nodes.blockquote)&&s("Ctrl->",xi(n)),n=r.nodes.hard_break){let o=n,i=nr(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",Xf(n)),s("Mod-[",Qf(n)),s("Mod-]",eh(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 hh(r){return Ms(/^\s*>\s$/,r)}function ph(r){return Ms(/^(\d+)\.\s$/,r,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function mh(r){return Ms(/^\s*([-+*])\s$/,r)}function gh(r){return jl(/^```$/,r)}function yh(r,e){return jl(new RegExp("^(#{1,"+e+"})\\s$"),r,t=>({level:t[1].length}))}function bh(r){let e=dh.concat(ih,oh),t;return(t=r.nodes.blockquote)&&e.push(hh(t)),(t=r.nodes.ordered_list)&&e.push(ph(t)),(t=r.nodes.bullet_list)&&e.push(mh(t)),(t=r.nodes.code_block)&&e.push(gh(t)),(t=r.nodes.heading)&&e.push(yh(t,6)),rh({rules:e})}const Ke=new tt("ImagePluginKey"),xh=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}}}),kh=(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},wh=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=kh(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}`)}},Sh=(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 vs,Ns;if(typeof WeakMap<"u"){let r=new WeakMap;vs=e=>r.get(e),Ns=(e,t)=>(r.set(e,t),t)}else{const r=[];let t=0;vs=n=>{for(let s=0;s<r.length;s+=2)if(r[s]==n)return r[s+1]},Ns=(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 vs(r)||Ns(r,Ch(r))}};function Ch(r){if(r.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+r.type.name);const e=Mh(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&&vh(l,i,r),l}function Mh(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 vh(r,e,t){r.problems||(r.problems=[]);const n={};for(let s=0;s<r.map.length;s++){const o=r.map[s];if(n[o])continue;n[o]=!0;const i=t.nodeAt(o);if(!i)throw new RangeError(`No cell with offset ${o} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const u=(s+c)%r.width,d=e[u*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=Nh(a)))[c]=d)}l&&r.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:l})}}function Nh(r){if(r.colwidth)return r.colwidth.slice();const e=[];for(let t=0;t<r.colspan;t++)e.push(0);return e}function 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 Eh(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 Oh(r){const e=r.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:Eh}};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 Mn(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 Dh(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 hr(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=Mn(e.$head)||Th(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Th(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 Ah(r){return r.node(0).resolve(r.pos+r.nodeAfter.nodeSize)}function Es(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 Ph(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)&&Es(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 Ih(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1,V.jsonID("cell",W);var Ih=class bc{constructor(e,t){this.anchor=e,this.head=t}map(e){return new bc(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&&Es(t,n)?new W(t,n):V.near(n,1)}};function Vh(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 Rh({$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 zh({$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 jh(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&&Rh(n)?o=j.create(s,n.from):n instanceof j&&zh(n)&&(o=j.create(s,n.$from.start(),n.$from.end()));return o&&(e||(e=r.tr)).setSelection(o),e}var Bh=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 Os(r,e){let t;const n=(s,o)=>{s.type.spec.tableRole=="table"&&(t=Fh(r,s,o,t))};return e?e.doc!=r.doc&&ql(e.doc,r.doc,0,n):r.doc.descendants(n),t}function Fh(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(Bh,{fixTables:!0})}function je(r){const e=r.selection,t=hr(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;Ph(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 Lh(r,e){if(!ve(r))return!1;if(e){const t=je(r);e(Hl(r.tr,t,t.left))}return!0}function $h(r,e){if(!ve(r))return!1;if(e){const t=je(r);e(Hl(r.tr,t,t.right))}return!0}function Wh(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;Wh(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 qh(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;qh(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 Hh(r,e){if(!ve(r))return!1;if(e){const t=je(r);e(Jl(r.tr,t,t.top))}return!0}function Jh(r,e){if(!ve(r))return!1;if(e){const t=je(r);e(Jl(r.tr,t,t.bottom))}return!0}function Kh(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 Yh(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;Kh(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 Gh({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 Xh(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(Gh(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 Qh(r,e){const t=pe(r.schema);return Uh(({node:n})=>t[n.type.spec.tableRole])(r,e)}function Uh(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=Dh(s.$from),!o)return!1;i=(n=Mn(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=hr(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 Zh(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 Ds(r,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Zh(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 ep=Ds("row",{useDeprecatedLogic:!0}),tp=Ds("column",{useDeprecatedLogic:!0}),np=Ds("cell",{useDeprecatedLogic:!0});function rp(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=rp(hr(e),r);if(n==null)return!1;if(t){const s=e.doc.resolve(n);t(e.tr.setSelection(j.between(s,Ah(s))).scrollIntoView())}return!0}}function sp(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 pr(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 op(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=Ts(pe(i).row,new E(c,u,d)).content),l.push(c)}else if(o=="cell"||o=="header_cell")l.push(t||n?Ts(pe(i).row,new E(e,t,n)).content:e);else return null;return ip(i,l)}function ip(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 Ts(r,e){const t=r.createAndFill();return new Qo(t).replace(0,t.content.size,e).doc}function lp({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 ap(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}ap(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 cp=Jr({ArrowLeft:gr("horiz",-1),ArrowRight:gr("horiz",1),ArrowUp:gr("vert",-1),ArrowDown:gr("vert",1),"Shift-ArrowLeft":yr("horiz",-1),"Shift-ArrowRight":yr("horiz",1),"Shift-ArrowUp":yr("vert",-1),"Shift-ArrowDown":yr("vert",1),Backspace:pr,"Mod-Backspace":pr,Delete:pr,"Mod-Delete":pr});function mr(r,e,t){return t.eq(r.selection)?!1:(e&&e(r.tr.setSelection(t).scrollIntoView()),!0)}function gr(r,e){return(t,n,s)=>{if(!s)return!1;const o=t.selection;if(o instanceof W)return mr(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 mr(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),mr(t,n,c)}}}function yr(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?mr(t,n,new W(i.$anchorCell,l)):!1}}function up(r,e){const t=r.state.doc,n=Mn(t.resolve(e));return n?(r.dispatch(r.state.tr.setSelection(new W(n))),!0):!1}function dp(r,e,t){if(!ve(r.state))return!1;let n=op(t);const s=r.state.selection;if(s instanceof W){n||(n={width:1,height:1,rows:[S.from(Ts(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=lp(n,l.right-l.left,l.bottom-l.top),Ul(r.state,r.dispatch,i,l,n),!0}else if(n){const o=hr(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 fp(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=Mn(r.state.selection.$anchor))!=null&&((t=As(r,e))==null?void 0:t.pos)!=s.pos)o(s,e),e.preventDefault();else if(!n)return;function o(a,c){let u=As(r,c);const d=ft.getState(r.state)==null;if(!u||!Es(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=As(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 As(r,e){const t=r.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Mn(r.state.doc.resolve(t.pos)):null}new tt("tableColumnResizing");function hp({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:Vh,handleDOMEvents:{mousedown:fp},createSelectionBetween(e){return ft.getState(e.state)!=null?e.state.selection:null},handleTripleClick:up,handleKeyDown:cp,handlePaste:dp},appendTransaction(e,t,n){return jh(n,Os(n,t),r)}})}const Xt=m.createContext(null),pp=m.createContext(null),ta=m.createContext(null),br=new WeakMap;function mp(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=br.get(r);return!n||n[0].to!==r.state.doc.content.size||!n[0].type.eq(t[0].type)?(br.set(r,t),t):n}const gp=[],yp={},Ps=L.empty;let na=class nn{constructor(e){$(this,"members");this.members=e}map(e,t){const n=this.members.map(s=>s.map(e,t,yp));return nn.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!=Ps&&(o instanceof nn?n=n.concat(o.members):n.push(o))}return nn.from(n)}eq(e){if(!(e instanceof nn)||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?bp(n?t:t.sort(ra)):gp}static from(e){switch(e.length){case 0:return Ps;case 1:return e[0];default:return new nn(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 bp(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 Is=new WeakMap;function xp(r,e){const t=[];r.someProp("decorations",i=>{const l=i(r.state);l&&l!=Ps&&t.push(l)}),e&&t.push(L.create(r.state.doc,[e]));const n=Is.get(r);if(!n){const i=na.from(t);return Is.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 Is.set(r,i),i}return n}const kp=new Hn({nodes:{doc:{content:"text*"},text:{inline:!0}}}),Vs=et.create({schema:kp});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 wp(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 Af{constructor(t,n){var e=(...zg)=>(super(...zg),$(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:Vs}),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=Vs,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);wp(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))},Sp=/^(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||Cp(r)||Sp.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 Cp(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 Mp(r,e){const t=m.useContext(ua);re(()=>t(r),e)}function Be(r,e){const{view:t,flushSyncRef:n}=m.useContext(Xt);Mp(()=>{if(t instanceof Et){n.current=!1;const s=r(t);return n.current=!0,s}},e&&[t,...e])}const vp=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 Np(r,e){if(r==e)return!0;for(const t in r)if(r[t]!==e[t])return!1;for(const t in e)if(!(t in r))return!1;return!0}const Ep={side:0};class Qt{constructor(e,t){$(this,"Component");$(this,"side");$(this,"spec");this.Component=e,this.spec=t??Ep,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&&Np(this.spec,e.spec))}destroy(){}}function Op(r,e,t){return new ne(r,r,new Qt(e,t))}function Rs(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 Dp(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(Op(s.selection.from,vp,{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&&Rs(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);Rs(n,a,{from:u,to:d})}});break}case"insertText":{Rs(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 Tp(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 Ap(){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(()=>Tp(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 Pp(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??Vs,[l,a]=m.useState(i),c=e.state??l,{componentEventListenersPlugin:u,registerEventListener:d,unregisterEventListener:f}=Ap(),h=m.useCallback(v=>{Le.flushSync(()=>{s(v)})},[]),p=m.useMemo(()=>[...e.plugins??[],u,Dp(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 Ip(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||"",zs=/Edge\/(\d+)/.exec(Ot),pa=/MSIE \d/.exec(Ot),js=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ot),Bs=!!(pa||js||zs);pa?document.documentMode:js?+js[1]:zs&&+zs[1];const ma=!Bs&&/gecko\/(\d+)/i.test(Ot);ma&&+(/Firefox\/(\d+)/.exec(Ot)||[0,0])[1];const Fs=!Bs&&/Chrome\/(\d+)/.exec(Ot),Vp=!!Fs;Fs&&+Fs[1];const ga=!Bs&&!!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:Vp,safari:ga};function Dt(r,e){return r instanceof Nn?1:e instanceof Nn?-1:r.getPos()-e.getPos()}const pt=0,ya=1,xr=2,Tt=3;class vn{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 Nn){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 Ls&&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?xr: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?xr:Tt}n=i}this.dirty=xr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const n=e==1?xr:ya;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class Ls extends vn{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 $s extends vn{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 Rp extends vn{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 vn{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)&&Fp(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 zp 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 Nn extends vn{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 jp=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 Bp extends jp{updateChildren(e,t){}updateOuterDeco(e){this.outerDeco=e}destroy(){this.children=[],super.destroy()}}function Fp(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 Ws(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 Bp(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 $s){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 Lp(r,e){return r.type.side-e.type.side}function $p(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(Lp);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 Wp(){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:{}};/*!
43
43
  Copyright (c) 2018 Jed Watson.
44
44
  Licensed under the MIT License (MIT), see
45
45
  http://jedwatson.github.io/classnames
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={};/**
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 qp=Sa.exports;const Hp=xc(qp);let Ca=!1;function Jp(){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 Kp(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:Hp(r.className,e.className),STYLE:Kp(r,e),style:{...r.style,...e.style}}}function va(r){Jp();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 Rp(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 Yp(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 Ls(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 Gp=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}=Ws(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(Ys,{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(kr,y),x)}),Xp=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)}),Qp=m.createContext(null),Up=m.createContext(null),Oa=m.createContext(null),Zp=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}=Ws(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(Ys,{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(kr,G),ce);return m.createElement(Up.Provider,{value:x},m.createElement(Oa.Provider,{value:w},m.createElement(Qp.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]??Xp,o=n[e.node.type.name],i=m.useMemo(()=>o?function(a){return m.createElement(Gp,{constructor:o,...a})}:function(a){return m.createElement(Zp,{component:s,...a})},[o,s]);return m.createElement(i,e)});function em(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 Nn(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 qs={exports:{}},Ne={};/**
47
47
  * @license React
48
48
  * react-reconciler-reflection.production.js
49
49
  *
@@ -51,7 +51,7 @@ Check the top-level render call using <`+k+">."),A}var C=m,v=Symbol.for("react.t
51
51
  *
52
52
  * This source code is licensed under the MIT license found in the
53
53
  * LICENSE file in the root directory of this source tree.
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={};/**
54
+ */var Ta;function tm(){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={};/**
55
55
  * @license React
56
56
  * react-reconciler-reflection.development.js
57
57
  *
@@ -59,5 +59,5 @@ Check the top-level render call using <`+k+">."),A}var C=m,v=Symbol.for("react.t
59
59
  *
60
60
  * This source code is licensed under the MIT license found in the
61
61
  * LICENSE file in the root directory of this source tree.
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"})});
62
+ */var Aa;function nm(){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"?qs.exports=tm():qs.exports=nm();var rm=qs.exports;function sm(r){return r._reactInternals}function Rg(r){return r}function om(r){const e=sm(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=rm.findCurrentHostFiber(e);return t===null?null:t.stateNode}function im(r){return om(r)}function lm(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 am 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=im(this);if(!a){if(!t.composing)return;this.viewDescRef=new $s(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 $s?this.viewDescRef=new zp(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!lm(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(kr,s.text),this.renderRef)}}function cm(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 Nn(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 um(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 Ls(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 kr(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 Hs(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 dm=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(um,{key:t.key,widget:t.widget,getPos:i}):t.type==="native-widget"?m.createElement(Yp,{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(am,{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})}),fm=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(Js,{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(dm,{key:a.key,child:a,getInnerPos:n})))}),Js=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(fm,{key:i.key,childViews:o,getInnerPos:t}):null}))});function Ks(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 hm(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 pm(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 mm=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(Js,{key:t.key,childViews:[t],getInnerPos:n})});function gm(r,e){return r.length?r.every(t=>t.type!=="node"||t.node.isInline)?[m.createElement(Js,{key:r[0].key,childViews:r,getInnerPos:e})]:r.map(t=>m.createElement(mm,{key:t.key,child:t,getInnerPos:e})):[]}const Ys=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;$p(n,s,(h,p,b,y)=>{const x=h.type.spec.marks??[];let w;if(p){w=Ks(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&&Hs(O,v)?O.offset=b:l.set(w,v),a.set(w,a.size)}else{w=Ks(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&&Hs(O,v)?O.offset=b:l.set(w,v),a.set(w,a.size)}const C=l.get(w);c.push(C),hm(u,l.get(w))},(h,p,b,y,x)=>{const w=Ks(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&&Hs(v,C)?(v.offset=y,u=v):(l.set(w,C),u=C),a.set(w,a.size),pm(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:em,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:cm,marks:[],offset:(h==null?void 0:h.offset)??0,index:((h==null?void 0:h.index)??0)+1,key:"trailing-hack-br"})}const f=gm(d,i);return m.createElement(m.Fragment,null,f)}),ym=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}=Ws(u,()=>{const y=u.current;return{dom:y,contentDOM:y,update(){return!0}}},d),h=m.createElement(Te.Provider,{value:f},m.createElement(Ys,{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(kr,b)})),Pa=m.createContext(null),Ia=m.forwardRef(function(e,t){let{as:n,...s}=e;const o=m.useContext(Pa);return m.createElement(ym,{ref:t,...s,...o,as:n})});function bm(){return-1}function xm(r){let{className:e,children:t,nodeViews:n,customNodeViews:s,...o}=r;const[i,l]=m.useState(null),{editor:a,state:c}=Pp(i,{...o,nodeViews:s}),u=a.view.nodeViews,d=m.useMemo(()=>({components:{...n},constructors:u}),[u,n]),f=c.doc,h=mp(a.view),p=xp(a.view,a.cursorWrapper),b=m.useMemo(()=>({className:e,setMount:l,node:f,getPos:bm,decorations:h,innerDecorations:p}),[e,f,h,p]);return m.createElement(Xt.Provider,{value:a},m.createElement(pp.Provider,{value:c},m.createElement(ta.Provider,{value:d},m.createElement(Pa.Provider,{value:b},t))))}function Va(r){return m.createElement(Ip,null,m.createElement(xm,r))}function km(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 km(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=>[hp(),Hr({Tab:Gl(1),"Shift-Tab":Gl(-1)}),bh(r.schema),Hr(fh(r.schema)),Hr(Gu),Xu({color:"#F00",width:2}),zf(),Mu(),xh(r),Wp()],wm=["p",0],Sm=["blockquote",0],Cm=["hr"],Mm=["pre",["code",0]],vm=["br"],Nm={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return wm}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return Sm}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Cm}},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 Mm}},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 vm}}},Em=["em",0],Om=["strong",0],Dm=["code",0],Tm={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 Em}},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 Om}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return Dm}}},ja=new Hn({nodes:Nm,marks:Tm}),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]}}});let Zt="",Fa="",La="",En="",On="";const Am=r=>{Zt=r.api_url??Zt,Fa=r.video_image??Fa,La=r.empty_image??La,En=r.error_image??En,On=r.error_embed??On},Dn=(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}},Tn=(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}},An=(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 Dn(e,!0)+"";case"rutube.ru":return Tn(e,!0)+"";case"youtube.com":case"www.youtube.com":case"youtu.be":return An(e,!0)+"";default:throw new Error}}catch{return""}},Pm={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=`${Zt}/${e}`),t||(t=En),["div",{title:s,class:"image"},["img",{fid:e,src:t,alt:n,title:s}]]}},Im={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:On}]]}},Vm={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]}},Rm={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]}},zm={atom:!0,content:"image*",group:"block",toDOM(){return["div",{class:"carousel"},0]}},$a=ja.spec.nodes.remove("image").append({image:Pm,video:Im}),Pn=new Hn({nodes:$a.remove("horizontal_rule").remove("heading"),marks:Ba}),jm=$a.remove("heading").remove("paragraph").prepend({paragraph:Vm}).append({heading:Rm}).append({carousel:zm}).append(Oh({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 Hn({nodes:Kf(jm,"(paragraph | ordered_list | bullet_list)+","block"),marks:Ba}),Bm=r=>{if(r)try{const e=ye.fromJSON(Ye,JSON.parse(r)),t=$e.fromSchema(Ye).serializeFragment(e.content);return Jn.fromSchema(Pn).parse(t)}catch(e){console.error(`Can not convert content to simple schema: ${e}`)}},In=({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})},Wa=({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(In,{item:e}),n&&g.jsx(In,{item:n})]})},Vn=({items:r})=>g.jsx("div",{className:"MenuBlock",children:r.map((e,t)=>g.jsx(In,{item:e},t))}),Fm=({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(Vn,{items:e}),g.jsx(Fm,{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 qa=()=>g.jsxs("div",{className:"MenuBlock",children:[g.jsx(In,{item:{icon:g.jsx(N.Icons.Undo,{}),command:Wr}}),g.jsx(In,{item:{icon:g.jsx(N.Icons.Redo,{}),command:er}})]}),Ha=({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)=>fr(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)=>fr(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(Vn,{items:e})},Ja=({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?wh(f,o,l,r):Sh(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:"Подпись"})]})]})},Lm=({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=Tn(l,!0)+"",O=An(c,!0)+"",M=Dn(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&&!Tn(l)||c&&!An(c)||o&&!Dn(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},Ka=({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:$m()}),t(l)},[r]),e.length<1?null:g.jsxs(g.Fragment,{children:[g.jsx(Vn,{items:e}),g.jsx(Ja,{isOpen:n,onClose:()=>s(!1)}),g.jsx(Lm,{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 $m(){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 Ya=({schema:r})=>r.nodes.carousel?g.jsx(Vn,{items:[{icon:g.jsx(N.Icons.JoinUp,{}),command:mi},{icon:g.jsx(N.Icons.IndentDecrease,{}),command:Kr},{icon:g.jsx(N.Icons.SquareDashed,{}),command:Gr}]}):g.jsx(Vn,{items:[{icon:g.jsx(N.Icons.IndentDecrease,{}),command:Kr},{icon:g.jsx(N.Icons.SquareDashed,{}),command:Gr}]}),Wm=({schema:r})=>g.jsxs("div",{className:"SimpleMenuBar",children:[g.jsx("div",{className:"MenuBlock",children:g.jsx(Wa,{schema:r})}),g.jsx(_a,{schema:r}),g.jsx(Ka,{schema:r}),g.jsx(Ha,{schema:r}),g.jsx(Ya,{schema:r}),g.jsx(qa,{})]}),Ga=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?`${Zt}/${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"}})})]})}),Xa=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=>{Tn(w)?(i(w),a(w)):An(w)?(i(w),u(w)):Dn(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:On}),g.jsx("div",{className:"video-title",children:g.jsx(N.Editable,{value:h,placeholder:"Подпись под видео (не обязательно)",onChange:y,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Qa=({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=Os(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})},_m=({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:Bm(e),schema:Pn,plugins:za({schema:Pn,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(!!vu(b)),b}),nodeViews:{image:Ga,video:Xa},children:[g.jsxs("div",{className:"ProseNotesContent",children:[g.jsx(Wm,{schema:Pn}),g.jsx(Ia,{})]}),(t||n)&&g.jsxs("div",{className:"ProseNotesButtons",children:[n&&g.jsx("span",{className:"a small",onClick:f,children:"Отменить"}),t&&g.jsx(Qa,{onSave:d,disabled:!u()})]})]})]}):null},qm=({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(Hm,{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},Hm=({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,{})}},Jm=[{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:"Выровнять по краям"}],Km=({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:Jm,isOpen:t,onClose:()=>n(!1),onClick:s,horizontal:"inner-left"})]}):null},Ym=({schema:r,onSave:e,onView:t})=>g.jsxs("div",{className:"MenuBar",children:[g.jsxs("div",{className:"MenuBlock",children:[g.jsx(qm,{schema:r}),g.jsx(Wa,{schema:r})]}),g.jsx(_a,{schema:r}),g.jsx(Ka,{schema:r}),g.jsx(Ha,{schema:r}),g.jsx(Km,{schema:r}),g.jsx(Ya,{schema:r}),g.jsx(qa,{}),t&&g.jsx("div",{className:"MenuItem",onClick:()=>t(),children:g.jsx(N.Icons.Eye,{})}),g.jsx("div",{className:"MenuBlock",children:g.jsx(Qa,{onSave:e})})]}),Gm=7,Ua=1,Rn=50,Xm=({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<Rn&&(p=Rn-b),y-p<Rn&&(p=y-Rn),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+Ua-Math.floor(Gm/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))})},Qm=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)*Ua,w=Math.max(b?(o.current.offsetWidth-y-x)/b:0,Rn);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=>{sp(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(Xm,{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})]})]})}),Um=[{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,{})}],Zm=[{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,{})}],eg=[{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,{})}],Za=({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":ep(c.state,c.dispatch);break;case"addRowBefore":Hh(c.state,c.dispatch);break;case"addRowAfter":Jh(c.state,c.dispatch);break;case"deleteRow":Yh(c.state,c.dispatch);break;case"toggleHeaderColumn":tp(c.state,c.dispatch);break;case"addColumnBefore":Lh(c.state,c.dispatch);break;case"addColumnAfter":$h(c.state,c.dispatch);break;case"deleteColumn":_h(c.state,c.dispatch);break;case"mergeCells":Xh(c.state,c.dispatch);break;case"splitCell":Qh(c.state,c.dispatch);break;case"toggleHeaderCell":np(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:Um,isOpen:t,onClose:o,onClick:a}),g.jsx(N.Menu,{x:r,y:e,items:eg,isOpen:n,onClose:i,onClick:a}),g.jsx(N.Menu,{x:r,y:e,items:Zm,isOpen:s,onClose:l,onClick:a})]})},ec=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(Za,{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(Za,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>d(!1),isCellMenuOpen:f,onCellMenuClose:()=>h(!1),isColumnMenuOpen:p,onColumnMenuClose:()=>b(!1)})]})}),tg=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(Ja,{pos:f,isOpen:i,onClose:()=>l(!1)})]})}),ng=({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=Os(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:Ga,video:Xa,table:Qm,table_header:ec,table_cell:ec,carousel:tg},children:[g.jsx(Ym,{schema:Ye,onSave:l,onView:t}),g.jsx(Ia,{})]})}):null},rg=({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))})},sg=({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)},og=({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))}),ig=({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=`${Zt}/${d}`),f||(f=En),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},lg=({node:r})=>g.jsx("blockquote",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(Y,{node:e},t))}),ag=50,cg=({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(ag))}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))})]})},ug=({node:r})=>g.jsx("tr",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(Y,{node:e},t))}),dg=({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))})},fg=({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))})}},hg=({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,pg=({node:r})=>g.jsx("li",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(Y,{node:e},t))}),mg=({node:r})=>g.jsx("pre",{children:Array.isArray(r.content)&&r.content.map((e,t)=>g.jsx(Y,{node:e},t))}),gg=()=>g.jsx("hr",{}),yg=({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=>{Tn(x)?(t(x),s(x)):An(x)?(t(x),i(x)):Dn(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:On}),c&&g.jsx("div",{className:"image-title",children:c})]})},bg=()=>g.jsx("br",{}),xg=({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(kg,{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},kg=({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=`${Zt}/${a}`),c||(c=En),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(og,{node:n,className:e});case"list_item":return g.jsx(pg,{node:n});case"bullet_list":case"ordered_list":return g.jsx(hg,{node:n});case"image":return g.jsx(ig,{node:n});case"video":return g.jsx(yg,{node:n});case"text":return g.jsx(sg,{node:n});case"table":return g.jsx(cg,{node:n});case"table_row":return g.jsx(ug,{node:n});case"table_cell":case"table_header":return g.jsx(dg,{node:n});case"heading":return g.jsx(fg,{node:n});case"code_block":return g.jsx(mg,{node:n});case"paragraph":return g.jsx(rg,{node:n});case"blockquote":return g.jsx(lg,{node:n});case"carousel":return g.jsx(xg,{node:n});case"horizontal_rule":return g.jsx(gg,{});case"hard_break":return g.jsx(bg,{});default:return g.jsx("span",{className:"unknown_node_type",children:n.type})}})(r):null,wg=({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"})},Sg=({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:"ОШИБКА"})})},Cg='{"type":"doc","content":[{"type":"paragraph","attrs":{"align":null},"content":[{"type":"text","text":"@"}]}]}',Mg='{"type":"doc","content":[{"type":"paragraph","attrs":{"align":null},"content":[{"type":"text","text":"При парсинге документа произошла ошибка"}]}]}',vg=(r,e,t)=>{if(!r)return Cg;try{const s=new DOMParser().parseFromString(r,"text/html");if(t){const i=s.getElementsByTagName("img");for(var n=0;n<i.length;n++){const l=i[n].getAttribute(t);l&&i[n].setAttribute("fid",l)}}const o=Jn.fromSchema(e?Pn:Ye).parse(s).toJSON();return JSON.stringify(o)}catch(s){return console.error(`Can not convert html content to prose format: ${s}`),Mg}};J.DOM=Sg,J.Editor=ng,J.Notes=_m,J.Viewer=wg,J.htmlToProse=vg,J.setConfig=Am,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"})});
63
63
  //# sourceMappingURL=prose-editor.umd.js.map