diff --git a/django_prose_editor/static/django_prose_editor/editor.css b/django_prose_editor/static/django_prose_editor/editor.css index 7584629..068f051 100644 --- a/django_prose_editor/static/django_prose_editor/editor.css +++ b/django_prose_editor/static/django_prose_editor/editor.css @@ -1 +1 @@ -.ProseMirror{padding:1rem 1.75rem;outline:none!important;font-family:-apple-system,blinkmacsystemfont,Segoe UI,roboto,oxygen,ubuntu,cantarell,Open Sans,Helvetica Neue,sans-serif;margin:0!important}.ProseMirror *{color:var(--body-fg)!important}.ProseMirror p{font-size:15px!important}.ProseMirror h1{display:block!important;font-size:2em!important;margin-block-start:.67em!important;margin-block-end:.67em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important}.ProseMirror h2{padding:0;display:block!important;font-size:1.5em!important;margin-block-start:.83em!important;margin-block-end:.83em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important;background:#fff!important}.ProseMirror h3{display:block!important;font-size:1.17em!important;margin-block-start:1em!important;margin-block-end:1em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important;padding:0!important}.ProseMirror>*+*{margin-top:.75em!important}.ProseMirror p.is-editor-empty:first-child:before{content:attr(data-placeholder);float:left;color:#a8a8a8;pointer-events:none;height:0}.ProseMirror ol{padding-left:0!important;list-style-type:decimal!important}.ProseMirror ol li::marker{font-size:16px!important}.ProseMirror ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:lower-latin!important}.ProseMirror ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:lower-roman!important}.ProseMirror ol>li>ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:upper-latin!important}.ProseMirror ol>li>ol>li>ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:upper-roman!important}.ProseMirror ul{list-style-type:disc!important;margin-block-start:0!important;margin-block-end:0!important;margin-inline-start:0px!important;margin-inline-end:0px!important}.ProseMirror ul li{list-style:disc!important}.ProseMirror ul>li>ul{padding-left:10px!important;margin-left:10px!important;list-style-type:disc!important}.ProseMirror{margin:1rem 0}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;text-transform:none;padding:0;background:none!important;border:none!important}.ProseMirror pre{background:#0d0d0d!important;color:#fff!important;font-family:JetBrainsMono,monospace!important;padding:.75rem 1rem!important;border-radius:.5rem!important}.ProseMirror pre code{color:#fff!important;padding:0!important;background:none!important;font-size:.8rem!important}.ProseMirror img{max-width:100%;height:auto}.ProseMirror blockquote{padding-left:1rem;border-left:2px solid rgba(13,13,13,.1)}.ProseMirror hr{border:none;border-top:2px solid rgba(13,13,13,.1);margin:2rem 0!important}.ProseMirror a{text-decoration:underline}.ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;margin:0;overflow:hidden}.ProseMirror table td,.ProseMirror table th,.ProseMirror table[show_borders=false]:hover td,.ProseMirror table[show_borders=false]:hover th{min-width:1em;border:2px solid #ced4da;padding:3px 5px;vertical-align:top;box-sizing:border-box;position:relative}.ProseMirror table[show_borders=false] td,.ProseMirror table[show_borders=false] th{border:none;box-sizing:border-box}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{font-weight:700;text-align:left;background-color:#f1f3f5}.ProseMirror tr{background-color:#fff!important}.ProseMirror table .selectedCell:after{z-index:2;position:absolute;content:"";inset:0;background:#c8c8ff66;pointer-events:none}.ProseMirror table .column-resize-handle{position:absolute;right:-2px;top:0;bottom:-2px;width:4px;background-color:#adf;pointer-events:none}.tableWrapper{overflow-x:auto}.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror{padding:0 6px;border:1px solid var(--border-color);border-radius:4px}.prose-editor *,.prose-editor *:before,.prose-editor *:after{box-sizing:inherit}.prose-editor{box-sizing:border-box;position:relative;max-width:120ch;min-width:40ch;flex-grow:1}.prose-editor+textarea{display:none}.prose-menubar{font-size:14px;background:var(--body-bg);display:inline-flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:2px}.prose-menubar__dropdown{display:flex;>span{border-radius:4px}>div{display:none;position:absolute;background:var(--body-bg);z-index:1}&:hover>div{display:flex}}.prose-menubar__group{display:flex}.prose-menubar__button{cursor:pointer;padding:0 .25em;min-width:2em;transition:all .25s;border:1px solid var(--border-color);text-align:center;display:inline-flex;position:relative}.prose-menubar__button--heading .level{position:absolute;right:3px;bottom:2px;font-size:80%}.prose-menubar__button:first-child{border-top-left-radius:4px;border-bottom-left-radius:4px}.prose-menubar__button:last-child{border-top-right-radius:4px;border-bottom-right-radius:4px}.prose-menubar__button+.prose-menubar__button{border-left:none}.prose-menubar__button.material-icons{padding:0 .125em;min-width:auto}.prose-menubar__button:hover{filter:brightness(110%)}.prose-menubar__button.active{background-color:var(--primary)}.prose-menubar__button.disabled{background:var(--border-color);filter:brightness(100%);cursor:not-allowed;opacity:.3}.prose-editor-dialog{background:var(--body-bg);color:var(--body-fg);border:1px solid var(--border-color)}.prose-editor-dialog label{display:block}label:empty:has(+.prose-editor){display:none}.prose-editor-nbsp{background:#add8e6}.ProseMirror{position:relative}.ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;font-variant-ligatures:none;font-feature-settings:"liga" 0}.ProseMirror pre{white-space:pre-wrap}.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;-moz-user-select:text;user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;inset:-2px -2px -2px -32px;border:2px solid #8cf;pointer-events:none}img.ProseMirror-separator{display:inline!important;border:none!important;margin:0!important} +.ProseMirror{padding:1rem 1.75rem;outline:none!important;font-family:-apple-system,blinkmacsystemfont,Segoe UI,roboto,oxygen,ubuntu,cantarell,Open Sans,Helvetica Neue,sans-serif;margin:0!important}.ProseMirror *{color:var(--body-fg)!important}.ProseMirror p{font-size:15px!important}.ProseMirror h1{display:block!important;font-size:2em!important;margin-block-start:.67em!important;margin-block-end:.67em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important}.ProseMirror h2{padding:0;display:block!important;font-size:1.5em!important;margin-block-start:.83em!important;margin-block-end:.83em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important;background:#fff!important}.ProseMirror h3{display:block!important;font-size:1.17em!important;margin-block-start:1em!important;margin-block-end:1em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important;padding:0!important}.ProseMirror>*+*{margin-top:.75em!important}.ProseMirror p.is-editor-empty:first-child:before{content:attr(data-placeholder);float:left;color:#a8a8a8;pointer-events:none;height:0}.ProseMirror ol{padding-left:0!important;list-style-type:decimal!important}.ProseMirror ol li::marker{font-size:16px!important}.ProseMirror ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:lower-latin!important}.ProseMirror ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:lower-roman!important}.ProseMirror ol>li>ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:upper-latin!important}.ProseMirror ol>li>ol>li>ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:upper-roman!important}.ProseMirror ul{list-style-type:disc!important;margin-block-start:0!important;margin-block-end:0!important;margin-inline-start:0px!important;margin-inline-end:0px!important}.ProseMirror ul li{list-style:disc!important}.ProseMirror ul>li>ul{padding-left:10px!important;margin-left:10px!important;list-style-type:disc!important}.ProseMirror{margin:1rem 0}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;text-transform:none;padding:0;background:none!important;border:none!important}.ProseMirror pre{background:#0d0d0d!important;color:#fff!important;font-family:JetBrainsMono,monospace!important;padding:.75rem 1rem!important;border-radius:.5rem!important}.ProseMirror pre code{color:#fff!important;padding:0!important;background:none!important;font-size:.8rem!important}.ProseMirror img{max-width:100%;height:auto}.ProseMirror blockquote{padding-left:1rem;border-left:2px solid rgba(13,13,13,.1)}.ProseMirror hr{border:none;border-top:2px solid rgba(13,13,13,.1);margin:2rem 0!important}.ProseMirror a{text-decoration:underline}.ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;margin:0;overflow:hidden}.ProseMirror table td,.ProseMirror table th,.ProseMirror table[show_borders=false]:hover td,.ProseMirror table[show_borders=false]:hover th{min-width:1em;border:2px solid #ced4da;padding:3px 5px;vertical-align:top;box-sizing:border-box;position:relative}.ProseMirror table[show_borders=false] td,.ProseMirror table[show_borders=false] th{border:none;box-sizing:border-box}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{font-weight:700;text-align:left;background-color:#f1f3f5}.ProseMirror tr{background-color:#fff!important}.ProseMirror table .selectedCell:after{z-index:2;position:absolute;content:"";inset:0;background:#c8c8ff66;pointer-events:none}.ProseMirror table .column-resize-handle{position:absolute;right:-2px;top:0;bottom:-2px;width:4px;background-color:#adf;pointer-events:none}.tableWrapper{overflow-x:auto}.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror{padding:0 6px;border:1px solid var(--border-color);border-radius:4px}.prose-editor *,.prose-editor *:before,.prose-editor *:after{box-sizing:inherit}.prose-editor{box-sizing:border-box;position:relative;max-width:120ch;min-width:40ch;flex-grow:1}.prose-editor+textarea{display:none}.prose-menubar{font-size:14px;background:var(--body-bg);display:inline-flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:2px}.prose-menubar__dropdown{display:flex;>span{border-radius:4px}>div{display:none;position:absolute;background:var(--body-bg);z-index:1}&:hover>div{display:flex}}.prose-menubar__group{display:flex}.prose-menubar__button{cursor:pointer;padding:0 .25em;min-width:2em;transition:all .25s;border:1px solid var(--border-color);text-align:center;display:inline-flex;position:relative}.prose-menubar__button--heading .level{position:absolute;right:3px;bottom:2px;font-size:80%}.prose-menubar__button:first-child{border-top-left-radius:4px;border-bottom-left-radius:4px}.prose-menubar__button:last-child{border-top-right-radius:4px;border-bottom-right-radius:4px}.prose-menubar__button+.prose-menubar__button{border-left:none}.prose-menubar__button.material-icons{padding:0 .125em;min-width:auto}.prose-menubar__button:hover{filter:brightness(110%)}.prose-menubar__button.active{background-color:var(--primary)}.prose-menubar__button.disabled{background:var(--border-color);filter:brightness(100%);cursor:not-allowed;opacity:.3}.prose-editor-dialog{background:var(--body-bg);color:var(--body-fg);border:1px solid var(--border-color)}.prose-editor-dialog label{display:block}label:empty:has(+.prose-editor){display:none}.prose-editor-nbsp{background:#ddd;box-shadow:0 2px #ddd,0 -2px #ddd}.ProseMirror{position:relative}.ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;font-variant-ligatures:none;font-feature-settings:"liga" 0}.ProseMirror pre{white-space:pre-wrap}.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;-moz-user-select:text;user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;inset:-2px -2px -2px -32px;border:2px solid #8cf;pointer-events:none}img.ProseMirror-separator{display:inline!important;border:none!important;margin:0!important} diff --git a/django_prose_editor/static/django_prose_editor/editor.js b/django_prose_editor/static/django_prose_editor/editor.js index 229880b..e1e2fe2 100644 --- a/django_prose_editor/static/django_prose_editor/editor.js +++ b/django_prose_editor/static/django_prose_editor/editor.js @@ -1,13 +1,13 @@ -var DjangoProseEditor=(()=>{var zt=Object.defineProperty;var Ws=Object.getOwnPropertyDescriptor;var qs=Object.getOwnPropertyNames,Lr=Object.getOwnPropertySymbols;var Wr=Object.prototype.hasOwnProperty,Ks=Object.prototype.propertyIsEnumerable;var Jr=(n,e,t)=>e in n?zt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Cn=(n,e)=>{for(var t in e||(e={}))Wr.call(e,t)&&Jr(n,t,e[t]);if(Lr)for(var t of Lr(e))Ks.call(e,t)&&Jr(n,t,e[t]);return n};var $s=(n,e)=>{for(var t in e)zt(n,t,{get:e[t],enumerable:!0})},Hs=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of qs(e))!Wr.call(n,i)&&i!==t&&zt(n,i,{get:()=>e[i],enumerable:!(r=Ws(e,i))||r.enumerable});return n};var js=n=>Hs(zt({},"__esModule",{value:!0}),n);var Qf={};$s(Qf,{createEditor:()=>Ls});function v(n){this.content=n}v.prototype={constructor:v,find:function(n){for(var e=0;e>1}};v.from=function(n){if(n instanceof v)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new v(e)};var On=v;function Ur(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=Ur(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function Gr(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,f=Math.min(s.text.length,l.text.length);for(;ce&&r(a,i+l,o||null,s)!==!1&&a.content.size){let f=l+1;a.nodesBetween(Math.max(0,e-f),Math.min(a.content.size,t-f),r,i+f)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);oe)for(let o=0,s=0;se&&((st)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=a}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,o)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=e)return s==e||t>0?Bt(r+1,s):Bt(r,i);i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};O.none=[];var Ae=class extends Error{},b=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Xr(this.content,e+this.openStart,t);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Yr(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 n.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(y.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new n(e,r,i)}};b.empty=new b(y.empty,0,0);function Yr(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Yr(o.content,e-i-1,t-i-1)))}function Xr(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Xr(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function _s(n,e,t){if(t.openStart>n.depth)throw new Ae("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ae("Inconsistent open depths");return Qr(n,e,t,0)}function Qr(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function lt(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(De(n.nodeAfter,r),o++));for(let l=o;li&&En(n,e,i+1),s=r.depth>i&&En(t,r,i+1),l=[];return lt(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(Zr(o,s),De(Ee(o,ei(n,e,t,r,i+1)),l)):(o&&De(Ee(o,Vt(n,e,i+1)),l),lt(e,t,i,l),s&&De(Ee(s,Vt(t,r,i+1)),l)),lt(r,null,i,l),new y(l)}function Vt(n,e,t){let r=[];if(lt(null,n,t,r),n.depth>t){let i=En(n,e,t+1);De(Ee(i,Vt(n,e,t+1)),r)}return lt(e,null,t,r),new y(r)}function Us(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(y.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var Lt=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Ie(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(r.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new n(t,r,o)}static resolveCached(e,t){for(let i=0;ie&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}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()+")"),ti(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=y.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;at.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=y.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};ie.prototype.text=void 0;var An=class n extends ie{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ti(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 ti(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var Re=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new In(e,t);if(r.next==null)return n.empty;let i=ni(r);r.next&&r.err("Unexpected trailing text");let o=rl(nl(i));return il(o,r),o}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return o}).join(` -`)}};Re.empty=new Re(!0);var In=class{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 ni(n){let e=[];do e.push(Xs(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Xs(n){let e=[];do e.push(Qs(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Qs(n){let e=tl(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Zs(n,e);else break;return e}function qr(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Zs(n,e){let t=qr(n),r=t;return n.eat(",")&&(n.next!="}"?r=qr(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function el(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.groups.indexOf(e)>-1&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function tl(n){if(n.eat("(")){let e=ni(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=el(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function nl(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let f=0;f{c||i.push([l,c=[]]),c.indexOf(f)==-1&&c.push(f)})})});let o=e[r.join(",")]=new Re(r.indexOf(n.length-1)>-1);for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[o]=new n(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}},Rn=class{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}},ct=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=si(i.attrs),this.excluded=null;let o=ii(this.attrs);this.instance=o?new O(this,o):null}create(e=null){return!e&&this.instance?this.instance:new O(this,oi(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new n(o,i++,t,s)),r}removeFromSet(e){for(var t=0;t-1}},ke=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=On.from(e.nodes),t.marks=On.from(e.marks||{}),this.nodes=Jt.compile(this.spec.nodes,this),this.marks=ct.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=Re.parse(s,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?$r(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:$r(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Jt){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new An(r,r.defaultAttrs,e,O.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return ie.fromJSON(this,e)}markFromJSON(e){return O.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function $r(n,e){let t=[];for(let r=0;r-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function ol(n){return n.tag!=null}function sl(n){return n.style!=null}var ve=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(r=>{ol(r)?this.tags.push(r):sl(r)&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Kt(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Kt(this,t,!0);return r.addAll(e,t.from,t.to),b.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s{r(s=jr(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=jr(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},li={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},ll={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ai={ol:!0,ul:!0},Wt=1,qt=2,at=4;function Hr(n,e,t){return e!=null?(e?Wt:0)|(e==="full"?qt:0):n&&n.whitespace=="pre"?Wt|qt:t&~at}var je=class{constructor(e,t,r,i,o,s,l){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=i,this.solid=o,this.options=l,this.content=[],this.activeMarks=O.none,this.stashMarks=[],this.match=s||(l&at?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(y.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Wt)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=y.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(y.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;t{var zt=Object.defineProperty;var Ws=Object.getOwnPropertyDescriptor;var qs=Object.getOwnPropertyNames,Vr=Object.getOwnPropertySymbols;var Jr=Object.prototype.hasOwnProperty,Ks=Object.prototype.propertyIsEnumerable;var Lr=(n,e,t)=>e in n?zt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Cn=(n,e)=>{for(var t in e||(e={}))Jr.call(e,t)&&Lr(n,t,e[t]);if(Vr)for(var t of Vr(e))Ks.call(e,t)&&Lr(n,t,e[t]);return n};var $s=(n,e)=>{for(var t in e)zt(n,t,{get:e[t],enumerable:!0})},Hs=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of qs(e))!Jr.call(n,i)&&i!==t&&zt(n,i,{get:()=>e[i],enumerable:!(r=Ws(e,i))||r.enumerable});return n};var js=n=>Hs(zt({},"__esModule",{value:!0}),n);var Qf={};$s(Qf,{createEditor:()=>Ls});function v(n){this.content=n}v.prototype={constructor:v,find:function(n){for(var e=0;e>1}};v.from=function(n){if(n instanceof v)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new v(e)};var On=v;function Ur(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=Ur(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function Gr(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,f=Math.min(s.text.length,l.text.length);for(;ce&&r(a,i+l,o||null,s)!==!1&&a.content.size){let f=l+1;a.nodesBetween(Math.max(0,e-f),Math.min(a.content.size,t-f),r,i+f)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);oe)for(let o=0,s=0;se&&((st)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=a}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,o)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=e)return s==e||t>0?Bt(r+1,s):Bt(r,i);i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};O.none=[];var Ae=class extends Error{},b=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Xr(this.content,e+this.openStart,t);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Yr(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 n.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(y.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new n(e,r,i)}};b.empty=new b(y.empty,0,0);function Yr(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Yr(o.content,e-i-1,t-i-1)))}function Xr(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Xr(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function _s(n,e,t){if(t.openStart>n.depth)throw new Ae("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ae("Inconsistent open depths");return Qr(n,e,t,0)}function Qr(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function lt(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(De(n.nodeAfter,r),o++));for(let l=o;li&&Tn(n,e,i+1),s=r.depth>i&&Tn(t,r,i+1),l=[];return lt(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(Zr(o,s),De(Ee(o,ei(n,e,t,r,i+1)),l)):(o&&De(Ee(o,Vt(n,e,i+1)),l),lt(e,t,i,l),s&&De(Ee(s,Vt(t,r,i+1)),l)),lt(r,null,i,l),new y(l)}function Vt(n,e,t){let r=[];if(lt(null,n,t,r),n.depth>t){let i=Tn(n,e,t+1);De(Ee(i,Vt(n,e,t+1)),r)}return lt(e,null,t,r),new y(r)}function Us(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(y.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var Lt=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Ie(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(r.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new n(t,r,o)}static resolveCached(e,t){let r=Wr.get(e);if(r)for(let o=0;oe&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}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()+")"),ti(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=y.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;at.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=y.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};ie.prototype.text=void 0;var En=class n extends ie{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ti(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 ti(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var Re=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new An(e,t);if(r.next==null)return n.empty;let i=ni(r);r.next&&r.err("Unexpected trailing text");let o=rl(nl(i));return il(o,r),o}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return o}).join(` +`)}};Re.empty=new Re(!0);var An=class{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 ni(n){let e=[];do e.push(Xs(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Xs(n){let e=[];do e.push(Qs(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Qs(n){let e=tl(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Zs(n,e);else break;return e}function qr(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Zs(n,e){let t=qr(n),r=t;return n.eat(",")&&(n.next!="}"?r=qr(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function el(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.groups.indexOf(e)>-1&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function tl(n){if(n.eat("(")){let e=ni(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=el(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function nl(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let f=0;f{c||i.push([l,c=[]]),c.indexOf(f)==-1&&c.push(f)})})});let o=e[r.join(",")]=new Re(r.indexOf(n.length-1)>-1);for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[o]=new n(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}},In=class{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}},ct=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=si(i.attrs),this.excluded=null;let o=ii(this.attrs);this.instance=o?new O(this,o):null}create(e=null){return!e&&this.instance?this.instance:new O(this,oi(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new n(o,i++,t,s)),r}removeFromSet(e){for(var t=0;t-1}},ke=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=On.from(e.nodes),t.marks=On.from(e.marks||{}),this.nodes=Jt.compile(this.spec.nodes,this),this.marks=ct.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=Re.parse(s,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?$r(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:$r(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Jt){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new En(r,r.defaultAttrs,e,O.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return ie.fromJSON(this,e)}markFromJSON(e){return O.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function $r(n,e){let t=[];for(let r=0;r-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function ol(n){return n.tag!=null}function sl(n){return n.style!=null}var ve=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(ol(i))this.tags.push(i);else if(sl(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new Kt(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Kt(this,t,!0);return r.addAll(e,t.from,t.to),b.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s{r(s=jr(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=jr(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},li={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},ll={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ai={ol:!0,ul:!0},Wt=1,qt=2,at=4;function Hr(n,e,t){return e!=null?(e?Wt:0)|(e==="full"?qt:0):n&&n.whitespace=="pre"?Wt|qt:t&~at}var je=class{constructor(e,t,r,i,o,s,l){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=i,this.solid=o,this.options=l,this.content=[],this.activeMarks=O.none,this.stashMarks=[],this.match=s||(l&at?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(y.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Wt)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=y.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(y.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;tthis.addAll(e)),s&&this.sync(l),this.needsBlock=a}else this.withStyleRules(e,()=>{this.addElementByRule(e,o,o.consuming===!1?i:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` -`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=O.none,r=O.none;for(let i=0,o=e.length;i{a.clearMark(c)&&(r=c.addToSet(r))}):t=this.parser.schema.marks[a.mark].create(a.attrs).addToSet(t),a.consuming===!1)l=a;else break}}return[t,r]}addElementByRule(e,t,r){let i,o,s;t.node?(o=this.parser.schema.nodes[t.node],o.isLeaf?this.insertNode(o.create(t.attrs))||this.leafFallback(e):i=this.enter(o,t.attrs||null,t.preserveWhitespace)):(s=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(s));let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));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)}i&&this.sync(l)&&this.open--,s&&this.removePendingMark(s,l)}addAll(e,t,r){let i=t||0;for(let o=t?e.childNodes[t]:e.firstChild,s=r==null?null:e.childNodes[r];o!=s;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o);this.findAtPoint(e,i)}findPlace(e){let t,r;for(let i=this.open;i>=0;i--){let o=this.nodes[i],s=o.findWrapping(e);if(s&&(!t||t.length>s.length)&&(t=s,r=o,!s.length)||o.solid)break}if(!t)return!1;this.sync(r);for(let i=0;ithis.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;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(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(s(l-1,a))return!0;return!1}else{let f=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!f||f.name!=c&&f.groups.indexOf(c)==-1)return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=hl(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let s=i.popFromStashMark(e);s&&i.type&&i.type.allowsMarkType(s.type)&&(i.activeMarks=s.addToSet(i.activeMarks))}if(i==t)break}}};function al(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ai.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function cl(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function jr(n){let e={};for(let t in n)e[t]=n[t];return e}function fl(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let a=0;a{if(o.length||s.marks.length){let l=0,a=0;for(;l=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&n.renderSpec(Dn(r),i(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],o=i.indexOf(" ");o>0&&(r=i.slice(0,o),i=i.slice(o+1));let s,l=r?e.createElementNS(r,i):e.createElement(i),a=t[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let f in a)if(a[f]!=null){let h=f.indexOf(" ");h>0?l.setAttributeNS(f.slice(0,h),f.slice(h+1),a[f]):l.setAttribute(f,a[f])}}for(let f=c;fc)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:d,contentDOM:p}=n.renderSpec(e,h,r);if(l.appendChild(d),p){if(s)throw new RangeError("Multiple content holes");s=p}}}return{dom:l,contentDOM:s}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=_r(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return _r(e.marks)}};function _r(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Dn(n){return n.document||window.document}var hi=65535,di=Math.pow(2,16);function dl(n,e){return n+e*di}function ci(n){return n&hi}function ul(n){return(n-(n&hi))/di}var ui=1,pi=2,$t=4,mi=8,dt=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&mi)>0}get deletedBefore(){return(this.delInfo&(ui|$t))>0}get deletedAfter(){return(this.delInfo&(pi|$t))>0}get deletedAcross(){return(this.delInfo&$t)>0}},he=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=ci(e);if(!this.inverted)for(let i=0;ie)break;let c=this.ranges[l+o],f=this.ranges[l+s],h=a+c;if(e<=h){let d=c?e==a?-1:e==h?1:t:t,p=a+i+(d<0?0:f);if(r)return p;let u=e==(t<0?a:h)?null:dl(l/3,e-a),m=e==a?pi:e==h?ui:$t;return(t<0?e!=a:e!=h)&&(m|=mi),new dt(p,m,u)}i+=f-c}return r?e+i:new dt(e+i,0,null)}touches(e,t){let r=0,i=ci(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+o],f=a+c;if(e<=f&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return A.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),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};D.jsonID("addMark",pt);var Pe=class n extends D{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new b(Vn(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return A.fromReplace(e,this.from,this.to,r)}invert(){return new pt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};D.jsonID("removeMark",Pe);var mt=class n extends D{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return A.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return A.fromReplace(e,this.pos,this.pos+1,new b(y.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new n(t.pos,r.pos,i,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 n(t.from,t.to,t.gapFrom,t.gapTo,b.fromJSON(e,t.slice),t.insert,!!t.structure)}};D.jsonID("replaceAround",E);function Bn(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function pl(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,c,f)=>{if(!a.isInline)return;let h=a.marks;if(!r.isInSet(h)&&f.type.allowsMarkType(r.type)){let d=Math.max(c,e),p=Math.min(c+a.nodeSize,t),u=r.addToSet(h);for(let m=0;mn.step(a)),o.forEach(a=>n.step(a))}function ml(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof ct){let c=s.marks,f;for(;f=r.isInSet(c);)(a||(a=[])).push(f),c=f.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let f=0;fn.step(new Pe(s.from,s.to,s.style)))}function gi(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a=0;a--)n.step(s[a])}function gl(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ue(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),o=n.$from.index(r),s=n.$to.indexAfter(r);if(rt;u--)m||r.index(u)>0?(m=!0,f=y.from(r.node(u).copy(f)),h++):a--;let d=y.empty,p=0;for(let u=o,m=!1;u>t;u--)m||i.after(u+1)=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=y.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new E(i,o,i,o,new b(r,0,0),t.length,!0))}function Sl(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,i)&&Ol(n.doc,n.mapping.slice(o).map(l),r)){let a=null;if(r.schema.linebreakReplacement){let d=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);d&&!p?a=!1:!d&&p&&(a=!0)}a===!1&&Cl(n,s,l,o),gi(n,n.mapping.slice(o).map(l,1),r,void 0,a===null);let c=n.mapping.slice(o),f=c.map(l,1),h=c.map(l+s.nodeSize,1);return n.step(new E(f,h,f+1,h-1,new b(y.from(r.create(i,null,s.marks)),0,0),1,!0)),a===!0&&Ml(n,s,l,o),!1}})}function Ml(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Cl(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+o);n.replaceWith(s,s+1,e.type.schema.text(` -`))}})}function Ol(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function wl(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new E(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new b(y.from(s),0,0),1,!0))}function xe(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,f=t-2;c>o;c--,f--){let h=i.node(c),d=i.index(c);if(h.type.spec.isolating)return!1;let p=h.content.cutByIndex(d,h.childCount),u=r&&r[f+1];u&&(p=p.replaceChild(0,u.type.create(u.attrs)));let m=r&&r[f]||h;if(!h.canReplace(d+1,h.childCount)||!m.type.validContent(p))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function Nl(n,e,t=1,r){let i=n.doc.resolve(e),o=y.empty,s=y.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){o=y.from(i.node(l).copy(o));let f=r&&r[c];s=y.from(f?f.type.create(f.attrs,s):i.node(l).copy(s))}n.step(new K(e,e,new b(o.append(s),t,t),!0))}function yt(n,e){let t=n.resolve(e),r=t.index();return Tl(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Tl(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function Dl(n,e,t){let r=new K(e-t,e+t,b.empty,!0);n.step(r)}function El(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),f=!1;if(o==1)f=c.canReplace(a,a,i);else{let h=c.contentMatchAt(a).findWrapping(i.firstChild.type);f=h&&c.canReplaceWith(a,a,h[0])}if(f)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Yt(n,e,t=e,r=b.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return yi(i,o,r)?new K(e,t,r):new Fn(i,o,r).fit()}function yi(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Fn=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=y.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=y.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new b(o,s,l);return e>-1?new E(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new K(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Pn(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],f,h=null;if(t==1&&(s?c.matchType(s.type)||(h=c.fillBefore(y.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:h};if(t==2&&s&&(f=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:f};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Pn(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new b(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Pn(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new b(ft(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new b(ft(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(h=g,f.push(bi(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let u=c==l.childCount;u||(p=-1),this.placed=ht(this.placed,t,y.from(f)),this.frontier[t].match=h,u&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;l--){let{match:a,type:c}=this.frontier[l],f=zn(e,l,c,a,!0);if(!f||f.childCount)continue e}return{depth:t,fit:s,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=ht(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=ht(this.placed,this.depth,y.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(y.empty,!0);t.childCount&&(this.placed=ht(this.placed,this.frontier.length,t))}};function ft(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(ft(n.firstChild.content,e-1,t)))}function ht(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(ht(n.lastChild.content,e-1,t)))}function Pn(n,e){for(let t=0;t1&&(r=r.replaceChild(0,bi(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(y.empty,!0)))),n.copy(r)}function zn(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!Al(t,o.content,s)?l:null}function Al(n,e,t){for(let r=t;r0;d--,p--){let u=i.node(d).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),c=[],f=r.openStart;for(let d=r.content,p=0;;p++){let u=d.firstChild;if(c.push(u),p==r.openStart)break;d=u.content}for(let d=f-1;d>=0;d--){let p=c[d],u=Il(p.type);if(u&&!p.sameMarkup(i.node(Math.abs(l)-1)))f=d;else if(u||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+f+1)%(r.openStart+1),u=c[p];if(u)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>h));d--){let p=s[d];p<0||(e=i.before(p),t=o.after(p))}}function ki(n,e,t,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(y.empty,!0))}return n}function vl(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=El(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new b(y.from(r),0,0))}function Pl(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=xi(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s)return n.delete(r.before(s),t);n.delete(e,t)}function xi(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(oe.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}var Ht=class n extends D{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return A.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return A.fromReplace(e,this.pos,this.pos+1,new b(y.from(i),0,t.isLeaf?0:1))}getMap(){return he.empty}invert(e){return new n(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 n(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 n(t.pos,t.attr,t.value)}};D.jsonID("attr",Ht);var jt=class n extends D{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return A.ok(r)}getMap(){return he.empty}invert(e){return new n(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 n(t.attr,t.value)}};D.jsonID("docAttr",jt);var _e=class extends Error{};_e=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};_e.prototype=Object.create(Error.prototype);_e.prototype.constructor=_e;_e.prototype.name="TransformError";var _t=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ut}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new _e(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=b.empty){let i=Yt(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new b(y.from(r),0,0))}delete(e,t){return this.replace(e,t,b.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Rl(this,e,t,r),this}replaceRangeWith(e,t,r){return vl(this,e,t,r),this}deleteRange(e,t){return Pl(this,e,t),this}lift(e,t){return yl(this,e,t),this}join(e,t=1){return Dl(this,e,t),this}wrap(e,t){return xl(this,e,t),this}setBlockType(e,t=e,r,i=null){return Sl(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return wl(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Ht(e,t,r)),this}setDocAttribute(e,t){return this.step(new jt(e,t)),this}addNodeMark(e,t){return this.step(new mt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof O)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new gt(e,t)),this}split(e,t=1,r){return Nl(this,e,t,r),this}addMark(e,t,r){return pl(this,e,t,r),this}removeMark(e,t,r){return ml(this,e,t,r),this}clearIncompatible(e,t,r){return gi(this,e,t,r),this}};var Ln=Object.create(null),S=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Wn(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=0;o--){let s=t<0?Ge(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Ge(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new $(e.node(0))}static atStart(e){return Ge(e,e,0,0,1)||new $(e)}static atEnd(e){return Ge(e,e,e.content.size,e.childCount,-1)||new $(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ln[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Ln)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ln[e]=t,t.prototype.jsonID=e,t}getBookmark(){return w.between(this.$anchor,this.$head).getBookmark()}};S.prototype.visible=!0;var Wn=class{constructor(e,t){this.$from=e,this.$to=t}},Si=!1;function Mi(n){!Si&&!n.parent.inlineContent&&(Si=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var w=class n extends S{constructor(e,t=e){Mi(e),Mi(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return S.near(r);let i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(e,t=b.empty){if(super.replace(e,t),t==b.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Qt(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 n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=S.findFrom(t,r,!0)||S.findFrom(t,-r,!0);if(o)t=o.$head;else return S.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(S.findFrom(e,-r,!0)||S.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?s=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&x.isSelectable(l))return x.create(n,t-(i<0?l.nodeSize:0))}else{let a=Ge(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function Ci(n,e,t){let r=n.steps.length-1;if(r{s==null&&(s=f)}),n.setSelection(S.near(n.doc.resolve(s),t))}var Oi=1,Xt=2,wi=4,Kn=class extends _t{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.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Xt,this}ensureMarks(e){return O.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&Xt)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Xt,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||O.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r==null?t:r,!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),this.selection.empty||this.setSelection(S.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|=wi,this}get scrolledIntoView(){return(this.updated&wi)>0}};function Ni(n,e){return!e||!n?n:n.bind(e)}var ze=class{constructor(e,t,r){this.name=e,this.init=Ni(t.init,r),this.apply=Ni(t.apply,r)}},Bl=[new ze("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new ze("selection",{init(n,e){return n.selection||S.atStart(e.doc)},apply(n){return n.selection}}),new ze("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new ze("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],bt=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Bl.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new ze(r.key,r.spec.state,r))})}},Zt=class n{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new bt(e.schema,e.plugins),o=new n(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=ie.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=S.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function Ti(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Ti(i,e,{})),t[r]=i}return t}var P=class{constructor(e){this.spec=e,this.props={},e.props&&Ti(e.props,this,this.props),this.key=e.key?e.key.key:Di("plugin")}getState(e){return e[this.key]}},Jn=Object.create(null);function Di(n){return n in Jn?n+"$"+ ++Jn[n]:(Jn[n]=0,n+"$")}var kt=class{constructor(e="key"){this.key=Di(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Ai=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Fl(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var Vl=(n,e,t)=>{let r=Fl(n,t);if(!r)return!1;let i=Ii(r);if(!i){let s=r.blockRange(),l=s&&Ue(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(!o.type.spec.isolating&&vi(n,i,e))return!0;if(r.parent.content.size==0&&(Ye(o,"end")||x.isSelectable(o))){let s=Yt(n.doc,r.before(),r.after(),b.empty);if(s&&s.slice.size{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=Ii(r)}let s=o&&o.nodeBefore;return!s||!x.isSelectable(s)?!1:(e&&e(n.tr.setSelection(x.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Ii(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Jl(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=Jl(n,t);if(!r)return!1;let i=Ri(r);if(!i)return!1;let o=i.nodeAfter;if(vi(n,i,e))return!0;if(r.parent.content.size==0&&(Ye(o,"start")||x.isSelectable(o))){let s=Yt(n.doc,r.before(),r.after(),b.empty);if(s&&s.slice.size{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` -`).scrollIntoView()),!0)};function Hn(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=Hn(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(S.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},$l=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof $||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Hn(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(xe(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Ue(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function jl(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof x&&e.selection.node.isBlock)return!r.parentOffset||!xe(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.parent.isBlock)return!1;if(t){let o=i.parentOffset==i.parent.content.size,s=e.tr;(e.selection instanceof w||e.selection instanceof $)&&s.deleteSelection();let l=r.depth==0?null:Hn(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=n&&n(i.parent,o),c=a?[a]:o&&l?[{type:l}]:void 0,f=xe(s.doc,s.mapping.map(r.pos),1,c);if(!c&&!f&&xe(s.doc,s.mapping.map(r.pos),1,l?[{type:l}]:void 0)&&(l&&(c=[{type:l}]),f=!0),f&&(s.split(s.mapping.map(r.pos),1,c),!o&&!r.parentOffset&&r.parent.type!=l)){let h=s.mapping.map(r.before()),d=s.doc.resolve(h);l&&r.node(-1).canReplaceWith(d.index(),d.index()+1,l)&&s.setNodeMarkup(s.mapping.map(r.before()),l)}t(s.scrollIntoView())}return!0}}var _l=jl();var Ul=(n,e)=>(e&&e(n.tr.setSelection(new $(n.doc))),!0);function Gl(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||yt(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function vi(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o,s;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(Gl(n,e,t))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(o=(s=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&s.matchType(o[0]||i.type).validEnd){if(t){let h=e.pos+i.nodeSize,d=y.empty;for(let m=o.length-1;m>=0;m--)d=y.from(o[m].create(null,d));d=y.from(r.copy(d));let p=n.tr.step(new E(e.pos-1,h,e.pos,h,new b(d,1,0),o.length,!0)),u=h+2*o.length;yt(p.doc,u)&&p.join(u),t(p.scrollIntoView())}return!0}let a=S.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),f=c&&Ue(c);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(c,f).scrollIntoView()),!0;if(l&&Ye(i,"start",!0)&&Ye(r,"end")){let h=r,d=[];for(;d.push(h),!h.isTextblock;)h=h.lastChild;let p=i,u=1;for(;!p.isTextblock;p=p.firstChild)u++;if(h.canReplace(h.childCount,h.childCount,p.content)){if(t){let m=y.empty;for(let k=d.length-1;k>=0;k--)m=y.from(d[k].copy(m));let g=n.tr.step(new E(e.pos-d.length,e.pos+i.nodeSize,e.pos+u,e.pos+i.nodeSize-u,new b(m,d.length,0),0,!0));t(g.scrollIntoView())}return!0}}return!1}function Pi(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(w.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}var Yl=Pi(-1),Xl=Pi(1);function en(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),l=s&&Ut(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function _n(n,e=null){return function(t,r){let i=!1;for(let o=0;o{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let f=t.doc.resolve(c),h=f.index();i=f.parent.canReplaceWith(h,h+1,n)}})}if(!i)return!1;if(r){let o=t.tr;for(let s=0;s{if(s)return!1;s=l.inlineContent&&l.type.allowsMarkType(t)}),s)return!0}return!1}function Q(n,e=null){return function(t,r){let{empty:i,$cursor:o,ranges:s}=t.selection;if(i&&!o||!Ql(t.doc,s,n))return!1;if(r)if(o)n.isInSet(t.storedMarks||o.marks())?r(t.tr.removeStoredMark(n)):r(t.tr.addStoredMark(n.create(e)));else{let l=!1,a=t.tr;for(let c=0;!l&&c{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,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,r;if(t){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let f=c.getBoundingClientRect(),h=l?f.bottom:f.top;l&&a&&(h=(h+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:f.left,right:f.right,top:h-this.width/2,bottom:h+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.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 o,s;if(!i||i==document.body&&getComputedStyle(i).position=="static")o=-pageXOffset,s=-pageYOffset;else{let l=i.getBoundingClientRect();o=l.left-i.scrollLeft,s=l.top-i.scrollTop}this.element.style.left=r.left-o+"px",this.element.style.top=r.top-s+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!o){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Gt(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}};var ue={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:"'"},nn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ea=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),ta=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(T=0;T<10;T++)ue[48+T]=ue[96+T]=String(T);var T;for(T=1;T<=24;T++)ue[T+111]="F"+T;var T;for(T=65;T<=90;T++)ue[T]=String.fromCharCode(T+32),nn[T]=String.fromCharCode(T);var T;for(tn in ue)nn.hasOwnProperty(tn)||(nn[tn]=ue[tn]);var tn;function Vi(n){var e=ea&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||ta&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?nn:ue)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var na=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function ra(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=ue[r.keyCode])&&o!=i){let l=e[Gn(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var I=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ot=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},nr=null,me=function(n,e,t){let r=nr||(nr=document.createRange());return r.setEnd(n,t==null?n.nodeValue.length:t),r.setStart(n,e||0),r},oa=function(){nr=null},qe=function(n,e,t,r){return t&&(Li(n,e,t,r,-1)||Li(n,e,t,r,1))},sa=/^(img|br|input|textarea|hr)$/i;function Li(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:se(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Dt(n)||sa.test(n.nodeName)||n.contentEditable=="false")return!1;e=I(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?se(n):0}else return!1}}function se(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function la(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=se(n)}else if(n.parentNode&&!Dt(n))e=I(n),n=n.parentNode;else return null}}function aa(n,e){for(;;){if(n.nodeType==3&&e2),_=tt||(le?/Mac/.test(le.platform):!1),ua=le?/Win/.test(le.platform):!1,Z=/Android \d/.test(Ne),Et=!!Ji&&"webkitFontSmoothing"in Ji.documentElement.style,pa=Et?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ma(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function pe(n,e){return typeof n=="number"?n:n[e]}function ga(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Wi(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;s=Ot(s)){if(s.nodeType!=1)continue;let l=s,a=l==o.body,c=a?ma(o):ga(l),f=0,h=0;if(e.topc.bottom-pe(r,"bottom")&&(h=e.bottom-e.top>c.bottom-c.top?e.top+pe(i,"top")-c.top:e.bottom-c.bottom+pe(i,"bottom")),e.leftc.right-pe(r,"right")&&(f=e.right-c.right+pe(i,"right")),f||h)if(a)o.defaultView.scrollBy(f,h);else{let d=l.scrollLeft,p=l.scrollTop;h&&(l.scrollTop+=h),f&&(l.scrollLeft+=f);let u=l.scrollLeft-d,m=l.scrollTop-p;e={left:e.left-u,top:e.top-m,right:e.right-u,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function ya(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:xo(n.dom)}}function xo(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Ot(r));return e}function ba({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;So(t,r==0?0:r-e)}function So(n,e){for(let t=0;t=l){s=Math.max(u.bottom,s),l=Math.min(u.top,l);let m=u.left>e.left?u.left-e.left:u.right=(u.left+u.right)/2?1:0));continue}}else u.top>e.top&&!a&&u.left<=e.left&&u.right>=e.left&&(a=f,c={left:Math.max(u.left,Math.min(u.right,e.left)),top:u.top});!t&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(o=h+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?xa(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:Mo(t,i)}function xa(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i=(o.left+o.right)/2?1:0)}}return{node:n,offset:0}}function Sr(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Sa(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function Ca(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right-1?i:n.docView.posFromDOM(e,t,-1)}function Co(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let c;Et&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=Ca(n,r,i,e))}l==null&&(l=Ma(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function qi(n){return n.top=0&&i==r.nodeValue.length?(a--,f=1):t<0?a--:c++,St(Se(me(r,a,c),f),f<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==se(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Qn(a.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(t<0||i==se(r))){let a=r.childNodes[i-1],c=a.nodeType==3?me(a,se(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return St(Se(c,1),!1)}if(o==null&&i=0)}function St(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Qn(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function wo(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Na(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return wo(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Oo(n,i.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=me(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cf.top+1&&(t=="up"?s.top-f.top>(f.bottom-s.top)*2:f.bottom-s.bottom>(s.bottom-f.top)*2))return!1}}return!0})}var Ta=/[\u0590-\u08ac]/;function Da(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return!Ta.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:wo(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:f,anchorOffset:h}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:u,focusOffset:m}=n.domSelectionRange(),g=u&&!p.contains(u.nodeType==1?u:u.parentNode)||a==u&&c==m;try{l.collapse(f,h),a&&(a!=f||c!=h)&&l.extend&&l.extend(a,c)}catch(k){}return d!=null&&(l.caretBidiLevel=d),g})}var Ki=null,$i=null,Hi=!1;function Ea(n,e,t){return Ki==e&&$i==t?Hi:(Ki=e,$i=t,Hi=t=="up"||t=="down"?Na(n,e,t):Da(n,e,t))}var U=0,ji=1,Fe=2,ae=3,Ke=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=U,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tI(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return(i==null?r>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof sn){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof rn&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?I(o.dom)+1:0}}else{let o,s=!0;for(;o=r=f&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,f);e=s;for(let h=l;h>0;h--){let d=this.children[h-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=I(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let f=l+1;fp&&st){let p=l;l=a,a=p}let d=document.createRange();d.setEnd(a.node,a.offset),d.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(d)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i=r:er){let l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?Fe:ji,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ae:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Fe:ae}r=s}this.dirty=Fe}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Fe:ji;t.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==U&&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}},sr=class extends Ke{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}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}},nt=class n extends Ke{constructor(e,t,r,i){super(e,[],r,i),this.mark=t}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=oe.renderSpec(document,t.type.spec.toDOM(t,r))),new n(e,t,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&ae||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ae&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=U){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=hr(o,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),f=c&&c.dom,h=c&&c.contentDOM;if(t.isText){if(!f)f=document.createTextNode(t.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:h}=oe.renderSpec(document,t.type.spec.toDOM(t)));!h&&!t.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),t.type.spec.draggable&&(f.draggable=!0));let d=f;return f=Do(f,r,t),c?a=new lr(e,t,r,i,f,h||null,d,c,o,s+1):t.isText?new on(e,t,r,i,f,d,o):new n(e,t,r,i,f,h||null,d,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>y.empty)}return e}matchesNode(e,t,r){return this.dirty==U&&e.eq(this.node)&&cr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new fr(this,s&&s.node,e);va(this.node,this.innerDeco,(c,f,h)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!h&&a.syncToMarks(f==this.node.childCount?O.none:this.node.child(f).marks,r,e),a.placeWidget(c,e,i)},(c,f,h,d)=>{a.syncToMarks(c.marks,r,e);let p;a.findNodeMatch(c,f,h,d)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(c,f,h,p,e)||a.updateNextNode(c,f,h,e,d,i)||a.addNode(c,f,h,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Fe)&&(s&&this.protectLocalComposition(e,s),No(this.contentDOM,this.children,e),tt&&Pa(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof w)||rt+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 s=o.nodeValue,l=za(this.node.content,s,r-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){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 s=new sr(this,o,t,i);e.input.compositionNodes.push(s),this.children=hr(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==ae||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=U}updateOuterDeco(e){if(cr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=To(this.dom,this.nodeDOM,ar(this.outerDeco,this.node,t),ar(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function _i(n,e,t,r,i){Do(r,e,n);let o=new we(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}var on=class n extends we{constructor(e,t,r,i,o,s,l){super(e,t,r,i,o,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==ae||this.dirty!=U&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=U||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=U,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ae)}get domAtom(){return!1}isText(e){return this.node.text==e}},sn=class extends Ke{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==U&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},lr=class extends we{constructor(e,t,r,i,o,s,l,a,c,f){super(e,t,r,i,o,s,l,c,f),this.spec=a}update(e,t,r,i){if(this.dirty==ae)return!1;if(this.spec.update){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r):super.setSelection(e,t,r,i)}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 No(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o>1,s=Math.min(o,e.length);for(;i-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=nt.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof nt)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function Ra(n,e){return n.type.side-e.type.side}function va(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let c=0;co;)l.push(i[s++]);let u=o+d.nodeSize;if(d.isText){let g=u;s!g.inline):l.slice();r(d,m,e.forChild(o,d),p),o=u}}function Pa(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function za(n,e,t,r){for(let i=0,o=0;i=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function hr(n,e,t,r,i){let o=[];for(let s=0,l=0;s=t||f<=e?o.push(a):(ct&&o.push(a.slice(t-c,a.size,r)))}return o}function Mr(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(pn(t)){for(a=l;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&x.isSelectable(f)&&i.parent&&!(f.isInline&&ca(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;c=new x(s==h?l:r.resolve(h))}}else{let f=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(f<0)return null;a=r.resolve(f)}if(!c){let f=e=="pointer"||n.state.selection.head{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Eo(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Fa(n){let e=n.domSelection(),t=document.createRange(),r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setEnd(r.parentNode,I(r)+1):t.setEnd(r,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&q&&Oe<=11&&(r.disabled=!0,r.disabled=!1)}function Ao(n,e){if(e instanceof x){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Qi(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Qi(n)}function Qi(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Cr(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||w.between(e,t,r)}function Zi(n){return n.editable&&!n.hasFocus()?!1:Io(n)}function Io(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Va(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return qe(e.node,e.offset,t.anchorNode,t.anchorOffset)}function dr(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&S.findFrom(o,e)}function Me(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function eo(n,e,t){let r=n.state.selection;if(r instanceof w)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Me(n,new w(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=dr(n.state,e);return i&&i instanceof x?Me(n,i):!1}else if(!(_&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?x.isSelectable(o)?Me(n,new x(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Et?Me(n,new w(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof x&&r.node.isInline)return Me(n,new w(e>0?r.$to:r.$from));{let i=dr(n.state,e);return i?Me(n,i):!1}}}function ln(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ct(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Qe(n,e){return e<0?La(n):Ja(n)}function La(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(ee&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Ct(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Ro(t))break;{let l=t.previousSibling;for(;l&&Ct(l,-1);)i=t.parentNode,o=I(l),l=l.previousSibling;if(l)t=l,r=ln(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?ur(n,t,r):i&&ur(n,i,o)}function Ja(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=ln(t),o,s;for(;;)if(r{n.state==i&&ge(n)},50)}function to(n,e){let t=n.state.doc.resolve(e);if(!(V||ua)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s1)return o.lefti.top&&s1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function no(n,e,t){let r=n.state.selection;if(r instanceof w&&!r.empty||t.indexOf("s")>-1||_&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=dr(n.state,e);if(s&&s instanceof x)return Me(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof $?S.near(s,e):S.findFrom(s,e);return l?Me(n,l):!1}return!1}function ro(n,e){if(!(n.state.selection instanceof w))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function io(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Ka(n){if(!L||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;io(n,r,"true"),setTimeout(()=>io(n,r,"false"),20)}return!1}function $a(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Ha(n,e){let t=e.keyCode,r=$a(e);if(t==8||_&&t==72&&r=="c")return ro(n,-1)||Qe(n,-1);if(t==46&&!e.shiftKey||_&&t==68&&r=="c")return ro(n,1)||Qe(n,1);if(t==13||t==27)return!0;if(t==37||_&&t==66&&r=="c"){let i=t==37?to(n,n.state.selection.from)=="ltr"?-1:1:-1;return eo(n,i,r)||Qe(n,i)}else if(t==39||_&&t==70&&r=="c"){let i=t==39?to(n,n.state.selection.from)=="ltr"?1:-1:1;return eo(n,i,r)||Qe(n,i)}else{if(t==38||_&&t==80&&r=="c")return no(n,-1,r)||Qe(n,-1);if(t==40||_&&t==78&&r=="c")return Ka(n)||no(n,1,r)||Qe(n,1);if(r==(_?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function vo(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||oe.fromSchema(n.state.schema),l=Lo(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,f,h=0;for(;c&&c.nodeType==1&&(f=Vo[c.nodeName.toLowerCase()]);){for(let p=f.length-1;p>=0;p--){let u=l.createElement(f[p]);for(;a.firstChild;)u.appendChild(a.firstChild);a.appendChild(u),h++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${h?` -${h}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,` +`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=O.none,r=O.none;if(e.length)for(let i=0;i{a.clearMark(c)&&(r=c.addToSet(r))}):t=this.parser.schema.marks[a.mark].create(a.attrs).addToSet(t),a.consuming===!1)l=a;else break}}return[t,r]}addElementByRule(e,t,r){let i,o,s;t.node?(o=this.parser.schema.nodes[t.node],o.isLeaf?this.insertNode(o.create(t.attrs))||this.leafFallback(e):i=this.enter(o,t.attrs||null,t.preserveWhitespace)):(s=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(s));let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));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)}i&&this.sync(l)&&this.open--,s&&this.removePendingMark(s,l)}addAll(e,t,r){let i=t||0;for(let o=t?e.childNodes[t]:e.firstChild,s=r==null?null:e.childNodes[r];o!=s;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o);this.findAtPoint(e,i)}findPlace(e){let t,r;for(let i=this.open;i>=0;i--){let o=this.nodes[i],s=o.findWrapping(e);if(s&&(!t||t.length>s.length)&&(t=s,r=o,!s.length)||o.solid)break}if(!t)return!1;this.sync(r);for(let i=0;ithis.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;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(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(s(l-1,a))return!0;return!1}else{let f=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!f||f.name!=c&&f.groups.indexOf(c)==-1)return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=dl(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let s=i.popFromStashMark(e);s&&i.type&&i.type.allowsMarkType(s.type)&&(i.activeMarks=s.addToSet(i.activeMarks))}if(i==t)break}}};function al(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ai.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function cl(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function jr(n){let e={};for(let t in n)e[t]=n[t];return e}function fl(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let a=0;a{if(o.length||s.marks.length){let l=0,a=0;for(;l=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&n.renderSpec(Nn(r),i(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],o=i.indexOf(" ");o>0&&(r=i.slice(0,o),i=i.slice(o+1));let s,l=r?e.createElementNS(r,i):e.createElement(i),a=t[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let f in a)if(a[f]!=null){let d=f.indexOf(" ");d>0?l.setAttributeNS(f.slice(0,d),f.slice(d+1),a[f]):l.setAttribute(f,a[f])}}for(let f=c;fc)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:p}=n.renderSpec(e,d,r);if(l.appendChild(h),p){if(s)throw new RangeError("Multiple content holes");s=p}}}return{dom:l,contentDOM:s}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=_r(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return _r(e.marks)}};function _r(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Nn(n){return n.document||window.document}var di=65535,hi=Math.pow(2,16);function hl(n,e){return n+e*hi}function ci(n){return n&di}function ul(n){return(n-(n&di))/hi}var ui=1,pi=2,$t=4,mi=8,ht=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&mi)>0}get deletedBefore(){return(this.delInfo&(ui|$t))>0}get deletedAfter(){return(this.delInfo&(pi|$t))>0}get deletedAcross(){return(this.delInfo&$t)>0}},de=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=ci(e);if(!this.inverted)for(let i=0;ie)break;let c=this.ranges[l+o],f=this.ranges[l+s],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:t:t,p=a+i+(h<0?0:f);if(r)return p;let u=e==(t<0?a:d)?null:hl(l/3,e-a),m=e==a?pi:e==d?ui:$t;return(t<0?e!=a:e!=d)&&(m|=mi),new ht(p,m,u)}i+=f-c}return r?e+i:new ht(e+i,0,null)}touches(e,t){let r=0,i=ci(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+o],f=a+c;if(e<=f&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return A.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),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};D.jsonID("addMark",pt);var Pe=class n extends D{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new b(Fn(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return A.fromReplace(e,this.from,this.to,r)}invert(){return new pt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};D.jsonID("removeMark",Pe);var mt=class n extends D{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return A.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return A.fromReplace(e,this.pos,this.pos+1,new b(y.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new n(t.pos,r.pos,i,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 n(t.from,t.to,t.gapFrom,t.gapTo,b.fromJSON(e,t.slice),t.insert,!!t.structure)}};D.jsonID("replaceAround",E);function zn(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function pl(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,c,f)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&f.type.allowsMarkType(r.type)){let h=Math.max(c,e),p=Math.min(c+a.nodeSize,t),u=r.addToSet(d);for(let m=0;mn.step(a)),o.forEach(a=>n.step(a))}function ml(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof ct){let c=s.marks,f;for(;f=r.isInSet(c);)(a||(a=[])).push(f),c=f.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let f=0;fn.step(new Pe(s.from,s.to,s.style)))}function gi(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a=0;a--)n.step(s[a])}function gl(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ue(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),o=n.$from.index(r),s=n.$to.indexAfter(r);if(rt;u--)m||r.index(u)>0?(m=!0,f=y.from(r.node(u).copy(f)),d++):a--;let h=y.empty,p=0;for(let u=o,m=!1;u>t;u--)m||i.after(u+1)=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=y.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new E(i,o,i,o,new b(r,0,0),t.length,!0))}function Sl(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,i)&&Ol(n.doc,n.mapping.slice(o).map(l),r)){let a=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?a=!1:!h&&p&&(a=!0)}a===!1&&Cl(n,s,l,o),gi(n,n.mapping.slice(o).map(l,1),r,void 0,a===null);let c=n.mapping.slice(o),f=c.map(l,1),d=c.map(l+s.nodeSize,1);return n.step(new E(f,d,f+1,d-1,new b(y.from(r.create(i,null,s.marks)),0,0),1,!0)),a===!0&&Ml(n,s,l,o),!1}})}function Ml(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Cl(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+o);n.replaceWith(s,s+1,e.type.schema.text(` +`))}})}function Ol(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function wl(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new E(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new b(y.from(s),0,0),1,!0))}function xe(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,f=t-2;c>o;c--,f--){let d=i.node(c),h=i.index(c);if(d.type.spec.isolating)return!1;let p=d.content.cutByIndex(h,d.childCount),u=r&&r[f+1];u&&(p=p.replaceChild(0,u.type.create(u.attrs)));let m=r&&r[f]||d;if(!d.canReplace(h+1,d.childCount)||!m.type.validContent(p))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function Nl(n,e,t=1,r){let i=n.doc.resolve(e),o=y.empty,s=y.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){o=y.from(i.node(l).copy(o));let f=r&&r[c];s=y.from(f?f.type.create(f.attrs,s):i.node(l).copy(s))}n.step(new K(e,e,new b(o.append(s),t,t),!0))}function yt(n,e){let t=n.resolve(e),r=t.index();return Tl(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Tl(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function Dl(n,e,t){let r=new K(e-t,e+t,b.empty,!0);n.step(r)}function El(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),f=!1;if(o==1)f=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);f=d&&c.canReplaceWith(a,a,d[0])}if(f)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Yt(n,e,t=e,r=b.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return yi(i,o,r)?new K(e,t,r):new Bn(i,o,r).fit()}function yi(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Bn=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=y.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=y.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new b(o,s,l);return e>-1?new E(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new K(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=vn(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],f,d=null;if(t==1&&(s?c.matchType(s.type)||(d=c.fillBefore(y.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:d};if(t==2&&s&&(f=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:f};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=vn(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new b(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=vn(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new b(ft(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new b(ft(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(d=g,f.push(bi(m.mark(h.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let u=c==l.childCount;u||(p=-1),this.placed=dt(this.placed,t,y.from(f)),this.frontier[t].match=d,u&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;l--){let{match:a,type:c}=this.frontier[l],f=Pn(e,l,c,a,!0);if(!f||f.childCount)continue e}return{depth:t,fit:s,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=dt(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=dt(this.placed,this.depth,y.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(y.empty,!0);t.childCount&&(this.placed=dt(this.placed,this.frontier.length,t))}};function ft(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(ft(n.firstChild.content,e-1,t)))}function dt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(dt(n.lastChild.content,e-1,t)))}function vn(n,e){for(let t=0;t1&&(r=r.replaceChild(0,bi(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(y.empty,!0)))),n.copy(r)}function Pn(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!Al(t,o.content,s)?l:null}function Al(n,e,t){for(let r=t;r0;h--,p--){let u=i.node(h).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;s.indexOf(h)>-1?l=h:i.before(h)==p&&s.splice(1,0,-h)}let a=s.indexOf(l),c=[],f=r.openStart;for(let h=r.content,p=0;;p++){let u=h.firstChild;if(c.push(u),p==r.openStart)break;h=u.content}for(let h=f-1;h>=0;h--){let p=c[h],u=Il(p.type);if(u&&!p.sameMarkup(i.node(Math.abs(l)-1)))f=h;else if(u||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+f+1)%(r.openStart+1),u=c[p];if(u)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>d));h--){let p=s[h];p<0||(e=i.before(p),t=o.after(p))}}function ki(n,e,t,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(y.empty,!0))}return n}function vl(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=El(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new b(y.from(r),0,0))}function Pl(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=xi(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s)return n.delete(r.before(s),t);n.delete(e,t)}function xi(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(oe.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}var Ht=class n extends D{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return A.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return A.fromReplace(e,this.pos,this.pos+1,new b(y.from(i),0,t.isLeaf?0:1))}getMap(){return de.empty}invert(e){return new n(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 n(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 n(t.pos,t.attr,t.value)}};D.jsonID("attr",Ht);var jt=class n extends D{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return A.ok(r)}getMap(){return de.empty}invert(e){return new n(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 n(t.attr,t.value)}};D.jsonID("docAttr",jt);var _e=class extends Error{};_e=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};_e.prototype=Object.create(Error.prototype);_e.prototype.constructor=_e;_e.prototype.name="TransformError";var _t=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ut}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new _e(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=b.empty){let i=Yt(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new b(y.from(r),0,0))}delete(e,t){return this.replace(e,t,b.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Rl(this,e,t,r),this}replaceRangeWith(e,t,r){return vl(this,e,t,r),this}deleteRange(e,t){return Pl(this,e,t),this}lift(e,t){return yl(this,e,t),this}join(e,t=1){return Dl(this,e,t),this}wrap(e,t){return xl(this,e,t),this}setBlockType(e,t=e,r,i=null){return Sl(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return wl(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Ht(e,t,r)),this}setDocAttribute(e,t){return this.step(new jt(e,t)),this}addNodeMark(e,t){return this.step(new mt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof O)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new gt(e,t)),this}split(e,t=1,r){return Nl(this,e,t,r),this}addMark(e,t,r){return pl(this,e,t,r),this}removeMark(e,t,r){return ml(this,e,t,r),this}clearIncompatible(e,t,r){return gi(this,e,t,r),this}};var Vn=Object.create(null),S=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Jn(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=0;o--){let s=t<0?Ge(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Ge(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new $(e.node(0))}static atStart(e){return Ge(e,e,0,0,1)||new $(e)}static atEnd(e){return Ge(e,e,e.content.size,e.childCount,-1)||new $(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Vn[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Vn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return w.between(this.$anchor,this.$head).getBookmark()}};S.prototype.visible=!0;var Jn=class{constructor(e,t){this.$from=e,this.$to=t}},Si=!1;function Mi(n){!Si&&!n.parent.inlineContent&&(Si=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var w=class n extends S{constructor(e,t=e){Mi(e),Mi(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return S.near(r);let i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(e,t=b.empty){if(super.replace(e,t),t==b.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Qt(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 n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=S.findFrom(t,r,!0)||S.findFrom(t,-r,!0);if(o)t=o.$head;else return S.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(S.findFrom(e,-r,!0)||S.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?s=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&x.isSelectable(l))return x.create(n,t-(i<0?l.nodeSize:0))}else{let a=Ge(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function Ci(n,e,t){let r=n.steps.length-1;if(r{s==null&&(s=f)}),n.setSelection(S.near(n.doc.resolve(s),t))}var Oi=1,Xt=2,wi=4,qn=class extends _t{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.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Xt,this}ensureMarks(e){return O.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&Xt)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Xt,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||O.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r==null?t:r,!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),this.selection.empty||this.setSelection(S.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|=wi,this}get scrolledIntoView(){return(this.updated&wi)>0}};function Ni(n,e){return!e||!n?n:n.bind(e)}var ze=class{constructor(e,t,r){this.name=e,this.init=Ni(t.init,r),this.apply=Ni(t.apply,r)}},Bl=[new ze("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new ze("selection",{init(n,e){return n.selection||S.atStart(e.doc)},apply(n){return n.selection}}),new ze("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new ze("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],bt=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Bl.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new ze(r.key,r.spec.state,r))})}},Zt=class n{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new bt(e.schema,e.plugins),o=new n(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=ie.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=S.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function Ti(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Ti(i,e,{})),t[r]=i}return t}var P=class{constructor(e){this.spec=e,this.props={},e.props&&Ti(e.props,this,this.props),this.key=e.key?e.key.key:Di("plugin")}getState(e){return e[this.key]}},Ln=Object.create(null);function Di(n){return n in Ln?n+"$"+ ++Ln[n]:(Ln[n]=0,n+"$")}var kt=class{constructor(e="key"){this.key=Di(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Ai=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Fl(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var Vl=(n,e,t)=>{let r=Fl(n,t);if(!r)return!1;let i=Ii(r);if(!i){let s=r.blockRange(),l=s&&Ue(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(!o.type.spec.isolating&&vi(n,i,e))return!0;if(r.parent.content.size==0&&(Ye(o,"end")||x.isSelectable(o))){let s=Yt(n.doc,r.before(),r.after(),b.empty);if(s&&s.slice.size{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=Ii(r)}let s=o&&o.nodeBefore;return!s||!x.isSelectable(s)?!1:(e&&e(n.tr.setSelection(x.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Ii(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Jl(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=Jl(n,t);if(!r)return!1;let i=Ri(r);if(!i)return!1;let o=i.nodeAfter;if(vi(n,i,e))return!0;if(r.parent.content.size==0&&(Ye(o,"start")||x.isSelectable(o))){let s=Yt(n.doc,r.before(),r.after(),b.empty);if(s&&s.slice.size{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` +`).scrollIntoView()),!0)};function $n(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=$n(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(S.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},$l=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof $||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=$n(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(xe(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Ue(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function jl(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof x&&e.selection.node.isBlock)return!r.parentOffset||!xe(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.parent.isBlock)return!1;if(t){let o=i.parentOffset==i.parent.content.size,s=e.tr;(e.selection instanceof w||e.selection instanceof $)&&s.deleteSelection();let l=r.depth==0?null:$n(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=n&&n(i.parent,o),c=a?[a]:o&&l?[{type:l}]:void 0,f=xe(s.doc,s.mapping.map(r.pos),1,c);if(!c&&!f&&xe(s.doc,s.mapping.map(r.pos),1,l?[{type:l}]:void 0)&&(l&&(c=[{type:l}]),f=!0),f&&(s.split(s.mapping.map(r.pos),1,c),!o&&!r.parentOffset&&r.parent.type!=l)){let d=s.mapping.map(r.before()),h=s.doc.resolve(d);l&&r.node(-1).canReplaceWith(h.index(),h.index()+1,l)&&s.setNodeMarkup(s.mapping.map(r.before()),l)}t(s.scrollIntoView())}return!0}}var _l=jl();var Ul=(n,e)=>(e&&e(n.tr.setSelection(new $(n.doc))),!0);function Gl(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||yt(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function vi(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o,s;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(Gl(n,e,t))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(o=(s=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&s.matchType(o[0]||i.type).validEnd){if(t){let d=e.pos+i.nodeSize,h=y.empty;for(let m=o.length-1;m>=0;m--)h=y.from(o[m].create(null,h));h=y.from(r.copy(h));let p=n.tr.step(new E(e.pos-1,d,e.pos,d,new b(h,1,0),o.length,!0)),u=d+2*o.length;yt(p.doc,u)&&p.join(u),t(p.scrollIntoView())}return!0}let a=S.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),f=c&&Ue(c);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(c,f).scrollIntoView()),!0;if(l&&Ye(i,"start",!0)&&Ye(r,"end")){let d=r,h=[];for(;h.push(d),!d.isTextblock;)d=d.lastChild;let p=i,u=1;for(;!p.isTextblock;p=p.firstChild)u++;if(d.canReplace(d.childCount,d.childCount,p.content)){if(t){let m=y.empty;for(let k=h.length-1;k>=0;k--)m=y.from(h[k].copy(m));let g=n.tr.step(new E(e.pos-h.length,e.pos+i.nodeSize,e.pos+u,e.pos+i.nodeSize-u,new b(m,h.length,0),0,!0));t(g.scrollIntoView())}return!0}}return!1}function Pi(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(w.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}var Yl=Pi(-1),Xl=Pi(1);function en(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),l=s&&Ut(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function jn(n,e=null){return function(t,r){let i=!1;for(let o=0;o{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let f=t.doc.resolve(c),d=f.index();i=f.parent.canReplaceWith(d,d+1,n)}})}if(!i)return!1;if(r){let o=t.tr;for(let s=0;s{if(s)return!1;s=l.inlineContent&&l.type.allowsMarkType(t)}),s)return!0}return!1}function Q(n,e=null){return function(t,r){let{empty:i,$cursor:o,ranges:s}=t.selection;if(i&&!o||!Ql(t.doc,s,n))return!1;if(r)if(o)n.isInSet(t.storedMarks||o.marks())?r(t.tr.removeStoredMark(n)):r(t.tr.addStoredMark(n.create(e)));else{let l=!1,a=t.tr;for(let c=0;!l&&c{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,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,r;if(t){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let f=c.getBoundingClientRect(),d=l?f.bottom:f.top;l&&a&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:f.left,right:f.right,top:d-this.width/2,bottom:d+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.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 o,s;if(!i||i==document.body&&getComputedStyle(i).position=="static")o=-pageXOffset,s=-pageYOffset;else{let l=i.getBoundingClientRect();o=l.left-i.scrollLeft,s=l.top-i.scrollTop}this.element.style.left=r.left-o+"px",this.element.style.top=r.top-s+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!o){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Gt(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}};var ue={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:"'"},nn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ea=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),ta=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(T=0;T<10;T++)ue[48+T]=ue[96+T]=String(T);var T;for(T=1;T<=24;T++)ue[T+111]="F"+T;var T;for(T=65;T<=90;T++)ue[T]=String.fromCharCode(T+32),nn[T]=String.fromCharCode(T);var T;for(tn in ue)nn.hasOwnProperty(tn)||(nn[tn]=ue[tn]);var tn;function Vi(n){var e=ea&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||ta&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?nn:ue)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var na=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function ra(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=ue[r.keyCode])&&o!=i){let l=e[Un(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var I=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ot=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},tr=null,me=function(n,e,t){let r=tr||(tr=document.createRange());return r.setEnd(n,t==null?n.nodeValue.length:t),r.setStart(n,e||0),r},oa=function(){tr=null},qe=function(n,e,t,r){return t&&(Li(n,e,t,r,-1)||Li(n,e,t,r,1))},sa=/^(img|br|input|textarea|hr)$/i;function Li(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:se(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Dt(n)||sa.test(n.nodeName)||n.contentEditable=="false")return!1;e=I(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?se(n):0}else return!1}}function se(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function la(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=se(n)}else if(n.parentNode&&!Dt(n))e=I(n),n=n.parentNode;else return null}}function aa(n,e){for(;;){if(n.nodeType==3&&e2),_=tt||(le?/Mac/.test(le.platform):!1),ua=le?/Win/.test(le.platform):!1,Z=/Android \d/.test(Ne),Et=!!Ji&&"webkitFontSmoothing"in Ji.documentElement.style,pa=Et?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ma(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function pe(n,e){return typeof n=="number"?n:n[e]}function ga(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Wi(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;s=Ot(s)){if(s.nodeType!=1)continue;let l=s,a=l==o.body,c=a?ma(o):ga(l),f=0,d=0;if(e.topc.bottom-pe(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+pe(i,"top")-c.top:e.bottom-c.bottom+pe(i,"bottom")),e.leftc.right-pe(r,"right")&&(f=e.right-c.right+pe(i,"right")),f||d)if(a)o.defaultView.scrollBy(f,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),f&&(l.scrollLeft+=f);let u=l.scrollLeft-h,m=l.scrollTop-p;e={left:e.left-u,top:e.top-m,right:e.right-u,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function ya(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:xo(n.dom)}}function xo(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Ot(r));return e}function ba({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;So(t,r==0?0:r-e)}function So(n,e){for(let t=0;t=l){s=Math.max(u.bottom,s),l=Math.min(u.top,l);let m=u.left>e.left?u.left-e.left:u.right=(u.left+u.right)/2?1:0));continue}}else u.top>e.top&&!a&&u.left<=e.left&&u.right>=e.left&&(a=f,c={left:Math.max(u.left,Math.min(u.right,e.left)),top:u.top});!t&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(o=d+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?xa(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:Mo(t,i)}function xa(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i=(o.left+o.right)/2?1:0)}}return{node:n,offset:0}}function xr(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Sa(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function Ca(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right-1?i:n.docView.posFromDOM(e,t,-1)}function Co(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let c;Et&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=Ca(n,r,i,e))}l==null&&(l=Ma(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function qi(n){return n.top=0&&i==r.nodeValue.length?(a--,f=1):t<0?a--:c++,St(Se(me(r,a,c),f),f<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==se(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Xn(a.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(t<0||i==se(r))){let a=r.childNodes[i-1],c=a.nodeType==3?me(a,se(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return St(Se(c,1),!1)}if(o==null&&i=0)}function St(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Xn(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function wo(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Na(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return wo(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Oo(n,i.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=me(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cf.top+1&&(t=="up"?s.top-f.top>(f.bottom-s.top)*2:f.bottom-s.bottom>(s.bottom-f.top)*2))return!1}}return!0})}var Ta=/[\u0590-\u08ac]/;function Da(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return!Ta.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:wo(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:f,anchorOffset:d}=n.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:u,focusOffset:m}=n.domSelectionRange(),g=u&&!p.contains(u.nodeType==1?u:u.parentNode)||a==u&&c==m;try{l.collapse(f,d),a&&(a!=f||c!=d)&&l.extend&&l.extend(a,c)}catch(k){}return h!=null&&(l.caretBidiLevel=h),g})}var Ki=null,$i=null,Hi=!1;function Ea(n,e,t){return Ki==e&&$i==t?Hi:(Ki=e,$i=t,Hi=t=="up"||t=="down"?Na(n,e,t):Da(n,e,t))}var U=0,ji=1,Fe=2,ae=3,Ke=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=U,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tI(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return(i==null?r>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof sn){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof rn&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?I(o.dom)+1:0}}else{let o,s=!0;for(;o=r=f&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,f);e=s;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=I(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let f=l+1;fp&&st){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 r=0,i=0;i=r:er){let l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?Fe:ji,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ae:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Fe:ae}r=s}this.dirty=Fe}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Fe:ji;t.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==U&&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}},or=class extends Ke{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}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}},nt=class n extends Ke{constructor(e,t,r,i){super(e,[],r,i),this.mark=t}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=oe.renderSpec(document,t.type.spec.toDOM(t,r))),new n(e,t,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&ae||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ae&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=U){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=fr(o,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),f=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!f)f=document.createTextNode(t.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:d}=oe.renderSpec(document,t.type.spec.toDOM(t)));!d&&!t.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),t.type.spec.draggable&&(f.draggable=!0));let h=f;return f=Do(f,r,t),c?a=new sr(e,t,r,i,f,d||null,h,c,o,s+1):t.isText?new on(e,t,r,i,f,h,o):new n(e,t,r,i,f,d||null,h,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>y.empty)}return e}matchesNode(e,t,r){return this.dirty==U&&e.eq(this.node)&&ar(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new cr(this,s&&s.node,e);va(this.node,this.innerDeco,(c,f,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(f==this.node.childCount?O.none:this.node.child(f).marks,r,e),a.placeWidget(c,e,i)},(c,f,d,h)=>{a.syncToMarks(c.marks,r,e);let p;a.findNodeMatch(c,f,d,h)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(c,f,d,p,e)||a.updateNextNode(c,f,d,e,h,i)||a.addNode(c,f,d,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Fe)&&(s&&this.protectLocalComposition(e,s),No(this.contentDOM,this.children,e),tt&&Pa(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof w)||rt+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 s=o.nodeValue,l=za(this.node.content,s,r-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){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 s=new or(this,o,t,i);e.input.compositionNodes.push(s),this.children=fr(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==ae||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=U}updateOuterDeco(e){if(ar(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=To(this.dom,this.nodeDOM,lr(this.outerDeco,this.node,t),lr(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function _i(n,e,t,r,i){Do(r,e,n);let o=new we(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}var on=class n extends we{constructor(e,t,r,i,o,s,l){super(e,t,r,i,o,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==ae||this.dirty!=U&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=U||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=U,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ae)}get domAtom(){return!1}isText(e){return this.node.text==e}},sn=class extends Ke{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==U&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},sr=class extends we{constructor(e,t,r,i,o,s,l,a,c,f){super(e,t,r,i,o,s,l,c,f),this.spec=a}update(e,t,r,i){if(this.dirty==ae)return!1;if(this.spec.update){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r):super.setSelection(e,t,r,i)}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 No(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o>1,s=Math.min(o,e.length);for(;i-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=nt.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof nt)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function Ra(n,e){return n.type.side-e.type.side}function va(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let c=0;co;)l.push(i[s++]);let u=o+h.nodeSize;if(h.isText){let g=u;s!g.inline):l.slice();r(h,m,e.forChild(o,h),p),o=u}}function Pa(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function za(n,e,t,r){for(let i=0,o=0;i=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function fr(n,e,t,r,i){let o=[];for(let s=0,l=0;s=t||f<=e?o.push(a):(ct&&o.push(a.slice(t-c,a.size,r)))}return o}function Sr(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(pn(t)){for(a=l;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&x.isSelectable(f)&&i.parent&&!(f.isInline&&ca(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new x(s==d?l:r.resolve(d))}}else{let f=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(f<0)return null;a=r.resolve(f)}if(!c){let f=e=="pointer"||n.state.selection.head{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Eo(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Fa(n){let e=n.domSelection(),t=document.createRange(),r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setEnd(r.parentNode,I(r)+1):t.setEnd(r,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&q&&Oe<=11&&(r.disabled=!0,r.disabled=!1)}function Ao(n,e){if(e instanceof x){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Qi(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Qi(n)}function Qi(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Mr(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||w.between(e,t,r)}function Zi(n){return n.editable&&!n.hasFocus()?!1:Io(n)}function Io(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Va(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return qe(e.node,e.offset,t.anchorNode,t.anchorOffset)}function dr(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&S.findFrom(o,e)}function Me(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function eo(n,e,t){let r=n.state.selection;if(r instanceof w)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Me(n,new w(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=dr(n.state,e);return i&&i instanceof x?Me(n,i):!1}else if(!(_&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?x.isSelectable(o)?Me(n,new x(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Et?Me(n,new w(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof x&&r.node.isInline)return Me(n,new w(e>0?r.$to:r.$from));{let i=dr(n.state,e);return i?Me(n,i):!1}}}function ln(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ct(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Qe(n,e){return e<0?La(n):Ja(n)}function La(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(ee&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Ct(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Ro(t))break;{let l=t.previousSibling;for(;l&&Ct(l,-1);)i=t.parentNode,o=I(l),l=l.previousSibling;if(l)t=l,r=ln(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?hr(n,t,r):i&&hr(n,i,o)}function Ja(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=ln(t),o,s;for(;;)if(r{n.state==i&&ge(n)},50)}function to(n,e){let t=n.state.doc.resolve(e);if(!(V||ua)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s1)return o.lefti.top&&s1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function no(n,e,t){let r=n.state.selection;if(r instanceof w&&!r.empty||t.indexOf("s")>-1||_&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=dr(n.state,e);if(s&&s instanceof x)return Me(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof $?S.near(s,e):S.findFrom(s,e);return l?Me(n,l):!1}return!1}function ro(n,e){if(!(n.state.selection instanceof w))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function io(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Ka(n){if(!L||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;io(n,r,"true"),setTimeout(()=>io(n,r,"false"),20)}return!1}function $a(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Ha(n,e){let t=e.keyCode,r=$a(e);if(t==8||_&&t==72&&r=="c")return ro(n,-1)||Qe(n,-1);if(t==46&&!e.shiftKey||_&&t==68&&r=="c")return ro(n,1)||Qe(n,1);if(t==13||t==27)return!0;if(t==37||_&&t==66&&r=="c"){let i=t==37?to(n,n.state.selection.from)=="ltr"?-1:1:-1;return eo(n,i,r)||Qe(n,i)}else if(t==39||_&&t==70&&r=="c"){let i=t==39?to(n,n.state.selection.from)=="ltr"?1:-1:1;return eo(n,i,r)||Qe(n,i)}else{if(t==38||_&&t==80&&r=="c")return no(n,-1,r)||Qe(n,-1);if(t==40||_&&t==78&&r=="c")return Ka(n)||no(n,1,r)||Qe(n,1);if(r==(_?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function vo(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||oe.fromSchema(n.state.schema),l=Lo(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,f,d=0;for(;c&&c.nodeType==1&&(f=Vo[c.nodeName.toLowerCase()]);){for(let p=f.length-1;p>=0;p--){let u=l.createElement(f[p]);for(;a.firstChild;)u.appendChild(a.firstChild);a.appendChild(u),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${d?` -${d}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,` -`);return{dom:a,text:d,slice:e}}function Po(n,e,t,r,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,o||r,n)}),o)return e?new b(y.from(n.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0):b.empty;let h=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(h)l=h;else{let d=i.marks(),{schema:p}=n.state,u=oe.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(u.serializeNode(p.text(m,d)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),s=Ua(t),Et&&Ga(s);let c=s&&s.querySelector("[data-pm-slice]"),f=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let h=+f[3];h>0;h--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||ve.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!ja.test(d.parentNode.nodeName)?{ignore:!0}:null}})),f)l=Ya(oo(l,+f[1],+f[2]),f[4]);else if(l=b.maxOpen(_a(l.content,i),!0),l.openStart||l.openEnd){let h=0,d=0;for(let p=l.content.firstChild;h{l=h(l,n)}),l}var ja=/^(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 _a(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&Bo(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Fo(s[s.length-1],o.length));let f=zo(l,a);s.push(f),i=i.matchType(f.type),o=a}}),s)return y.from(s)}return n}function zo(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,y.from(n));return n}function Bo(n,e,t,r,i){if(i1&&(o=0),i=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(y.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function oo(n,e,t){return e]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Lo().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Vo[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"").reverse().join("")),t.innerHTML=n,i)for(let o=0;o=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=y.from(a.create(r[l+1],i)),o++,s++}return new b(i,o,s)}var J={},W={},Xa={touchstart:!0,touchmove:!0},mr=class{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.lastAndroidDelete=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 Qa(n){for(let e in J){let t=J[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{ec(n,r)&&!Or(n,r)&&(n.editable||!(r.type in W))&&t(n,r)},Xa[e]?{passive:!0}:void 0)}L&&n.dom.addEventListener("input",()=>null),gr(n)}function Ce(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Za(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function gr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Or(n,r))})}function Or(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function ec(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function tc(n,e){!Or(n,e)&&J[e.type]&&(n.editable||!(e.type in W))&&J[e.type](n,e)}W.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Wo(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Z&&V&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),tt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Be(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Ha(n,t)?t.preventDefault():Ce(n,"key")};W.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};W.keypress=(n,e)=>{let t=e;if(Wo(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||_&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof w)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function mn(n){return{left:n.clientX,top:n.clientY}}function nc(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function wr(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,l=>s>o.depth?l(n,t,o.nodeAfter,o.before(s),i,!0):l(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function et(n,e,t){n.focused||n.focus();let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function rc(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&x.isSelectable(r)?(et(n,new x(t),"pointer"),!0):!1}function ic(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof x&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(x.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(et(n,x.create(n.state.doc,i),"pointer"),!0):!1}function oc(n,e,t,r,i){return wr(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?ic(n,t):rc(n,t))}function sc(n,e,t,r){return wr(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function lc(n,e,t,r){return wr(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||ac(n,t,r)}function ac(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(et(n,w.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)et(n,w.create(r,l+1,l+1+s.content.size),"pointer");else if(x.isSelectable(s))et(n,x.create(r,l),"pointer");else continue;return!0}}function Nr(n){return an(n)}var Jo=_?"metaKey":"ctrlKey";J.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Nr(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&nc(t,n.input.lastClick)&&!t[Jo]&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o};let s=n.posAtCoords(mn(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new yr(n,s,t,!!r)):(o=="doubleClick"?sc:lc)(n,s.pos,s.inside,t)?t.preventDefault():Ce(n,"pointer"))};var yr=class{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Jo],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let f=e.state.doc.resolve(t.pos);o=f.parent,s=f.depth?f.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof x&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ee&&!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)),Ce(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(()=>ge(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(mn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ce(this.view,"pointer"):oc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||L&&this.mightDrag&&!this.mightDrag.node.isAtom||V&&!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)?(et(this.view,S.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ce(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ce(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)}};J.touchstart=n=>{n.input.lastTouch=Date.now(),Nr(n),Ce(n,"pointer")};J.touchmove=n=>{n.input.lastTouch=Date.now(),Ce(n,"pointer")};J.contextmenu=n=>Nr(n);function Wo(n,e){return n.composing?!0:L&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var cc=Z?5e3:-1;W.compositionstart=W.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),an(n,!0),n.markCursor=null;else if(an(n),ee&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){n.domSelection().collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}qo(n,cc)};W.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,qo(n,20))};function qo(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>an(n),e))}function Ko(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=hc());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function fc(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=la(e.focusNode,e.focusOffset),r=aa(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function hc(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function an(n,e=!1){if(!(Z&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ko(n),e||n.docView&&n.docView.dirty){let t=Mr(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):n.updateState(n.state),!0}return!1}}function dc(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var wt=q&&Oe<15||tt&&pa<604;J.copy=W.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=wt?null:t.clipboardData,s=r.content(),{dom:l,text:a}=vo(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):dc(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function uc(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function pc(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Nt(n,r.value,null,i,e):Nt(n,r.textContent,r.innerHTML,i,e)},50)}function Nt(n,e,t,r,i){let o=Po(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||b.empty)))return!0;if(!o)return!1;let s=uc(o),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function $o(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}W.paste=(n,e)=>{let t=e;if(n.composing&&!Z)return;let r=wt?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Nt(n,$o(r),r.getData("text/html"),i,t)?t.preventDefault():pc(n,t)};var cn=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Ho=_?"altKey":"ctrlKey";J.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(mn(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof x?i.to-1:i.to))){if(r&&r.mightDrag)s=x.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(s=x.create(n.state.doc,h.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:f}=vo(n,l);t.dataTransfer.clearData(),t.dataTransfer.setData(wt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",wt||t.dataTransfer.setData("text/plain",c),n.dragging=new cn(f,!t[Ho],s)};J.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};W.dragover=W.dragenter=(n,e)=>e.preventDefault();W.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(mn(t));if(!i)return;let o=n.state.doc.resolve(i.pos),s=r&&r.slice;s?n.someProp("transformPasted",u=>{s=u(s,n)}):s=Po(n,$o(t.dataTransfer),wt?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&!t[Ho]);if(n.someProp("handleDrop",u=>u(n,t,s||b.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Gt(n.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let c=n.state.tr;if(l){let{node:u}=r;u?u.replace(c):c.deleteSelection()}let f=c.mapping.map(a),h=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=c.doc;if(h?c.replaceRangeWith(f,f,s.content.firstChild):c.replaceRange(f,f,s),c.doc.eq(d))return;let p=c.doc.resolve(f);if(h&&x.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new x(p));else{let u=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,k,N)=>u=N),c.setSelection(Cr(n,p,c.doc.resolve(u)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};J.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&ge(n)},20))};J.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};J.beforeinput=(n,e)=>{if(V&&Z&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,Be(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in W)J[n]=W[n];function Tt(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var fn=class n{constructor(e,t){this.toDOM=e,this.spec=t||Je,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new G(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Tt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Le=class n{constructor(e,t){this.attrs=e,this.spec=t||Je}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new G(o,s,this)}valid(e,t){return t.from=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,i+l,o)}}map(e,t,r){return this==z||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Je)}mapInner(e,t,r,i,o){let s;for(let l=0;l{let c=a+r,f;if(f=_o(t,l,c)){for(i||(i=this.children.slice());ol&&h.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;lo&&a.type instanceof Le){let c=Math.max(o,a.from)-o,f=Math.min(s,a.to)-o;ci.map(e,t,Je));return n.from(r)}forChild(e,t){if(t.isLeaf)return B.empty;let r=[];for(let i=0;it instanceof B)?e:e.reduce((t,r)=>t.concat(r instanceof B?r:r.members),[]))}}};function mc(n,e,t,r,i,o,s){let l=n.slice();for(let c=0,f=o;c{let g=m-u-(p-d);for(let k=0;kN+f-h)continue;let te=l[k]+f-h;p>=te?l[k+1]=d<=te?-2:-1:d>=f&&g&&(l[k]+=g,l[k+1]+=g)}h+=g}),f=t.maps[c].map(f,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let d=t.map(n[c+1]+o,-1),p=d-i,{index:u,offset:m}=r.content.findIndex(h),g=r.maybeChild(u);if(g&&m==h&&m+g.nodeSize==p){let k=l[c+2].mapInner(t,g,f+1,n[c]+o+1,s);k!=z?(l[c]=h,l[c+1]=p,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=gc(l,n,e,t,i,o,s),f=dn(c,r,0,s);e=f.local;for(let h=0;ht&&s.to{let c=_o(n,l,a+t);if(c){o=!0;let f=dn(c,l,t+a+1,r);f!=z&&i.push(a,a+l.nodeSize,f)}});let s=jo(o?Uo(n):n,-t).sort(We);for(let l=0;l0;)e++;n.splice(e,0,t)}function er(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=z&&e.push(r)}),n.cursorWrapper&&e.push(B.create(n.state.doc,[n.cursorWrapper.deco])),hn.from(e)}var yc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},bc=q&&Oe<=11,kr=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},xr=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new kr,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),bc&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,yc)),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;tthis.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(Zi(this.view)){if(this.suppressingSelectionUpdates)return ge(this.view);if(q&&Oe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&qe(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=Ot(o))t.add(o);for(let o=e.anchorNode;o;o=Ot(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Zi(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let f=0;fh.nodeName=="BR");if(f.length==2){let[h,d]=f;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of f){let p=d.parentNode;p&&p.nodeName=="LI"&&(!h||Sc(e,h)!=p)&&d.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,s),kc(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ge(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;fi;g--){let k=r.childNodes[g-1],N=k.pmViewDesc;if(k.nodeName=="BR"&&!N){o=g;break}if(!N||N.size)break}let h=n.state.doc,d=n.someProp("domParser")||ve.fromSchema(n.state.schema),p=h.resolve(s),u=null,m=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Cc,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,k=c[1]&&c[1].pos;k==null&&(k=g),u={anchor:g+s,head:k+s}}return{doc:m,sel:u,from:s,to:l}}function Cc(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(L&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||L&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var Oc=/^(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 wc(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,be=Mr(n,M);if(be&&!n.state.selection.eq(be)){if(V&&Z&&n.input.lastKeyCode===13&&Date.now()-100Js(n,Be(13,"Enter"))))return;let Pt=n.state.tr.setSelection(be);M=="pointer"?Pt.setMeta("pointer",!0):M=="key"&&Pt.scrollIntoView(),o&&Pt.setMeta("composition",o),n.dispatch(Pt)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Mc(n,e,t),f=n.state.doc,h=f.slice(c.from,c.to),d,p;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Z)&&i.some(M=>M.nodeType==1&&!Oc.test(M.nodeName))&&(!u||u.endA>=u.endB)&&n.someProp("handleKeyDown",M=>M(n,Be(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!u)if(r&&a instanceof w&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))u={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let M=ho(n,n.state.doc,c.sel);if(M&&!M.eq(n.state.selection)){let be=n.state.tr.setSelection(M);o&&be.setMeta("composition",o),n.dispatch(be)}}return}n.input.domChangeCount++,n.state.selection.fromn.state.selection.from&&u.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?u.start=n.state.selection.from:u.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(u.endB+=n.state.selection.to-u.endA,u.endA=n.state.selection.to)),q&&Oe<=11&&u.endB==u.start+1&&u.endA==u.start&&u.start>c.from&&c.doc.textBetween(u.start-c.from-1,u.start-c.from+1)==" \xA0"&&(u.start--,u.endA--,u.endB--);let m=c.doc.resolveNoCache(u.start-c.from),g=c.doc.resolveNoCache(u.endB-c.from),k=f.resolve(u.start),N=m.sameParent(g)&&m.parent.inlineContent&&k.end()>=u.endA,te;if((tt&&n.input.lastIOSEnter>Date.now()-225&&(!N||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!N&&m.posM(n,Be(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>u.start&&Tc(f,u.start,u.endA,m,g)&&n.someProp("handleKeyDown",M=>M(n,Be(8,"Backspace")))){Z&&V&&n.domObserver.suppressSelectionUpdates();return}V&&Z&&u.endB==u.start&&(n.input.lastAndroidDelete=Date.now()),Z&&!N&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==u.endA&&(u.endB-=2,g=c.doc.resolveNoCache(u.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(M){return M(n,Be(13,"Enter"))})},20));let ne=u.start,X=u.endA,C,j,re;if(N){if(m.pos==g.pos)q&&Oe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ge(n),20)),C=n.state.tr.delete(ne,X),j=f.resolve(u.start).marksAcross(f.resolve(u.endA));else if(u.endA==u.endB&&(re=Nc(m.parent.content.cut(m.parentOffset,g.parentOffset),k.parent.content.cut(k.parentOffset,u.endA-k.start()))))C=n.state.tr,re.type=="add"?C.addMark(ne,X,re.mark):C.removeMark(ne,X,re.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",be=>be(n,ne,X,M)))return;C=n.state.tr.insertText(M,ne,X)}}if(C||(C=n.state.tr.replace(ne,X,c.doc.slice(u.start-c.from,u.endB-c.from))),c.sel){let M=ho(n,C.doc,c.sel);M&&!(V&&Z&&n.composing&&M.empty&&(u.start!=u.endB||n.input.lastAndroidDeletee.content.size?null:Cr(n,e.resolve(t.anchor),e.resolve(t.head))}function Nc(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,l,a;for(let f=0;ff.mark(l.addToSet(f.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=f=>f.mark(l.removeFromSet(f.marks));else return null;let c=[];for(let f=0;ft||tr(s,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Dc(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s=s?o-r:0;o-=a,o&&o=l?o-r:0;o-=a,o&&o=56320&&e<=57343&&t>=55296&&t<=56319}var un=class{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 mr,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(bo),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=go(this),mo(this),this.nodeViews=yo(this),this.docView=_i(this.state.doc,po(this),er(this),this.dom,this),this.domObserver=new xr(this,(r,i,o,s)=>wc(this,r,i,o,s)),this.domObserver.start(),Qa(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&&gr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(bo),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(Ko(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=yo(this);Ac(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&gr(this),this.editable=go(this),mo(this);let a=er(this),c=po(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=o||!this.docView.matchesNode(e.doc,c,a);(h||!e.selection.eq(i.selection))&&(s=!0);let d=f=="preserve"&&s&&this.dom.style.overflowAnchor==null&&ya(this);if(s){this.domObserver.stop();let p=h&&(q||V)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Ec(i.selection,e.selection);if(h){let u=V?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=fc(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=_i(e.doc,c,a,this.dom,this)),u&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Va(this))?ge(this,p):(Ao(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():d&&ba(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof x){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Wi(this,t.getBoundingClientRect(),e)}else Wi(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;t0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new cn(e.slice,e.move,i<0?void 0:x.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let s=0;st.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Oa(this,e)}coordsAtPos(e,t=1){return Oo(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Ea(this,t||this.state,e)}pasteHTML(e,t){return Nt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Nt(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Za(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],er(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,oa())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return tc(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 L&&this.root.nodeType===11&&fa(this.dom.ownerDocument)==this.dom&&xc(this,e)||e}domSelection(){return this.root.getSelection()}};function po(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[G.node(0,n.state.doc.content.size,e)]}function mo(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:G.widget(n.state.selection.head,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function go(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Ec(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function yo(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Ac(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function bo(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var F=class n extends S{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):S.near(r)}content(){return b.empty}eq(e){return e instanceof n&&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 n(e.resolve(t.pos))}getBookmark(){return new Dr(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Ic(e)||!Rc(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(n.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!x.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(n.valid(l))return l}return null}}};F.prototype.visible=!1;F.findFrom=F.findGapCursorFrom;S.jsonID("gapcursor",F);var Dr=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return F.valid(t)?new F(t):S.near(t)}};function Ic(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Rc(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Go(){return new P({props:{decorations:Bc,createSelectionBetween(n,e,t){return e.pos==t.pos&&F.valid(t)?new F(t):null},handleClick:Pc,handleKeyDown:vc,handleDOMEvents:{beforeinput:zc}}})}var vc=Xn({ArrowLeft:gn("horiz",-1),ArrowRight:gn("horiz",1),ArrowUp:gn("vert",-1),ArrowDown:gn("vert",1)});function gn(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof w){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=F.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new F(c))),!0):!1}}function Pc(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!F.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&x.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new F(r))),!0)}function zc(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof F))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=y.empty;for(let s=r.length-1;s>=0;s--)i=y.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new b(i,0,0));return o.setSelection(w.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Bc(n){if(!(n.selection instanceof F))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",B.create(n.doc,[G.widget(n.selection.head,e,{key:"gapcursor"})])}var yn=200,R=function(){};R.prototype.append=function(e){return e.length?(e=R.from(e),!this.length&&e||e.length=t?R.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};R.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};R.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};R.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};R.from=function(e){return e instanceof R?e:e&&e.length?new Yo(e):R.empty};var Yo=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=yn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=yn)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(R);R.empty=new Yo([]);var Fc=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(R),Er=R;var Vc=500,He=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],f=[];return this.items.forEach((h,d)=>{if(!h.step){i||(i=this.remapping(r,d+1),o=i.maps.length),o--,f.push(h);return}if(i){f.push(new ce(h.map));let p=h.step.map(i.slice(o)),u;p&&s.maybeStep(p).doc&&(u=s.mapping.maps[s.mapping.maps.length-1],c.push(new ce(u,void 0,void 0,c.length+f.length))),o--,u&&i.appendMap(u,o)}else s.maybeStep(h.step);if(h.selection)return l=i?h.selection.map(i.slice(o)):h.selection,a=new n(this.items.slice(0,r).append(f.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let f=0;fJc&&(l=Lc(l,c),s-=c),new n(l.append(o),s)}remapping(e,t){let r=new ut;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new ce(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},i);let a=t;this.items.forEach(d=>{let p=o.getMirror(--a);if(p==null)return;s=Math.min(s,p);let u=o.maps[p];if(d.step){let m=e.steps[p].invert(e.docs[p]),g=d.selection&&d.selection.map(o.slice(a+1,p));g&&l++,r.push(new ce(u,m,g))}else r.push(new ce(u))},i);let c=[];for(let d=t;dVc&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let f=s.selection&&s.selection.map(t.slice(r));f&&o++;let h=new ce(c.invert(),a,f),d,p=i.length-1;(d=i.length&&i[p].merge(h))?i[p]=d:i.push(h)}}else s.map&&r--},this.items.length,0),new n(Er.from(i.reverse()),o)}};He.empty=new He(Er.empty,0);function Lc(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var ce=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},fe=class{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}},Jc=20;function Wc(n,e,t,r){let i=t.getMeta($e),o;if(i)return i.historyState;t.getMeta($c)&&(n=new fe(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta($e))return s.getMeta($e).redo?new fe(n.done.addTransform(t,void 0,r,bn(e)),n.undone,Xo(t.mapping.maps[t.steps.length-1]),n.prevTime,n.prevComposition):new fe(n.done,n.undone.addTransform(t,void 0,r,bn(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!qc(t,n.prevRanges)),c=s?Ar(n.prevRanges,t.mapping):Xo(t.mapping.maps[t.steps.length-1]);return new fe(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,bn(e)),He.empty,c,t.time,l==null?n.prevComposition:l)}else return(o=t.getMeta("rebased"))?new fe(n.done.rebased(t,o),n.undone.rebased(t,o),Ar(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new fe(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Ar(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function qc(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o=e[o]&&(t=!0)}),t}function Xo(n){let e=[];return n.forEach((t,r,i,o)=>e.push(i,o)),e}function Ar(n,e){if(!n)return null;let t=[];for(let r=0;r{let i=$e.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=Kc(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}var At=kn(!1,!0),rt=kn(!0,!0),Jh=kn(!1,!1),Wh=kn(!0,!1);var Hc=["p",0],jc=["blockquote",0],_c=["hr"],Uc=["pre",["code",0]],Gc=["br"],ye={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Hc}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return jc}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return _c}},heading:{attrs:{level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(n){return["h"+n.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Uc}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(n){return{src:n.getAttribute("src"),title:n.getAttribute("title"),alt:n.getAttribute("alt")}}}],toDOM(n){let{src:e,alt:t,title:r}=n.attrs;return["img",{src:e,alt:t,title:r}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return Gc}}},Yc=["em",0],Xc=["strong",0],Qc=["code",0],It={link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(n){return{href:n.getAttribute("href"),title:n.getAttribute("title")}}}],toDOM(n){let{href:e,title:t}=n.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:n=>n.type.name=="em"}],toDOM(){return Yc}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name=="strong"},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}],toDOM(){return Xc}},code:{parseDOM:[{tag:"code"}],toDOM(){return Qc}}},$h=new ke({nodes:ye,marks:It});var Zc=["ol",0],ef=["ul",0],tf=["li",0],nf={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs(n){return{order:n.hasAttribute("start")?+n.getAttribute("start"):1}}}],toDOM(n){return n.attrs.order==1?Zc:["ol",{start:n.attrs.order},0]}},rf={parseDOM:[{tag:"ul"}],toDOM(){return ef}},of={parseDOM:[{tag:"li"}],toDOM(){return tf},defining:!0};function Rr(n,e){let t={};for(let r in n)t[r]=n[r];for(let r in e)t[r]=e[r];return t}function es(n,e,t){return n.append({ordered_list:Rr(nf,{content:"list_item+",group:t}),bullet_list:Rr(rf,{content:"list_item+",group:t}),list_item:Rr(of,{content:e})})}function it(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),l=!1,a=s;if(!s)return!1;if(s.depth>=2&&i.node(s.depth-1).type.compatibleContent(n)&&s.startIndex==0){if(i.index(s.depth-1)==0)return!1;let f=t.doc.resolve(s.start-2);a=new Ie(f,f,s.depth),s.endIndex=0;f--)o=y.from(t[f].type.create(t[f].attrs,o));n.step(new E(e.start-(r?2:0),e.end,e.start,e.end,new b(o,0,0),t.length,!0));let s=0;for(let f=0;f=i.depth-3;k--)h=y.from(i.node(k).copy(h));let p=i.indexAfter(-1){if(g>-1)return!1;k.isTextblock&&k.content.size==0&&(g=N+1)}),g>-1&&m.setSelection(S.near(m.doc.resolve(g))),r(m.scrollIntoView())}return!0}let a=o.pos==i.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(i.pos,o.pos),f=a?[e?{type:n,attrs:e}:null,{type:a}]:void 0;return xe(c.doc,i.pos,2,f)?(r&&r(c.split(i.pos,2,f).scrollIntoView()),!0):!1}}function ns(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?lf(e,t,n,o):af(e,t,o):!0:!1}}function lf(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);om;u--)p-=i.child(u).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(t.start),s=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=o.node(-1),f=o.index(-1);if(!c.canReplace(f+(l?0:1),f+1,s.content.append(a?y.empty:y.from(i))))return!1;let h=o.pos,d=h+s.nodeSize;return r.step(new E(h-(l?1:0),d+(a?1:0),h+1,d-1,new b((l?y.empty:y.from(i.copy(y.empty))).append(a?y.empty:y.from(i.copy(y.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function rs(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,f=y.from(c?n.create():null),h=new b(y.from(n.create(null,y.from(l.type.create(null,f)))),c?3:1,0),d=o.start,p=o.end;t(e.tr.step(new E(d-(c?3:1),p,d,p,h,1,!0)).scrollIntoView())}return!0}}var Te=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?cf(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}};function cf(n){return function(e,t,r,i){let o=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);o+=t[0].slice(s+t[1].length),r+=s;let l=r-i;l>0&&(o=t[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}var is=(n,e)=>{let t=n.plugins;for(let r=0;r=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else s.delete(o.from,o.to);e(s)}return!0}}return!1},Yh=new Te(/--$/,"\u2014"),Xh=new Te(/\.\.\.$/,"\u2026"),Qh=new Te(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C"),Zh=new Te(/"$/,"\u201D"),ed=new Te(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018"),td=new Te(/'$/,"\u2019");function ff(n,e){let t=Object.keys(e);return t.length?!!t.filter(r=>e[r]===n[r]).length:!0}function vr(n,e,t={}){return n.find(r=>r.type===e&&ff(r.attrs,t))}function hf(n,e,t={}){return!!vr(n,e,t)}function Pr(n,e,t={}){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if(!r.node)return;let i=vr(r.node.marks,e,t);if(!i)return;let o=n.index(),s=n.start()+r.offset,l=o+1,a=s+r.node.nodeSize;for(vr(r.node.marks,e,t);o>0&&i.isInSet(n.parent.child(o-1).marks);)o-=1,s-=n.parent.child(o).nodeSize;for(;l=e||j<0||h&&re>=o}function k(){var C=Sn();if(g(C))return N(C);l=setTimeout(k,m(C))}function N(C){return l=void 0,d&&r?p(C):(r=i=void 0,s)}function te(){l!==void 0&&clearTimeout(l),c=0,r=a=i=l=void 0}function ne(){return l===void 0?s:N(Sn())}function X(){var C=Sn(),j=g(C);if(r=arguments,i=this,a=C,j){if(l===void 0)return u(a);if(h)return clearTimeout(l),l=setTimeout(k,e),p(a)}return l===void 0&&(l=setTimeout(k,e)),s}return X.cancel=te,X.flush=ne,X}var ys=qf;var H=(n,e=null)=>{let t=document.createElement(n);if(e)for(let[r,i]of Object.entries(e))/^data-|^aria-|^role/.test(r)?t.setAttribute(r,i):t[r]=i;return t};function Mn(n,e){let t=document.createElement("article");return t.innerHTML=e,ve.fromSchema(n).parse(t)}function bs(n){let{schema:e,doc:t}=n,r=oe.fromSchema(e),i=H("article");return i.appendChild(r.serializeFragment(t.content)),i.innerHTML}var ks=(n,e,t)=>{let r=oe.fromSchema(n),i=()=>{let s=H("article");return s.appendChild(r.serializeFragment(e.state.doc.content)),s.innerHTML};return ys(()=>{let s=i();t.value!==s&&(t.value=s,t.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0})))},250)},xs=n=>{let{$from:e,$to:t}=n,r=e.pos,i=t.pos,o=e.nodeAfter,s=t.nodeBefore,l=o!=null&&o.isText?/^\s*/.exec(o.text)[0].length:0,a=s!=null&&s.isText?/\s*$/.exec(s.text)[0].length:0;return r+lnew Promise(e=>{let t=document.createElement("div");t.innerHTML=` +`);return{dom:a,text:h,slice:e}}function Po(n,e,t,r,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",h=>{e=h(e,o||r,n)}),o)return e?new b(y.from(n.state.schema.text(e.replace(/\r\n?/g,` +`))),0,0):b.empty;let d=n.someProp("clipboardTextParser",h=>h(e,i,r,n));if(d)l=d;else{let h=i.marks(),{schema:p}=n.state,u=oe.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(u.serializeNode(p.text(m,h)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),s=Ua(t),Et&&Ga(s);let c=s&&s.querySelector("[data-pm-slice]"),f=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let d=+f[3];d>0;d--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||ve.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!ja.test(h.parentNode.nodeName)?{ignore:!0}:null}})),f)l=Ya(oo(l,+f[1],+f[2]),f[4]);else if(l=b.maxOpen(_a(l.content,i),!0),l.openStart||l.openEnd){let d=0,h=0;for(let p=l.content.firstChild;d{l=d(l,n)}),l}var ja=/^(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 _a(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&Bo(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Fo(s[s.length-1],o.length));let f=zo(l,a);s.push(f),i=i.matchType(f.type),o=a}}),s)return y.from(s)}return n}function zo(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,y.from(n));return n}function Bo(n,e,t,r,i){if(i1&&(o=0),i=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(y.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function oo(n,e,t){return e]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Lo().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Vo[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"").reverse().join("")),t.innerHTML=n,i)for(let o=0;o=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=y.from(a.create(r[l+1],i)),o++,s++}return new b(i,o,s)}var J={},W={},Xa={touchstart:!0,touchmove:!0},pr=class{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.lastAndroidDelete=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 Qa(n){for(let e in J){let t=J[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{ec(n,r)&&!Cr(n,r)&&(n.editable||!(r.type in W))&&t(n,r)},Xa[e]?{passive:!0}:void 0)}L&&n.dom.addEventListener("input",()=>null),mr(n)}function Ce(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Za(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function mr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Cr(n,r))})}function Cr(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function ec(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function tc(n,e){!Cr(n,e)&&J[e.type]&&(n.editable||!(e.type in W))&&J[e.type](n,e)}W.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Wo(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Z&&V&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),tt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Be(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Ha(n,t)?t.preventDefault():Ce(n,"key")};W.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};W.keypress=(n,e)=>{let t=e;if(Wo(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||_&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof w)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function mn(n){return{left:n.clientX,top:n.clientY}}function nc(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Or(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,l=>s>o.depth?l(n,t,o.nodeAfter,o.before(s),i,!0):l(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function et(n,e,t){n.focused||n.focus();let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function rc(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&x.isSelectable(r)?(et(n,new x(t),"pointer"),!0):!1}function ic(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof x&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(x.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(et(n,x.create(n.state.doc,i),"pointer"),!0):!1}function oc(n,e,t,r,i){return Or(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?ic(n,t):rc(n,t))}function sc(n,e,t,r){return Or(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function lc(n,e,t,r){return Or(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||ac(n,t,r)}function ac(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(et(n,w.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)et(n,w.create(r,l+1,l+1+s.content.size),"pointer");else if(x.isSelectable(s))et(n,x.create(r,l),"pointer");else continue;return!0}}function wr(n){return an(n)}var Jo=_?"metaKey":"ctrlKey";J.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=wr(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&nc(t,n.input.lastClick)&&!t[Jo]&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o};let s=n.posAtCoords(mn(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new gr(n,s,t,!!r)):(o=="doubleClick"?sc:lc)(n,s.pos,s.inside,t)?t.preventDefault():Ce(n,"pointer"))};var gr=class{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Jo],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let f=e.state.doc.resolve(t.pos);o=f.parent,s=f.depth?f.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof x&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ee&&!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)),Ce(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(()=>ge(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(mn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ce(this.view,"pointer"):oc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||L&&this.mightDrag&&!this.mightDrag.node.isAtom||V&&!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)?(et(this.view,S.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ce(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ce(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)}};J.touchstart=n=>{n.input.lastTouch=Date.now(),wr(n),Ce(n,"pointer")};J.touchmove=n=>{n.input.lastTouch=Date.now(),Ce(n,"pointer")};J.contextmenu=n=>wr(n);function Wo(n,e){return n.composing?!0:L&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var cc=Z?5e3:-1;W.compositionstart=W.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),an(n,!0),n.markCursor=null;else if(an(n),ee&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){n.domSelection().collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}qo(n,cc)};W.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,qo(n,20))};function qo(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>an(n),e))}function Ko(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=dc());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function fc(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=la(e.focusNode,e.focusOffset),r=aa(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function dc(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function an(n,e=!1){if(!(Z&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ko(n),e||n.docView&&n.docView.dirty){let t=Sr(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):n.updateState(n.state),!0}return!1}}function hc(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var wt=q&&Oe<15||tt&&pa<604;J.copy=W.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=wt?null:t.clipboardData,s=r.content(),{dom:l,text:a}=vo(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):hc(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function uc(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function pc(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Nt(n,r.value,null,i,e):Nt(n,r.textContent,r.innerHTML,i,e)},50)}function Nt(n,e,t,r,i){let o=Po(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||b.empty)))return!0;if(!o)return!1;let s=uc(o),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function $o(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}W.paste=(n,e)=>{let t=e;if(n.composing&&!Z)return;let r=wt?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Nt(n,$o(r),r.getData("text/html"),i,t)?t.preventDefault():pc(n,t)};var cn=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Ho=_?"altKey":"ctrlKey";J.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(mn(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof x?i.to-1:i.to))){if(r&&r.mightDrag)s=x.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(s=x.create(n.state.doc,d.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:f}=vo(n,l);t.dataTransfer.clearData(),t.dataTransfer.setData(wt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",wt||t.dataTransfer.setData("text/plain",c),n.dragging=new cn(f,!t[Ho],s)};J.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};W.dragover=W.dragenter=(n,e)=>e.preventDefault();W.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(mn(t));if(!i)return;let o=n.state.doc.resolve(i.pos),s=r&&r.slice;s?n.someProp("transformPasted",u=>{s=u(s,n)}):s=Po(n,$o(t.dataTransfer),wt?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&!t[Ho]);if(n.someProp("handleDrop",u=>u(n,t,s||b.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Gt(n.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let c=n.state.tr;if(l){let{node:u}=r;u?u.replace(c):c.deleteSelection()}let f=c.mapping.map(a),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=c.doc;if(d?c.replaceRangeWith(f,f,s.content.firstChild):c.replaceRange(f,f,s),c.doc.eq(h))return;let p=c.doc.resolve(f);if(d&&x.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new x(p));else{let u=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,k,N)=>u=N),c.setSelection(Mr(n,p,c.doc.resolve(u)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};J.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&ge(n)},20))};J.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};J.beforeinput=(n,e)=>{if(V&&Z&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,Be(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in W)J[n]=W[n];function Tt(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var fn=class n{constructor(e,t){this.toDOM=e,this.spec=t||Je,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new G(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Tt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Le=class n{constructor(e,t){this.attrs=e,this.spec=t||Je}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new G(o,s,this)}valid(e,t){return t.from=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,i+l,o)}}map(e,t,r){return this==z||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Je)}mapInner(e,t,r,i,o){let s;for(let l=0;l{let c=a+r,f;if(f=_o(t,l,c)){for(i||(i=this.children.slice());ol&&d.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;lo&&a.type instanceof Le){let c=Math.max(o,a.from)-o,f=Math.min(s,a.to)-o;ci.map(e,t,Je));return n.from(r)}forChild(e,t){if(t.isLeaf)return B.empty;let r=[];for(let i=0;it instanceof B)?e:e.reduce((t,r)=>t.concat(r instanceof B?r:r.members),[]))}}};function mc(n,e,t,r,i,o,s){let l=n.slice();for(let c=0,f=o;c{let g=m-u-(p-h);for(let k=0;kN+f-d)continue;let te=l[k]+f-d;p>=te?l[k+1]=h<=te?-2:-1:h>=f&&g&&(l[k]+=g,l[k+1]+=g)}d+=g}),f=t.maps[c].map(f,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let h=t.map(n[c+1]+o,-1),p=h-i,{index:u,offset:m}=r.content.findIndex(d),g=r.maybeChild(u);if(g&&m==d&&m+g.nodeSize==p){let k=l[c+2].mapInner(t,g,f+1,n[c]+o+1,s);k!=z?(l[c]=d,l[c+1]=p,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=gc(l,n,e,t,i,o,s),f=hn(c,r,0,s);e=f.local;for(let d=0;dt&&s.to{let c=_o(n,l,a+t);if(c){o=!0;let f=hn(c,l,t+a+1,r);f!=z&&i.push(a,a+l.nodeSize,f)}});let s=jo(o?Uo(n):n,-t).sort(We);for(let l=0;l0;)e++;n.splice(e,0,t)}function Zn(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=z&&e.push(r)}),n.cursorWrapper&&e.push(B.create(n.state.doc,[n.cursorWrapper.deco])),dn.from(e)}var yc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},bc=q&&Oe<=11,br=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},kr=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new br,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),bc&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,yc)),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;tthis.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(Zi(this.view)){if(this.suppressingSelectionUpdates)return ge(this.view);if(q&&Oe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&qe(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=Ot(o))t.add(o);for(let o=e.anchorNode;o;o=Ot(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Zi(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let f=0;fd.nodeName=="BR");if(f.length==2){let[d,h]=f;d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let h of f){let p=h.parentNode;p&&p.nodeName=="LI"&&(!d||Sc(e,d)!=p)&&h.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,s),kc(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ge(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;fi;g--){let k=r.childNodes[g-1],N=k.pmViewDesc;if(k.nodeName=="BR"&&!N){o=g;break}if(!N||N.size)break}let d=n.state.doc,h=n.someProp("domParser")||ve.fromSchema(n.state.schema),p=d.resolve(s),u=null,m=h.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Cc,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,k=c[1]&&c[1].pos;k==null&&(k=g),u={anchor:g+s,head:k+s}}return{doc:m,sel:u,from:s,to:l}}function Cc(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(L&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||L&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var Oc=/^(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 wc(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,be=Sr(n,M);if(be&&!n.state.selection.eq(be)){if(V&&Z&&n.input.lastKeyCode===13&&Date.now()-100Js(n,Be(13,"Enter"))))return;let Pt=n.state.tr.setSelection(be);M=="pointer"?Pt.setMeta("pointer",!0):M=="key"&&Pt.scrollIntoView(),o&&Pt.setMeta("composition",o),n.dispatch(Pt)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Mc(n,e,t),f=n.state.doc,d=f.slice(c.from,c.to),h,p;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Z)&&i.some(M=>M.nodeType==1&&!Oc.test(M.nodeName))&&(!u||u.endA>=u.endB)&&n.someProp("handleKeyDown",M=>M(n,Be(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!u)if(r&&a instanceof w&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))u={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let M=ho(n,n.state.doc,c.sel);if(M&&!M.eq(n.state.selection)){let be=n.state.tr.setSelection(M);o&&be.setMeta("composition",o),n.dispatch(be)}}return}n.input.domChangeCount++,n.state.selection.fromn.state.selection.from&&u.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?u.start=n.state.selection.from:u.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(u.endB+=n.state.selection.to-u.endA,u.endA=n.state.selection.to)),q&&Oe<=11&&u.endB==u.start+1&&u.endA==u.start&&u.start>c.from&&c.doc.textBetween(u.start-c.from-1,u.start-c.from+1)==" \xA0"&&(u.start--,u.endA--,u.endB--);let m=c.doc.resolveNoCache(u.start-c.from),g=c.doc.resolveNoCache(u.endB-c.from),k=f.resolve(u.start),N=m.sameParent(g)&&m.parent.inlineContent&&k.end()>=u.endA,te;if((tt&&n.input.lastIOSEnter>Date.now()-225&&(!N||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!N&&m.posM(n,Be(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>u.start&&Tc(f,u.start,u.endA,m,g)&&n.someProp("handleKeyDown",M=>M(n,Be(8,"Backspace")))){Z&&V&&n.domObserver.suppressSelectionUpdates();return}V&&Z&&u.endB==u.start&&(n.input.lastAndroidDelete=Date.now()),Z&&!N&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==u.endA&&(u.endB-=2,g=c.doc.resolveNoCache(u.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(M){return M(n,Be(13,"Enter"))})},20));let ne=u.start,X=u.endA,C,j,re;if(N){if(m.pos==g.pos)q&&Oe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ge(n),20)),C=n.state.tr.delete(ne,X),j=f.resolve(u.start).marksAcross(f.resolve(u.endA));else if(u.endA==u.endB&&(re=Nc(m.parent.content.cut(m.parentOffset,g.parentOffset),k.parent.content.cut(k.parentOffset,u.endA-k.start()))))C=n.state.tr,re.type=="add"?C.addMark(ne,X,re.mark):C.removeMark(ne,X,re.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",be=>be(n,ne,X,M)))return;C=n.state.tr.insertText(M,ne,X)}}if(C||(C=n.state.tr.replace(ne,X,c.doc.slice(u.start-c.from,u.endB-c.from))),c.sel){let M=ho(n,C.doc,c.sel);M&&!(V&&Z&&n.composing&&M.empty&&(u.start!=u.endB||n.input.lastAndroidDeletee.content.size?null:Mr(n,e.resolve(t.anchor),e.resolve(t.head))}function Nc(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,l,a;for(let f=0;ff.mark(l.addToSet(f.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=f=>f.mark(l.removeFromSet(f.marks));else return null;let c=[];for(let f=0;ft||er(s,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Dc(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s=s?o-r:0;o-=a,o&&o=l?o-r:0;o-=a,o&&o=56320&&e<=57343&&t>=55296&&t<=56319}var un=class{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 pr,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(bo),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=go(this),mo(this),this.nodeViews=yo(this),this.docView=_i(this.state.doc,po(this),Zn(this),this.dom,this),this.domObserver=new kr(this,(r,i,o,s)=>wc(this,r,i,o,s)),this.domObserver.start(),Qa(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&&mr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(bo),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(Ko(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=yo(this);Ac(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&mr(this),this.editable=go(this),mo(this);let a=Zn(this),c=po(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(s=!0);let h=f=="preserve"&&s&&this.dom.style.overflowAnchor==null&&ya(this);if(s){this.domObserver.stop();let p=d&&(q||V)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Ec(i.selection,e.selection);if(d){let u=V?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=fc(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=_i(e.doc,c,a,this.dom,this)),u&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Va(this))?ge(this,p):(Ao(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():h&&ba(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof x){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Wi(this,t.getBoundingClientRect(),e)}else Wi(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;t0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new cn(e.slice,e.move,i<0?void 0:x.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let s=0;st.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Oa(this,e)}coordsAtPos(e,t=1){return Oo(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Ea(this,t||this.state,e)}pasteHTML(e,t){return Nt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Nt(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Za(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Zn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,oa())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return tc(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 L&&this.root.nodeType===11&&fa(this.dom.ownerDocument)==this.dom&&xc(this,e)||e}domSelection(){return this.root.getSelection()}};function po(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[G.node(0,n.state.doc.content.size,e)]}function mo(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:G.widget(n.state.selection.head,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function go(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Ec(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function yo(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Ac(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function bo(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var F=class n extends S{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):S.near(r)}content(){return b.empty}eq(e){return e instanceof n&&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 n(e.resolve(t.pos))}getBookmark(){return new Tr(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Ic(e)||!Rc(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(n.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!x.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(n.valid(l))return l}return null}}};F.prototype.visible=!1;F.findFrom=F.findGapCursorFrom;S.jsonID("gapcursor",F);var Tr=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return F.valid(t)?new F(t):S.near(t)}};function Ic(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Rc(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Go(){return new P({props:{decorations:Bc,createSelectionBetween(n,e,t){return e.pos==t.pos&&F.valid(t)?new F(t):null},handleClick:Pc,handleKeyDown:vc,handleDOMEvents:{beforeinput:zc}}})}var vc=Yn({ArrowLeft:gn("horiz",-1),ArrowRight:gn("horiz",1),ArrowUp:gn("vert",-1),ArrowDown:gn("vert",1)});function gn(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof w){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=F.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new F(c))),!0):!1}}function Pc(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!F.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&x.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new F(r))),!0)}function zc(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof F))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=y.empty;for(let s=r.length-1;s>=0;s--)i=y.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new b(i,0,0));return o.setSelection(w.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Bc(n){if(!(n.selection instanceof F))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",B.create(n.doc,[G.widget(n.selection.head,e,{key:"gapcursor"})])}var yn=200,R=function(){};R.prototype.append=function(e){return e.length?(e=R.from(e),!this.length&&e||e.length=t?R.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};R.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};R.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};R.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};R.from=function(e){return e instanceof R?e:e&&e.length?new Yo(e):R.empty};var Yo=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=yn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=yn)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(R);R.empty=new Yo([]);var Fc=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(R),Dr=R;var Vc=500,He=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],f=[];return this.items.forEach((d,h)=>{if(!d.step){i||(i=this.remapping(r,h+1),o=i.maps.length),o--,f.push(d);return}if(i){f.push(new ce(d.map));let p=d.step.map(i.slice(o)),u;p&&s.maybeStep(p).doc&&(u=s.mapping.maps[s.mapping.maps.length-1],c.push(new ce(u,void 0,void 0,c.length+f.length))),o--,u&&i.appendMap(u,o)}else s.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(o)):d.selection,a=new n(this.items.slice(0,r).append(f.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let f=0;fJc&&(l=Lc(l,c),s-=c),new n(l.append(o),s)}remapping(e,t){let r=new ut;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new ce(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},i);let a=t;this.items.forEach(h=>{let p=o.getMirror(--a);if(p==null)return;s=Math.min(s,p);let u=o.maps[p];if(h.step){let m=e.steps[p].invert(e.docs[p]),g=h.selection&&h.selection.map(o.slice(a+1,p));g&&l++,r.push(new ce(u,m,g))}else r.push(new ce(u))},i);let c=[];for(let h=t;hVc&&(d=d.compress(this.items.length-r.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),r=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let f=s.selection&&s.selection.map(t.slice(r));f&&o++;let d=new ce(c.invert(),a,f),h,p=i.length-1;(h=i.length&&i[p].merge(d))?i[p]=h:i.push(d)}}else s.map&&r--},this.items.length,0),new n(Dr.from(i.reverse()),o)}};He.empty=new He(Dr.empty,0);function Lc(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var ce=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},fe=class{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}},Jc=20;function Wc(n,e,t,r){let i=t.getMeta($e),o;if(i)return i.historyState;t.getMeta($c)&&(n=new fe(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta($e))return s.getMeta($e).redo?new fe(n.done.addTransform(t,void 0,r,bn(e)),n.undone,Xo(t.mapping.maps[t.steps.length-1]),n.prevTime,n.prevComposition):new fe(n.done,n.undone.addTransform(t,void 0,r,bn(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!qc(t,n.prevRanges)),c=s?Er(n.prevRanges,t.mapping):Xo(t.mapping.maps[t.steps.length-1]);return new fe(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,bn(e)),He.empty,c,t.time,l==null?n.prevComposition:l)}else return(o=t.getMeta("rebased"))?new fe(n.done.rebased(t,o),n.undone.rebased(t,o),Er(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new fe(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Er(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function qc(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o=e[o]&&(t=!0)}),t}function Xo(n){let e=[];return n.forEach((t,r,i,o)=>e.push(i,o)),e}function Er(n,e){if(!n)return null;let t=[];for(let r=0;r{let i=$e.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=Kc(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}var At=kn(!1,!0),rt=kn(!0,!0),Jd=kn(!1,!1),Wd=kn(!0,!1);var Hc=["p",0],jc=["blockquote",0],_c=["hr"],Uc=["pre",["code",0]],Gc=["br"],ye={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Hc}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return jc}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return _c}},heading:{attrs:{level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(n){return["h"+n.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Uc}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(n){return{src:n.getAttribute("src"),title:n.getAttribute("title"),alt:n.getAttribute("alt")}}}],toDOM(n){let{src:e,alt:t,title:r}=n.attrs;return["img",{src:e,alt:t,title:r}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return Gc}}},Yc=["em",0],Xc=["strong",0],Qc=["code",0],It={link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(n){return{href:n.getAttribute("href"),title:n.getAttribute("title")}}}],toDOM(n){let{href:e,title:t}=n.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:n=>n.type.name=="em"}],toDOM(){return Yc}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name=="strong"},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}],toDOM(){return Xc}},code:{parseDOM:[{tag:"code"}],toDOM(){return Qc}}},$d=new ke({nodes:ye,marks:It});var Zc=["ol",0],ef=["ul",0],tf=["li",0],nf={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs(n){return{order:n.hasAttribute("start")?+n.getAttribute("start"):1}}}],toDOM(n){return n.attrs.order==1?Zc:["ol",{start:n.attrs.order},0]}},rf={parseDOM:[{tag:"ul"}],toDOM(){return ef}},of={parseDOM:[{tag:"li"}],toDOM(){return tf},defining:!0};function Ir(n,e){let t={};for(let r in n)t[r]=n[r];for(let r in e)t[r]=e[r];return t}function es(n,e,t){return n.append({ordered_list:Ir(nf,{content:"list_item+",group:t}),bullet_list:Ir(rf,{content:"list_item+",group:t}),list_item:Ir(of,{content:e})})}function it(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),l=!1,a=s;if(!s)return!1;if(s.depth>=2&&i.node(s.depth-1).type.compatibleContent(n)&&s.startIndex==0){if(i.index(s.depth-1)==0)return!1;let f=t.doc.resolve(s.start-2);a=new Ie(f,f,s.depth),s.endIndex=0;f--)o=y.from(t[f].type.create(t[f].attrs,o));n.step(new E(e.start-(r?2:0),e.end,e.start,e.end,new b(o,0,0),t.length,!0));let s=0;for(let f=0;f=i.depth-3;k--)d=y.from(i.node(k).copy(d));let p=i.indexAfter(-1){if(g>-1)return!1;k.isTextblock&&k.content.size==0&&(g=N+1)}),g>-1&&m.setSelection(S.near(m.doc.resolve(g))),r(m.scrollIntoView())}return!0}let a=o.pos==i.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(i.pos,o.pos),f=a?[e?{type:n,attrs:e}:null,{type:a}]:void 0;return xe(c.doc,i.pos,2,f)?(r&&r(c.split(i.pos,2,f).scrollIntoView()),!0):!1}}function ns(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?lf(e,t,n,o):af(e,t,o):!0:!1}}function lf(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);om;u--)p-=i.child(u).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(t.start),s=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=o.node(-1),f=o.index(-1);if(!c.canReplace(f+(l?0:1),f+1,s.content.append(a?y.empty:y.from(i))))return!1;let d=o.pos,h=d+s.nodeSize;return r.step(new E(d-(l?1:0),h+(a?1:0),d+1,h-1,new b((l?y.empty:y.from(i.copy(y.empty))).append(a?y.empty:y.from(i.copy(y.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function rs(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,f=y.from(c?n.create():null),d=new b(y.from(n.create(null,y.from(l.type.create(null,f)))),c?3:1,0),h=o.start,p=o.end;t(e.tr.step(new E(h-(c?3:1),p,h,p,d,1,!0)).scrollIntoView())}return!0}}var Te=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?cf(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}};function cf(n){return function(e,t,r,i){let o=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);o+=t[0].slice(s+t[1].length),r+=s;let l=r-i;l>0&&(o=t[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}var is=(n,e)=>{let t=n.plugins;for(let r=0;r=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else s.delete(o.from,o.to);e(s)}return!0}}return!1},Yd=new Te(/--$/,"\u2014"),Xd=new Te(/\.\.\.$/,"\u2026"),Qd=new Te(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C"),Zd=new Te(/"$/,"\u201D"),eh=new Te(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018"),th=new Te(/'$/,"\u2019");function ff(n,e){let t=Object.keys(e);return t.length?!!t.filter(r=>e[r]===n[r]).length:!0}function Rr(n,e,t={}){return n.find(r=>r.type===e&&ff(r.attrs,t))}function df(n,e,t={}){return!!Rr(n,e,t)}function vr(n,e,t={}){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if(!r.node)return;let i=Rr(r.node.marks,e,t);if(!i)return;let o=n.index(),s=n.start()+r.offset,l=o+1,a=s+r.node.nodeSize;for(Rr(r.node.marks,e,t);o>0&&i.isInSet(n.parent.child(o-1).marks);)o-=1,s-=n.parent.child(o).nodeSize;for(;l=e||j<0||d&&re>=o}function k(){var C=Sn();if(g(C))return N(C);l=setTimeout(k,m(C))}function N(C){return l=void 0,h&&r?p(C):(r=i=void 0,s)}function te(){l!==void 0&&clearTimeout(l),c=0,r=a=i=l=void 0}function ne(){return l===void 0?s:N(Sn())}function X(){var C=Sn(),j=g(C);if(r=arguments,i=this,a=C,j){if(l===void 0)return u(a);if(d)return clearTimeout(l),l=setTimeout(k,e),p(a)}return l===void 0&&(l=setTimeout(k,e)),s}return X.cancel=te,X.flush=ne,X}var ys=qf;var H=(n,e=null)=>{let t=document.createElement(n);if(e)for(let[r,i]of Object.entries(e))/^data-|^aria-|^role/.test(r)?t.setAttribute(r,i):t[r]=i;return t};function Mn(n,e){let t=document.createElement("article");return t.innerHTML=e,ve.fromSchema(n).parse(t)}function bs(n){let{schema:e,doc:t}=n,r=oe.fromSchema(e),i=H("article");return i.appendChild(r.serializeFragment(t.content)),i.innerHTML}var ks=(n,e,t)=>{let r=oe.fromSchema(n),i=()=>{let s=H("article");return s.appendChild(r.serializeFragment(e.state.doc.content)),s.innerHTML};return ys(()=>{let s=i();t.value!==s&&(t.value=s,t.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0})))},250)},xs=n=>{let{$from:e,$to:t}=n,r=e.pos,i=t.pos,o=e.nodeAfter,s=t.nodeBefore,l=o!=null&&o.isText?/^\s*/.exec(o.text)[0].length:0,a=s!=null&&s.isText?/\s*$/.exec(s.text)[0].length:0;return r+lnew Promise(e=>{let t=document.createElement("div");t.innerHTML=`

@@ -16,7 +16,7 @@ var DjangoProseEditor=(()=>{var zt=Object.defineProperty;var Ws=Object.getOwnPro
- `,document.body.append(t);let r=t.querySelector("dialog"),i=t.querySelector("form");i.href.value=n.href||"",i.title.value=n.title||"",r.querySelector("button[value=cancel]").addEventListener("click",()=>{r.close()}),r.addEventListener("close",()=>{t.remove(),e(null)}),t.querySelector("button[type=submit]").addEventListener("click",o=>{o.preventDefault(),i.reportValidity()&&(t.remove(),e(i.href.value?{href:i.href.value,title:i.title.value}:null))}),r.showModal()}),st=(n,e)=>{let{$from:t,empty:r}=n.selection,i=n.schema.marks.link;if(r&&!i.isInSet(t.marks()))return!1;if(e){let o=t.marks().find(s=>s.type===i);Kf((o==null?void 0:o.attrs)||{}).then(s=>{if(s){let l;if(r)l=Pr(t,i),e(n.tr.removeMark(l.from,l.to,i).addMark(l.from,l.to,i.create(s)));else{let{from:a,to:c}=xs(n.selection);e(n.tr.addMark(a,c,i.create(s)))}}})}return!0},Ss=(n,e)=>{let t=n.schema.marks.link,{$from:r,from:i,to:o}=n.selection,s=Pr(r,t);return s&&s.from<=i&&s.to>=o?(e&&e(n.tr.removeMark(s.from,s.to,t)),!0):!1},$f=n=>new Promise(e=>{let t=document.createElement("div");t.innerHTML=` + `,document.body.append(t);let r=t.querySelector("dialog"),i=t.querySelector("form");i.href.value=n.href||"",i.title.value=n.title||"",r.querySelector("button[value=cancel]").addEventListener("click",()=>{r.close()}),r.addEventListener("close",()=>{t.remove(),e(null)}),t.querySelector("button[type=submit]").addEventListener("click",o=>{o.preventDefault(),i.reportValidity()&&(t.remove(),e(i.href.value?{href:i.href.value,title:i.title.value}:null))}),r.showModal()}),st=(n,e)=>{let{$from:t,empty:r}=n.selection,i=n.schema.marks.link;if(r&&!i.isInSet(t.marks()))return!1;if(e){let o=t.marks().find(s=>s.type===i);Kf((o==null?void 0:o.attrs)||{}).then(s=>{if(s){let l;if(r)l=vr(t,i),e(n.tr.removeMark(l.from,l.to,i).addMark(l.from,l.to,i.create(s)));else{let{from:a,to:c}=xs(n.selection);e(n.tr.addMark(a,c,i.create(s)))}}})}return!0},Ss=(n,e)=>{let t=n.schema.marks.link,{$from:r,from:i,to:o}=n.selection,s=vr(r,t);return s&&s.from<=i&&s.to>=o?(e&&e(n.tr.removeMark(s.from,s.to,t)),!0):!1},$f=n=>new Promise(e=>{let t=document.createElement("div");t.innerHTML=`

@@ -24,4 +24,4 @@ var DjangoProseEditor=(()=>{var zt=Object.defineProperty;var Ws=Object.getOwnPro
- `,document.body.append(t);let r=t.querySelector("dialog"),i=t.querySelector("form");i.html.value=n,r.querySelector("button[value=cancel]").addEventListener("click",()=>{r.close()}),r.addEventListener("close",()=>{t.remove(),e(null)}),t.querySelector("button[type=submit]").addEventListener("click",o=>{o.preventDefault(),i.reportValidity()&&(t.remove(),e(i.html.value))}),r.showModal()}),Ms=(n,e)=>(e&&$f(bs(n)).then(t=>{if(t){let r=Mn(n.schema,t);e(n.tr.replaceWith(0,n.tr.doc.content.size,r))}}),!0),Cs=(n,e)=>(e&&e(n.tr.replaceSelectionWith(n.schema.nodes.horizontal_rule.create())),!0);var Os=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1,ws=n=>(e,t)=>{n[e]=t};function Ns(n){let e={},t,r=ws(e);if(r("Mod-z",At),r("Shift-Mod-z",rt),r("Backspace",is),Os||r("Mod-y",rt),t=n.nodes.hard_break){let i=t,o=xt(jn,(s,l)=>(l&&l(s.tr.replaceSelectionWith(i.create()).scrollIntoView()),!0));r("Mod-Enter",o),r("Shift-Enter",o),Os&&r("Ctrl-Enter",o)}return(t=n.nodes.bullet_list)&&r("Shift-Ctrl-8",it(t)),(t=n.nodes.ordered_list)&&r("Shift-Ctrl-9",it(t)),(t=n.nodes.blockquote)&&r("Ctrl->",en(t)),(t=n.nodes.list_item)&&(r("Enter",ts(t)),r("Mod-[",ns(t)),r("Mod-]",rs(t))),e}function Ts(n){let e={},t,r=ws(e);return(t=n.marks.strong)&&(r("Mod-b",Q(t)),r("Mod-B",Q(t))),(t=n.marks.em)&&(r("Mod-i",Q(t)),r("Mod-I",Q(t))),(t=n.marks.underline)&&(r("Mod-Shift-u",Q(t)),r("Mod-Shift-U",Q(t))),(t=n.marks.strikethrough)&&(r("Mod-Shift-s",Q(t)),r("Mod-Shift-S",Q(t))),(t=n.marks.link)&&(r("Mod-k",st),r("Mod-K",st)),e}function Ds(n,e){return new P({view(t){let r=new Br(t,n,e);return t.dom.parentNode.insertBefore(r.dom,t.dom),r}})}function Es(n,e){let{from:t,$from:r,to:i,empty:o}=n.selection;return o?e.isInSet(n.storedMarks||r.marks()):n.doc.rangeHasMark(t,i,e)}function Hf(n){let e=H("span",{className:"prose-menubar__button prose-menubar__button--heading"});return e.append(H("span",{className:"material-icons",textContent:"title",title:`heading ${n}`}),H("span",{className:"level",textContent:`${n}`})),e}function Y(n,e){return H("span",{className:"prose-menubar__button material-icons",textContent:n,title:e})}function As(n){if(!n.nodes.heading)return[];let e=t=>({command:_n(n.nodes.heading,{level:t}),dom:Hf(t),active(r){return r.selection.$from.parent.hasMarkup(n.nodes.heading,{level:t})}});return[e(1),e(2),e(3),e(4),e(5),{command:_n(n.nodes.paragraph),dom:Y("notes","paragraph"),active(t){return t.selection.$from.parent.hasMarkup(n.nodes.paragraph)}}]}function Is(n){let e=[],t;return(t=n.nodes.bullet_list)&&e.push({command:it(t),dom:Y("format_list_bulleted","unordered list"),active(r){return!1}}),(t=n.nodes.ordered_list)&&e.push({command:it(t),dom:Y("format_list_numbered","ordered list"),active(r){return!1}}),(t=n.nodes.blockquote)&&e.push({command:en(t),dom:Y("format_quote","blockquote"),active(r){return!1}}),(t=n.nodes.horizontal_rule)&&e.push({command:Cs,dom:Y("horizontal_rule","horizontal rule"),active(r){return!1}}),e}function Rs(n){let e=(t,r,i)=>t?{command:Q(t),dom:Y(r,i),active:o=>Es(o,t)}:null;return[e(n.marks.strong,"format_bold","bold"),e(n.marks.em,"format_italic","italic"),e(n.marks.underline,"format_underline","underline"),e(n.marks.strikethrough,"format_strikethrough","strikethrough"),e(n.marks.sub,"subscript","subscript"),e(n.marks.sup,"superscript","superscript")].filter(Boolean)}function vs(n){return n.marks.link?[{command:st,dom:Y("insert_link","insert link"),active:st},{command:Ss,dom:Y("link_off","remove link"),active:e=>Es(e,n.marks.link)}]:[]}function Ps(){return[{command:At,dom:Y("undo","undo"),active(n){return!1}},{command:rt,dom:Y("redo","redo"),active(n){return!1}}]}function zs(){return[{command:Ms,dom:Y("code","edit HTML"),active:()=>!1}]}var Br=class{constructor(e,t,r){if(this.items=[t,...r].flat(),this.editorView=e,this.dom=H("div",{className:"prose-menubar"}),t.length){let i=H("div",{className:"prose-menubar__dropdown"}),o=H("div");this.dom.append(i),i.append(Y("notes","paragraph")),i.append(o),t.forEach(({dom:s})=>o.append(s))}r.filter(i=>i.length).forEach(i=>{let o=H("div",{className:"prose-menubar__group"});this.dom.append(o),i.forEach(({dom:s})=>o.append(s))}),this.update(),this.dom.addEventListener("mousedown",i=>{i.preventDefault(),e.focus(),this.items.forEach(({command:o,dom:s})=>{s.contains(i.target)&&o(e.state,e.dispatch,e)})})}update(){this.items.forEach(({command:e,dom:t,active:r})=>{let i=e(this.editorView.state,null,this.editorView);t.classList.toggle("disabled",!i),t.classList.toggle("active",r(this.editorView.state)||!1)})}destroy(){this.dom.remove()}};function Bs(){return new P({view(n){return new Fr(n)}})}var Fr=class{constructor(e){this.editorView=e,this.editorView.dom.setAttribute("spellcheck","false")}update(){}destroy(){this.editorView.dom.removeAttribute("spellcheck")}};function Fs(n,e,t,r){let i=n.childCount,o=e.childCount;e:for(let s=0,l=0;s{let t=[];if(n.text)for(let r of n.text.matchAll(/\u00A0/g)){let i=e+(r.index||0);t.push(G.inline(i,i+1,{class:"prose-editor-nbsp"}))}return t},jf=n=>{let e=[];return n.descendants((t,r)=>{e.push(Vs(t,r))}),B.create(n,e.flat())},Vr=new P({state:{init(n,{doc:e}){return jf(e)},apply(n,e,t){let r=e.map(n.mapping,n.doc);return Fs(t.doc,n.doc,0,(i,o)=>{let s=Vs(i,o);r=r.add(n.doc,s)}),r}},props:{decorations(n){return Vr.getState(n)}}});var _f=["u",0],Uf=["s",0],Gf=["sub",0],Yf=["sup",0],Xf=(n,e=null)=>{if(!e)return n;let t=["doc","paragraph","text",...e],r={},i={};return n.spec.nodes.forEach((o,s)=>{t.includes(o)&&(r[o]=s)}),n.spec.marks.forEach((o,s)=>{t.includes(o)&&(i[o]=s)}),new ke({nodes:r,marks:i})};function Ls(n,e){let t={nodes:{doc:ye.doc,paragraph:ye.paragraph,heading:ye.heading,blockquote:ye.blockquote,horizontal_rule:ye.horizontal_rule,text:ye.text,hard_break:ye.hard_break},marks:{link:It.link,strong:It.strong,em:It.em,underline:{parseDOM:[{tag:"u"},{style:"text-decoration:underline"}],toDOM(){return _f}},strikethrough:{parseDOM:[{tag:"s"},{style:"text-decoration:line-through"}],toDOM(){return Uf}},sub:{parseDOM:[{tag:"sub"}],toDOM(){return Gf}},sup:{parseDOM:[{tag:"sup"}],toDOM(){return Yf}}}},r=new ke(t);r=new ke({nodes:es(r.spec.nodes,"paragraph block*","block"),marks:r.spec.marks}),r=Xf(r,e.types);let i=Cn(Cn({},Ns(r)),Ts(r)),o=[Yn(i),Yn(Bi),Fi(),Go(),Zo(),Ds(As(r),[Is(r),vs(r),Rs(r),e.history?Ps():null,e.html?zs():null].filter(Boolean)),Bs(),e.typograpic?Vr:null].filter(Boolean),s=H("div",{className:"prose-editor"});n.before(s);let l=new un(s,{state:Zt.create({doc:Mn(r,n.value),plugins:o}),dispatchTransaction:c=>{l.updateState(l.state.apply(c)),a()}}),a=ks(r,l,n);return()=>{try{l.destroy()}catch(c){}s.remove()}}return js(Qf);})(); + `,document.body.append(t);let r=t.querySelector("dialog"),i=t.querySelector("form");i.html.value=n,r.querySelector("button[value=cancel]").addEventListener("click",()=>{r.close()}),r.addEventListener("close",()=>{t.remove(),e(null)}),t.querySelector("button[type=submit]").addEventListener("click",o=>{o.preventDefault(),i.reportValidity()&&(t.remove(),e(i.html.value))}),r.showModal()}),Ms=(n,e)=>(e&&$f(bs(n)).then(t=>{if(t){let r=Mn(n.schema,t);e(n.tr.replaceWith(0,n.tr.doc.content.size,r))}}),!0),Cs=(n,e)=>(e&&e(n.tr.replaceSelectionWith(n.schema.nodes.horizontal_rule.create())),!0);var Os=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1,ws=n=>(e,t)=>{n[e]=t};function Ns(n){let e={},t,r=ws(e);if(r("Mod-z",At),r("Shift-Mod-z",rt),r("Backspace",is),Os||r("Mod-y",rt),t=n.nodes.hard_break){let i=t,o=xt(Hn,(s,l)=>(l&&l(s.tr.replaceSelectionWith(i.create()).scrollIntoView()),!0));r("Mod-Enter",o),r("Shift-Enter",o),Os&&r("Ctrl-Enter",o)}return(t=n.nodes.bullet_list)&&r("Shift-Ctrl-8",it(t)),(t=n.nodes.ordered_list)&&r("Shift-Ctrl-9",it(t)),(t=n.nodes.blockquote)&&r("Ctrl->",en(t)),(t=n.nodes.list_item)&&(r("Enter",ts(t)),r("Mod-[",ns(t)),r("Mod-]",rs(t))),e}function Ts(n){let e={},t,r=ws(e);return(t=n.marks.strong)&&(r("Mod-b",Q(t)),r("Mod-B",Q(t))),(t=n.marks.em)&&(r("Mod-i",Q(t)),r("Mod-I",Q(t))),(t=n.marks.underline)&&(r("Mod-Shift-u",Q(t)),r("Mod-Shift-U",Q(t))),(t=n.marks.strikethrough)&&(r("Mod-Shift-s",Q(t)),r("Mod-Shift-S",Q(t))),(t=n.marks.link)&&(r("Mod-k",st),r("Mod-K",st)),e}function Ds(n,e){return new P({view(t){let r=new zr(t,n,e);return t.dom.parentNode.insertBefore(r.dom,t.dom),r}})}function Es(n,e){let{from:t,$from:r,to:i,empty:o}=n.selection;return o?e.isInSet(n.storedMarks||r.marks()):n.doc.rangeHasMark(t,i,e)}function Hf(n){let e=H("span",{className:"prose-menubar__button prose-menubar__button--heading"});return e.append(H("span",{className:"material-icons",textContent:"title",title:`heading ${n}`}),H("span",{className:"level",textContent:`${n}`})),e}function Y(n,e){return H("span",{className:"prose-menubar__button material-icons",textContent:n,title:e})}function As(n){if(!n.nodes.heading)return[];let e=t=>({command:jn(n.nodes.heading,{level:t}),dom:Hf(t),active(r){return r.selection.$from.parent.hasMarkup(n.nodes.heading,{level:t})}});return[e(1),e(2),e(3),e(4),e(5),{command:jn(n.nodes.paragraph),dom:Y("notes","paragraph"),active(t){return t.selection.$from.parent.hasMarkup(n.nodes.paragraph)}}]}function Is(n){let e=[],t;return(t=n.nodes.bullet_list)&&e.push({command:it(t),dom:Y("format_list_bulleted","unordered list"),active(r){return!1}}),(t=n.nodes.ordered_list)&&e.push({command:it(t),dom:Y("format_list_numbered","ordered list"),active(r){return!1}}),(t=n.nodes.blockquote)&&e.push({command:en(t),dom:Y("format_quote","blockquote"),active(r){return!1}}),(t=n.nodes.horizontal_rule)&&e.push({command:Cs,dom:Y("horizontal_rule","horizontal rule"),active(r){return!1}}),e}function Rs(n){let e=(t,r,i)=>t?{command:Q(t),dom:Y(r,i),active:o=>Es(o,t)}:null;return[e(n.marks.strong,"format_bold","bold"),e(n.marks.em,"format_italic","italic"),e(n.marks.underline,"format_underline","underline"),e(n.marks.strikethrough,"format_strikethrough","strikethrough"),e(n.marks.sub,"subscript","subscript"),e(n.marks.sup,"superscript","superscript")].filter(Boolean)}function vs(n){return n.marks.link?[{command:st,dom:Y("insert_link","insert link"),active:st},{command:Ss,dom:Y("link_off","remove link"),active:e=>Es(e,n.marks.link)}]:[]}function Ps(){return[{command:At,dom:Y("undo","undo"),active(n){return!1}},{command:rt,dom:Y("redo","redo"),active(n){return!1}}]}function zs(){return[{command:Ms,dom:Y("code","edit HTML"),active:()=>!1}]}var zr=class{constructor(e,t,r){if(this.items=[t,...r].flat(),this.editorView=e,this.dom=H("div",{className:"prose-menubar"}),t.length){let i=H("div",{className:"prose-menubar__dropdown"}),o=H("div");this.dom.append(i),i.append(Y("notes","paragraph")),i.append(o),t.forEach(({dom:s})=>o.append(s))}r.filter(i=>i.length).forEach(i=>{let o=H("div",{className:"prose-menubar__group"});this.dom.append(o),i.forEach(({dom:s})=>o.append(s))}),this.update(),this.dom.addEventListener("mousedown",i=>{i.preventDefault(),e.focus(),this.items.forEach(({command:o,dom:s})=>{s.contains(i.target)&&o(e.state,e.dispatch,e)})})}update(){this.items.forEach(({command:e,dom:t,active:r})=>{let i=e(this.editorView.state,null,this.editorView);t.classList.toggle("disabled",!i),t.classList.toggle("active",r(this.editorView.state)||!1)})}destroy(){this.dom.remove()}};function Bs(){return new P({view(n){return new Br(n)}})}var Br=class{constructor(e){this.editorView=e,this.editorView.dom.setAttribute("spellcheck","false")}update(){}destroy(){this.editorView.dom.removeAttribute("spellcheck")}};function Fs(n,e,t,r){let i=n.childCount,o=e.childCount;e:for(let s=0,l=0;s{let t=[];if(n.text)for(let r of n.text.matchAll(/\u00A0/g)){let i=e+(r.index||0);t.push(G.inline(i,i+1,{class:"prose-editor-nbsp"}))}return t},jf=n=>{let e=[];return n.descendants((t,r)=>{e.push(Vs(t,r))}),B.create(n,e.flat())},Fr=new P({state:{init(n,{doc:e}){return jf(e)},apply(n,e,t){let r=e.map(n.mapping,n.doc);return Fs(t.doc,n.doc,0,(i,o)=>{let s=Vs(i,o);r=r.add(n.doc,s)}),r}},props:{decorations(n){return Fr.getState(n)}}});var _f=["u",0],Uf=["s",0],Gf=["sub",0],Yf=["sup",0],Xf=(n,e=null)=>{if(!e)return n;let t=["doc","paragraph","text",...e],r={},i={};return n.spec.nodes.forEach((o,s)=>{t.includes(o)&&(r[o]=s)}),n.spec.marks.forEach((o,s)=>{t.includes(o)&&(i[o]=s)}),new ke({nodes:r,marks:i})};function Ls(n,e){let t={nodes:{doc:ye.doc,paragraph:ye.paragraph,heading:ye.heading,blockquote:ye.blockquote,horizontal_rule:ye.horizontal_rule,text:ye.text,hard_break:ye.hard_break},marks:{link:It.link,strong:It.strong,em:It.em,underline:{parseDOM:[{tag:"u"},{style:"text-decoration:underline"}],toDOM(){return _f}},strikethrough:{parseDOM:[{tag:"s"},{style:"text-decoration:line-through"}],toDOM(){return Uf}},sub:{parseDOM:[{tag:"sub"}],toDOM(){return Gf}},sup:{parseDOM:[{tag:"sup"}],toDOM(){return Yf}}}},r=new ke(t);r=new ke({nodes:es(r.spec.nodes,"paragraph block*","block"),marks:r.spec.marks}),r=Xf(r,e.types);let i=Cn(Cn({},Ns(r)),Ts(r)),o=[Gn(i),Gn(Bi),Fi(),Go(),Zo(),Ds(As(r),[Is(r),vs(r),Rs(r),e.history?Ps():null,e.html?zs():null].filter(Boolean)),Bs(),e.typograpic?Fr:null].filter(Boolean),s=H("div",{className:"prose-editor"});n.before(s);let l=new un(s,{state:Zt.create({doc:Mn(r,n.value),plugins:o}),dispatchTransaction:c=>{l.updateState(l.state.apply(c)),a()}}),a=ks(r,l,n);return()=>{try{l.destroy()}catch(c){}s.remove()}}return js(Qf);})(); diff --git a/package.json b/package.json index b25ddd6..f761651 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,10 @@ "license": "MIT", "dependencies": { "autoprefixer": "^10.4.19", - "esbuild": "^0.21.5", + "esbuild": "^0.23.0", "esbuild-postcss": "^0.0.4", "lodash-es": "^4.17.21", - "postcss": "^8.4.38", + "postcss": "^8.4.39", "prosemirror-commands": "^1.5.2", "prosemirror-dropcursor": "^1.8.1", "prosemirror-gapcursor": "^1.3.2", @@ -16,7 +16,7 @@ "prosemirror-inputrules": "^1.2.1", "prosemirror-keymap": "^1.2.2", "prosemirror-menu": "^1.2.2", - "prosemirror-model": "^1.21.1", + "prosemirror-model": "^1.21.3", "prosemirror-schema-basic": "^1.2.2", "prosemirror-schema-list": "^1.4.0", "prosemirror-state": "^1.4.3", diff --git a/src/editor.css b/src/editor.css index e76ad6a..740f7d9 100644 --- a/src/editor.css +++ b/src/editor.css @@ -125,5 +125,6 @@ label:empty:has(+ .prose-editor) { } .prose-editor-nbsp { - background: lightblue; + background: #ddd; + box-shadow: 0 2px 0 0 #ddd, 0 -2px 0 0 #ddd; } diff --git a/yarn.lock b/yarn.lock index 5b2234b..820b72d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,120 +2,125 @@ # yarn lockfile v1 -"@esbuild/aix-ppc64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz#c7184a326533fcdf1b8ee0733e21c713b975575f" - integrity sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ== - -"@esbuild/android-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz#09d9b4357780da9ea3a7dfb833a1f1ff439b4052" - integrity sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A== - -"@esbuild/android-arm@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz#9b04384fb771926dfa6d7ad04324ecb2ab9b2e28" - integrity sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg== - -"@esbuild/android-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz#29918ec2db754cedcb6c1b04de8cd6547af6461e" - integrity sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA== - -"@esbuild/darwin-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz#e495b539660e51690f3928af50a76fb0a6ccff2a" - integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ== - -"@esbuild/darwin-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz#c13838fa57372839abdddc91d71542ceea2e1e22" - integrity sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw== - -"@esbuild/freebsd-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz#646b989aa20bf89fd071dd5dbfad69a3542e550e" - integrity sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g== - -"@esbuild/freebsd-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz#aa615cfc80af954d3458906e38ca22c18cf5c261" - integrity sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ== - -"@esbuild/linux-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz#70ac6fa14f5cb7e1f7f887bcffb680ad09922b5b" - integrity sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q== - -"@esbuild/linux-arm@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz#fc6fd11a8aca56c1f6f3894f2bea0479f8f626b9" - integrity sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA== - -"@esbuild/linux-ia32@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz#3271f53b3f93e3d093d518d1649d6d68d346ede2" - integrity sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg== - -"@esbuild/linux-loong64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz#ed62e04238c57026aea831c5a130b73c0f9f26df" - integrity sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg== - -"@esbuild/linux-mips64el@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz#e79b8eb48bf3b106fadec1ac8240fb97b4e64cbe" - integrity sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg== - -"@esbuild/linux-ppc64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz#5f2203860a143b9919d383ef7573521fb154c3e4" - integrity sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w== - -"@esbuild/linux-riscv64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz#07bcafd99322d5af62f618cb9e6a9b7f4bb825dc" - integrity sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA== - -"@esbuild/linux-s390x@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz#b7ccf686751d6a3e44b8627ababc8be3ef62d8de" - integrity sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A== - -"@esbuild/linux-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz#6d8f0c768e070e64309af8004bb94e68ab2bb3b0" - integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ== - -"@esbuild/netbsd-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz#bbe430f60d378ecb88decb219c602667387a6047" - integrity sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg== - -"@esbuild/openbsd-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz#99d1cf2937279560d2104821f5ccce220cb2af70" - integrity sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow== - -"@esbuild/sunos-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz#08741512c10d529566baba837b4fe052c8f3487b" - integrity sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg== - -"@esbuild/win32-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz#675b7385398411240735016144ab2e99a60fc75d" - integrity sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A== - -"@esbuild/win32-ia32@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz#1bfc3ce98aa6ca9a0969e4d2af72144c59c1193b" - integrity sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA== - -"@esbuild/win32-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz#acad351d582d157bb145535db2a6ff53dd514b5c" - integrity sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw== +"@esbuild/aix-ppc64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.23.0.tgz#145b74d5e4a5223489cabdc238d8dad902df5259" + integrity sha512-3sG8Zwa5fMcA9bgqB8AfWPQ+HFke6uD3h1s3RIwUNK8EG7a4buxvuFTs3j1IMs2NXAk9F30C/FF4vxRgQCcmoQ== + +"@esbuild/android-arm64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.23.0.tgz#453bbe079fc8d364d4c5545069e8260228559832" + integrity sha512-EuHFUYkAVfU4qBdyivULuu03FhJO4IJN9PGuABGrFy4vUuzk91P2d+npxHcFdpUnfYKy0PuV+n6bKIpHOB3prQ== + +"@esbuild/android-arm@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.23.0.tgz#26c806853aa4a4f7e683e519cd9d68e201ebcf99" + integrity sha512-+KuOHTKKyIKgEEqKbGTK8W7mPp+hKinbMBeEnNzjJGyFcWsfrXjSTNluJHCY1RqhxFurdD8uNXQDei7qDlR6+g== + +"@esbuild/android-x64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.23.0.tgz#1e51af9a6ac1f7143769f7ee58df5b274ed202e6" + integrity sha512-WRrmKidLoKDl56LsbBMhzTTBxrsVwTKdNbKDalbEZr0tcsBgCLbEtoNthOW6PX942YiYq8HzEnb4yWQMLQuipQ== + +"@esbuild/darwin-arm64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.23.0.tgz#d996187a606c9534173ebd78c58098a44dd7ef9e" + integrity sha512-YLntie/IdS31H54Ogdn+v50NuoWF5BDkEUFpiOChVa9UnKpftgwzZRrI4J132ETIi+D8n6xh9IviFV3eXdxfow== + +"@esbuild/darwin-x64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.23.0.tgz#30c8f28a7ef4e32fe46501434ebe6b0912e9e86c" + integrity sha512-IMQ6eme4AfznElesHUPDZ+teuGwoRmVuuixu7sv92ZkdQcPbsNHzutd+rAfaBKo8YK3IrBEi9SLLKWJdEvJniQ== + +"@esbuild/freebsd-arm64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.0.tgz#30f4fcec8167c08a6e8af9fc14b66152232e7fb4" + integrity sha512-0muYWCng5vqaxobq6LB3YNtevDFSAZGlgtLoAc81PjUfiFz36n4KMpwhtAd4he8ToSI3TGyuhyx5xmiWNYZFyw== + +"@esbuild/freebsd-x64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.23.0.tgz#1003a6668fe1f5d4439e6813e5b09a92981bc79d" + integrity sha512-XKDVu8IsD0/q3foBzsXGt/KjD/yTKBCIwOHE1XwiXmrRwrX6Hbnd5Eqn/WvDekddK21tfszBSrE/WMaZh+1buQ== + +"@esbuild/linux-arm64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.23.0.tgz#3b9a56abfb1410bb6c9138790f062587df3e6e3a" + integrity sha512-j1t5iG8jE7BhonbsEg5d9qOYcVZv/Rv6tghaXM/Ug9xahM0nX/H2gfu6X6z11QRTMT6+aywOMA8TDkhPo8aCGw== + +"@esbuild/linux-arm@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.23.0.tgz#237a8548e3da2c48cd79ae339a588f03d1889aad" + integrity sha512-SEELSTEtOFu5LPykzA395Mc+54RMg1EUgXP+iw2SJ72+ooMwVsgfuwXo5Fn0wXNgWZsTVHwY2cg4Vi/bOD88qw== + +"@esbuild/linux-ia32@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.23.0.tgz#4269cd19cb2de5de03a7ccfc8855dde3d284a238" + integrity sha512-P7O5Tkh2NbgIm2R6x1zGJJsnacDzTFcRWZyTTMgFdVit6E98LTxO+v8LCCLWRvPrjdzXHx9FEOA8oAZPyApWUA== + +"@esbuild/linux-loong64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.23.0.tgz#82b568f5658a52580827cc891cb69d2cb4f86280" + integrity sha512-InQwepswq6urikQiIC/kkx412fqUZudBO4SYKu0N+tGhXRWUqAx+Q+341tFV6QdBifpjYgUndV1hhMq3WeJi7A== + +"@esbuild/linux-mips64el@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.23.0.tgz#9a57386c926262ae9861c929a6023ed9d43f73e5" + integrity sha512-J9rflLtqdYrxHv2FqXE2i1ELgNjT+JFURt/uDMoPQLcjWQA5wDKgQA4t/dTqGa88ZVECKaD0TctwsUfHbVoi4w== + +"@esbuild/linux-ppc64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.23.0.tgz#f3a79fd636ba0c82285d227eb20ed8e31b4444f6" + integrity sha512-cShCXtEOVc5GxU0fM+dsFD10qZ5UpcQ8AM22bYj0u/yaAykWnqXJDpd77ublcX6vdDsWLuweeuSNZk4yUxZwtw== + +"@esbuild/linux-riscv64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.23.0.tgz#f9d2ef8356ce6ce140f76029680558126b74c780" + integrity sha512-HEtaN7Y5UB4tZPeQmgz/UhzoEyYftbMXrBCUjINGjh3uil+rB/QzzpMshz3cNUxqXN7Vr93zzVtpIDL99t9aRw== + +"@esbuild/linux-s390x@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.23.0.tgz#45390f12e802201f38a0229e216a6aed4351dfe8" + integrity sha512-WDi3+NVAuyjg/Wxi+o5KPqRbZY0QhI9TjrEEm+8dmpY9Xir8+HE/HNx2JoLckhKbFopW0RdO2D72w8trZOV+Wg== + +"@esbuild/linux-x64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.23.0.tgz#c8409761996e3f6db29abcf9b05bee8d7d80e910" + integrity sha512-a3pMQhUEJkITgAw6e0bWA+F+vFtCciMjW/LPtoj99MhVt+Mfb6bbL9hu2wmTZgNd994qTAEw+U/r6k3qHWWaOQ== + +"@esbuild/netbsd-x64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.23.0.tgz#ba70db0114380d5f6cfb9003f1d378ce989cd65c" + integrity sha512-cRK+YDem7lFTs2Q5nEv/HHc4LnrfBCbH5+JHu6wm2eP+d8OZNoSMYgPZJq78vqQ9g+9+nMuIsAO7skzphRXHyw== + +"@esbuild/openbsd-arm64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.0.tgz#72fc55f0b189f7a882e3cf23f332370d69dfd5db" + integrity sha512-suXjq53gERueVWu0OKxzWqk7NxiUWSUlrxoZK7usiF50C6ipColGR5qie2496iKGYNLhDZkPxBI3erbnYkU0rQ== + +"@esbuild/openbsd-x64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.23.0.tgz#b6ae7a0911c18fe30da3db1d6d17a497a550e5d8" + integrity sha512-6p3nHpby0DM/v15IFKMjAaayFhqnXV52aEmv1whZHX56pdkK+MEaLoQWj+H42ssFarP1PcomVhbsR4pkz09qBg== + +"@esbuild/sunos-x64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.23.0.tgz#58f0d5e55b9b21a086bfafaa29f62a3eb3470ad8" + integrity sha512-BFelBGfrBwk6LVrmFzCq1u1dZbG4zy/Kp93w2+y83Q5UGYF1d8sCzeLI9NXjKyujjBBniQa8R8PzLFAUrSM9OA== + +"@esbuild/win32-arm64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.23.0.tgz#b858b2432edfad62e945d5c7c9e5ddd0f528ca6d" + integrity sha512-lY6AC8p4Cnb7xYHuIxQ6iYPe6MfO2CC43XXKo9nBXDb35krYt7KGhQnOkRGar5psxYkircpCqfbNDB4uJbS2jQ== + +"@esbuild/win32-ia32@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.23.0.tgz#167ef6ca22a476c6c0c014a58b4f43ae4b80dec7" + integrity sha512-7L1bHlOTcO4ByvI7OXVI5pNN6HSu6pUQq9yodga8izeuB1KcT2UkHaH6118QJwopExPn0rMHIseCTx1CRo/uNA== + +"@esbuild/win32-x64@0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.23.0.tgz#db44a6a08520b5f25bbe409f34a59f2d4bcc7ced" + integrity sha512-Arm+WgUFLUATuoxCJcahGuk6Yj9Pzxd6l11Zb/2aAuv5kWWvvfhLFo2fni4uSK5vzlUdCGZ/BdV5tH8klj8p8g== autoprefixer@^10.4.19: version "10.4.19" @@ -140,9 +145,9 @@ browserslist@^4.23.0: update-browserslist-db "^1.0.16" caniuse-lite@^1.0.30001599, caniuse-lite@^1.0.30001629: - version "1.0.30001636" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz#b15f52d2bdb95fad32c2f53c0b68032b85188a78" - integrity sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg== + version "1.0.30001640" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001640.tgz#32c467d4bf1f1a0faa63fc793c2ba81169e7652f" + integrity sha512-lA4VMpW0PSUrFnkmVuEKBUovSWKhj7puyCg8StBChgu298N1AtuF1sKWEvfDuimSEDbhlb/KqPKC3fs1HbuQUA== crelt@^1.0.0: version "1.0.6" @@ -150,9 +155,9 @@ crelt@^1.0.0: integrity sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g== electron-to-chromium@^1.4.796: - version "1.4.806" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.806.tgz#2cb046631cbabceb26fc72be68d273fa183e36bc" - integrity sha512-nkoEX2QIB8kwCOtvtgwhXWy2IHVcOLQZu9Qo36uaGB835mdX/h8uLRlosL6QIhLVUnAiicXRW00PwaPZC74Nrg== + version "1.4.818" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.818.tgz#7762c8bfd15a07c3833b7f5deed990e9e5a4c24f" + integrity sha512-eGvIk2V0dGImV9gWLq8fDfTTsCAeMDwZqEPMr+jMInxZdnp9Us8UpovYpRCf9NQ7VOFgrN2doNSgvISbsbNpxA== esbuild-postcss@^0.0.4: version "0.0.4" @@ -161,34 +166,35 @@ esbuild-postcss@^0.0.4: dependencies: postcss-load-config "^3.1.0" -esbuild@^0.21.5: - version "0.21.5" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.21.5.tgz#9ca301b120922959b766360d8ac830da0d02997d" - integrity sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw== +esbuild@^0.23.0: + version "0.23.0" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.23.0.tgz#de06002d48424d9fdb7eb52dbe8e95927f852599" + integrity sha512-1lvV17H2bMYda/WaFb2jLPeHU3zml2k4/yagNMG8Q/YtfMjCwEUZa2eXXMgZTVSL5q1n4H7sQ0X6CdJDqqeCFA== optionalDependencies: - "@esbuild/aix-ppc64" "0.21.5" - "@esbuild/android-arm" "0.21.5" - "@esbuild/android-arm64" "0.21.5" - "@esbuild/android-x64" "0.21.5" - "@esbuild/darwin-arm64" "0.21.5" - "@esbuild/darwin-x64" "0.21.5" - "@esbuild/freebsd-arm64" "0.21.5" - "@esbuild/freebsd-x64" "0.21.5" - "@esbuild/linux-arm" "0.21.5" - "@esbuild/linux-arm64" "0.21.5" - "@esbuild/linux-ia32" "0.21.5" - "@esbuild/linux-loong64" "0.21.5" - "@esbuild/linux-mips64el" "0.21.5" - "@esbuild/linux-ppc64" "0.21.5" - "@esbuild/linux-riscv64" "0.21.5" - "@esbuild/linux-s390x" "0.21.5" - "@esbuild/linux-x64" "0.21.5" - "@esbuild/netbsd-x64" "0.21.5" - "@esbuild/openbsd-x64" "0.21.5" - "@esbuild/sunos-x64" "0.21.5" - "@esbuild/win32-arm64" "0.21.5" - "@esbuild/win32-ia32" "0.21.5" - "@esbuild/win32-x64" "0.21.5" + "@esbuild/aix-ppc64" "0.23.0" + "@esbuild/android-arm" "0.23.0" + "@esbuild/android-arm64" "0.23.0" + "@esbuild/android-x64" "0.23.0" + "@esbuild/darwin-arm64" "0.23.0" + "@esbuild/darwin-x64" "0.23.0" + "@esbuild/freebsd-arm64" "0.23.0" + "@esbuild/freebsd-x64" "0.23.0" + "@esbuild/linux-arm" "0.23.0" + "@esbuild/linux-arm64" "0.23.0" + "@esbuild/linux-ia32" "0.23.0" + "@esbuild/linux-loong64" "0.23.0" + "@esbuild/linux-mips64el" "0.23.0" + "@esbuild/linux-ppc64" "0.23.0" + "@esbuild/linux-riscv64" "0.23.0" + "@esbuild/linux-s390x" "0.23.0" + "@esbuild/linux-x64" "0.23.0" + "@esbuild/netbsd-x64" "0.23.0" + "@esbuild/openbsd-arm64" "0.23.0" + "@esbuild/openbsd-x64" "0.23.0" + "@esbuild/sunos-x64" "0.23.0" + "@esbuild/win32-arm64" "0.23.0" + "@esbuild/win32-ia32" "0.23.0" + "@esbuild/win32-x64" "0.23.0" escalade@^3.1.2: version "3.1.2" @@ -248,13 +254,13 @@ postcss-value-parser@^4.2.0: resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== -postcss@^8.4.38: - version "8.4.38" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.38.tgz#b387d533baf2054288e337066d81c6bee9db9e0e" - integrity sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A== +postcss@^8.4.39: + version "8.4.39" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.39.tgz#aa3c94998b61d3a9c259efa51db4b392e1bde0e3" + integrity sha512-0vzE+lAiG7hZl1/9I8yzKLx3aR9Xbof3fBHKunvMfOCYAtMhrsnccJY2iTURb9EZd5+pLuiNV9/c/GZJOHsgIw== dependencies: nanoid "^3.3.7" - picocolors "^1.0.0" + picocolors "^1.0.1" source-map-js "^1.2.0" prosemirror-commands@^1.0.0, prosemirror-commands@^1.5.2: @@ -321,10 +327,10 @@ prosemirror-menu@^1.2.2: prosemirror-history "^1.0.0" prosemirror-state "^1.0.0" -prosemirror-model@^1.0.0, prosemirror-model@^1.19.0, prosemirror-model@^1.20.0, prosemirror-model@^1.21.0, prosemirror-model@^1.21.1: - version "1.21.1" - resolved "https://registry.yarnpkg.com/prosemirror-model/-/prosemirror-model-1.21.1.tgz#023b804cfc7942bc9b3104e65f59b18bf18514c6" - integrity sha512-IVBAuMqOfltTr7yPypwpfdGT+6rGAteVOw2FO6GEvCGGa1ZwxLseqC1Eax/EChDvG/xGquB2d/hLdgh3THpsYg== +prosemirror-model@^1.0.0, prosemirror-model@^1.19.0, prosemirror-model@^1.20.0, prosemirror-model@^1.21.0, prosemirror-model@^1.21.3: + version "1.21.3" + resolved "https://registry.yarnpkg.com/prosemirror-model/-/prosemirror-model-1.21.3.tgz#97fa434d670331c1ab25f75964b1bcd7a948ce61" + integrity sha512-nt2Xs/RNGepD9hrrkzXvtCm1mpGJoQfFSPktGa0BF/aav6XsnmVGZ9sTXNWRLupAz5SCLa3EyKlFeK7zJWROKg== dependencies: orderedmap "^2.0.0" @@ -380,9 +386,9 @@ source-map-js@^1.2.0: integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg== update-browserslist-db@^1.0.16: - version "1.0.16" - resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz#f6d489ed90fb2f07d67784eb3f53d7891f736356" - integrity sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ== + version "1.1.0" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz#7ca61c0d8650766090728046e416a8cde682859e" + integrity sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ== dependencies: escalade "^3.1.2" picocolors "^1.0.1"