D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
diafdxji
/
shihty.com
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
surecart
/
Filename :
p-34d36635.entry.js
back
Copy
import{r as t,c as e,h as r,H as i}from"./p-e97fde0a.js";function n(t){this.content=t}n.prototype={constructor:n,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?undefined:this.content[e+1]},update:function(t,e,r){var i=r&&r!=t?this.remove(r):this;var s=i.find(t),o=i.content.slice();if(s==-1){o.push(r||t,e)}else{o[s+1]=e;if(r)o[s]=r}return new n(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var r=this.content.slice();r.splice(e,2);return new n(r)},addToStart:function(t,e){return new n([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();r.push(t,e);return new n(r)},addBefore:function(t,e,r){var i=this.remove(e),s=i.content.slice();var o=i.find(t);s.splice(o==-1?s.length:o,0,e,r);return new n(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){t=n.from(t);if(!t.size)return this;return new n(t.content.concat(this.subtract(t).content))},append:function(t){t=n.from(t);if(!t.size)return this;return new n(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=n.from(t);for(var r=0;r<t.content.length;r+=2)e=e.remove(t.content[r]);return e},toObject:function(){var t={};this.forEach((function(e,r){t[e]=r}));return t},get size(){return this.content.length>>1}};n.from=function(t){if(t instanceof n)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new n(e)};function s(t,e,r){for(let i=0;;i++){if(i==t.childCount||i==e.childCount)return t.childCount==e.childCount?null:r;let n=t.child(i),o=e.child(i);if(n==o){r+=n.nodeSize;continue}if(!n.sameMarkup(o))return r;if(n.isText&&n.text!=o.text){for(let t=0;n.text[t]==o.text[t];t++)r++;return r}if(n.content.size||o.content.size){let t=s(n.content,o.content,r+1);if(t!=null)return t}r+=n.nodeSize}}function o(t,e,r,i){for(let n=t.childCount,s=e.childCount;;){if(n==0||s==0)return n==s?null:{a:r,b:i};let l=t.child(--n),u=e.child(--s),f=l.nodeSize;if(l==u){r-=f;i-=f;continue}if(!l.sameMarkup(u))return{a:r,b:i};if(l.isText&&l.text!=u.text){let t=0,e=Math.min(l.text.length,u.text.length);while(t<e&&l.text[l.text.length-t-1]==u.text[u.text.length-t-1]){t++;r--;i--}return{a:r,b:i}}if(l.content.size||u.content.size){let t=o(l.content,u.content,r-1,i-1);if(t)return t}r-=f;i-=f}}class l{constructor(t,e){this.content=t;this.size=e||0;if(e==null)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,r,i=0,n){for(let s=0,o=0;o<e;s++){let l=this.content[s],u=o+l.nodeSize;if(u>t&&r(l,i+o,n||null,s)!==false&&l.content.size){let n=o+1;l.nodesBetween(Math.max(0,t-n),Math.min(l.content.size,e-n),r,i+n)}o=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){let n="",s=true;this.nodesBetween(t,e,((o,l)=>{let u=o.isText?o.text.slice(Math.max(t,l)-l,e-l):!o.isLeaf?"":i?typeof i==="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"";if(o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r){if(s)s=false;else n+=r}n+=u}),0);return n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,i=this.content.slice(),n=0;if(e.isText&&e.sameMarkup(r)){i[i.length-1]=e.withText(e.text+r.text);n=1}for(;n<t.content.length;n++)i.push(t.content[n]);return new l(i,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let r=[],i=0;if(e>t)for(let n=0,s=0;s<e;n++){let o=this.content[n],l=s+o.nodeSize;if(l>t){if(s<t||l>e){if(o.isText)o=o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s));else o=o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))}r.push(o);i+=o.nodeSize}s=l}return new l(r,i)}cutByIndex(t,e){if(t==e)return l.empty;if(t==0&&e==this.content.length)return this;return new l(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let i=this.content.slice();let n=this.size+e.nodeSize-r.nodeSize;i[t]=e;return new l(i,n)}addToStart(t){return new l([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new l(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return false;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return false;return true}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,r=0;e<this.content.length;e++){let i=this.content[e];t(i,r,e);r+=i.nodeSize}}findDiffStart(t,e=0){return s(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return o(this,t,e,r)}findIndex(t,e=-1){if(t==0)return f(0,t);if(t==this.size)return f(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let r=0,i=0;;r++){let n=this.child(r),s=i+n.nodeSize;if(s>=t){if(s==t||e>0)return f(r+1,s);return f(r,i)}i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return l.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new l(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return l.empty;let e,r=0;for(let i=0;i<t.length;i++){let n=t[i];r+=n.nodeSize;if(i&&n.isText&&t[i-1].sameMarkup(n)){if(!e)e=t.slice(0,i);e[e.length-1]=n.withText(e[e.length-1].text+n.text)}else if(e){e.push(n)}}return new l(e||t,r)}static from(t){if(!t)return l.empty;if(t instanceof l)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new l([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}l.empty=new l([],0);const u={index:0,offset:0};function f(t,e){u.index=t;u.offset=e;return u}function h(t,e){if(t===e)return true;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return false;let r=Array.isArray(t);if(Array.isArray(e)!=r)return false;if(r){if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!h(t[r],e[r]))return false}else{for(let r in t)if(!(r in e)||!h(t[r],e[r]))return false;for(let r in e)if(!(r in t))return false}return true}class a{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,r=false;for(let i=0;i<t.length;i++){let n=t[i];if(this.eq(n))return t;if(this.type.excludes(n.type)){if(!e)e=t.slice(0,i)}else if(n.type.excludes(this.type)){return t}else{if(!r&&n.type.rank>this.type.rank){if(!e)e=t.slice(0,i);e.push(this);r=true}if(e)e.push(n)}}if(!e)e=t.slice();if(!r)e.push(this);return e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return true;return false}eq(t){return this==t||this.type==t.type&&h(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[e.type];if(!r)throw new RangeError(`There is no mark type ${e.type} in this schema`);return r.create(e.attrs)}static sameSet(t,e){if(t==e)return true;if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return false;return true}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return a.none;if(t instanceof a)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}a.none=[];class c extends Error{}class d{constructor(t,e,r){this.content=t;this.openStart=e;this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let r=m(this.content,t+this.openStart,e);return r&&new d(r,this.openStart,this.openEnd)}removeBetween(t,e){return new d(p(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};if(this.openStart>0)t.openStart=this.openStart;if(this.openEnd>0)t.openEnd=this.openEnd;return t}static fromJSON(t,e){if(!e)return d.empty;let r=e.openStart||0,i=e.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new d(l.fromJSON(t,e.content),r,i)}static maxOpen(t,e=true){let r=0,i=0;for(let i=t.firstChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.firstChild)r++;for(let r=t.lastChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.lastChild)i++;return new d(t,r,i)}}d.empty=new d(l.empty,0,0);function p(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i);let{index:o,offset:l}=t.findIndex(r);if(n==e||s.isText){if(l!=r&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(i!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(p(s.content,e-n-1,r-n-1)))}function m(t,e,r,i){let{index:n,offset:s}=t.findIndex(e),o=t.maybeChild(n);if(s==e||o.isText){if(i&&!i.canReplace(n,n,r))return null;return t.cut(0,e).append(r).append(t.cut(e))}let l=m(o.content,e-s-1,r);return l&&t.replaceChild(n,o.copy(l))}function g(t,e,r){if(r.openStart>t.depth)throw new c("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new c("Inconsistent open depths");return w(t,e,r,0)}function w(t,e,r,i){let n=t.index(i),s=t.node(i);if(n==e.index(i)&&i<t.depth-r.openStart){let o=w(t,e,r,i+1);return s.copy(s.content.replaceChild(n,o))}else if(!r.content.size){return k(s,S(t,e,i))}else if(!r.openStart&&!r.openEnd&&t.depth==i&&e.depth==i){let i=t.parent,n=i.content;return k(i,n.cut(0,t.parentOffset).append(r.content).append(n.cut(e.parentOffset)))}else{let{start:n,end:o}=O(r,t);return k(s,x(t,n,o,e,i))}}function b(t,e){if(!e.type.compatibleContent(t.type))throw new c("Cannot join "+e.type.name+" onto "+t.type.name)}function v(t,e,r){let i=t.node(r);b(i,e.node(r));return i}function y(t,e){let r=e.length-1;if(r>=0&&t.isText&&t.sameMarkup(e[r]))e[r]=t.withText(e[r].text+t.text);else e.push(t)}function M(t,e,r,i){let n=(e||t).node(r);let s=0,o=e?e.index(r):n.childCount;if(t){s=t.index(r);if(t.depth>r){s++}else if(t.textOffset){y(t.nodeAfter,i);s++}}for(let t=s;t<o;t++)y(n.child(t),i);if(e&&e.depth==r&&e.textOffset)y(e.nodeBefore,i)}function k(t,e){t.type.checkContent(e);return t.copy(e)}function x(t,e,r,i,n){let s=t.depth>n&&v(t,e,n+1);let o=i.depth>n&&v(r,i,n+1);let u=[];M(null,t,n,u);if(s&&o&&e.index(n)==r.index(n)){b(s,o);y(k(s,x(t,e,r,i,n+1)),u)}else{if(s)y(k(s,S(t,e,n+1)),u);M(e,r,n,u);if(o)y(k(o,S(r,i,n+1)),u)}M(i,null,n,u);return new l(u)}function S(t,e,r){let i=[];M(null,t,r,i);if(t.depth>r){let n=v(t,e,r+1);y(k(n,S(t,e,r+1)),i)}M(e,null,r,i);return new l(i)}function O(t,e){let r=e.depth-t.openStart,i=e.node(r);let n=i.copy(t.content);for(let t=r-1;t>=0;t--)n=e.node(t).copy(l.from(n));return{start:n.resolveNoCache(t.openStart+r),end:n.resolveNoCache(n.content.size-t.openEnd-r)}}class T{constructor(t,e,r){this.pos=t;this.path=e;this.parentOffset=r;this.depth=e.length/3-1}resolveDepth(t){if(t==null)return this.depth;if(t<0)return this.depth+t;return t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){t=this.resolveDepth(t);return this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){t=this.resolveDepth(t);return t==0?0:this.path[t*3-1]+1}end(t){t=this.resolveDepth(t);return this.start(t)+this.node(t).content.size}before(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=t.child(e);return r?t.child(e).cut(r):i}get nodeBefore(){let t=this.index(this.depth);let e=this.pos-this.path[this.path.length-1];if(e)return this.parent.child(t).cut(0,e);return t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[e*3],i=e==0?0:this.path[e*3-1]+1;for(let e=0;e<t;e++)i+=r.child(e).nodeSize;return i}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return a.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),i=t.maybeChild(e);if(!r){let t=r;r=i;i=t}let n=r.marks;for(var s=0;s<n.length;s++)if(n[s].type.spec.inclusive===false&&(!i||!n[s].isInSet(i.marks)))n=n[s--].removeFromSet(n);return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,i=t.parent.maybeChild(t.index());for(var n=0;n<r.length;n++)if(r[n].type.spec.inclusive===false&&(!i||!r[n].isInSet(i.marks)))r=r[n--].removeFromSet(r);return r}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new C(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[];let i=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n);let o=n-s;r.push(e,t,i+s);if(!o)break;e=e.child(t);if(e.isText)break;n=o-1;i+=s+1}return new T(e,r,n)}static resolveCached(t,e){for(let r=0;r<E.length;r++){let i=E[r];if(i.pos==e&&i.doc==t)return i}let r=E[P]=T.resolve(t,e);P=(P+1)%A;return r}}let E=[],P=0,A=12;class C{constructor(t,e,r){this.$from=t;this.$to=e;this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const N=Object.create(null);class ${constructor(t,e,r,i=a.none){this.type=t;this.attrs=e;this.marks=i;this.content=r||l.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,r,i=0){this.content.nodesBetween(t,e,r,i,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,r,i){return this.content.textBetween(t,e,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,r){return this.type==t&&h(this.attrs,e||t.defaultAttrs||N)&&a.sameSet(this.marks,r||a.none)}copy(t=null){if(t==this.content)return this;return new $(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new $(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){if(t==0&&e==this.content.size)return this;return this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,r=false){if(t==e)return d.empty;let i=this.resolve(t),n=this.resolve(e);let s=r?0:i.sharedDepth(e);let o=i.start(s),l=i.node(s);let u=l.content.cut(i.pos-o,n.pos-o);return new d(u,i.depth-s,n.depth-s)}replace(t,e,r){return g(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:i}=e.content.findIndex(t);e=e.maybeChild(r);if(!e)return null;if(i==t||e.isText)return e;t-=i+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let i=this.content.child(e-1);return{node:i,index:e-1,offset:r-i.nodeSize}}resolve(t){return T.resolveCached(this,t)}resolveNoCache(t){return T.resolve(this,t)}rangeHasMark(t,e,r){let i=false;if(e>t)this.nodesBetween(t,e,(t=>{if(r.isInSet(t.marks))i=true;return!i}));return 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 t=this.type.name;if(this.content.size)t+="("+this.content.toStringInner()+")";return D(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,r=l.empty,i=0,n=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,i,n);let o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return false;for(let t=i;t<n;t++)if(!this.type.allowsMarks(r.child(t).marks))return false;return true}canReplaceWith(t,e,r,i){if(i&&!this.type.allowsMarks(i))return false;let n=this.contentMatchAt(t).matchType(r);let s=n&&n.matchFragment(this.content,e);return s?s.validEnd:false}canAppend(t){if(t.content.size)return this.canReplace(this.childCount,this.childCount,t.content);else return this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);let t=a.none;for(let e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!a.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}if(this.content.size)t.content=this.content.toJSON();if(this.marks.length)t.marks=this.marks.map((t=>t.toJSON()));return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let i=l.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,i,r)}}$.prototype.text=undefined;class R extends ${constructor(t,e,r,i){super(t,e,null,i);if(!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return D(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new R(this.type,this.attrs,this.text,t)}withText(t){if(t==this.text)return this;return new R(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){if(t==0&&e==this.text.length)return this;return this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();t.text=this.text;return t}}function D(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class I{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let r=new L(t,e);if(r.next==null)return I.empty;let i=H(r);if(r.next)r.err("Unexpected trailing text");let n=W(K(i));G(n,r);return n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,r=t.childCount){let i=this;for(let n=e;i&&n<r;n++)i=i.matchType(t.child(n).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!(e.isText||e.hasRequiredAttrs()))return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return true;return false}fillBefore(t,e=false,r=0){let i=[this];function n(s,o){let u=s.matchFragment(t,r);if(u&&(!e||u.validEnd))return l.from(o.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:r}=s.next[t];if(!(e.isText||e.hasRequiredAttrs())&&i.indexOf(r)==-1){i.push(r);let t=n(r,o.concat(e));if(t)return t}}return null}return n(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);this.wrapCache.push(t,e);return e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];while(r.length){let i=r.shift(),n=i.match;if(n.matchType(t)){let t=[];for(let e=i;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:o}=n.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!i.type||o.validEnd)){r.push({match:s.contentMatch,type:s,via:i});e[s.name]=true}}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(r){t.push(r);for(let i=0;i<r.next.length;i++)if(t.indexOf(r.next[i].next)==-1)e(r.next[i].next)}e(this);return t.map(((e,r)=>{let i=r+(e.validEnd?"*":" ")+" ";for(let r=0;r<e.next.length;r++)i+=(r?", ":"")+e.next[r].type.name+"->"+t.indexOf(e.next[r].next);return i})).join("\n")}}I.empty=new I(true);class L{constructor(t,e){this.string=t;this.nodeTypes=e;this.inline=null;this.pos=0;this.tokens=t.split(/\s*(?=\b|\W|$)/);if(this.tokens[this.tokens.length-1]=="")this.tokens.pop();if(this.tokens[0]=="")this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||true)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function H(t){let e=[];do{e.push(j(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function j(t){let e=[];do{e.push(B(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function B(t){let e=_(t);for(;;){if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=z(t,e);else break}return e}function J(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function z(t,e){let r=J(t),i=r;if(t.eat(",")){if(t.next!="}")i=J(t);else i=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:r,max:i,expr:e}}function F(t,e){let r=t.nodeTypes,i=r[e];if(i)return[i];let n=[];for(let t in r){let i=r[t];if(i.groups.indexOf(e)>-1)n.push(i)}if(n.length==0)t.err("No node type or group '"+e+"' found");return n}function _(t){if(t.eat("(")){let e=H(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=F(t,t.next).map((e=>{if(t.inline==null)t.inline=e.isInline;else if(t.inline!=e.isInline)t.err("Mixing inline and block content");return{type:"name",value:e}}));t.pos++;return e.length==1?e[0]:{type:"choice",exprs:e}}else{t.err("Unexpected token '"+t.next+"'")}}function K(t){let e=[[]];n(s(t,0),r());return e;function r(){return e.push([])-1}function i(t,r,i){let n={term:i,to:r};e[t].push(n);return n}function n(t,e){t.forEach((t=>t.to=e))}function s(t,e){if(t.type=="choice"){return t.exprs.reduce(((t,r)=>t.concat(s(r,e))),[])}else if(t.type=="seq"){for(let i=0;;i++){let o=s(t.exprs[i],e);if(i==t.exprs.length-1)return o;n(o,e=r())}}else if(t.type=="star"){let o=r();i(e,o);n(s(t.expr,o),o);return[i(o)]}else if(t.type=="plus"){let o=r();n(s(t.expr,e),o);n(s(t.expr,o),o);return[i(o)]}else if(t.type=="opt"){return[i(e)].concat(s(t.expr,e))}else if(t.type=="range"){let o=e;for(let e=0;e<t.min;e++){let e=r();n(s(t.expr,o),e);o=e}if(t.max==-1){n(s(t.expr,o),o)}else{for(let e=t.min;e<t.max;e++){let e=r();i(o,e);n(s(t.expr,o),e);o=e}}return[i(o)]}else if(t.type=="name"){return[i(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function q(t,e){return e-t}function U(t,e){let r=[];i(e);return r.sort(q);function i(e){let n=t[e];if(n.length==1&&!n[0].term)return i(n[0].to);r.push(e);for(let t=0;t<n.length;t++){let{term:e,to:s}=n[t];if(!e&&r.indexOf(s)==-1)i(s)}}}function W(t){let e=Object.create(null);return r(U(t,0));function r(i){let n=[];i.forEach((e=>{t[e].forEach((({term:e,to:r})=>{if(!e)return;let i;for(let t=0;t<n.length;t++)if(n[t][0]==e)i=n[t][1];U(t,r).forEach((t=>{if(!i)n.push([e,i=[]]);if(i.indexOf(t)==-1)i.push(t)}))}))}));let s=e[i.join(",")]=new I(i.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let i=n[t][1].sort(q);s.next.push({type:n[t][0],next:e[i.join(",")]||r(i)})}return s}}function G(t,e){for(let r=0,i=[t];r<i.length;r++){let t=i[r],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:r,next:o}=t.next[e];s.push(r.name);if(n&&!(r.isText||r.hasRequiredAttrs()))n=false;if(i.indexOf(o)==-1)i.push(o)}if(n)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function V(t){let e=Object.create(null);for(let r in t){let i=t[r];if(!i.hasDefault)return null;e[r]=i.default}return e}function X(t,e){let r=Object.create(null);for(let i in t){let n=e&&e[i];if(n===undefined){let e=t[i];if(e.hasDefault)n=e.default;else throw new RangeError("No value supplied for attribute "+i)}r[i]=n}return r}function Y(t){let e=Object.create(null);if(t)for(let r in t)e[r]=new Z(t[r]);return e}class Q{constructor(t,e,r){this.name=t;this.schema=e;this.spec=r;this.markSet=null;this.groups=r.group?r.group.split(" "):[];this.attrs=Y(r.attrs);this.defaultAttrs=V(this.attrs);this.contentMatch=null;this.inlineContent=null;this.isBlock=!(r.inline||t=="text");this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==I.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return true;return false}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){if(!t&&this.defaultAttrs)return this.defaultAttrs;else return X(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new $(this,this.computeAttrs(t),l.from(e),a.setFrom(r))}createChecked(t=null,e,r){e=l.from(e);this.checkContent(e);return new $(this,this.computeAttrs(t),e,a.setFrom(r))}createAndFill(t=null,e,r){t=this.computeAttrs(t);e=l.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let i=this.contentMatch.matchFragment(e);let n=i&&i.fillBefore(l.empty,true);if(!n)return null;return new $(this,t,e.append(n),a.setFrom(r))}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return false;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return false;return true}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return true;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return false;return true}allowedMarks(t){if(this.markSet==null)return t;let e;for(let r=0;r<t.length;r++){if(!this.allowsMarkType(t[r].type)){if(!e)e=t.slice(0,r)}else if(e){e.push(t[r])}}return!e?t:e.length?e:a.none}static compile(t,e){let r=Object.create(null);t.forEach(((t,i)=>r[t]=new Q(t,e,i)));let i=e.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 t in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}class Z{constructor(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default");this.default=t.default}get isRequired(){return!this.hasDefault}}class tt{constructor(t,e,r,i){this.name=t;this.rank=e;this.schema=r;this.spec=i;this.attrs=Y(i.attrs);this.excluded=null;let n=V(this.attrs);this.instance=n?new a(this,n):null}create(t=null){if(!t&&this.instance)return this.instance;return new a(this,X(this.attrs,t))}static compile(t,e){let r=Object.create(null),i=0;t.forEach(((t,n)=>r[t]=new tt(t,i++,e,n)));return r}removeFromSet(t){for(var e=0;e<t.length;e++)if(t[e].type==this){t=t.slice(0,e).concat(t.slice(e+1));e--}return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}excludes(t){return this.excluded.indexOf(t)>-1}}class et{constructor(t){this.linebreakReplacement=null;this.cached=Object.create(null);let e=this.spec={};for(let r in t)e[r]=t[r];e.nodes=n.from(t.nodes),e.marks=n.from(t.marks||{}),this.nodes=Q.compile(this.spec.nodes,this);this.marks=tt.compile(this.spec.marks,this);let r=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],i=e.spec.content||"",n=e.spec.marks;e.contentMatch=r[i]||(r[i]=I.parse(i,this.nodes));e.inlineContent=e.contentMatch.inlineContent;if(e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet=n=="_"?null:n?rt(this,n.split(" ")):n==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=r==null?[e]:r==""?[]:rt(this,r.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(t,e=null,r,i){if(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof Q))throw new RangeError("Invalid node type: "+t);else if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")");return t.createChecked(e,r,i)}text(t,e){let r=this.nodes.text;return new R(r,r.defaultAttrs,t,a.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeFromJSON(t){return $.fromJSON(this,t)}markFromJSON(t){return a.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function rt(t,e){let r=[];for(let i=0;i<e.length;i++){let n=e[i],s=t.marks[n],o=s;if(s){r.push(s)}else{for(let e in t.marks){let i=t.marks[e];if(n=="_"||i.spec.group&&i.spec.group.split(" ").indexOf(n)>-1)r.push(o=i)}}if(!o)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return r}function it(t){return t.tag!=null}function nt(t){return t.style!=null}class st{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];e.forEach((t=>{if(it(t))this.tags.push(t);else if(nt(t))this.styles.push(t)}));this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return false;let r=t.nodes[e.node];return r.contentMatch.matchType(r)}))}parse(t,e={}){let r=new pt(this,e,false);r.addAll(t,e.from,e.to);return r.finish()}parseSlice(t,e={}){let r=new pt(this,e,true);r.addAll(t,e.from,e.to);return d.maxOpen(r.finish())}matchTag(t,e,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let r=this.tags[i];if(gt(t,r.tag)&&(r.namespace===undefined||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(e===false)continue;r.attrs=e||undefined}return r}}}matchStyle(t,e,r,i){for(let n=i?this.styles.indexOf(i)+1:0;n<this.styles.length;n++){let i=this.styles[n],s=i.style;if(s.indexOf(t)!=0||i.context&&!r.matchesContext(i.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(i.getAttrs){let t=i.getAttrs(e);if(t===false)continue;i.attrs=t||undefined}return i}}static schemaRules(t){let e=[];function r(t){let r=t.priority==null?50:t.priority,i=0;for(;i<e.length;i++){let t=e[i],n=t.priority==null?50:t.priority;if(n<r)break}e.splice(i,0,t)}for(let e in t.marks){let i=t.marks[e].spec.parseDOM;if(i)i.forEach((t=>{r(t=wt(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let i=t.nodes[e].spec.parseDOM;if(i)i.forEach((t=>{r(t=wt(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new st(t,st.schemaRules(t)))}}const ot={address:true,article:true,aside:true,blockquote:true,canvas:true,dd:true,div:true,dl:true,fieldset:true,figcaption:true,figure:true,footer:true,form:true,h1:true,h2:true,h3:true,h4:true,h5:true,h6:true,header:true,hgroup:true,hr:true,li:true,noscript:true,ol:true,output:true,p:true,pre:true,section:true,table:true,tfoot:true,ul:true};const lt={head:true,noscript:true,object:true,script:true,style:true,title:true};const ut={ol:true,ul:true};const ft=1,ht=2,at=4;function ct(t,e,r){if(e!=null)return(e?ft:0)|(e==="full"?ht:0);return t&&t.whitespace=="pre"?ft|ht:r&~at}class dt{constructor(t,e,r,i,n,s,o){this.type=t;this.attrs=e;this.marks=r;this.pendingMarks=i;this.solid=n;this.options=o;this.content=[];this.activeMarks=a.none;this.stashMarks=[];this.match=s||(o&at?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(l.from(t));if(e){this.match=this.type.contentMatch.matchFragment(e)}else{let e=this.type.contentMatch,r;if(r=e.findWrapping(t.type)){this.match=e;return r}else{return null}}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&ft)){let t=this.content[this.content.length-1],e;if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let r=t;if(t.text.length==e[0].length)this.content.pop();else this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-e[0].length))}}let e=l.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(l.empty,true));return this.type?this.type.create(this.attrs,e,this.marks):e}popFromStashMark(t){for(let e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]}applyPending(t){for(let e=0,r=this.pendingMarks;e<r.length;e++){let i=r[e];if((this.type?this.type.allowsMarkType(i.type):bt(i.type,t))&&!i.isInSet(this.activeMarks)){this.activeMarks=i.addToSet(this.activeMarks);this.pendingMarks=i.removeFromSet(this.pendingMarks)}}}inlineContext(t){if(this.type)return this.type.inlineContent;if(this.content.length)return this.content[0].isInline;return t.parentNode&&!ot.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class pt{constructor(t,e,r){this.parser=t;this.options=e;this.isOpen=r;this.open=0;let i=e.topNode,n;let s=ct(null,e.preserveWhitespace,0)|(r?at:0);if(i)n=new dt(i.type,i.attrs,a.none,a.none,true,e.topMatch||i.type.contentMatch,s);else if(r)n=new dt(null,null,a.none,a.none,true,null,s);else n=new dt(t.schema.topNodeType,null,a.none,a.none,true,null,s);this.nodes=[n];this.find=e.findPositions;this.needsBlock=false}get top(){return this.nodes[this.open]}addDOM(t){if(t.nodeType==3)this.addTextNode(t);else if(t.nodeType==1)this.addElement(t)}withStyleRules(t,e){let r=t.style;if(!r||!r.length)return e();let i=this.readStyles(t.style);if(!i)return;let[n,s]=i,o=this.top;for(let t=0;t<s.length;t++)this.removePendingMark(s[t],o);for(let t=0;t<n.length;t++)this.addPendingMark(n[t]);e();for(let t=0;t<n.length;t++)this.removePendingMark(n[t],o);for(let t=0;t<s.length;t++)this.addPendingMark(s[t])}addTextNode(t){let e=t.nodeValue;let r=this.top;if(r.options&ht||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(e)){if(!(r.options&ft)){e=e.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){let i=r.content[r.content.length-1];let n=t.previousSibling;if(!i||n&&n.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))e=e.slice(1)}}else if(!(r.options&ht)){e=e.replace(/\r?\n|\r/g," ")}else{e=e.replace(/\r\n?/g,"\n")}if(e)this.insertNode(this.parser.schema.text(e));this.findInText(t)}else{this.findInside(t)}}addElement(t,e){let r=t.nodeName.toLowerCase(),i;if(ut.hasOwnProperty(r)&&this.parser.normalizeLists)mt(t);let n=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,e));if(n?n.ignore:lt.hasOwnProperty(r)){this.findInside(t);this.ignoreFallback(t)}else if(!n||n.skip||n.closeParent){if(n&&n.closeParent)this.open=Math.max(0,this.open-1);else if(n&&n.skip.nodeType)t=n.skip;let e,i=this.top,s=this.needsBlock;if(ot.hasOwnProperty(r)){if(i.content.length&&i.content[0].isInline&&this.open){this.open--;i=this.top}e=true;if(!i.type)this.needsBlock=true}else if(!t.firstChild){this.leafFallback(t);return}if(n&&n.skip)this.addAll(t);else this.withStyleRules(t,(()=>this.addAll(t)));if(e)this.sync(i);this.needsBlock=s}else{this.withStyleRules(t,(()=>{this.addElementByRule(t,n,n.consuming===false?i:undefined)}))}}leafFallback(t){if(t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent)this.addTextNode(t.ownerDocument.createTextNode("\n"))}ignoreFallback(t){if(t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent))this.findPlace(this.parser.schema.text("-"))}readStyles(t){let e=a.none,r=a.none;for(let i=0,n=t.length;i<n;i++){let n=t.item(i);for(let i=undefined;;){let s=this.parser.matchStyle(n,t.getPropertyValue(n),this,i);if(!s)break;if(s.ignore)return null;if(s.clearMark){this.top.pendingMarks.concat(this.top.activeMarks).forEach((t=>{if(s.clearMark(t))r=t.addToSet(r)}))}else{e=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(e)}if(s.consuming===false)i=s;else break}}return[e,r]}addElementByRule(t,e,r){let i,n,s;if(e.node){n=this.parser.schema.nodes[e.node];if(!n.isLeaf){i=this.enter(n,e.attrs||null,e.preserveWhitespace)}else if(!this.insertNode(n.create(e.attrs))){this.leafFallback(t)}}else{let t=this.parser.schema.marks[e.mark];s=t.create(e.attrs);this.addPendingMark(s)}let o=this.top;if(n&&n.isLeaf){this.findInside(t)}else if(r){this.addElement(t,r)}else if(e.getContent){this.findInside(t);e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t)))}else{let r=t;if(typeof e.contentElement=="string")r=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")r=e.contentElement(t);else if(e.contentElement)r=e.contentElement;this.findAround(t,r,true);this.addAll(r)}if(i&&this.sync(o))this.open--;if(s)this.removePendingMark(s,o)}addAll(t,e,r){let i=e||0;for(let n=e?t.childNodes[e]:t.firstChild,s=r==null?null:t.childNodes[r];n!=s;n=n.nextSibling,++i){this.findAtPoint(t,i);this.addDOM(n)}this.findAtPoint(t,i)}findPlace(t){let e,r;for(let i=this.open;i>=0;i--){let n=this.nodes[i];let s=n.findWrapping(t);if(s&&(!e||e.length>s.length)){e=s;r=n;if(!s.length)break}if(n.solid)break}if(!e)return false;this.sync(r);for(let t=0;t<e.length;t++)this.enterInner(e[t],null,false);return true}insertNode(t){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();if(t)this.enterInner(t)}if(this.findPlace(t)){this.closeExtra();let e=this.top;e.applyPending(t.type);if(e.match)e.match=e.match.matchType(t.type);let r=e.activeMarks;for(let i=0;i<t.marks.length;i++)if(!e.type||e.type.allowsMarkType(t.marks[i].type))r=t.marks[i].addToSet(r);e.content.push(t.mark(r));return true}return false}enter(t,e,r){let i=this.findPlace(t.create(e));if(i)this.enterInner(t,e,true,r);return i}enterInner(t,e=null,r=false,i){this.closeExtra();let n=this.top;n.applyPending(t);n.match=n.match&&n.match.matchType(t);let s=ct(t,i,n.options);if(n.options&at&&n.content.length==0)s|=at;this.nodes.push(new dt(t,e,n.activeMarks,n.pendingMarks,r,null,s));this.open++}closeExtra(t=false){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){this.open=0;this.closeExtra(this.isOpen);return this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t){this.open=e;return true}return false}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++){if(this.find[r].node==t&&this.find[r].offset==e)this.find[r].pos=this.currentPos}}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node))this.find[e].pos=this.currentPos}}findAround(t,e,r){if(t!=e&&this.find)for(let i=0;i<this.find.length;i++){if(this.find[i].pos==null&&t.nodeType==1&&t.contains(this.find[i].node)){let t=e.compareDocumentPosition(this.find[i].node);if(t&(r?2:4))this.find[i].pos=this.currentPos}}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].node==t)this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset)}}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/");let r=this.options.context;let i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type);let n=-(r?r.depth+1:0)+(i?0:1);let s=(t,o)=>{for(;t>=0;t--){let l=e[t];if(l==""){if(t==e.length-1||t==0)continue;for(;o>=n;o--)if(s(t-1,o))return true;return false}else{let t=o>0||o==0&&i?this.nodes[o].type:r&&o>=n?r.node(o-n).type:null;if(!t||t.name!=l&&t.groups.indexOf(l)==-1)return false;o--}}return true};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}addPendingMark(t){let e=vt(t,this.top.pendingMarks);if(e)this.top.stashMarks.push(e);this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,e){for(let r=this.open;r>=0;r--){let i=this.nodes[r];let n=i.pendingMarks.lastIndexOf(t);if(n>-1){i.pendingMarks=t.removeFromSet(i.pendingMarks)}else{i.activeMarks=t.removeFromSet(i.activeMarks);let e=i.popFromStashMark(t);if(e&&i.type&&i.type.allowsMarkType(e.type))i.activeMarks=e.addToSet(i.activeMarks)}if(i==e)break}}}function mt(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&ut.hasOwnProperty(t)&&r){r.appendChild(e);e=r}else if(t=="li"){r=e}else if(t){r=null}}}function gt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function wt(t){let e={};for(let r in t)e[r]=t[r];return e}function bt(t,e){let r=e.schema.nodes;for(let i in r){let n=r[i];if(!n.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:i,next:n}=t.edge(r);if(i==e)return true;if(s.indexOf(n)<0&&o(n))return true}};if(o(n.contentMatch))return true}}function vt(t,e){for(let r=0;r<e.length;r++){if(t.eq(e[r]))return e[r]}}class yt{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},r){if(!r)r=kt(e).createDocumentFragment();let i=r,n=[];t.forEach((t=>{if(n.length||t.marks.length){let r=0,s=0;while(r<n.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(n[r][0])||e.type.spec.spanning===false)break;r++;s++}while(r<n.length)i=n.pop()[1];while(s<t.marks.length){let r=t.marks[s++];let o=this.serializeMark(r,t.isInline,e);if(o){n.push([r,i]);i.appendChild(o.dom);i=o.contentDOM||o.dom}}}i.appendChild(this.serializeNodeInner(t,e))}));return r}serializeNodeInner(t,e){let{dom:r,contentDOM:i}=yt.renderSpec(kt(e),this.nodes[t.type.name](t));if(i){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,i)}return r}serializeNode(t,e={}){let r=this.serializeNodeInner(t,e);for(let i=t.marks.length-1;i>=0;i--){let n=this.serializeMark(t.marks[i],t.isInline,e);if(n){(n.contentDOM||n.dom).appendChild(r);r=n.dom}}return r}serializeMark(t,e,r={}){let i=this.marks[t.type.name];return i&&yt.renderSpec(kt(r),i(t,e))}static renderSpec(t,e,r=null){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],n=i.indexOf(" ");if(n>0){r=i.slice(0,n);i=i.slice(n+1)}let s;let o=r?t.createElementNS(r,i):t.createElement(i);let l=e[1],u=1;if(l&&typeof l=="object"&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let t in l)if(l[t]!=null){let e=t.indexOf(" ");if(e>0)o.setAttributeNS(t.slice(0,e),t.slice(e+1),l[t]);else o.setAttribute(t,l[t])}}for(let i=u;i<e.length;i++){let n=e[i];if(n===0){if(i<e.length-1||i>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:o,contentDOM:o}}else{let{dom:e,contentDOM:i}=yt.renderSpec(t,n,r);o.appendChild(e);if(i){if(s)throw new RangeError("Multiple content holes");s=i}}}return{dom:o,contentDOM:s}}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new yt(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=Mt(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return Mt(t.marks)}}function Mt(t){let e={};for(let r in t){let i=t[r].spec.toDOM;if(i)e[r]=i}return e}function kt(t){return t.document||window.document}const xt=65535;const St=Math.pow(2,16);function Ot(t,e){return t+e*St}function Tt(t){return t&xt}function Et(t){return(t-(t&xt))/St}const Pt=1,At=2,Ct=4,Nt=8;class $t{constructor(t,e,r){this.pos=t;this.delInfo=e;this.recover=r}get deleted(){return(this.delInfo&Nt)>0}get deletedBefore(){return(this.delInfo&(Pt|Ct))>0}get deletedAfter(){return(this.delInfo&(At|Ct))>0}get deletedAcross(){return(this.delInfo&Ct)>0}}class Rt{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&Rt.empty)return Rt.empty}recover(t){let e=0,r=Tt(t);if(!this.inverted)for(let t=0;t<r;t++)e+=this.ranges[t*3+2]-this.ranges[t*3+1];return this.ranges[r*3]+e+Et(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,r){let i=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>t)break;let u=this.ranges[o+n],f=this.ranges[o+s],h=l+u;if(t<=h){let n=!u?e:t==l?-1:t==h?1:e;let s=l+i+(n<0?0:f);if(r)return s;let a=t==(e<0?l:h)?null:Ot(o/3,t-l);let c=t==l?At:t==h?Pt:Ct;if(e<0?t!=l:t!=h)c|=Nt;return new $t(s,c,a)}i+=f-u}return r?t+i:new $t(t+i,0,null)}touches(t,e){let r=0,i=Tt(e);let n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?r:0);if(o>t)break;let l=this.ranges[e+n],u=o+l;if(t<=u&&e==i*3)return true;r+=this.ranges[e+s]-l}return false}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,n=0;i<this.ranges.length;i+=3){let s=this.ranges[i],o=s-(this.inverted?n:0),l=s+(this.inverted?0:n);let u=this.ranges[i+e],f=this.ranges[i+r];t(o,o+u,l,l+f);n+=f-u}}invert(){return new Rt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Rt.empty:new Rt(t<0?[0,-t,0]:[0,0,t])}}Rt.empty=new Rt([]);class Dt{constructor(t=[],e,r=0,i=t.length){this.maps=t;this.mirror=e;this.from=r;this.to=i}slice(t=0,e=this.maps.length){return new Dt(this.maps,this.mirror,t,e)}copy(){return new Dt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t);if(e!=null)this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,r=this.maps.length;e<t.maps.length;e++){let i=t.getMirror(e);this.appendMap(t.maps[e],i!=null&&i<e?r+i:undefined)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){if(!this.mirror)this.mirror=[];this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,r=this.maps.length+t.maps.length;e>=0;e--){let i=t.getMirror(e);this.appendMap(t.maps[e].invert(),i!=null&&i>e?r-i-1:undefined)}}invert(){let t=new Dt;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let r=this.from;r<this.to;r++)t=this.maps[r].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,r){let i=0;for(let r=this.from;r<this.to;r++){let n=this.maps[r],s=n.mapResult(t,e);if(s.recover!=null){let e=this.getMirror(r);if(e!=null&&e>r&&e<this.to){r=e;t=this.maps[e].recover(s.recover);continue}}i|=s.delInfo;t=s.pos}return r?t:new $t(t,i,null)}}const It=Object.create(null);class Lt{getMap(){return Rt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=It[e.stepType];if(!r)throw new RangeError(`No step type ${e.stepType} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in It)throw new RangeError("Duplicate use of step JSON ID "+t);It[t]=e;e.prototype.jsonID=t;return e}}class Ht{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new Ht(t,null)}static fail(t){return new Ht(null,t)}static fromReplace(t,e,r,i){try{return Ht.ok(t.replace(e,r,i))}catch(t){if(t instanceof c)return Ht.fail(t.message);throw t}}}function jt(t,e,r){let i=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);if(s.content.size)s=s.copy(jt(s.content,e,s));if(s.isInline)s=e(s,r,n);i.push(s)}return l.fromArray(i)}class Bt extends Lt{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=t.resolve(this.from);let i=r.node(r.sharedDepth(this.to));let n=new d(jt(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),i),e.openStart,e.openEnd);return Ht.fromReplace(t,this.from,this.to,n)}invert(){return new Jt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deleted&&r.deleted||e.pos>=r.pos)return null;return new Bt(e.pos,r.pos,this.mark)}merge(t){if(t instanceof Bt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Bt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Bt(e.from,e.to,t.markFromJSON(e.mark))}}Lt.jsonID("addMark",Bt);class Jt extends Lt{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to);let r=new d(jt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return Ht.fromReplace(t,this.from,this.to,r)}invert(){return new Bt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deleted&&r.deleted||e.pos>=r.pos)return null;return new Jt(e.pos,r.pos,this.mark)}merge(t){if(t instanceof Jt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Jt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Jt(e.from,e.to,t.markFromJSON(e.mark))}}Lt.jsonID("removeMark",Jt);class zt extends Lt{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Ht.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Ht.fromReplace(t,this.pos,this.pos+1,new d(l.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let r=0;r<e.marks.length;r++)if(!e.marks[r].isInSet(t))return new zt(this.pos,e.marks[r]);return new zt(this.pos,this.mark)}}return new Ft(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new zt(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new zt(e.pos,t.markFromJSON(e.mark))}}Lt.jsonID("addNodeMark",zt);class Ft extends Lt{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Ht.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Ht.fromReplace(t,this.pos,this.pos+1,new d(l.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(!e||!this.mark.isInSet(e.marks))return this;return new zt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ft(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ft(e.pos,t.markFromJSON(e.mark))}}Lt.jsonID("removeNodeMark",Ft);class _t extends Lt{constructor(t,e,r,i=false){super();this.from=t;this.to=e;this.slice=r;this.structure=i}apply(t){if(this.structure&&qt(t,this.from,this.to))return Ht.fail("Structure replace would overwrite content");return Ht.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Rt([this.from,this.to-this.from,this.slice.size])}invert(t){return new _t(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deletedAcross&&r.deletedAcross)return null;return new _t(e.pos,Math.max(e.pos,r.pos),this.slice)}merge(t){if(!(t instanceof _t)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let e=this.slice.size+t.slice.size==0?d.empty:new d(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new _t(this.from,this.to+(t.to-t.from),e,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let e=this.slice.size+t.slice.size==0?d.empty:new d(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new _t(t.from,this.to,e,this.structure)}else{return null}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new _t(e.from,e.to,d.fromJSON(t,e.slice),!!e.structure)}}Lt.jsonID("replace",_t);class Kt extends Lt{constructor(t,e,r,i,n,s,o=false){super();this.from=t;this.to=e;this.gapFrom=r;this.gapTo=i;this.slice=n;this.insert=s;this.structure=o}apply(t){if(this.structure&&(qt(t,this.from,this.gapFrom)||qt(t,this.gapTo,this.to)))return Ht.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Ht.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);if(!r)return Ht.fail("Content does not fit in gap");return Ht.fromReplace(t,this.from,this.to,r)}getMap(){return new Rt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Kt(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);let i=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1);let n=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);if(e.deletedAcross&&r.deletedAcross||i<e.pos||n>r.pos)return null;return new Kt(e.pos,r.pos,i,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Kt(e.from,e.to,e.gapFrom,e.gapTo,d.fromJSON(t,e.slice),e.insert,!!e.structure)}}Lt.jsonID("replaceAround",Kt);function qt(t,e,r){let i=t.resolve(e),n=r-e,s=i.depth;while(n>0&&s>0&&i.indexAfter(s)==i.node(s).childCount){s--;n--}if(n>0){let t=i.node(s).maybeChild(i.indexAfter(s));while(n>0){if(!t||t.isLeaf)return true;t=t.firstChild;n--}}return false}function Ut(t,e,r,i){let n=[],s=[];let o,l;t.doc.nodesBetween(e,r,((t,u,f)=>{if(!t.isInline)return;let h=t.marks;if(!i.isInSet(h)&&f.type.allowsMarkType(i.type)){let f=Math.max(u,e),a=Math.min(u+t.nodeSize,r);let c=i.addToSet(h);for(let t=0;t<h.length;t++){if(!h[t].isInSet(c)){if(o&&o.to==f&&o.mark.eq(h[t]))o.to=a;else n.push(o=new Jt(f,a,h[t]))}}if(l&&l.to==f)l.to=a;else s.push(l=new Bt(f,a,i))}}));n.forEach((e=>t.step(e)));s.forEach((e=>t.step(e)))}function Wt(t,e,r,i){let n=[],s=0;t.doc.nodesBetween(e,r,((t,o)=>{if(!t.isInline)return;s++;let l=null;if(i instanceof tt){let e=t.marks,r;while(r=i.isInSet(e)){(l||(l=[])).push(r);e=r.removeFromSet(e)}}else if(i){if(i.isInSet(t.marks))l=[i]}else{l=t.marks}if(l&&l.length){let i=Math.min(o+t.nodeSize,r);for(let t=0;t<l.length;t++){let r=l[t],u;for(let t=0;t<n.length;t++){let e=n[t];if(e.step==s-1&&r.eq(n[t].style))u=e}if(u){u.to=i;u.step=s}else{n.push({style:r,from:Math.max(o,e),to:i,step:s})}}}}));n.forEach((e=>t.step(new Jt(e.from,e.to,e.style))))}function Gt(t,e,r,i=r.contentMatch,n=true){let s=t.doc.nodeAt(e);let o=[],u=e+1;for(let e=0;e<s.childCount;e++){let f=s.child(e),h=u+f.nodeSize;let a=i.matchType(f.type);if(!a){o.push(new _t(u,h,d.empty))}else{i=a;for(let e=0;e<f.marks.length;e++)if(!r.allowsMarkType(f.marks[e].type))t.step(new Jt(u,h,f.marks[e]));if(n&&f.isText&&r.whitespace!="pre"){let t,e=/\r?\n|\r/g,i;while(t=e.exec(f.text)){if(!i)i=new d(l.from(r.schema.text(" ",r.allowedMarks(f.marks))),0,0);o.push(new _t(u+t.index,u+t.index+t[0].length,i))}}}u=h}if(!i.validEnd){let e=i.fillBefore(l.empty,true);t.replace(u,u,new d(e,0,0))}for(let e=o.length-1;e>=0;e--)t.step(o[e])}function Vt(t,e,r){return(e==0||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function Xt(t){let e=t.parent;let r=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth;;--e){let i=t.$from.node(e);let n=t.$from.index(e),s=t.$to.indexAfter(e);if(e<t.depth&&i.canReplace(n,s,r))return e;if(e==0||i.type.spec.isolating||!Vt(i,n,s))break}return null}function Yt(t,e,r){let{$from:i,$to:n,depth:s}=e;let o=i.before(s+1),u=n.after(s+1);let f=o,h=u;let a=l.empty,c=0;for(let t=s,e=false;t>r;t--)if(e||i.index(t)>0){e=true;a=l.from(i.node(t).copy(a));c++}else{f--}let p=l.empty,m=0;for(let t=s,e=false;t>r;t--)if(e||n.after(t+1)<n.end(t)){e=true;p=l.from(n.node(t).copy(p));m++}else{h++}t.step(new Kt(f,h,o,u,new d(a.append(p),c,m),a.size-c,true))}function Qt(t,e,r=null,i=t){let n=te(t,e);let s=n&&ee(i,e);if(!s)return null;return n.map(Zt).concat({type:e,attrs:r}).concat(s.map(Zt))}function Zt(t){return{type:t,attrs:null}}function te(t,e){let{parent:r,startIndex:i,endIndex:n}=t;let s=r.contentMatchAt(i).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return r.canReplaceWith(i,n,o)?s:null}function ee(t,e){let{parent:r,startIndex:i,endIndex:n}=t;let s=r.child(i);let o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=o.length?o[o.length-1]:e;let u=l.contentMatch;for(let t=i;u&&t<n;t++)u=u.matchType(r.child(t).type);if(!u||!u.validEnd)return null;return o}function re(t,e,r){let i=l.empty;for(let t=r.length-1;t>=0;t--){if(i.size){let e=r[t].type.contentMatch.matchFragment(i);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=l.from(r[t].type.create(r[t].attrs,i))}let n=e.start,s=e.end;t.step(new Kt(n,s,n,s,new d(i,0,0),r.length,true))}function ie(t,e,r,i,n){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,r,((e,r)=>{if(e.isTextblock&&!e.hasMarkup(i,n)&&oe(t.doc,t.mapping.slice(s).map(r),i)){let o=null;if(i.schema.linebreakReplacement){let t=i.whitespace=="pre",e=!!i.contentMatch.matchType(i.schema.linebreakReplacement);if(t&&!e)o=false;else if(!t&&e)o=true}if(o===false)se(t,e,r,s);Gt(t,t.mapping.slice(s).map(r,1),i,undefined,o===null);let u=t.mapping.slice(s);let f=u.map(r,1),h=u.map(r+e.nodeSize,1);t.step(new Kt(f,h,f+1,h-1,new d(l.from(i.create(n,null,e.marks)),0,0),1,true));if(o===true)ne(t,e,r,s);return false}}))}function ne(t,e,r,i){e.forEach(((n,s)=>{if(n.isText){let o,l=/\r?\n|\r/g;while(o=l.exec(n.text)){let n=t.mapping.slice(i).map(r+1+s+o.index);t.replaceWith(n,n+1,e.type.schema.linebreakReplacement.create())}}}))}function se(t,e,r,i){e.forEach(((n,s)=>{if(n.type==n.type.schema.linebreakReplacement){let n=t.mapping.slice(i).map(r+1+s);t.replaceWith(n,n+1,e.type.schema.text("\n"))}}))}function oe(t,e,r){let i=t.resolve(e),n=i.index();return i.parent.canReplaceWith(n,n+1,r)}function le(t,e,r,i,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");if(!r)r=s.type;let o=r.create(i,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!r.validContent(s.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new Kt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new d(l.from(o),0,0),1,true))}function ue(t,e,r=1,i){let n=t.resolve(e),s=n.depth-r;let o=i&&i[i.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!o.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return false;for(let t=n.depth-1,e=r-2;t>s;t--,e--){let r=n.node(t),s=n.index(t);if(r.type.spec.isolating)return false;let o=r.content.cutByIndex(s,r.childCount);let l=i&&i[e+1];if(l)o=o.replaceChild(0,l.type.create(l.attrs));let u=i&&i[e]||r;if(!r.canReplace(s+1,r.childCount)||!u.type.validContent(o))return false}let l=n.indexAfter(s);let u=i&&i[0];return n.node(s).canReplaceWith(l,l,u?u.type:n.node(s+1).type)}function fe(t,e,r=1,i){let n=t.doc.resolve(e),s=l.empty,o=l.empty;for(let t=n.depth,e=n.depth-r,u=r-1;t>e;t--,u--){s=l.from(n.node(t).copy(s));let e=i&&i[u];o=l.from(e?e.type.create(e.attrs,o):n.node(t).copy(o))}t.step(new _t(e,e,new d(s.append(o),r,r),true))}function he(t,e){let r=t.resolve(e),i=r.index();return ae(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(i,i+1)}function ae(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function ce(t,e,r=-1){let i=t.resolve(e);for(let t=i.depth;;t--){let n,s,o=i.index(t);if(t==i.depth){n=i.nodeBefore;s=i.nodeAfter}else if(r>0){n=i.node(t+1);o++;s=i.node(t).maybeChild(o)}else{n=i.node(t).maybeChild(o-1);s=i.node(t+1)}if(n&&!n.isTextblock&&ae(n,s)&&i.node(t).canReplace(o,o+1))return e;if(t==0)break;e=r<0?i.before(t):i.after(t)}}function de(t,e,r){let i=new _t(e-r,e+r,d.empty,true);t.step(i)}function pe(t,e,r){let i=t.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),r))return e;if(i.parentOffset==0)for(let t=i.depth-1;t>=0;t--){let e=i.index(t);if(i.node(t).canReplaceWith(e,e,r))return i.before(t+1);if(e>0)return null}if(i.parentOffset==i.parent.content.size)for(let t=i.depth-1;t>=0;t--){let e=i.indexAfter(t);if(i.node(t).canReplaceWith(e,e,r))return i.after(t+1);if(e<i.node(t).childCount)return null}return null}function me(t,e,r){let i=t.resolve(e);if(!r.content.size)return e;let n=r.content;for(let t=0;t<r.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(r.openStart==0&&r.size?2:1);t++){for(let e=i.depth;e>=0;e--){let r=e==i.depth?0:i.pos<=(i.start(e+1)+i.end(e+1))/2?-1:1;let s=i.index(e)+(r>0?1:0);let o=i.node(e),l=false;if(t==1){l=o.canReplace(s,s,n)}else{let t=o.contentMatchAt(s).findWrapping(n.firstChild.type);l=t&&o.canReplaceWith(s,s,t[0])}if(l)return r==0?i.pos:r<0?i.before(e+1):i.after(e+1)}}return null}function ge(t,e,r=e,i=d.empty){if(e==r&&!i.size)return null;let n=t.resolve(e),s=t.resolve(r);if(we(n,s,i))return new _t(e,r,i);return new be(n,s,i).fit()}function we(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}class be{constructor(t,e,r){this.$from=t;this.$to=e;this.unplaced=r;this.frontier=[];this.placed=l.empty;for(let e=0;e<=t.depth;e++){let r=t.node(e);this.frontier.push({type:r.type,match:r.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=l.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let t=this.findFittable();if(t)this.placeNodes(t);else this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth;let r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;let n=this.placed,s=r.depth,o=i.depth;while(s&&o&&n.childCount==1){n=n.firstChild.content;s--;o--}let l=new d(n,s,o);if(t>-1)return new Kt(r.pos,t,this.$to.pos,this.$to.end(),l,e);if(l.size||r.pos!=this.$to.pos)return new _t(r.pos,i.pos,l);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<t;r++){let n=e.firstChild;if(e.childCount>1)i=0;if(n.type.spec.isolating&&i<=r){t=r;break}e=n.content}for(let e=1;e<=2;e++){for(let r=e==1?t:this.unplaced.openStart;r>=0;r--){let t,i=null;if(r){i=Me(this.unplaced.content,r-1).firstChild;t=i.content}else{t=this.unplaced.content}let n=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:s,match:o}=this.frontier[t],u,f=null;if(e==1&&(n?o.matchType(n.type)||(f=o.fillBefore(l.from(n),false)):i&&s.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:t,parent:i,inject:f};else if(e==2&&n&&(u=o.findWrapping(n.type)))return{sliceDepth:r,frontierDepth:t,parent:i,wrap:u};if(i&&o.matchType(i.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let i=Me(t,e);if(!i.childCount||i.firstChild.isLeaf)return false;this.unplaced=new d(t,e+1,Math.max(r,i.size+e>=t.size-r?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let i=Me(t,e);if(i.childCount<=1&&e>0){let n=t.size-e<=e+i.size;this.unplaced=new d(ve(t,e-1,1),e-1,n?e-1:r)}else{this.unplaced=new d(ve(t,e,1),e,r)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:i,wrap:n}){while(this.depth>e)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,o=r?r.content:s.content;let u=s.openStart-t;let f=0,h=[];let{match:a,type:c}=this.frontier[e];if(i){for(let t=0;t<i.childCount;t++)h.push(i.child(t));a=a.matchFragment(i)}let p=o.size+t-(s.content.size-s.openEnd);while(f<o.childCount){let t=o.child(f),e=a.matchType(t.type);if(!e)break;f++;if(f>1||u==0||t.content.size){a=e;h.push(ke(t.mark(c.allowedMarks(t.marks)),f==1?u:0,f==o.childCount?p:-1))}}let m=f==o.childCount;if(!m)p=-1;this.placed=ye(this.placed,e,l.from(h));this.frontier[e].match=a;if(m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let t=0,e=o;t<p;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)});e=t.content}this.unplaced=!m?new d(ve(s.content,t,f),s.openStart,s.openEnd):t==0?d.empty:new d(ve(s.content,t-1,1),t-1,p<0?s.openEnd:t-1)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!xe(this.$to,this.$to.depth,t.type,t.match,false)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);while(r>1&&i==this.$to.end(--r))++i;return i}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:r,type:i}=this.frontier[e];let n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let s=xe(t,e,i,r,n);if(!s)continue;for(let r=e-1;r>=0;r--){let{match:e,type:i}=this.frontier[r];let n=xe(t,r,i,e,true);if(!n||n.childCount)continue t}return{depth:e,fit:s,move:n?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=ye(this.placed,e.depth,e.fit);t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let e=t.node(r),i=e.type.contentMatch.fillBefore(e.content,true,t.index(r));this.openFrontierNode(e.type,e.attrs,i)}return t}openFrontierNode(t,e=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(t);this.placed=ye(this.placed,this.depth,l.from(t.create(e,r)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(l.empty,true);if(e.childCount)this.placed=ye(this.placed,this.frontier.length,e)}}function ve(t,e,r){if(e==0)return t.cutByIndex(r,t.childCount);return t.replaceChild(0,t.firstChild.copy(ve(t.firstChild.content,e-1,r)))}function ye(t,e,r){if(e==0)return t.append(r);return t.replaceChild(t.childCount-1,t.lastChild.copy(ye(t.lastChild.content,e-1,r)))}function Me(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function ke(t,e,r){if(e<=0)return t;let i=t.content;if(e>1)i=i.replaceChild(0,ke(i.firstChild,e-1,i.childCount==1?r-1:0));if(e>0){i=t.type.contentMatch.fillBefore(i).append(i);if(r<=0)i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(l.empty,true))}return t.copy(i)}function xe(t,e,r,i,n){let s=t.node(e),o=n?t.indexAfter(e):t.index(e);if(o==s.childCount&&!r.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,true,o);return l&&!Se(r,s.content,o)?l:null}function Se(t,e,r){for(let i=r;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return true;return false}function Oe(t){return t.spec.defining||t.spec.definingForContent}function Te(t,e,r,i){if(!i.size)return t.deleteRange(e,r);let n=t.doc.resolve(e),s=t.doc.resolve(r);if(we(n,s,i))return t.step(new _t(e,r,i));let o=Ce(n,t.doc.resolve(r));if(o[o.length-1]==0)o.pop();let l=-(n.depth+1);o.unshift(l);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let r=n.node(t).type.spec;if(r.defining||r.definingAsContext||r.isolating)break;if(o.indexOf(t)>-1)l=t;else if(n.before(t)==e)o.splice(1,0,-t)}let u=o.indexOf(l);let f=[],h=i.openStart;for(let t=i.content,e=0;;e++){let r=t.firstChild;f.push(r);if(e==i.openStart)break;t=r.content}for(let t=h-1;t>=0;t--){let e=f[t],r=Oe(e.type);if(r&&!e.sameMarkup(n.node(Math.abs(l)-1)))h=t;else if(r||!e.type.isTextblock)break}for(let e=i.openStart;e>=0;e--){let l=(e+h+1)%(i.openStart+1);let a=f[l];if(!a)continue;for(let e=0;e<o.length;e++){let f=o[(e+u)%o.length],h=true;if(f<0){h=false;f=-f}let c=n.node(f-1),p=n.index(f-1);if(c.canReplaceWith(p,p,a.type,a.marks))return t.replace(n.before(f),h?s.after(f):r,new d(Ee(i.content,0,i.openStart,l),l,i.openEnd))}}let a=t.steps.length;for(let l=o.length-1;l>=0;l--){t.replace(e,r,i);if(t.steps.length>a)break;let u=o[l];if(u<0)continue;e=n.before(u);r=s.after(u)}}function Ee(t,e,r,i,n){if(e<r){let n=t.firstChild;t=t.replaceChild(0,n.copy(Ee(n.content,e+1,r,i,n)))}if(e>i){let e=n.contentMatchAt(0);let r=e.fillBefore(t).append(t);t=r.append(e.matchFragment(r).fillBefore(l.empty,true))}return t}function Pe(t,e,r,i){if(!i.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let n=pe(t.doc,e,i.type);if(n!=null)e=r=n}t.replaceRange(e,r,new d(l.from(i),0,0))}function Ae(t,e,r){let i=t.doc.resolve(e),n=t.doc.resolve(r);let s=Ce(i,n);for(let e=0;e<s.length;e++){let r=s[e],o=e==s.length-1;if(o&&r==0||i.node(r).type.contentMatch.validEnd)return t.delete(i.start(r),n.end(r));if(r>0&&(o||i.node(r-1).canReplace(i.index(r-1),n.indexAfter(r-1))))return t.delete(i.before(r),n.after(r))}for(let s=1;s<=i.depth&&s<=n.depth;s++){if(e-i.start(s)==i.depth-s&&r>i.end(s)&&n.end(s)-r!=n.depth-s)return t.delete(i.before(s),r)}t.delete(e,r)}function Ce(t,e){let r=[],i=Math.min(t.depth,e.depth);for(let n=i;n>=0;n--){let i=t.start(n);if(i<t.pos-(t.depth-n)||e.end(n)>e.pos+(e.depth-n)||t.node(n).type.spec.isolating||e.node(n).type.spec.isolating)break;if(i==e.start(n)||n==t.depth&&n==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&n&&e.start(n-1)==i-1)r.push(n)}return r}class Ne extends Lt{constructor(t,e,r){super();this.pos=t;this.attr=e;this.value=r}apply(t){let e=t.nodeAt(this.pos);if(!e)return Ht.fail("No node at attribute step's position");let r=Object.create(null);for(let t in e.attrs)r[t]=e.attrs[t];r[this.attr]=this.value;let i=e.type.create(r,null,e.marks);return Ht.fromReplace(t,this.pos,this.pos+1,new d(l.from(i),0,e.isLeaf?0:1))}getMap(){return Rt.empty}invert(t){return new Ne(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ne(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.pos!="number"||typeof e.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ne(e.pos,e.attr,e.value)}}Lt.jsonID("attr",Ne);class $e extends Lt{constructor(t,e){super();this.attr=t;this.value=e}apply(t){let e=Object.create(null);for(let r in t.attrs)e[r]=t.attrs[r];e[this.attr]=this.value;let r=t.type.create(e,t.content,t.marks);return Ht.ok(r)}getMap(){return Rt.empty}invert(t){return new $e(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new $e(e.attr,e.value)}}Lt.jsonID("docAttr",$e);let Re=class extends Error{};Re=function t(e){let r=Error.call(this,e);r.__proto__=t.prototype;return r};Re.prototype=Object.create(Error.prototype);Re.prototype.constructor=Re;Re.prototype.name="TransformError";class De{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new Dt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Re(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);if(!e.failed)this.addStep(t,e.doc);return e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc);this.steps.push(t);this.mapping.appendMap(t.getMap());this.doc=e}replace(t,e=t,r=d.empty){let i=ge(this.doc,t,e,r);if(i)this.step(i);return this}replaceWith(t,e,r){return this.replace(t,e,new d(l.from(r),0,0))}delete(t,e){return this.replace(t,e,d.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){Te(this,t,e,r);return this}replaceRangeWith(t,e,r){Pe(this,t,e,r);return this}deleteRange(t,e){Ae(this,t,e);return this}lift(t,e){Yt(this,t,e);return this}join(t,e=1){de(this,t,e);return this}wrap(t,e){re(this,t,e);return this}setBlockType(t,e=t,r,i=null){ie(this,t,e,r,i);return this}setNodeMarkup(t,e,r=null,i){le(this,t,e,r,i);return this}setNodeAttribute(t,e,r){this.step(new Ne(t,e,r));return this}setDocAttribute(t,e){this.step(new $e(t,e));return this}addNodeMark(t,e){this.step(new zt(t,e));return this}removeNodeMark(t,e){if(!(e instanceof a)){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);e=e.isInSet(r.marks);if(!e)return this}this.step(new Ft(t,e));return this}split(t,e=1,r){fe(this,t,e,r);return this}addMark(t,e,r){Ut(this,t,e,r);return this}removeMark(t,e,r){Wt(this,t,e,r);return this}clearIncompatible(t,e,r){Gt(this,t,e,r);return this}}const Ie=Object.create(null);class Le{constructor(t,e,r){this.$anchor=t;this.$head=e;this.ranges=r||[new He(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return false;return true}content(){return this.$from.doc.slice(this.from,this.to,true)}replace(t,e=d.empty){let r=e.content.lastChild,i=null;for(let t=0;t<e.openEnd;t++){i=r;r=r.lastChild}let n=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:u}=s[o],f=t.mapping.slice(n);t.replaceRange(f.map(l.pos),f.map(u.pos),o?d.empty:e);if(o==0)We(t,n,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){let{$from:s,$to:o}=i[n],l=t.mapping.slice(r);let u=l.map(s.pos),f=l.map(o.pos);if(n){t.deleteRange(u,f)}else{t.replaceRangeWith(u,f,e);We(t,r,e.isInline?-1:1)}}}static findFrom(t,e,r=false){let i=t.parent.inlineContent?new Je(t):Ue(t.node(0),t.parent,t.pos,t.index(),e,r);if(i)return i;for(let i=t.depth-1;i>=0;i--){let n=e<0?Ue(t.node(0),t.node(i),t.before(i+1),t.index(i),e,r):Ue(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,r);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Ke(t.node(0))}static atStart(t){return Ue(t,t,0,0,1)||new Ke(t)}static atEnd(t){return Ue(t,t,t.content.size,t.childCount,-1)||new Ke(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ie[e.type];if(!r)throw new RangeError(`No selection type ${e.type} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in Ie)throw new RangeError("Duplicate use of selection JSON ID "+t);Ie[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return Je.between(this.$anchor,this.$head).getBookmark()}}Le.prototype.visible=true;class He{constructor(t,e){this.$from=t;this.$to=e}}let je=false;function Be(t){if(!je&&!t.parent.inlineContent){je=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class Je extends Le{constructor(t,e=t){Be(t);Be(e);super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let r=t.resolve(e.map(this.head));if(!r.parent.inlineContent)return Le.near(r);let i=t.resolve(e.map(this.anchor));return new Je(i.parent.inlineContent?i:r,r)}replace(t,e=d.empty){super.replace(t,e);if(e==d.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof Je&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ze(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if(typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Je(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,r=e){let i=t.resolve(e);return new this(i,r==e?i:t.resolve(r))}static between(t,e,r){let i=t.pos-e.pos;if(!r||i)r=i>=0?1:-1;if(!e.parent.inlineContent){let t=Le.findFrom(e,r,true)||Le.findFrom(e,-r,true);if(t)e=t.$head;else return Le.near(e,r)}if(!t.parent.inlineContent){if(i==0){t=e}else{t=(Le.findFrom(t,-r,true)||Le.findFrom(t,r,true)).$anchor;if(t.pos<e.pos!=i<0)t=e}}return new Je(t,e)}}Le.jsonID("text",Je);class ze{constructor(t,e){this.anchor=t;this.head=e}map(t){return new ze(t.map(this.anchor),t.map(this.head))}resolve(t){return Je.between(t.resolve(this.anchor),t.resolve(this.head))}}class Fe extends Le{constructor(t){let e=t.nodeAfter;let r=t.node(0).resolve(t.pos+e.nodeSize);super(t,r);this.node=e}map(t,e){let{deleted:r,pos:i}=e.mapResult(this.anchor);let n=t.resolve(i);if(r)return Le.near(n);return new Fe(n)}content(){return new d(l.from(this.node),0,0)}eq(t){return t instanceof Fe&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new _e(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Fe(t.resolve(e.anchor))}static create(t,e){return new Fe(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}Fe.prototype.visible=false;Le.jsonID("node",Fe);class _e{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new ze(r,r):new _e(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;if(r&&Fe.isSelectable(r))return new Fe(e);return Le.near(e)}}class Ke extends Le{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=d.empty){if(e==d.empty){t.delete(0,t.doc.content.size);let e=Le.atStart(t.doc);if(!e.eq(t.selection))t.setSelection(e)}else{super.replace(t,e)}}toJSON(){return{type:"all"}}static fromJSON(t){return new Ke(t)}map(t){return new Ke(t)}eq(t){return t instanceof Ke}getBookmark(){return qe}}Le.jsonID("all",Ke);const qe={map(){return this},resolve(t){return new Ke(t)}};function Ue(t,e,r,i,n,s=false){if(e.inlineContent)return Je.create(t,r);for(let o=i-(n>0?0:1);n>0?o<e.childCount:o>=0;o+=n){let i=e.child(o);if(!i.isAtom){let e=Ue(t,i,r+n,n<0?i.childCount:0,n,s);if(e)return e}else if(!s&&Fe.isSelectable(i)){return Fe.create(t,r-(n<0?i.nodeSize:0))}r+=i.nodeSize*n}return null}function We(t,e,r){let i=t.steps.length-1;if(i<e)return;let n=t.steps[i];if(!(n instanceof _t||n instanceof Kt))return;let s=t.mapping.maps[i],o;s.forEach(((t,e,r,i)=>{if(o==null)o=i}));t.setSelection(Le.near(t.doc.resolve(o),r))}const Ge=1,Ve=2,Xe=4;class Ye extends De{constructor(t){super(t.doc);this.curSelectionFor=0;this.updated=0;this.meta=Object.create(null);this.time=Date.now();this.curSelection=t.selection;this.storedMarks=t.storedMarks}get selection(){if(this.curSelectionFor<this.steps.length){this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor));this.curSelectionFor=this.steps.length}return this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");this.curSelection=t;this.curSelectionFor=this.steps.length;this.updated=(this.updated|Ge)&~Ve;this.storedMarks=null;return this}get selectionSet(){return(this.updated&Ge)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=Ve;return this}ensureMarks(t){if(!a.sameSet(this.storedMarks||this.selection.$from.marks(),t))this.setStoredMarks(t);return this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Ve)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&~Ve;this.storedMarks=null}setTime(t){this.time=t;return this}replaceSelection(t){this.selection.replace(this,t);return this}replaceSelectionWith(t,e=true){let r=this.selection;if(e)t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||a.none));r.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,r){let i=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(i.text(t),true)}else{if(r==null)r=e;r=r==null?e:r;if(!t)return this.deleteRange(e,r);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=r==e?t.marks():t.marksAcross(this.doc.resolve(r))}this.replaceRangeWith(e,r,i.text(t,n));if(!this.selection.empty)this.setSelection(Le.near(this.selection.$to));return this}}setMeta(t,e){this.meta[typeof t=="string"?t:t.key]=e;return this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return false;return true}scrollIntoView(){this.updated|=Xe;return this}get scrolledIntoView(){return(this.updated&Xe)>0}}function Qe(t,e){return!e||!t?t:t.bind(e)}class Ze{constructor(t,e,r){this.name=t;this.init=Qe(e.init,r);this.apply=Qe(e.apply,r)}}const tr=[new Ze("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ze("selection",{init(t,e){return t.selection||Le.atStart(e.doc)},apply(t){return t.selection}}),new Ze("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,i){return i.selection.$cursor?t.storedMarks:null}}),new Ze("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class er{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=tr.slice();if(e)e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t);this.pluginsByKey[t.key]=t;if(t.spec.state)this.fields.push(new Ze(t.key,t.spec.state,t))}))}}class rr{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=e){let e=this.config.plugins[r];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return false}return true}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),i=null;for(;;){let n=false;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=i?i[s].n:0,u=i?i[s].state:this;let f=l<e.length&&o.spec.appendTransaction.call(o,l?e.slice(l):e,u,r);if(f&&r.filterTransaction(f,s)){f.setMeta("appendedTransaction",t);if(!i){i=[];for(let t=0;t<this.config.plugins.length;t++)i.push(t<s?{state:r,n:e.length}:{state:this,n:0})}e.push(f);r=r.applyInner(f);n=true}if(i)i[s]={state:r,n:e.length}}}if(!n)return{state:r,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new rr(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let n=r[i];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new Ye(this)}static create(t){let e=new er(t.doc?t.doc.type.schema:t.schema,t.plugins);let r=new rr(e);for(let i=0;i<e.fields.length;i++)r[e.fields[i].name]=e.fields[i].init(t,r);return r}reconfigure(t){let e=new er(this.schema,t.plugins);let r=e.fields,i=new rr(e);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks)e.storedMarks=this.storedMarks.map((t=>t.toJSON()));if(t&&typeof t=="object")for(let r in t){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[r],n=i.spec.state;if(n&&n.toJSON)e[r]=n.toJSON.call(i,this[i.key])}return e}static fromJSON(t,e,r){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new er(t.schema,t.plugins);let n=new rr(i);i.fields.forEach((i=>{if(i.name=="doc"){n.doc=$.fromJSON(t.schema,e.doc)}else if(i.name=="selection"){n.selection=Le.fromJSON(n.doc,e.selection)}else if(i.name=="storedMarks"){if(e.storedMarks)n.storedMarks=e.storedMarks.map(t.schema.markFromJSON)}else{if(r)for(let s in r){let o=r[s],l=o.spec.state;if(o.key==i.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,s)){n[i.name]=l.fromJSON.call(o,t,e[s],n);return}}n[i.name]=i.init(t,n)}}));return n}}function ir(t,e,r){for(let i in t){let n=t[i];if(n instanceof Function)n=n.bind(e);else if(i=="handleDOMEvents")n=ir(n,e,{});r[i]=n}return r}class nr{constructor(t){this.spec=t;this.props={};if(t.props)ir(t.props,this,this.props);this.key=t.key?t.key.key:or("plugin")}getState(t){return t[this.key]}}const sr=Object.create(null);function or(t){if(t in sr)return t+"$"+ ++sr[t];sr[t]=0;return t+"$"}class lr{constructor(t="key"){this.key=or(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const ur=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const fr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let hr=null;const ar=function(t,e,r){let i=hr||(hr=document.createRange());i.setEnd(t,r==null?t.nodeValue.length:r);i.setStart(t,e||0);return i};const cr=function(){hr=null};const dr=function(t,e,r,i){return r&&(mr(t,e,r,i,-1)||mr(t,e,r,i,1))};const pr=/^(img|br|input|textarea|hr)$/i;function mr(t,e,r,i,n){for(;;){if(t==r&&e==i)return true;if(e==(n<0?0:gr(t))){let r=t.parentNode;if(!r||r.nodeType!=1||yr(t)||pr.test(t.nodeName)||t.contentEditable=="false")return false;e=ur(t)+(n<0?0:1);t=r}else if(t.nodeType==1){t=t.childNodes[e+(n<0?-1:0)];if(t.contentEditable=="false")return false;e=n<0?gr(t):0}else{return false}}}function gr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function wr(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1];e=gr(t)}else if(t.parentNode&&!yr(t)){e=ur(t);t=t.parentNode}else{return null}}}function br(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e];e=0}else if(t.parentNode&&!yr(t)){e=ur(t)+1;t=t.parentNode}else{return null}}}function vr(t,e,r){for(let i=e==0,n=e==gr(t);i||n;){if(t==r)return true;let e=ur(t);t=t.parentNode;if(!t)return false;i=i&&e==0;n=n&&e==gr(t)}}function yr(t){let e;for(let r=t;r;r=r.parentNode)if(e=r.pmViewDesc)break;return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Mr=function(t){return t.focusNode&&dr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function kr(t,e){let r=document.createEvent("Event");r.initEvent("keydown",true,true);r.keyCode=t;r.key=r.code=e;return r}function xr(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function Sr(t,e,r){if(t.caretPositionFromPoint){try{let i=t.caretPositionFromPoint(e,r);if(i)return{node:i.offsetNode,offset:i.offset}}catch(t){}}if(t.caretRangeFromPoint){let i=t.caretRangeFromPoint(e,r);if(i)return{node:i.startContainer,offset:i.startOffset}}}const Or=typeof navigator!="undefined"?navigator:null;const Tr=typeof document!="undefined"?document:null;const Er=Or&&Or.userAgent||"";const Pr=/Edge\/(\d+)/.exec(Er);const Ar=/MSIE \d/.exec(Er);const Cr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Er);const Nr=!!(Ar||Cr||Pr);const $r=Ar?document.documentMode:Cr?+Cr[1]:Pr?+Pr[1]:0;const Rr=!Nr&&/gecko\/(\d+)/i.test(Er);Rr&&+(/Firefox\/(\d+)/.exec(Er)||[0,0])[1];const Dr=!Nr&&/Chrome\/(\d+)/.exec(Er);const Ir=!!Dr;const Lr=Dr?+Dr[1]:0;const Hr=!Nr&&!!Or&&/Apple Computer/.test(Or.vendor);const jr=Hr&&(/Mobile\/\w+/.test(Er)||!!Or&&Or.maxTouchPoints>2);const Br=jr||(Or?/Mac/.test(Or.platform):false);const Jr=Or?/Win/.test(Or.platform):false;const zr=/Android \d/.test(Er);const Fr=!!Tr&&"webkitFontSmoothing"in Tr.documentElement.style;const _r=Fr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Kr(t){let e=t.defaultView&&t.defaultView.visualViewport;if(e)return{left:0,right:e.width,top:0,bottom:e.height};return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function qr(t,e){return typeof t=="number"?t:t[e]}function Ur(t){let e=t.getBoundingClientRect();let r=e.width/t.offsetWidth||1;let i=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*r,top:e.top,bottom:e.top+t.clientHeight*i}}function Wr(t,e,r){let i=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5;let s=t.dom.ownerDocument;for(let o=r||t.dom;;o=fr(o)){if(!o)break;if(o.nodeType!=1)continue;let t=o;let r=t==s.body;let l=r?Kr(s):Ur(t);let u=0,f=0;if(e.top<l.top+qr(i,"top"))f=-(l.top-e.top+qr(n,"top"));else if(e.bottom>l.bottom-qr(i,"bottom"))f=e.bottom-e.top>l.bottom-l.top?e.top+qr(n,"top")-l.top:e.bottom-l.bottom+qr(n,"bottom");if(e.left<l.left+qr(i,"left"))u=-(l.left-e.left+qr(n,"left"));else if(e.right>l.right-qr(i,"right"))u=e.right-l.right+qr(n,"right");if(u||f){if(r){s.defaultView.scrollBy(u,f)}else{let r=t.scrollLeft,i=t.scrollTop;if(f)t.scrollTop+=f;if(u)t.scrollLeft+=u;let n=t.scrollLeft-r,s=t.scrollTop-i;e={left:e.left-n,top:e.top-s,right:e.right-n,bottom:e.bottom-s}}}if(r||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function Gr(t){let e=t.dom.getBoundingClientRect(),r=Math.max(0,e.top);let i,n;for(let s=(e.left+e.right)/2,o=r+1;o<Math.min(innerHeight,e.bottom);o+=5){let e=t.root.elementFromPoint(s,o);if(!e||e==t.dom||!t.dom.contains(e))continue;let l=e.getBoundingClientRect();if(l.top>=r-20){i=e;n=l.top;break}}return{refDOM:i,refTop:n,stack:Vr(t.dom)}}function Vr(t){let e=[],r=t.ownerDocument;for(let i=t;i;i=fr(i)){e.push({dom:i,top:i.scrollTop,left:i.scrollLeft});if(t==r)break}return e}function Xr({refDOM:t,refTop:e,stack:r}){let i=t?t.getBoundingClientRect().top:0;Yr(r,i==0?0:i-e)}function Yr(t,e){for(let r=0;r<t.length;r++){let{dom:i,top:n,left:s}=t[r];if(i.scrollTop!=n+e)i.scrollTop=n+e;if(i.scrollLeft!=s)i.scrollLeft=s}}let Qr=null;function Zr(t){if(t.setActive)return t.setActive();if(Qr)return t.focus(Qr);let e=Vr(t);t.focus(Qr==null?{get preventScroll(){Qr={preventScroll:true};return true}}:undefined);if(!Qr){Qr=false;Yr(e,0)}}function ti(t,e){let r,i=2e8,n,s=0;let o=e.top,l=e.top;let u,f;for(let h=t.firstChild,a=0;h;h=h.nextSibling,a++){let t;if(h.nodeType==1)t=h.getClientRects();else if(h.nodeType==3)t=ar(h).getClientRects();else continue;for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=o&&d.bottom>=l){o=Math.max(d.bottom,o);l=Math.min(d.top,l);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<i){r=h;i=t;n=t&&r.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(h.nodeType==1&&t)s=a+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!u&&d.left<=e.left&&d.right>=e.left){u=h;f={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!r&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))s=a+1}}if(!r&&u){r=u;n=f;i=0}if(r&&r.nodeType==3)return ei(r,n);if(!r||i&&r.nodeType==1)return{node:t,offset:s};return ti(r,n)}function ei(t,e){let r=t.nodeValue.length;let i=document.createRange();for(let n=0;n<r;n++){i.setEnd(t,n+1);i.setStart(t,n);let r=fi(i,1);if(r.top==r.bottom)continue;if(ri(e,r))return{node:t,offset:n+(e.left>=(r.left+r.right)/2?1:0)}}return{node:t,offset:0}}function ri(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ii(t,e){let r=t.parentNode;if(r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left)return r;return t}function ni(t,e,r){let{node:i,offset:n}=ti(e,r),s=-1;if(i.nodeType==1&&!i.firstChild){let t=i.getBoundingClientRect();s=t.left!=t.right&&r.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(i,n,s)}function si(t,e,r,i){let n=-1;for(let r=e,s=false;;){if(r==t.dom)break;let e=t.docView.nearestDesc(r,true);if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent||!e.contentDOM)){let t=e.dom.getBoundingClientRect();if(e.node.isBlock&&e.parent){if(!s&&t.left>i.left||t.top>i.top)n=e.posBefore;else if(!s&&t.right<i.left||t.bottom<i.top)n=e.posAfter;s=true}if(!e.contentDOM&&n<0&&!e.node.isText){let r=e.node.isBlock?i.top<(t.top+t.bottom)/2:i.left<(t.left+t.right)/2;return r?e.posBefore:e.posAfter}}r=e.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,r,-1)}function oi(t,e,r){let i=t.childNodes.length;if(i&&r.top<r.bottom){for(let n=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-r.top)/(r.bottom-r.top))-2)),s=n;;){let r=t.childNodes[s];if(r.nodeType==1){let t=r.getClientRects();for(let i=0;i<t.length;i++){let n=t[i];if(ri(e,n))return oi(r,e,n)}}if((s=(s+1)%i)==n)break}}return t}function li(t,e){let r=t.dom.ownerDocument,i,n=0;let s=Sr(r,e.left,e.top);if(s)({node:i,offset:n}=s);let o=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);let l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let r=t.dom.getBoundingClientRect();if(!ri(e,r))return null;o=oi(t.dom,e,r);if(!o)return null}if(Hr){for(let t=o;i&&t;t=fr(t))if(t.draggable)i=undefined}o=ii(o,e);if(i){if(Rr&&i.nodeType==1){n=Math.min(n,i.childNodes.length);if(n<i.childNodes.length){let t=i.childNodes[n],r;if(t.nodeName=="IMG"&&(r=t.getBoundingClientRect()).right<=e.left&&r.bottom>e.top)n++}}let r;if(Fr&&n&&i.nodeType==1&&(r=i.childNodes[n-1]).nodeType==1&&r.contentEditable=="false"&&r.getBoundingClientRect().top>=e.top)n--;if(i==t.dom&&n==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom)l=t.state.doc.content.size;else if(n==0||i.nodeType!=1||i.childNodes[n-1].nodeName!="BR")l=si(t,i,n,e)}if(l==null)l=ni(t,o,e);let u=t.docView.nearestDesc(o,true);return{pos:l,inside:u?u.posAtStart-u.border:-1}}function ui(t){return t.top<t.bottom||t.left<t.right}function fi(t,e){let r=t.getClientRects();if(r.length){let t=r[e<0?0:r.length-1];if(ui(t))return t}return Array.prototype.find.call(r,ui)||t.getBoundingClientRect()}const hi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ai(t,e,r){let{node:i,offset:n,atom:s}=t.docView.domFromPos(e,r<0?-1:1);let o=Fr||Rr;if(i.nodeType==3){if(o&&(hi.test(i.nodeValue)||(r<0?!n:n==i.nodeValue.length))){let t=fi(ar(i,n,n),r);if(Rr&&n&&/\s/.test(i.nodeValue[n-1])&&n<i.nodeValue.length){let e=fi(ar(i,n-1,n-1),-1);if(e.top==t.top){let r=fi(ar(i,n,n+1),-1);if(r.top!=t.top)return ci(r,r.left<e.left)}}return t}else{let t=n,e=n,s=r<0?1:-1;if(r<0&&!n){e++;s=-1}else if(r>=0&&n==i.nodeValue.length){t--;s=1}else if(r<0){t--}else{e++}return ci(fi(ar(i,t,e),s),s<0)}}let l=t.state.doc.resolve(e-(s||0));if(!l.parent.inlineContent){if(s==null&&n&&(r<0||n==gr(i))){let t=i.childNodes[n-1];if(t.nodeType==1)return di(t.getBoundingClientRect(),false)}if(s==null&&n<gr(i)){let t=i.childNodes[n];if(t.nodeType==1)return di(t.getBoundingClientRect(),true)}return di(i.getBoundingClientRect(),r>=0)}if(s==null&&n&&(r<0||n==gr(i))){let t=i.childNodes[n-1];let e=t.nodeType==3?ar(t,gr(t)-(o?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return ci(fi(e,1),false)}if(s==null&&n<gr(i)){let t=i.childNodes[n];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?ar(t,0,o?0:1):t.nodeType==1?t:null;if(e)return ci(fi(e,-1),true)}return ci(fi(i.nodeType==3?ar(i):i,-r),r>=0)}function ci(t,e){if(t.width==0)return t;let r=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function di(t,e){if(t.height==0)return t;let r=e?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function pi(t,e,r){let i=t.state,n=t.root.activeElement;if(i!=e)t.updateState(e);if(n!=t.dom)t.focus();try{return r()}finally{if(i!=e)t.updateState(i);if(n!=t.dom&&n)n.focus()}}function mi(t,e,r){let i=e.selection;let n=r=="up"?i.$from:i.$to;return pi(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,r=="up"?-1:1);for(;;){let r=t.docView.nearestDesc(e,true);if(!r)break;if(r.node.isBlock){e=r.contentDOM||r.dom;break}e=r.dom.parentNode}let i=ai(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=ar(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&(r=="up"?i.top-n.top>(n.bottom-i.top)*2:n.bottom-i.bottom>(i.bottom-n.top)*2))return false}}return true}))}const gi=/[\u0590-\u08ac]/;function wi(t,e,r){let{$head:i}=e.selection;if(!i.parent.isTextblock)return false;let n=i.parentOffset,s=!n,o=n==i.parent.content.size;let l=t.domSelection();if(!gi.test(i.parent.textContent)||!l.modify)return r=="left"||r=="backward"?s:o;return pi(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:o}=t.domSelectionRange();let u=l.caretBidiLevel;l.modify("move",r,"character");let f=i.depth?t.docView.domAfterPos(i.before()):t.dom;let{focusNode:h,focusOffset:a}=t.domSelectionRange();let c=h&&!f.contains(h.nodeType==1?h:h.parentNode)||e==h&&n==a;try{l.collapse(s,o);if(e&&(e!=s||n!=o)&&l.extend)l.extend(e,n)}catch(t){}if(u!=null)l.caretBidiLevel=u;return c}))}let bi=null;let vi=null;let yi=false;function Mi(t,e,r){if(bi==e&&vi==r)return yi;bi=e;vi=r;return yi=r=="up"||r=="down"?mi(t,e,r):wi(t,e,r)}const ki=0,xi=1,Si=2,Oi=3;class Ti{constructor(t,e,r,i){this.parent=t;this.children=e;this.dom=r;this.contentDOM=i;this.dirty=ki;r.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,r){return false}matchesHack(t){return false}parseRule(){return null}stopEvent(t){return false}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=undefined;if(this.dom.pmViewDesc==this)this.dom.pmViewDesc=undefined;for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,r=this.posAtStart;;e++){let i=this.children[e];if(i==t)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,r){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(r<0){let r,i;if(t==this.contentDOM){r=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.previousSibling}while(r&&!((i=r.pmViewDesc)&&i.parent==this))r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}else{let r,i;if(t==this.contentDOM){r=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.nextSibling}while(r&&!((i=r.pmViewDesc)&&i.parent==this))r=r.nextSibling;return r?this.posBeforeChild(i):this.posAtEnd}}let i;if(t==this.dom&&this.contentDOM){i=e>ur(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){i=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){i=false;break}if(e.previousSibling)break}if(i==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){i=true;break}if(e.nextSibling)break}}return(i==null?r>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let r=true,i=t;i;i=i.parentNode){let n=this.getDesc(i),s;if(n&&(!e||n.node)){if(r&&(s=n.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))r=false;else return n}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,r){for(let i=t;i;i=i.parentNode){let n=this.getDesc(i);if(n)return n.localPosFromDOM(t,e,r)}return-1}descAt(t){for(let e=0,r=0;e<this.children.length;e++){let i=this.children[e],n=r+i.size;if(r==t&&n!=r){while(!i.border&&i.children.length)i=i.children[0];return i}if(t<n)return i.descAt(t-r-i.border);r=n}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,i=0;for(let e=0;r<this.children.length;r++){let n=this.children[r],s=e+n.size;if(s>t||n instanceof Ri){i=t-e;break}e=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,e);for(let t;r&&!(t=this.children[r-1]).size&&t instanceof Ei&&t.side>=0;r--){}if(e<=0){let t,i=true;for(;;r--,i=false){t=r?this.children[r-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&i&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?ur(t.dom)+1:0}}else{let t,i=true;for(;;r++,i=false){t=r<this.children.length?this.children[r]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&i&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?ur(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,n=-1;for(let s=r,o=0;;o++){let r=this.children[o],l=s+r.size;if(i==-1&&t<=l){let n=s+r.border;if(t>=n&&e<=l-r.border&&r.node&&r.contentDOM&&this.contentDOM.contains(r.contentDOM))return r.parseRange(t,e,n);t=s;for(let e=o;e>0;e--){let r=this.children[e-1];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(1)){i=ur(r.dom)+1;break}t-=r.size}if(i==-1)i=0}if(i>-1&&(l>e||o==this.children.length-1)){e=l;for(let t=o+1;t<this.children.length;t++){let r=this.children[t];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(-1)){n=ur(r.dom);break}e+=r.size}if(n==-1)n=this.contentDOM.childNodes.length;break}s=l}return{node:this.contentDOM,from:t,to:e,fromOffset:i,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:r}=this.domFromPos(t,0);if(e.nodeType!=1||r==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[r]}setSelection(t,e,r,i=false){let n=Math.min(t,e),s=Math.max(t,e);for(let o=0,l=0;o<this.children.length;o++){let u=this.children[o],f=l+u.size;if(n>l&&s<f)return u.setSelection(t-l-u.border,e-l-u.border,r,i);l=f}let o=this.domFromPos(t,t?-1:1);let l=e==t?o:this.domFromPos(e,e?-1:1);let u=r.getSelection();let f=false;if((Rr||Hr)&&t==e){let{node:t,offset:e}=o;if(t.nodeType==3){f=!!(e&&t.nodeValue[e-1]=="\n");if(f&&e==t.nodeValue.length){for(let e=t,r;e;e=e.parentNode){if(r=e.nextSibling){if(r.nodeName=="BR")o=l={node:r.parentNode,offset:ur(r)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let r=t.childNodes[e-1];f=r&&(r.nodeName=="BR"||r.contentEditable=="false")}}if(Rr&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let t=u.focusNode.childNodes[u.focusOffset];if(t&&t.contentEditable=="false")i=true}if(!(i||f&&Hr)&&dr(o.node,o.offset,u.anchorNode,u.anchorOffset)&&dr(l.node,l.offset,u.focusNode,u.focusOffset))return;let h=false;if((u.extend||t==e)&&!f){u.collapse(o.node,o.offset);try{if(t!=e)u.extend(l.node,l.offset);h=true}catch(t){}}if(!h){if(t>e){let t=o;o=l;l=t}let r=document.createRange();r.setEnd(l.node,l.offset);r.setStart(o.node,o.offset);u.removeAllRanges();u.addRange(r)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let r=0,i=0;i<this.children.length;i++){let n=this.children[i],s=r+n.size;if(r==s?t<=s&&e>=r:t<s&&e>r){let i=r+n.border,o=s-n.border;if(t>=i&&e<=o){this.dirty=t==r||e==s?Si:xi;if(t==i&&e==o&&(n.contentLost||n.dom.parentNode!=this.contentDOM))n.dirty=Oi;else n.markDirty(t-i,e-i);return}else{n.dirty=n.dom==n.contentDOM&&n.dom.parentNode==this.contentDOM&&!n.children.length?Si:Oi}}r=s}this.dirty=Si}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=t==1?Si:xi;if(e.dirty<r)e.dirty=r}}get domAtom(){return false}get ignoreForCoords(){return false}isText(t){return false}}class Ei extends Ti{constructor(t,e,r,i){let n,s=e.type.toDOM;if(typeof s=="function")s=s(r,(()=>{if(!n)return i;if(n.parent)return n.parent.posBeforeChild(n)}));if(!e.type.spec.raw){if(s.nodeType!=1){let t=document.createElement("span");t.appendChild(s);s=t}s.contentEditable="false";s.classList.add("ProseMirror-widget")}super(t,[],s,null);this.widget=e;this.widget=e;n=this}matchesWidget(t){return this.dirty==ki&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get side(){return this.widget.type.side}}class Pi extends Ti{constructor(t,e,r,i){super(t,[],e,null);this.textDOM=r;this.text=i}get size(){return this.text.length}localPosFromDOM(t,e){if(t!=this.textDOM)return this.posAtStart+(e?this.size:0);return this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class Ai extends Ti{constructor(t,e,r,i){super(t,[],r,i);this.mark=e}static create(t,e,r,i){let n=i.nodeViews[e.type.name];let s=n&&n(e,i,r);if(!s||!s.dom)s=yt.renderSpec(document,e.type.spec.toDOM(e,r));return new Ai(t,e,s.dom,s.contentDOM||s.dom)}parseRule(){if(this.dirty&Oi||this.mark.type.spec.reparseInView)return null;return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Oi&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=ki){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=ki}}slice(t,e,r){let i=Ai.create(this.parent,this.mark,true,r);let n=this.children,s=this.size;if(e<s)n=Xi(n,e,s,r);if(t>0)n=Xi(n,0,t,r);for(let t=0;t<n.length;t++)n[t].parent=i;i.children=n;return i}}class Ci extends Ti{constructor(t,e,r,i,n,s,o,l,u){super(t,[],n,s);this.node=e;this.outerDeco=r;this.innerDeco=i;this.nodeDOM=o}static create(t,e,r,i,n,s){let o=n.nodeViews[e.type.name],l;let u=o&&o(e,n,(()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)}),r,i);let f=u&&u.dom,h=u&&u.contentDOM;if(e.isText){if(!f)f=document.createTextNode(e.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!f){({dom:f,contentDOM:h}=yt.renderSpec(document,e.type.spec.toDOM(e)))}if(!h&&!e.isText&&f.nodeName!="BR"){if(!f.hasAttribute("contenteditable"))f.contentEditable="false";if(e.type.spec.draggable)f.draggable=true}let a=f;f=zi(f,r,e);if(u)return l=new Di(t,e,r,i,f,h||null,a,u,n,s+1);else if(e.isText)return new $i(t,e,r,i,f,a,n);else return new Ci(t,e,r,i,f,h||null,a,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let r=this.children[e];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>l.empty}return t}matchesNode(t,e,r){return this.dirty==ki&&t.eq(this.node)&&Fi(e,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let r=this.node.inlineContent,i=e;let n=t.composing?this.localCompositionInfo(t,e):null;let s=n&&n.pos>-1?n:null;let o=n&&n.pos<0;let l=new Ki(this,s&&s.node,t);Wi(this.node,this.innerDeco,((e,n,s)=>{if(e.spec.marks)l.syncToMarks(e.spec.marks,r,t);else if(e.type.side>=0&&!s)l.syncToMarks(n==this.node.childCount?a.none:this.node.child(n).marks,r,t);l.placeWidget(e,t,i)}),((e,s,u,f)=>{l.syncToMarks(e.marks,r,t);let h;if(l.findNodeMatch(e,s,u,f));else if(o&&t.state.selection.from>i&&t.state.selection.to<i+e.nodeSize&&(h=l.findIndexWithChild(n.node))>-1&&l.updateNodeAt(e,s,u,h,t));else if(l.updateNextNode(e,s,u,t,f,i));else{l.addNode(e,s,u,t,i)}i+=e.nodeSize}));l.syncToMarks([],r,t);if(this.node.isTextblock)l.addTextblockHacks();l.destroyRest();if(l.changed||this.dirty==Si){if(s)this.protectLocalComposition(t,s);Ii(this.contentDOM,this.children,t);if(jr)Gi(this.dom)}}localCompositionInfo(t,e){let{from:r,to:i}=t.state.selection;if(!(t.state.selection instanceof Je)||r<e||i>e+this.node.content.size)return null;let n=t.input.compositionNode;if(!n||!this.dom.contains(n.parentNode))return null;if(this.node.inlineContent){let t=n.nodeValue;let s=Vi(this.node.content,t,r-e,i-e);return s<0?null:{node:n,pos:s,text:t}}else{return{node:n,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:r,text:i}){if(this.getDesc(e))return;let n=e;for(;;n=n.parentNode){if(n.parentNode==this.contentDOM)break;while(n.previousSibling)n.parentNode.removeChild(n.previousSibling);while(n.nextSibling)n.parentNode.removeChild(n.nextSibling);if(n.pmViewDesc)n.pmViewDesc=undefined}let s=new Pi(this,n,e,i);t.input.compositionNodes.push(s);this.children=Xi(this.children,r,r+i.length,t,s)}update(t,e,r,i){if(this.dirty==Oi||!t.sameMarkup(this.node))return false;this.updateInner(t,e,r,i);return true}updateInner(t,e,r,i){this.updateOuterDeco(e);this.node=t;this.innerDeco=r;if(this.contentDOM)this.updateChildren(i,this.posAtStart);this.dirty=ki}updateOuterDeco(t){if(Fi(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let r=this.dom;this.dom=Bi(this.dom,this.nodeDOM,ji(this.outerDeco,this.node,e),ji(t,this.node,e));if(this.dom!=r){r.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1)this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.draggable=true}deselectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.removeAttribute("draggable")}}get domAtom(){return this.node.isAtom}}function Ni(t,e,r,i,n){zi(i,e,t);let s=new Ci(undefined,t,e,r,i,i,i,n,0);if(s.contentDOM)s.updateChildren(n,0);return s}class $i extends Ci{constructor(t,e,r,i,n,s,o){super(t,e,r,i,n,null,s,o,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,r,i){if(this.dirty==Oi||this.dirty!=ki&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=ki||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(i.trackWrites==this.nodeDOM)i.trackWrites=null}this.node=t;this.dirty=ki;return true}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return true;return false}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,r){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,r){let i=this.node.cut(t,e),n=document.createTextNode(i.text);return new $i(this.parent,i,this.outerDeco,this.innerDeco,n,n,r)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=Oi}get domAtom(){return false}isText(t){return this.node.text==t}}class Ri extends Ti{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==ki&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Di extends Ci{constructor(t,e,r,i,n,s,o,l,u,f){super(t,e,r,i,n,s,o,u,f);this.spec=l}update(t,e,r,i){if(this.dirty==Oi)return false;if(this.spec.update){let n=this.spec.update(t,e,r);if(n)this.updateInner(t,e,r,i);return n}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,r,i)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,r,i){this.spec.setSelection?this.spec.setSelection(t,e,r):super.setSelection(t,e,r,i)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):false}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Ii(t,e,r){let i=t.firstChild,n=false;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){while(l!=i){i=_i(i);n=true}i=i.nextSibling}else{n=true;t.insertBefore(l,i)}if(o instanceof Ai){let e=i?i.previousSibling:t.lastChild;Ii(o.contentDOM,o.children,r);i=e?e.nextSibling:t.firstChild}}while(i){i=_i(i);n=true}if(n&&r.trackWrites==t)r.trackWrites=null}const Li=function(t){if(t)this.nodeName=t};Li.prototype=Object.create(null);const Hi=[new Li];function ji(t,e,r){if(t.length==0)return Hi;let i=r?Hi[0]:new Li,n=[i];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(!o)continue;if(o.nodeName)n.push(i=new Li(o.nodeName));for(let t in o){let s=o[t];if(s==null)continue;if(r&&n.length==1)n.push(i=new Li(e.isInline?"span":"div"));if(t=="class")i.class=(i.class?i.class+" ":"")+s;else if(t=="style")i.style=(i.style?i.style+";":"")+s;else if(t!="nodeName")i[t]=s}}return n}function Bi(t,e,r,i){if(r==Hi&&i==Hi)return e;let n=e;for(let e=0;e<i.length;e++){let s=i[e],o=r[e];if(e){let e;if(o&&o.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName){n=e}else{e=document.createElement(s.nodeName);e.pmIsDeco=true;e.appendChild(n);o=Hi[0];n=e}}Ji(n,o||Hi[0],s)}return n}function Ji(t,e,r){for(let i in e)if(i!="class"&&i!="style"&&i!="nodeName"&&!(i in r))t.removeAttribute(i);for(let i in r)if(i!="class"&&i!="style"&&i!="nodeName"&&r[i]!=e[i])t.setAttribute(i,r[i]);if(e.class!=r.class){let i=e.class?e.class.split(" ").filter(Boolean):[];let n=r.class?r.class.split(" ").filter(Boolean):[];for(let e=0;e<i.length;e++)if(n.indexOf(i[e])==-1)t.classList.remove(i[e]);for(let e=0;e<n.length;e++)if(i.indexOf(n[e])==-1)t.classList.add(n[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=r.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;while(i=r.exec(e.style))t.style.removeProperty(i[1])}if(r.style)t.style.cssText+=r.style}}function zi(t,e,r){return Bi(t,t,Hi,ji(e,r,t.nodeType!=1))}function Fi(t,e){if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!t[r].type.eq(e[r].type))return false;return true}function _i(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class Ki{constructor(t,e,r){this.lock=e;this.view=r;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=qi(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let r=t;r<e;r++)this.top.children[r].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,r){let i=0,n=this.stack.length>>1;let s=Math.min(n,t.length);while(i<s&&(i==n-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&t[i].type.spec.spanning!==false)i++;while(i<n){this.destroyRest();this.top.dirty=ki;this.index=this.stack.pop();this.top=this.stack.pop();n--}while(n<t.length){this.stack.push(this.top,this.index+1);let i=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let r=this.top.children[e];if(r.matchesMark(t[n])&&!this.isLocked(r.dom)){i=e;break}}if(i>-1){if(i>this.index){this.changed=true;this.destroyBetween(this.index,i)}this.top=this.top.children[this.index]}else{let i=Ai.create(this.top,t[n],e,r);this.top.children.splice(this.index,0,i);this.top=i;this.changed=true}this.index=0;n++}}findNodeMatch(t,e,r,i){let n=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,r)){n=this.top.children.indexOf(s,this.index)}else{for(let i=this.index,s=Math.min(this.top.children.length,i+5);i<s;i++){let s=this.top.children[i];if(s.matchesNode(t,e,r)&&!this.preMatch.matched.has(s)){n=i;break}}}if(n<0)return false;this.destroyBetween(this.index,n);this.index++;return true}updateNodeAt(t,e,r,i,n){let s=this.top.children[i];if(s.dirty==Oi&&s.dom==s.contentDOM)s.dirty=Si;if(!s.update(t,e,r,n))return false;this.destroyBetween(this.index,i);this.index++;return true}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++){if(this.top.children[t]==e)return t}return-1}t=e}}updateNextNode(t,e,r,i,n,s){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof Ci){let u=this.preMatch.matched.get(l);if(u!=null&&u!=n)return false;let f=l.dom,h;let a=this.isLocked(f)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&l.dirty!=Oi&&Fi(e,l.outerDeco));if(!a&&l.update(t,e,r,i)){this.destroyBetween(this.index,o);if(l.dom!=f)this.changed=true;this.index++;return true}else if(!a&&(h=this.recreateWrapper(l,t,e,r,i,s))){this.top.children[this.index]=h;if(h.contentDOM){h.dirty=Si;h.updateChildren(i,s+1);h.dirty=ki}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,r,i,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content))return null;let o=Ci.create(this.top,e,r,i,n,s);if(o.contentDOM){o.children=t.children;t.children=[];for(let t of o.children)t.parent=o}t.destroy();return o}addNode(t,e,r,i,n){let s=Ci.create(this.top,t,e,r,i,n);if(s.contentDOM)s.updateChildren(i,n+1);this.top.children.splice(this.index++,0,s);this.changed=true}placeWidget(t,e,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(t)&&(t==i.widget||!i.widget.type.toDOM.parentNode)){this.index++}else{let i=new Ei(this.top,t,e,r);this.top.children.splice(this.index++,0,i);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof Ai){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof $i)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((Hr||Ir)&&t&&t.dom.contentEditable=="false")this.addHackNode("IMG",e);this.addHackNode("BR",this.top)}}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t)){this.index++}else{let r=document.createElement(t);if(t=="IMG"){r.className="ProseMirror-separator";r.alt=""}if(t=="BR")r.className="ProseMirror-trailingBreak";let i=new Ri(this.top,[],r,null);if(e!=this.top)e.children.push(i);else e.children.splice(this.index++,0,i);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function qi(t,e){let r=e,i=r.children.length;let n=t.childCount,s=new Map,o=[];t:while(n>0){let l;for(;;){if(i){let t=r.children[i-1];if(t instanceof Ai){r=t;i=t.children.length}else{l=t;i--;break}}else if(r==e){break t}else{i=r.parent.children.indexOf(r);r=r.parent}}let u=l.node;if(!u)continue;if(u!=t.child(n-1))break;--n;s.set(l,n);o.push(l)}return{index:n,matched:s,matches:o.reverse()}}function Ui(t,e){return t.type.side-e.type.side}function Wi(t,e,r,i){let n=e.locals(t),s=0;if(n.length==0){for(let r=0;r<t.childCount;r++){let o=t.child(r);i(o,n,e.forChild(s,o),r);s+=o.nodeSize}return}let o=0,l=[],u=null;for(let f=0;;){let h,a;while(o<n.length&&n[o].to==s){let t=n[o++];if(t.widget){if(!h)h=t;else(a||(a=[h])).push(t)}}if(h){if(a){a.sort(Ui);for(let t=0;t<a.length;t++)r(a[t],f,!!u)}else{r(h,f,!!u)}}let c,d;if(u){d=-1;c=u;u=null}else if(f<t.childCount){d=f;c=t.child(f++)}else{break}for(let t=0;t<l.length;t++)if(l[t].to<=s)l.splice(t--,1);while(o<n.length&&n[o].from<=s&&n[o].to>s)l.push(n[o++]);let p=s+c.nodeSize;if(c.isText){let t=p;if(o<n.length&&n[o].from<t)t=n[o].from;for(let e=0;e<l.length;e++)if(l[e].to<t)t=l[e].to;if(t<p){u=c.cut(t-s);c=c.cut(0,t-s);p=t;d=-1}}else{while(o<n.length&&n[o].to<p)o++}let m=c.isInline&&!c.isLeaf?l.filter((t=>!t.inline)):l.slice();i(c,m,e.forChild(s,c),d);s=p}}function Gi(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important";window.getComputedStyle(t).listStyle;t.style.cssText=e}}function Vi(t,e,r,i){for(let n=0,s=0;n<t.childCount&&s<=i;){let o=t.child(n++),l=s;s+=o.nodeSize;if(!o.isText)continue;let u=o.text;while(n<t.childCount){let e=t.child(n++);s+=e.nodeSize;if(!e.isText)break;u+=e.text}if(s>=r){if(s>=i&&u.slice(i-e.length-l,i-l)==e)return i-e.length;let t=l<i?u.lastIndexOf(e,i-l-1):-1;if(t>=0&&t+e.length+l>=r)return l+t;if(r==i&&u.length>=i+e.length-l&&u.slice(i-l,i-l+e.length)==e)return i}}return-1}function Xi(t,e,r,i,n){let s=[];for(let o=0,l=0;o<t.length;o++){let u=t[o],f=l,h=l+=u.size;if(f>=r||h<=e){s.push(u)}else{if(f<e)s.push(u.slice(0,e-f,i));if(n){s.push(n);n=undefined}if(h>r)s.push(u.slice(r-f,u.size,i))}}return s}function Yi(t,e=null){let r=t.domSelectionRange(),i=t.state.doc;if(!r.focusNode)return null;let n=t.docView.nearestDesc(r.focusNode),s=n&&n.size==0;let o=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(o<0)return null;let l=i.resolve(o),u,f;if(Mr(r)){u=l;while(n&&!n.node)n=n.parent;let t=n.node;if(n&&t.isAtom&&Fe.isSelectable(t)&&n.parent&&!(t.isInline&&vr(r.focusNode,r.focusOffset,n.dom))){let t=n.posBefore;f=new Fe(o==t?l:i.resolve(t))}}else{let e=t.docView.posFromDOM(r.anchorNode,r.anchorOffset,1);if(e<0)return null;u=i.resolve(e)}if(!f){let r=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;f=fn(t,u,l,r)}return f}function Qi(t){return t.editable?t.hasFocus():an(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Zi(t,e=false){let r=t.state.selection;ln(t,r);if(!Qi(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ir){let e=t.domSelectionRange(),r=t.domObserver.currentSelection;if(e.anchorNode&&r.anchorNode&&dr(e.anchorNode,e.anchorOffset,r.anchorNode,r.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){on(t)}else{let{anchor:i,head:n}=r,s,o;if(tn&&!(r instanceof Je)){if(!r.$from.parent.inlineContent)s=en(t,r.from);if(!r.empty&&!r.$from.parent.inlineContent)o=en(t,r.to)}t.docView.setSelection(i,n,t.root,e);if(tn){if(s)nn(s);if(o)nn(o)}if(r.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)sn(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const tn=Hr||Ir&&Lr<63;function en(t,e){let{node:r,offset:i}=t.docView.domFromPos(e,0);let n=i<r.childNodes.length?r.childNodes[i]:null;let s=i?r.childNodes[i-1]:null;if(Hr&&n&&n.contentEditable=="false")return rn(n);if((!n||n.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(n)return rn(n);else if(s)return rn(s)}}function rn(t){t.contentEditable="true";if(Hr&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function nn(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function sn(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let r=t.domSelectionRange();let i=r.anchorNode,n=r.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(r.anchorNode!=i||r.anchorOffset!=n){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!Qi(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function on(t){let e=t.domSelection(),r=document.createRange();let i=t.cursorWrapper.dom,n=i.nodeName=="IMG";if(n)r.setEnd(i.parentNode,ur(i)+1);else r.setEnd(i,0);r.collapse(false);e.removeAllRanges();e.addRange(r);if(!n&&!t.state.selection.visible&&Nr&&$r<=11){i.disabled=true;i.disabled=false}}function ln(t,e){if(e instanceof Fe){let r=t.docView.descAt(e.from);if(r!=t.lastSelectedViewDesc){un(t);if(r)r.selectNode();t.lastSelectedViewDesc=r}}else{un(t)}}function un(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function fn(t,e,r,i){return t.someProp("createSelectionBetween",(i=>i(t,e,r)))||Je.between(e,r,i)}function hn(t){if(t.editable&&!t.hasFocus())return false;return an(t)}function an(t){let e=t.domSelectionRange();if(!e.anchorNode)return false;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return false}}function cn(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let r=t.domSelectionRange();return dr(e.node,e.offset,r.anchorNode,r.anchorOffset)}function dn(t,e){let{$anchor:r,$head:i}=t.selection;let n=e>0?r.max(i):r.min(i);let s=!n.parent.inlineContent?n:n.depth?t.doc.resolve(e>0?n.after():n.before()):null;return s&&Le.findFrom(s,e)}function pn(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function mn(t,e,r){let i=t.state.selection;if(i instanceof Je){if(r.indexOf("s")>-1){let{$head:r}=i,n=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!n||n.isText||!n.isLeaf)return false;let s=t.state.doc.resolve(r.pos+n.nodeSize*(e<0?-1:1));return pn(t,new Je(i.$anchor,s))}else if(!i.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let r=dn(t.state,e);if(r&&r instanceof Fe)return pn(t,r);return false}else if(!(Br&&r.indexOf("m")>-1)){let r=i.$head,n=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,s;if(!n||n.isText)return false;let o=e<0?r.pos-n.nodeSize:r.pos;if(!(n.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM))return false;if(Fe.isSelectable(n)){return pn(t,new Fe(e<0?t.state.doc.resolve(r.pos-n.nodeSize):r))}else if(Fr){return pn(t,new Je(t.state.doc.resolve(e<0?o:o+n.nodeSize)))}else{return false}}}else if(i instanceof Fe&&i.node.isInline){return pn(t,new Je(e>0?i.$to:i.$from))}else{let r=dn(t.state,e);if(r)return pn(t,r);return false}}function gn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function wn(t,e){let r=t.pmViewDesc;return r&&r.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function bn(t,e){return e<0?vn(t):yn(t)}function vn(t){let e=t.domSelectionRange();let r=e.focusNode,i=e.focusOffset;if(!r)return;let n,s,o=false;if(Rr&&r.nodeType==1&&i<gn(r)&&wn(r.childNodes[i],-1))o=true;for(;;){if(i>0){if(r.nodeType!=1){break}else{let t=r.childNodes[i-1];if(wn(t,-1)){n=r;s=--i}else if(t.nodeType==3){r=t;i=r.nodeValue.length}else break}}else if(Mn(r)){break}else{let e=r.previousSibling;while(e&&wn(e,-1)){n=r.parentNode;s=ur(e);e=e.previousSibling}if(!e){r=r.parentNode;if(r==t.dom)break;i=0}else{r=e;i=gn(r)}}}if(o)Sn(t,r,i);else if(n)Sn(t,n,s)}function yn(t){let e=t.domSelectionRange();let r=e.focusNode,i=e.focusOffset;if(!r)return;let n=gn(r);let s,o;for(;;){if(i<n){if(r.nodeType!=1)break;let t=r.childNodes[i];if(wn(t,1)){s=r;o=++i}else break}else if(Mn(r)){break}else{let e=r.nextSibling;while(e&&wn(e,1)){s=e.parentNode;o=ur(e)+1;e=e.nextSibling}if(!e){r=r.parentNode;if(r==t.dom)break;i=n=0}else{r=e;i=0;n=gn(r)}}}if(s)Sn(t,s,o)}function Mn(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function kn(t,e){while(t&&e==t.childNodes.length&&!yr(t)){e=ur(t)+1;t=t.parentNode}while(t&&e<t.childNodes.length){let r=t.childNodes[e];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r;e=0}}function xn(t,e){while(t&&!e&&!yr(t)){e=ur(t);t=t.parentNode}while(t&&e){let r=t.childNodes[e-1];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r;e=t.childNodes.length}}function Sn(t,e,r){if(e.nodeType!=3){let t,i;if(i=kn(e,r)){e=i;r=0}else if(t=xn(e,r)){e=t;r=t.nodeValue.length}}let i=t.domSelection();if(Mr(i)){let t=document.createRange();t.setEnd(e,r);t.setStart(e,r);i.removeAllRanges();i.addRange(t)}else if(i.extend){i.extend(e,r)}t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{if(t.state==n)Zi(t)}),50)}function On(t,e){let r=t.state.doc.resolve(e);if(!(Ir||Jr)&&r.parent.inlineContent){let i=t.coordsAtPos(e);if(e>r.start()){let r=t.coordsAtPos(e-1);let n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left<i.left?"ltr":"rtl"}if(e<r.end()){let r=t.coordsAtPos(e+1);let n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left>i.left?"ltr":"rtl"}}let i=getComputedStyle(t.dom).direction;return i=="rtl"?"rtl":"ltr"}function Tn(t,e,r){let i=t.state.selection;if(i instanceof Je&&!i.empty||r.indexOf("s")>-1)return false;if(Br&&r.indexOf("m")>-1)return false;let{$from:n,$to:s}=i;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=dn(t.state,e);if(r&&r instanceof Fe)return pn(t,r)}if(!n.parent.inlineContent){let r=e<0?n:s;let o=i instanceof Ke?Le.near(r,e):Le.findFrom(r,e);return o?pn(t,o):false}return false}function En(t,e){if(!(t.state.selection instanceof Je))return true;let{$head:r,$anchor:i,empty:n}=t.state.selection;if(!r.sameParent(i))return true;if(!n)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){let i=t.state.tr;if(e<0)i.delete(r.pos-s.nodeSize,r.pos);else i.delete(r.pos,r.pos+s.nodeSize);t.dispatch(i);return true}return false}function Pn(t,e,r){t.domObserver.stop();e.contentEditable=r;t.domObserver.start()}function An(t){if(!Hr||t.state.selection.$head.parentOffset>0)return false;let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(e&&e.nodeType==1&&r==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Pn(t,r,"true");setTimeout((()=>Pn(t,r,"false")),20)}return false}function Cn(t){let e="";if(t.ctrlKey)e+="c";if(t.metaKey)e+="m";if(t.altKey)e+="a";if(t.shiftKey)e+="s";return e}function Nn(t,e){let r=e.keyCode,i=Cn(e);if(r==8||Br&&r==72&&i=="c"){return En(t,-1)||bn(t,-1)}else if(r==46&&!e.shiftKey||Br&&r==68&&i=="c"){return En(t,1)||bn(t,1)}else if(r==13||r==27){return true}else if(r==37||Br&&r==66&&i=="c"){let e=r==37?On(t,t.state.selection.from)=="ltr"?-1:1:-1;return mn(t,e,i)||bn(t,e)}else if(r==39||Br&&r==70&&i=="c"){let e=r==39?On(t,t.state.selection.from)=="ltr"?1:-1:1;return mn(t,e,i)||bn(t,e)}else if(r==38||Br&&r==80&&i=="c"){return Tn(t,-1,i)||bn(t,-1)}else if(r==40||Br&&r==78&&i=="c"){return An(t)||Tn(t,1,i)||bn(t,1)}else if(i==(Br?"m":"c")&&(r==66||r==73||r==89||r==90)){return true}return false}function $n(t,e){t.someProp("transformCopied",(r=>{e=r(e,t)}));let r=[],{content:i,openStart:n,openEnd:s}=e;while(n>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1){n--;s--;let t=i.firstChild;r.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);i=t.content}let o=t.someProp("clipboardSerializer")||yt.fromSchema(t.state.schema);let l=_n(),u=l.createElement("div");u.appendChild(o.serializeFragment(i,{document:l}));let f=u.firstChild,h,a=0;while(f&&f.nodeType==1&&(h=zn[f.nodeName.toLowerCase()])){for(let t=h.length-1;t>=0;t--){let e=l.createElement(h[t]);while(u.firstChild)e.appendChild(u.firstChild);u.appendChild(e);a++}f=u.firstChild}if(f&&f.nodeType==1)f.setAttribute("data-pm-slice",`${n} ${s}${a?` -${a}`:""} ${JSON.stringify(r)}`);let c=t.someProp("clipboardTextSerializer",(r=>r(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:u,text:c,slice:e}}function Rn(t,e,r,i,n){let s=n.parent.type.spec.code;let o,u;if(!r&&!e)return null;let f=e&&(i||s||!r);if(f){t.someProp("transformPastedText",(r=>{e=r(e,s||i,t)}));if(s)return e?new d(l.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):d.empty;let r=t.someProp("clipboardTextParser",(r=>r(e,n,i,t)));if(r){u=r}else{let r=n.marks();let{schema:i}=t.state,s=yt.fromSchema(i);o=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=o.appendChild(document.createElement("p"));if(t)e.appendChild(s.serializeNode(i.text(t,r)))}))}}else{t.someProp("transformPastedHTML",(e=>{r=e(r,t)}));o=Kn(r);if(Fr)qn(o)}let h=o&&o.querySelector("[data-pm-slice]");let a=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(a&&a[3])for(let t=+a[3];t>0;t--){let t=o.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;o=t}if(!u){let e=t.someProp("clipboardParser")||t.someProp("domParser")||st.fromSchema(t.state.schema);u=e.parseSlice(o,{preserveWhitespace:!!(f||a),context:n,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!Dn.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(a){u=Un(Jn(u,+a[1],+a[2]),a[4])}else{u=d.maxOpen(In(u.content,n),true);if(u.openStart||u.openEnd){let t=0,e=0;for(let e=u.content.firstChild;t<u.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=u.content.lastChild;e<u.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}u=Jn(u,t,e)}}t.someProp("transformPasted",(e=>{u=e(u,t)}));return u}const Dn=/^(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 In(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let i=e.node(r);let n=i.contentMatchAt(e.index(r));let s,o=[];t.forEach((t=>{if(!o)return;let e=n.findWrapping(t.type),r;if(!e)return o=null;if(r=o.length&&s.length&&Hn(e,s,t,o[o.length-1],0)){o[o.length-1]=r}else{if(o.length)o[o.length-1]=jn(o[o.length-1],s.length);let r=Ln(t,e);o.push(r);n=n.matchType(r.type);s=e}}));if(o)return l.from(o)}return t}function Ln(t,e,r=0){for(let i=e.length-1;i>=r;i--)t=e[i].create(null,l.from(t));return t}function Hn(t,e,r,i,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=Hn(t,e,r,i.lastChild,n+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));let o=i.contentMatchAt(i.childCount);if(o.matchType(n==t.length-1?r.type:t[n+1]))return i.copy(i.content.append(l.from(Ln(r,t,n+1))))}}function jn(t,e){if(e==0)return t;let r=t.content.replaceChild(t.childCount-1,jn(t.lastChild,e-1));let i=t.contentMatchAt(t.childCount).fillBefore(l.empty,true);return t.copy(r.append(i))}function Bn(t,e,r,i,n,s){let o=e<0?t.firstChild:t.lastChild,u=o.content;if(t.childCount>1)s=0;if(n<i-1)u=Bn(u,e,r,i,n+1,s);if(n>=r)u=e<0?o.contentMatchAt(0).fillBefore(u,s<=n).append(u):u.append(o.contentMatchAt(o.childCount).fillBefore(l.empty,true));return t.replaceChild(e<0?0:t.childCount-1,o.copy(u))}function Jn(t,e,r){if(e<t.openStart)t=new d(Bn(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(r<t.openEnd)t=new d(Bn(t.content,1,r,t.openEnd,0,0),t.openStart,r);return t}const zn={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Fn=null;function _n(){return Fn||(Fn=document.implementation.createHTMLDocument("title"))}function Kn(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let r=_n().createElement("div");let i=/<([a-z][^>\s]+)/i.exec(t),n;if(n=i&&zn[i[1].toLowerCase()])t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("");r.innerHTML=t;if(n)for(let t=0;t<n.length;t++)r=r.querySelector(n[t])||r;return r}function qn(t){let e=t.querySelectorAll(Ir?"span:not([class]):not([style])":"span.Apple-converted-space");for(let r=0;r<e.length;r++){let i=e[r];if(i.childNodes.length==1&&i.textContent==" "&&i.parentNode)i.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),i)}}function Un(t,e){if(!t.size)return t;let r=t.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:o}=t;for(let t=i.length-2;t>=0;t-=2){let e=r.nodes[i[t]];if(!e||e.hasRequiredAttrs())break;n=l.from(e.create(i[t+1],n));s++;o++}return new d(n,s,o)}const Wn={};const Gn={};const Vn={touchstart:true,touchmove:true};class Xn{constructor(){this.shiftKey=false;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=false;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 Yn(t){for(let e in Wn){let r=Wn[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(rs(t,e)&&!es(t,e)&&(t.editable||!(e.type in Gn)))r(t,e)},Vn[e]?{passive:true}:undefined)}if(Hr)t.dom.addEventListener("input",(()=>null));ts(t)}function Qn(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function Zn(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout);clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function ts(t){t.someProp("handleDOMEvents",(e=>{for(let r in e)if(!t.input.eventHandlers[r])t.dom.addEventListener(r,t.input.eventHandlers[r]=e=>es(t,e))}))}function es(t,e){return t.someProp("handleDOMEvents",(r=>{let i=r[e.type];return i?i(t,e)||e.defaultPrevented:false}))}function rs(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let r=e.target;r!=t.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(e))return false;return true}function is(t,e){if(!es(t,e)&&Wn[e.type]&&(t.editable||!(e.type in Gn)))Wn[e.type](t,e)}Gn.keydown=(t,e)=>{let r=e;t.input.shiftKey=r.keyCode==16||r.shiftKey;if(bs(t,r))return;t.input.lastKeyCode=r.keyCode;t.input.lastKeyCodeTime=Date.now();if(zr&&Ir&&r.keyCode==13)return;if(r.keyCode!=229)t.domObserver.forceFlush();if(jr&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let e=Date.now();t.input.lastIOSEnter=e;t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{if(t.input.lastIOSEnter==e){t.someProp("handleKeyDown",(e=>e(t,kr(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,r)))||Nn(t,r)){r.preventDefault()}else{Qn(t,"key")}};Gn.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};Gn.keypress=(t,e)=>{let r=e;if(bs(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||Br&&r.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,r)))){r.preventDefault();return}let i=t.state.selection;if(!(i instanceof Je)||!i.$from.sameParent(i.$to)){let e=String.fromCharCode(r.charCode);if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(r=>r(t,i.$from.pos,i.$to.pos,e))))t.dispatch(t.state.tr.insertText(e).scrollIntoView());r.preventDefault()}};function ns(t){return{left:t.clientX,top:t.clientY}}function ss(t,e){let r=e.x-t.clientX,i=e.y-t.clientY;return r*r+i*i<100}function ls(t,e,r,i,n){if(i==-1)return false;let s=t.state.doc.resolve(i);for(let i=s.depth+1;i>0;i--){if(t.someProp(e,(e=>i>s.depth?e(t,r,s.nodeAfter,s.before(i),n,true):e(t,r,s.node(i),s.before(i),n,false))))return true}return false}function us(t,e,r){if(!t.focused)t.focus();let i=t.state.tr.setSelection(e);if(r=="pointer")i.setMeta("pointer",true);t.dispatch(i)}function fs(t,e){if(e==-1)return false;let r=t.state.doc.resolve(e),i=r.nodeAfter;if(i&&i.isAtom&&Fe.isSelectable(i)){us(t,new Fe(r),"pointer");return true}return false}function hs(t,e){if(e==-1)return false;let r=t.state.selection,i,n;if(r instanceof Fe)i=r.node;let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(Fe.isSelectable(e)){if(i&&r.$from.depth>0&&t>=r.$from.depth&&s.before(r.$from.depth+1)==r.$from.pos)n=s.before(r.$from.depth);else n=s.before(t);break}}if(n!=null){us(t,Fe.create(t.state.doc,n),"pointer");return true}else{return false}}function as(t,e,r,i,n){return ls(t,"handleClickOn",e,r,i)||t.someProp("handleClick",(r=>r(t,e,i)))||(n?hs(t,r):fs(t,r))}function cs(t,e,r,i){return ls(t,"handleDoubleClickOn",e,r,i)||t.someProp("handleDoubleClick",(r=>r(t,e,i)))}function ds(t,e,r,i){return ls(t,"handleTripleClickOn",e,r,i)||t.someProp("handleTripleClick",(r=>r(t,e,i)))||ps(t,r,i)}function ps(t,e,r){if(r.button!=0)return false;let i=t.state.doc;if(e==-1){if(i.inlineContent){us(t,Je.create(i,0,i.content.size),"pointer");return true}return false}let n=i.resolve(e);for(let e=n.depth+1;e>0;e--){let r=e>n.depth?n.nodeAfter:n.node(e);let s=n.before(e);if(r.inlineContent)us(t,Je.create(i,s+1,s+1+r.content.size),"pointer");else if(Fe.isSelectable(r))us(t,Fe.create(i,s),"pointer");else continue;return true}}function ms(t){return Ss(t)}const gs=Br?"metaKey":"ctrlKey";Wn.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let i=ms(t);let n=Date.now(),s="singleClick";if(n-t.input.lastClick.time<500&&ss(r,t.input.lastClick)&&!r[gs]){if(t.input.lastClick.type=="singleClick")s="doubleClick";else if(t.input.lastClick.type=="doubleClick")s="tripleClick"}t.input.lastClick={time:n,x:r.clientX,y:r.clientY,type:s};let o=t.posAtCoords(ns(r));if(!o)return;if(s=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new ws(t,o,r,!!i)}else if((s=="doubleClick"?cs:ds)(t,o.pos,o.inside,r)){r.preventDefault()}else{Qn(t,"pointer")}};class ws{constructor(t,e,r,i){this.view=t;this.pos=e;this.event=r;this.flushed=i;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!r[gs];this.allowDefault=r.shiftKey;let n,s;if(e.inside>-1){n=t.state.doc.nodeAt(e.inside);s=e.inside}else{let r=t.state.doc.resolve(e.pos);n=r.parent;s=r.depth?r.before():0}const o=i?null:r.target;const l=o?t.docView.nearestDesc(o,true):null;this.target=l&&l.dom.nodeType==1?l.dom:null;let{selection:u}=t.state;if(r.button==0&&n.type.spec.draggable&&n.type.spec.selectable!==false||u instanceof Fe&&u.from<=s&&u.to>s)this.mightDrag={node:n,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Rr&&!this.target.hasAttribute("contentEditable"))};if(this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.draggable=true;if(this.mightDrag.setUneditable)setTimeout((()=>{if(this.view.input.mouseDown==this)this.target.setAttribute("contentEditable","false")}),20);this.view.domObserver.start()}t.root.addEventListener("mouseup",this.up=this.up.bind(this));t.root.addEventListener("mousemove",this.move=this.move.bind(this));Qn(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up);this.view.root.removeEventListener("mousemove",this.move);if(this.mightDrag&&this.target){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.removeAttribute("draggable");if(this.mightDrag.setUneditable)this.target.removeAttribute("contentEditable");this.view.domObserver.start()}if(this.delayedSelectionSync)setTimeout((()=>Zi(this.view)));this.view.input.mouseDown=null}up(t){this.done();if(!this.view.dom.contains(t.target))return;let e=this.pos;if(this.view.state.doc!=this.startDoc)e=this.view.posAtCoords(ns(t));this.updateAllowDefault(t);if(this.allowDefault||!e){Qn(this.view,"pointer")}else if(as(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||Hr&&this.mightDrag&&!this.mightDrag.node.isAtom||Ir&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)){us(this.view,Le.near(this.view.state.doc.resolve(e.pos)),"pointer");t.preventDefault()}else{Qn(this.view,"pointer")}}move(t){this.updateAllowDefault(t);Qn(this.view,"pointer");if(t.buttons==0)this.done()}updateAllowDefault(t){if(!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4))this.allowDefault=true}}Wn.touchstart=t=>{t.input.lastTouch=Date.now();ms(t);Qn(t,"pointer")};Wn.touchmove=t=>{t.input.lastTouch=Date.now();Qn(t,"pointer")};Wn.contextmenu=t=>ms(t);function bs(t,e){if(t.composing)return true;if(Hr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const vs=zr?5e3:-1;Gn.compositionstart=Gn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||r.marks();Ss(t,true);t.markCursor=null}else{Ss(t);if(Rr&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let e=t.domSelectionRange();for(let r=e.focusNode,i=e.focusOffset;r&&r.nodeType==1&&i!=0;){let e=i<0?r.lastChild:r.childNodes[i-1];if(!e)break;if(e.nodeType==3){t.domSelection().collapse(e,e.nodeValue.length);break}else{r=e;i=-1}}}}t.input.composing=true}ys(t,vs)};Gn.compositionend=(t,e)=>{if(t.composing){t.input.composing=false;t.input.compositionEndedAt=e.timeStamp;t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0;t.input.compositionNode=null;if(t.input.compositionPendingChanges)Promise.resolve().then((()=>t.domObserver.flush()));t.input.compositionID++;ys(t,20)}};function ys(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>Ss(t)),e)}function Ms(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=xs()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function ks(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let r=wr(e.focusNode,e.focusOffset);let i=br(e.focusNode,e.focusOffset);if(r&&i&&r!=i){let e=i.pmViewDesc;if(!e||!e.isText(i.nodeValue)){return i}else if(t.input.compositionNode==i){let t=r.pmViewDesc;if(!(!t||!t.isText(r.nodeValue)))return i}}return r||i}function xs(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function Ss(t,e=false){if(zr&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();Ms(t);if(e||t.docView&&t.docView.dirty){let e=Yi(t);if(e&&!e.eq(t.state.selection))t.dispatch(t.state.tr.setSelection(e));else t.updateState(t.state);return true}return false}function Os(t,e){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(e);r.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),n=document.createRange();n.selectNodeContents(e);t.dom.blur();i.removeAllRanges();i.addRange(n);setTimeout((()=>{if(r.parentNode)r.parentNode.removeChild(r);t.focus()}),50)}const Ts=Nr&&$r<15||jr&&_r<604;Wn.copy=Gn.cut=(t,e)=>{let r=e;let i=t.state.selection,n=r.type=="cut";if(i.empty)return;let s=Ts?null:r.clipboardData;let o=i.content(),{dom:l,text:u}=$n(t,o);if(s){r.preventDefault();s.clearData();s.setData("text/html",l.innerHTML);s.setData("text/plain",u)}else{Os(t,l)}if(n)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Es(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ps(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let i=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));if(!r)i.contentEditable="true";i.style.cssText="position: fixed; left: -10000px; top: 10px";i.focus();let n=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(i.parentNode)i.parentNode.removeChild(i);if(r)As(t,i.value,null,n,e);else As(t,i.textContent,i.innerHTML,n,e)}),50)}function As(t,e,r,i,n){let s=Rn(t,e,r,i,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||d.empty))))return true;if(!s)return false;let o=Es(s);let l=o?t.state.tr.replaceSelectionWith(o,i):t.state.tr.replaceSelection(s);t.dispatch(l.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function Cs(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let r=t.getData("text/uri-list");return r?r.replace(/\r?\n/g," "):""}Gn.paste=(t,e)=>{let r=e;if(t.composing&&!zr)return;let i=Ts?null:r.clipboardData;let n=t.input.shiftKey&&t.input.lastKeyCode!=45;if(i&&As(t,Cs(i),i.getData("text/html"),n,r))r.preventDefault();else Ps(t,r)};class Ns{constructor(t,e,r){this.slice=t;this.move=e;this.node=r}}const $s=Br?"altKey":"ctrlKey";Wn.dragstart=(t,e)=>{let r=e;let i=t.input.mouseDown;if(i)i.done();if(!r.dataTransfer)return;let n=t.state.selection;let s=n.empty?null:t.posAtCoords(ns(r));let o;if(s&&s.pos>=n.from&&s.pos<=(n instanceof Fe?n.to-1:n.to));else if(i&&i.mightDrag){o=Fe.create(t.state.doc,i.mightDrag.pos)}else if(r.target&&r.target.nodeType==1){let e=t.docView.nearestDesc(r.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)o=Fe.create(t.state.doc,e.posBefore)}let l=(o||t.state.selection).content();let{dom:u,text:f,slice:h}=$n(t,l);r.dataTransfer.clearData();r.dataTransfer.setData(Ts?"Text":"text/html",u.innerHTML);r.dataTransfer.effectAllowed="copyMove";if(!Ts)r.dataTransfer.setData("text/plain",f);t.dragging=new Ns(h,!r[$s],o)};Wn.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};Gn.dragover=Gn.dragenter=(t,e)=>e.preventDefault();Gn.drop=(t,e)=>{let r=e;let i=t.dragging;t.dragging=null;if(!r.dataTransfer)return;let n=t.posAtCoords(ns(r));if(!n)return;let s=t.state.doc.resolve(n.pos);let o=i&&i.slice;if(o){t.someProp("transformPasted",(e=>{o=e(o,t)}))}else{o=Rn(t,Cs(r.dataTransfer),Ts?null:r.dataTransfer.getData("text/html"),false,s)}let l=!!(i&&!r[$s]);if(t.someProp("handleDrop",(e=>e(t,r,o||d.empty,l)))){r.preventDefault();return}if(!o)return;r.preventDefault();let u=o?me(t.state.doc,s.pos,o):s.pos;if(u==null)u=s.pos;let f=t.state.tr;if(l){let{node:t}=i;if(t)t.replace(f);else f.deleteSelection()}let h=f.mapping.map(u);let a=o.openStart==0&&o.openEnd==0&&o.content.childCount==1;let c=f.doc;if(a)f.replaceRangeWith(h,h,o.content.firstChild);else f.replaceRange(h,h,o);if(f.doc.eq(c))return;let p=f.doc.resolve(h);if(a&&Fe.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild)){f.setSelection(new Fe(p))}else{let e=f.mapping.map(u);f.mapping.maps[f.mapping.maps.length-1].forEach(((t,r,i,n)=>e=n));f.setSelection(fn(t,p,f.doc.resolve(e)))}t.focus();t.dispatch(f.setMeta("uiEvent","drop"))};Wn.focus=t=>{t.input.lastFocus=Date.now();if(!t.focused){t.domObserver.stop();t.dom.classList.add("ProseMirror-focused");t.domObserver.start();t.focused=true;setTimeout((()=>{if(t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange()))Zi(t)}),20)}};Wn.blur=(t,e)=>{let r=e;if(t.focused){t.domObserver.stop();t.dom.classList.remove("ProseMirror-focused");t.domObserver.start();if(r.relatedTarget&&t.dom.contains(r.relatedTarget))t.domObserver.currentSelection.clear();t.focused=false}};Wn.beforeinput=(t,e)=>{let r=e;if(Ir&&zr&&r.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;t.dom.blur();t.focus();if(t.someProp("handleKeyDown",(e=>e(t,kr(8,"Backspace")))))return;let{$cursor:r}=t.state.selection;if(r&&r.pos>0)t.dispatch(t.state.tr.delete(r.pos-1,r.pos).scrollIntoView())}),50)}};for(let t in Gn)Wn[t]=Gn[t];function Rs(t,e){if(t==e)return true;for(let r in t)if(t[r]!==e[r])return false;for(let r in e)if(!(r in t))return false;return true}class Ds{constructor(t,e){this.toDOM=t;this.spec=e||Bs;this.side=this.spec.side||0}map(t,e,r,i){let{pos:n,deleted:s}=t.mapResult(e.from+i,this.side<0?-1:1);return s?null:new Hs(n-r,n-r,this)}valid(){return true}eq(t){return this==t||t instanceof Ds&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Rs(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class Is{constructor(t,e){this.attrs=t;this.spec=e||Bs}map(t,e,r,i){let n=t.map(e.from+i,this.spec.inclusiveStart?-1:1)-r;let s=t.map(e.to+i,this.spec.inclusiveEnd?1:-1)-r;return n>=s?null:new Hs(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Is&&Rs(this.attrs,t.attrs)&&Rs(this.spec,t.spec)}static is(t){return t.type instanceof Is}destroy(){}}class Ls{constructor(t,e){this.attrs=t;this.spec=e||Bs}map(t,e,r,i){let n=t.mapResult(e.from+i,1);if(n.deleted)return null;let s=t.mapResult(e.to+i,-1);if(s.deleted||s.pos<=n.pos)return null;return new Hs(n.pos-r,s.pos-r,this)}valid(t,e){let{index:r,offset:i}=t.content.findIndex(e.from),n;return i==e.from&&!(n=t.child(r)).isText&&i+n.nodeSize==e.to}eq(t){return this==t||t instanceof Ls&&Rs(this.attrs,t.attrs)&&Rs(this.spec,t.spec)}destroy(){}}class Hs{constructor(t,e,r){this.from=t;this.to=e;this.type=r}copy(t,e){return new Hs(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,r){return this.type.map(t,this,e,r)}static widget(t,e,r){return new Hs(t,t,new Ds(e,r))}static inline(t,e,r,i){return new Hs(t,e,new Is(r,i))}static node(t,e,r,i){return new Hs(t,e,new Ls(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Is}get widget(){return this.type instanceof Ds}}const js=[],Bs={};class Js{constructor(t,e){this.local=t.length?t:js;this.children=e.length?e:js}static create(t,e){return e.length?Gs(e,t,0,Bs):zs}find(t,e,r){let i=[];this.findInner(t==null?0:t,e==null?1e9:e,i,0,r);return i}findInner(t,e,r,i,n){for(let s=0;s<this.local.length;s++){let o=this.local[s];if(o.from<=e&&o.to>=t&&(!n||n(o.spec)))r.push(o.copy(o.from+i,o.to+i))}for(let s=0;s<this.children.length;s+=3){if(this.children[s]<e&&this.children[s+1]>t){let o=this.children[s]+1;this.children[s+2].findInner(t-o,e-o,r,i+o,n)}}}map(t,e,r){if(this==zs||t.maps.length==0)return this;return this.mapInner(t,e,0,0,r||Bs)}mapInner(t,e,r,i,n){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(t,r,i);if(l&&l.type.valid(e,l))(s||(s=[])).push(l);else if(n.onRemove)n.onRemove(this.local[o].spec)}if(this.children.length)return _s(this.children,s||[],t,e,r,i,n);else return s?new Js(s.sort(Vs),js):zs}add(t,e){if(!e.length)return this;if(this==zs)return Js.create(t,e);return this.addInner(t,e,0)}addInner(t,e,r){let i,n=0;t.forEach(((t,s)=>{let o=s+r,l;if(!(l=Us(e,t,o)))return;if(!i)i=this.children.slice();while(n<i.length&&i[n]<s)n+=3;if(i[n]==s)i[n+2]=i[n+2].addInner(t,l,o+1);else i.splice(n,0,s,s+t.nodeSize,Gs(l,t,o+1,Bs));n+=3}));let s=Ks(n?Ws(e):e,-r);for(let e=0;e<s.length;e++)if(!s[e].type.valid(t,s[e]))s.splice(e--,1);return new Js(s.length?this.local.concat(s).sort(Vs):this.local,i||this.children)}remove(t){if(t.length==0||this==zs)return this;return this.removeInner(t,0)}removeInner(t,e){let r=this.children,i=this.local;for(let i=0;i<r.length;i+=3){let n;let s=r[i]+e,o=r[i+1]+e;for(let e=0,r;e<t.length;e++)if(r=t[e]){if(r.from>s&&r.to<o){t[e]=null;(n||(n=[])).push(r)}}if(!n)continue;if(r==this.children)r=this.children.slice();let l=r[i+2].removeInner(n,s+1);if(l!=zs){r[i+2]=l}else{r.splice(i,3);i-=3}}if(i.length)for(let r=0,n;r<t.length;r++)if(n=t[r]){for(let t=0;t<i.length;t++)if(i[t].eq(n,e)){if(i==this.local)i=this.local.slice();i.splice(t--,1)}}if(r==this.children&&i==this.local)return this;return i.length||r.length?new Js(i,r):zs}forChild(t,e){if(this==zs)return this;if(e.isLeaf)return Js.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)r=this.children[e+2];break}let n=t+1,s=n+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>n&&e.type instanceof Is){let t=Math.max(n,e.from)-n,r=Math.min(s,e.to)-n;if(t<r)(i||(i=[])).push(e.copy(t,r))}}if(i){let t=new Js(i.sort(Vs),js);return r?new Fs([t,r]):t}return r||zs}eq(t){if(this==t)return true;if(!(t instanceof Js)||this.local.length!=t.local.length||this.children.length!=t.children.length)return false;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return false;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return false;return true}locals(t){return Xs(this.localsInner(t))}localsInner(t){if(this==zs)return js;if(t.inlineContent||!this.local.some(Is.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof Is))e.push(this.local[t])}return e}}Js.empty=new Js([],[]);Js.removeOverlap=Xs;const zs=Js.empty;class Fs{constructor(t){this.members=t}map(t,e){const r=this.members.map((r=>r.map(t,e,Bs)));return Fs.from(r)}forChild(t,e){if(e.isLeaf)return Js.empty;let r=[];for(let i=0;i<this.members.length;i++){let n=this.members[i].forChild(t,e);if(n==zs)continue;if(n instanceof Fs)r=r.concat(n.members);else r.push(n)}return Fs.from(r)}eq(t){if(!(t instanceof Fs)||t.members.length!=this.members.length)return false;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return false;return true}locals(t){let e,r=true;for(let i=0;i<this.members.length;i++){let n=this.members[i].localsInner(t);if(!n.length)continue;if(!e){e=n}else{if(r){e=e.slice();r=false}for(let t=0;t<n.length;t++)e.push(n[t])}}return e?Xs(r?e:e.sort(Vs)):js}static from(t){switch(t.length){case 0:return zs;case 1:return t[0];default:return new Fs(t.every((t=>t instanceof Js))?t:t.reduce(((t,e)=>t.concat(e instanceof Js?e:e.members)),[]))}}}function _s(t,e,r,i,n,s,o){let l=t.slice();for(let t=0,e=s;t<r.maps.length;t++){let i=0;r.maps[t].forEach(((t,r,n,s)=>{let o=s-n-(r-t);for(let n=0;n<l.length;n+=3){let s=l[n+1];if(s<0||t>s+e-i)continue;let u=l[n]+e-i;if(r>=u){l[n+1]=t<=u?-2:-1}else if(t>=e&&o){l[n]+=o;l[n+1]+=o}}i+=o}));e=r.maps[t].map(e,-1)}let u=false;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(l[e+1]==-2){u=true;l[e+1]=-1;continue}let f=r.map(t[e]+s),h=f-n;if(h<0||h>=i.content.size){u=true;continue}let a=r.map(t[e+1]+s,-1),c=a-n;let{index:d,offset:p}=i.content.findIndex(h);let m=i.maybeChild(d);if(m&&p==h&&p+m.nodeSize==c){let i=l[e+2].mapInner(r,m,f+1,t[e]+s+1,o);if(i!=zs){l[e]=h;l[e+1]=c;l[e+2]=i}else{l[e+1]=-2;u=true}}else{u=true}}if(u){let u=qs(l,t,e,r,n,s,o);let f=Gs(u,i,0,o);e=f.local;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){l.splice(t,3);t-=3}for(let t=0,e=0;t<f.children.length;t+=3){let r=f.children[t];while(e<l.length&&l[e]<r)e+=3;l.splice(e,0,f.children[t],f.children[t+1],f.children[t+2])}}return new Js(e.sort(Vs),l)}function Ks(t,e){if(!e||!t.length)return t;let r=[];for(let i=0;i<t.length;i++){let n=t[i];r.push(new Hs(n.from+e,n.to+e,n.type))}return r}function qs(t,e,r,i,n,s,o){function l(t,e){for(let s=0;s<t.local.length;s++){let l=t.local[s].map(i,n,e);if(l)r.push(l);else if(o.onRemove)o.onRemove(t.local[s].spec)}for(let r=0;r<t.children.length;r+=3)l(t.children[r+2],t.children[r]+e+1)}for(let r=0;r<t.length;r+=3)if(t[r+1]==-1)l(t[r+2],e[r]+s+1);return r}function Us(t,e,r){if(e.isLeaf)return null;let i=r+e.nodeSize,n=null;for(let e=0,s;e<t.length;e++){if((s=t[e])&&s.from>r&&s.to<i){(n||(n=[])).push(s);t[e]=null}}return n}function Ws(t){let e=[];for(let r=0;r<t.length;r++)if(t[r]!=null)e.push(t[r]);return e}function Gs(t,e,r,i){let n=[],s=false;e.forEach(((e,o)=>{let l=Us(t,e,o+r);if(l){s=true;let t=Gs(l,e,r+o+1,i);if(t!=zs)n.push(o,o+e.nodeSize,t)}}));let o=Ks(s?Ws(t):t,-r).sort(Vs);for(let t=0;t<o.length;t++)if(!o[t].type.valid(e,o[t])){if(i.onRemove)i.onRemove(o[t].spec);o.splice(t--,1)}return o.length||n.length?new Js(o,n):zs}function Vs(t,e){return t.from-e.from||t.to-e.to}function Xs(t){let e=t;for(let r=0;r<e.length-1;r++){let i=e[r];if(i.from!=i.to)for(let n=r+1;n<e.length;n++){let s=e[n];if(s.from==i.from){if(s.to!=i.to){if(e==t)e=t.slice();e[n]=s.copy(s.from,i.to);Ys(e,n+1,s.copy(i.to,s.to))}continue}else{if(s.from<i.to){if(e==t)e=t.slice();e[r]=i.copy(i.from,s.from);Ys(e,n,i.copy(s.from,i.to))}break}}}return e}function Ys(t,e,r){while(e<t.length&&Vs(r,t[e])>0)e++;t.splice(e,0,r)}function Qs(t){let e=[];t.someProp("decorations",(r=>{let i=r(t.state);if(i&&i!=zs)e.push(i)}));if(t.cursorWrapper)e.push(Js.create(t.state.doc,[t.cursorWrapper.deco]));return Fs.from(e)}const Zs={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const to=Nr&&$r<=11;class eo{constructor(){this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0}set(t){this.anchorNode=t.anchorNode;this.anchorOffset=t.anchorOffset;this.focusNode=t.focusNode;this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class ro{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new eo;this.onCharData=null;this.suppressingSelectionUpdates=false;this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);if(Nr&&$r<=11&&t.some((t=>t.type=="childList"&&t.removedNodes.length||t.type=="characterData"&&t.oldValue.length>t.target.nodeValue.length)))this.flushSoon();else this.flush()}));if(to){this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue});this.flushSoon()}}this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){if(this.flushingSoon<0)this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1;this.flush()}),20)}forceFlush(){if(this.flushingSoon>-1){window.clearTimeout(this.flushingSoon);this.flushingSoon=-1;this.flush()}}start(){if(this.observer){this.observer.takeRecords();this.observer.observe(this.view.dom,Zs)}if(this.onCharData)this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}if(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=true;setTimeout((()=>this.suppressingSelectionUpdates=false),50)}onSelectionChange(){if(!hn(this.view))return;if(this.suppressingSelectionUpdates)return Zi(this.view);if(Nr&&$r<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&dr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return true;let e=new Set,r;for(let r=t.focusNode;r;r=fr(r))e.add(r);for(let i=t.anchorNode;i;i=fr(i))if(e.has(i)){r=i;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r})){this.setCurSelection();return true}}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();if(e.length)this.queue=[];let r=t.domSelectionRange();let i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&hn(t)&&!this.ignoreSelectionChange(r);let n=-1,s=-1,o=false,l=[];if(t.editable){for(let t=0;t<e.length;t++){let r=this.registerMutation(e[t],l);if(r){n=n<0?r.from:Math.min(r.from,n);s=s<0?r.to:Math.max(r.to,s);if(r.typeOver)o=true}}}if(Rr&&l.length){let e=l.filter((t=>t.nodeName=="BR"));if(e.length==2){let[t,r]=e;if(t.parentNode&&t.parentNode.parentNode==r.parentNode)r.remove();else t.remove()}else{let{focusNode:r}=this.currentSelection;for(let i of e){let e=i.parentNode;if(e&&e.nodeName=="LI"&&(!r||uo(t,r)!=e))i.remove()}}}let u=null;if(n<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Mr(r)&&(u=Yi(t))&&u.eq(Le.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;Zi(t);this.currentSelection.set(r);t.scrollToSelection()}else if(n>-1||i){if(n>-1){t.docView.markDirty(n,s);so(t)}this.handleDOMChange(n,s,o,l);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(r))Zi(t);this.currentSelection.set(r)}}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(r==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!r||r.ignoreMutation(t))return null;if(t.type=="childList"){for(let r=0;r<t.addedNodes.length;r++)e.push(t.addedNodes[r]);if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let i=t.previousSibling,n=t.nextSibling;if(Nr&&$r<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:r,nextSibling:s}=t.addedNodes[e];if(!r||Array.prototype.indexOf.call(t.addedNodes,r)<0)i=r;if(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)n=s}}let s=i&&i.parentNode==t.target?ur(i)+1:0;let o=r.localPosFromDOM(t.target,s,-1);let l=n&&n.parentNode==t.target?ur(n):t.target.childNodes.length;let u=r.localPosFromDOM(t.target,l,1);return{from:o,to:u}}else if(t.type=="attributes"){return{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}}else{return{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let io=new WeakMap;let no=false;function so(t){if(io.has(t))return;io.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=Rr;if(no)return;console["warn"]("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.");no=true}}function oo(t,e){let r=e.startContainer,i=e.startOffset;let n=e.endContainer,s=e.endOffset;let o=t.domAtPos(t.state.selection.anchor);if(dr(o.node,o.offset,n,s))[r,i,n,s]=[n,s,r,i];return{anchorNode:r,anchorOffset:i,focusNode:n,focusOffset:s}}function lo(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return oo(t,r)}let r;function i(t){t.preventDefault();t.stopImmediatePropagation();r=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",i,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",i,true);return r?oo(t,r):null}function uo(t,e){for(let r=e.parentNode;r&&r!=t.dom;r=r.parentNode){let e=t.docView.nearestDesc(r,true);if(e&&e.node.isBlock)return r}return null}function fo(t,e,r){let{node:i,fromOffset:n,toOffset:s,from:o,to:l}=t.docView.parseRange(e,r);let u=t.domSelectionRange();let f;let h=u.anchorNode;if(h&&t.dom.contains(h.nodeType==1?h:h.parentNode)){f=[{node:h,offset:u.anchorOffset}];if(!Mr(u))f.push({node:u.focusNode,offset:u.focusOffset})}if(Ir&&t.input.lastKeyCode===8){for(let t=s;t>n;t--){let e=i.childNodes[t-1],r=e.pmViewDesc;if(e.nodeName=="BR"&&!r){s=t;break}if(!r||r.size)break}}let a=t.state.doc;let c=t.someProp("domParser")||st.fromSchema(t.state.schema);let d=a.resolve(o);let p=null,m=c.parse(i,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:n,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:f,ruleFromNode:ho,context:d});if(f&&f[0].pos!=null){let t=f[0].pos,e=f[1]&&f[1].pos;if(e==null)e=t;p={anchor:t+o,head:e+o}}return{doc:m,sel:p,from:o,to:l}}function ho(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(Hr&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");t.appendChild(document.createElement("li"));return{skip:t}}else if(t.parentNode.lastChild==t||Hr&&/^(tr|table)$/i.test(t.parentNode.nodeName)){return{ignore:true}}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder")){return{ignore:true}}return null}const ao=/^(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 co(t,e,r,i,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let r=Yi(t,e);if(r&&!t.state.selection.eq(r)){if(Ir&&zr&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,kr(13,"Enter")))))return;let i=t.state.tr.setSelection(r);if(e=="pointer")i.setMeta("pointer",true);else if(e=="key")i.scrollIntoView();if(s)i.setMeta("composition",s);t.dispatch(i)}return}let o=t.state.doc.resolve(e);let l=o.sharedDepth(r);e=o.before(l+1);r=t.state.doc.resolve(r).after(l+1);let u=t.state.selection;let f=fo(t,e,r);let h=t.state.doc,a=h.slice(f.from,f.to);let c,d;if(t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime){c=t.state.selection.to;d="end"}else{c=t.state.selection.from;d="start"}t.input.lastKeyCode=null;let p=bo(a.content,f.doc.content,f.from,c,d);if((jr&&t.input.lastIOSEnter>Date.now()-225||zr)&&n.some((t=>t.nodeType==1&&!ao.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,kr(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!p){if(i&&u instanceof Je&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head)){p={start:u.from,endA:u.to,endB:u.to}}else{if(f.sel){let e=po(t,t.state.doc,f.sel);if(e&&!e.eq(t.state.selection)){let r=t.state.tr.setSelection(e);if(s)r.setMeta("composition",s);t.dispatch(r)}}return}}t.input.domChangeCount++;if(t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof Je){if(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=f.from){p.start=t.state.selection.from}else if(p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to){p.endB+=t.state.selection.to-p.endA;p.endA=t.state.selection.to}}if(Nr&&$r<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>f.from&&f.doc.textBetween(p.start-f.from-1,p.start-f.from+1)==" "){p.start--;p.endA--;p.endB--}let m=f.doc.resolveNoCache(p.start-f.from);let g=f.doc.resolveNoCache(p.endB-f.from);let w=h.resolve(p.start);let b=m.sameParent(g)&&m.parent.inlineContent&&w.end()>=p.endA;let v;if((jr&&t.input.lastIOSEnter>Date.now()-225&&(!b||n.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!b&&m.pos<f.doc.content.size&&!m.sameParent(g)&&(v=Le.findFrom(f.doc.resolve(m.pos+1),1,true))&&v.head==g.pos)&&t.someProp("handleKeyDown",(e=>e(t,kr(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&go(h,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",(e=>e(t,kr(8,"Backspace"))))){if(zr&&Ir)t.domObserver.suppressSelectionUpdates();return}if(Ir&&zr&&p.endB==p.start)t.input.lastAndroidDelete=Date.now();if(zr&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==p.endA){p.endB-=2;g=f.doc.resolveNoCache(p.endB-f.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,kr(13,"Enter"))}))}),20)}let y=p.start,M=p.endA;let k,x,S;if(b){if(m.pos==g.pos){if(Nr&&$r<=11&&m.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>Zi(t)),20)}k=t.state.tr.delete(y,M);x=h.resolve(p.start).marksAcross(h.resolve(p.endA))}else if(p.endA==p.endB&&(S=mo(m.parent.content.cut(m.parentOffset,g.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start())))){k=t.state.tr;if(S.type=="add")k.addMark(y,M,S.mark);else k.removeMark(y,M,S.mark)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,g.parentOffset);if(t.someProp("handleTextInput",(r=>r(t,y,M,e))))return;k=t.state.tr.insertText(e,y,M)}}if(!k)k=t.state.tr.replace(y,M,f.doc.slice(p.start-f.from,p.endB-f.from));if(f.sel){let e=po(t,k.doc,f.sel);if(e&&!(Ir&&zr&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastAndroidDelete<Date.now()-100)&&(e.head==y||e.head==k.mapping.map(M)-1)||Nr&&e.empty&&e.head==y))k.setSelection(e)}if(x)k.ensureMarks(x);if(s)k.setMeta("composition",s);t.dispatch(k.scrollIntoView())}function po(t,e,r){if(Math.max(r.anchor,r.head)>e.content.size)return null;return fn(t,e.resolve(r.anchor),e.resolve(r.head))}function mo(t,e){let r=t.firstChild.marks,i=e.firstChild.marks;let n=r,s=i,o,u,f;for(let t=0;t<i.length;t++)n=i[t].removeFromSet(n);for(let t=0;t<r.length;t++)s=r[t].removeFromSet(s);if(n.length==1&&s.length==0){u=n[0];o="add";f=t=>t.mark(u.addToSet(t.marks))}else if(n.length==0&&s.length==1){u=s[0];o="remove";f=t=>t.mark(u.removeFromSet(t.marks))}else{return null}let h=[];for(let t=0;t<e.childCount;t++)h.push(f(e.child(t)));if(l.from(h).eq(t))return{mark:u,type:o}}function go(t,e,r,i,n){if(r-e<=n.pos-i.pos||wo(i,true,false)<n.pos)return false;let s=t.resolve(e);if(!i.parent.isTextblock){let t=s.nodeAfter;return t!=null&&r==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return false;let o=t.resolve(wo(s,true,true));if(!o.parent.isTextblock||o.pos>r||wo(o,true,false)<r)return false;return i.parent.content.cut(i.parentOffset).eq(o.parent.content)}function wo(t,e,r){let i=t.depth,n=e?t.end():t.pos;while(i>0&&(e||t.indexAfter(i)==t.node(i).childCount)){i--;n++;e=false}if(r){let e=t.node(i).maybeChild(t.indexAfter(i));while(e&&!e.isLeaf){e=e.firstChild;n++}}return n}function bo(t,e,r,i,n){let s=t.findDiffStart(e,r);if(s==null)return null;let{a:o,b:l}=t.findDiffEnd(e,r+t.size,r+e.size);if(n=="end"){let t=Math.max(0,s-Math.min(o,l));i-=o+t-s}if(o<s&&t.size<e.size){let t=i<=s&&i>=o?s-i:0;s-=t;if(s&&s<e.size&&vo(e.textBetween(s-1,s+1)))s+=t?1:-1;l=s+(l-o);o=s}else if(l<s){let e=i<=s&&i>=l?s-i:0;s-=e;if(s&&s<t.size&&vo(t.textBetween(s-1,s+1)))s+=e?1:-1;o=s+(o-l);l=s}return{start:s,endA:o,endB:l}}function vo(t){if(t.length!=2)return false;let e=t.charCodeAt(0),r=t.charCodeAt(1);return e>=56320&&e<=57343&&r>=55296&&r<=56319}class yo{constructor(t,e){this._root=null;this.focused=false;this.trackWrites=null;this.mounted=false;this.markCursor=null;this.cursorWrapper=null;this.lastSelectedViewDesc=undefined;this.input=new Xn;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(Eo);this.dispatch=this.dispatch.bind(this);this.dom=t&&t.mount||document.createElement("div");if(t){if(t.appendChild)t.appendChild(this.dom);else if(typeof t=="function")t(this.dom);else if(t.mount)this.mounted=true}this.editable=xo(this);ko(this);this.nodeViews=Oo(this);this.docView=Ni(this.state.doc,Mo(this),Qs(this),this.dom,this);this.domObserver=new ro(this,((t,e,r,i)=>co(this,t,e,r,i)));this.domObserver.start();Yn(this);this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){if(t.handleDOMEvents!=this._props.handleDOMEvents)ts(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(Eo);this.directPlugins=t.plugins}this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let r in t)e[r]=t[r];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var r;let i=this.state,n=false,s=false;if(t.storedMarks&&this.composing){Ms(this);s=true}this.state=t;let o=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(o||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Oo(this);if(To(t,this.nodeViews)){this.nodeViews=t;n=true}}if(o||e.handleDOMEvents!=this._props.handleDOMEvents){ts(this)}this.editable=xo(this);ko(this);let l=Qs(this),u=Mo(this);let f=i.plugins!=t.plugins&&!i.doc.eq(t.doc)?"reset":t.scrollToSelection>i.scrollToSelection?"to selection":"preserve";let h=n||!this.docView.matchesNode(t.doc,u,l);if(h||!t.selection.eq(i.selection))s=true;let a=f=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Gr(this);if(s){this.domObserver.stop();let e=h&&(Nr||Ir)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&So(i.selection,t.selection);if(h){let r=Ir?this.trackWrites=this.domSelectionRange().focusNode:null;if(this.composing)this.input.compositionNode=ks(this);if(n||!this.docView.update(t.doc,u,l,this)){this.docView.updateOuterDeco(u);this.docView.destroy();this.docView=Ni(t.doc,u,l,this.dom,this)}if(r&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cn(this))){Zi(this,e)}else{ln(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(i);if(((r=this.dragging)===null||r===void 0?void 0:r.node)&&!i.doc.eq(t.doc))this.updateDraggedNode(this.dragging,i);if(f=="reset"){this.dom.scrollTop=0}else if(f=="to selection"){this.scrollToSelection()}else if(a){Xr(a)}}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof Fe){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)Wr(this,e.getBoundingClientRect(),t)}else{Wr(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;while(t=this.pluginViews.pop())if(t.destroy)t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins;this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}}else{for(let e=0;e<this.pluginViews.length;e++){let r=this.pluginViews[e];if(r.update)r.update(this,t)}}}updateDraggedNode(t,e){let r=t.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node){i=r.from}else{let t=r.from+(this.state.doc.content.size-e.doc.content.size);let n=t>0&&this.state.doc.nodeAt(t);if(n==r.node)i=t}this.dragging=new Ns(t.slice,t.move,i<0?undefined:Fe.create(this.state.doc,i))}someProp(t,e){let r=this._props&&this._props[t],i;if(r!=null&&(i=e?e(r):r))return i;for(let r=0;r<this.directPlugins.length;r++){let n=this.directPlugins[r].props[t];if(n!=null&&(i=e?e(n):n))return i}let n=this.state.plugins;if(n)for(let r=0;r<n.length;r++){let s=n[r].props[t];if(s!=null&&(i=e?e(s):s))return i}}hasFocus(){if(Nr){let t=this.root.activeElement;if(t==this.dom)return true;if(!t||!this.dom.contains(t))return false;while(t&&this.dom!=t&&this.dom.contains(t)){if(t.contentEditable=="false")return false;t=t.parentElement}return true}return this.root.activeElement==this.dom}focus(){this.domObserver.stop();if(this.editable)Zr(this.dom);Zi(this);this.domObserver.start()}get root(){let t=this._root;if(t==null)for(let t=this.dom.parentNode;t;t=t.parentNode){if(t.nodeType==9||t.nodeType==11&&t.host){if(!t.getSelection)Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection();return this._root=t}}return t||document}updateRoot(){this._root=null}posAtCoords(t){return li(this,t)}coordsAtPos(t,e=1){return ai(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,r=-1){let i=this.docView.posFromDOM(t,e,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(t,e){return Mi(this,e||this.state,t)}pasteHTML(t,e){return As(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return As(this,t,null,true,e||new ClipboardEvent("paste"))}destroy(){if(!this.docView)return;Zn(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],Qs(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null;cr()}get isDestroyed(){return this.docView==null}dispatchEvent(t){return is(this,t)}dispatch(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();return Hr&&this.root.nodeType===11&&xr(this.dom.ownerDocument)==this.dom&&lo(this,t)||t}domSelection(){return this.root.getSelection()}}function Mo(t){let e=Object.create(null);e.class="ProseMirror";e.contenteditable=String(t.editable);t.someProp("attributes",(r=>{if(typeof r=="function")r=r(t.state);if(r)for(let t in r){if(t=="class")e.class+=" "+r[t];else if(t=="style")e.style=(e.style?e.style+";":"")+r[t];else if(!e[t]&&t!="contenteditable"&&t!="nodeName")e[t]=String(r[t])}}));if(!e.translate)e.translate="no";return[Hs.node(0,t.state.doc.content.size,e)]}function ko(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator";e.setAttribute("mark-placeholder","true");e.setAttribute("alt","");t.cursorWrapper={dom:e,deco:Hs.widget(t.state.selection.head,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function xo(t){return!t.someProp("editable",(e=>e(t.state)===false))}function So(t,e){let r=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(r)!=e.$anchor.start(r)}function Oo(t){let e=Object.create(null);function r(t){for(let r in t)if(!Object.prototype.hasOwnProperty.call(e,r))e[r]=t[r]}t.someProp("nodeViews",r);t.someProp("markViews",r);return e}function To(t,e){let r=0,i=0;for(let i in t){if(t[i]!=e[i])return true;r++}for(let t in e)i++;return r!=i}function Eo(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Po={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:"'"};var Ao={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};var Co=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var No=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var $o=0;$o<10;$o++)Po[48+$o]=Po[96+$o]=String($o);for(var $o=1;$o<=24;$o++)Po[$o+111]="F"+$o;for(var $o=65;$o<=90;$o++){Po[$o]=String.fromCharCode($o+32);Ao[$o]=String.fromCharCode($o)}for(var Ro in Po)if(!Ao.hasOwnProperty(Ro))Ao[Ro]=Po[Ro];function Do(t){var e=Co&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||No&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var r=!e&&t.key||(t.shiftKey?Ao:Po)[t.keyCode]||t.key||"Unidentified";if(r=="Esc")r="Escape";if(r=="Del")r="Delete";if(r=="Left")r="ArrowLeft";if(r=="Up")r="ArrowUp";if(r=="Right")r="ArrowRight";if(r=="Down")r="ArrowDown";return r}const Io=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function Lo(t){let e=t.split(/-(?!$)/),r=e[e.length-1];if(r=="Space")r=" ";let i,n,s,o;for(let t=0;t<e.length-1;t++){let r=e[t];if(/^(cmd|meta|m)$/i.test(r))o=true;else if(/^a(lt)?$/i.test(r))i=true;else if(/^(c|ctrl|control)$/i.test(r))n=true;else if(/^s(hift)?$/i.test(r))s=true;else if(/^mod$/i.test(r)){if(Io)o=true;else n=true}else throw new Error("Unrecognized modifier name: "+r)}if(i)r="Alt-"+r;if(n)r="Ctrl-"+r;if(o)r="Meta-"+r;if(s)r="Shift-"+r;return r}function Ho(t){let e=Object.create(null);for(let r in t)e[Lo(r)]=t[r];return e}function jo(t,e,r=true){if(e.altKey)t="Alt-"+t;if(e.ctrlKey)t="Ctrl-"+t;if(e.metaKey)t="Meta-"+t;if(r&&e.shiftKey)t="Shift-"+t;return t}function Bo(t){return new nr({props:{handleKeyDown:Jo(t)}})}function Jo(t){let e=Ho(t);return function(t,r){let i=Do(r),n,s=e[jo(i,r)];if(s&&s(t.state,t.dispatch,t))return true;if(i.length==1&&i!=" "){if(r.shiftKey){let n=e[jo(i,r,false)];if(n&&n(t.state,t.dispatch,t))return true}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(n=Po[r.keyCode])&&n!=i){let i=e[jo(n,r)];if(i&&i(t.state,t.dispatch,t))return true}}return false}}const zo=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function Fo(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0))return null;return r}const _o=(t,e,r)=>{let i=Fo(t,r);if(!i)return false;let n=Vo(i);if(!n){let r=i.blockRange(),n=r&&Xt(r);if(n==null)return false;if(e)e(t.tr.lift(r,n).scrollIntoView());return true}let s=n.nodeBefore;if(!s.type.spec.isolating&&dl(t,n,e))return true;if(i.parent.content.size==0&&(Wo(s,"end")||Fe.isSelectable(s))){let r=ge(t.doc,i.before(),i.after(),d.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(Wo(s,"end")?Le.findFrom(i.doc.resolve(i.mapping.map(n.pos,-1)),-1):Fe.create(i.doc,n.pos-s.nodeSize));e(i.scrollIntoView())}return true}}if(s.isAtom&&n.depth==i.depth-1){if(e)e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView());return true}return false};const Ko=(t,e,r)=>{let i=Fo(t,r);if(!i)return false;let n=Vo(i);return n?Uo(t,n,e):false};const qo=(t,e,r)=>{let i=Xo(t,r);if(!i)return false;let n=Zo(i);return n?Uo(t,n,e):false};function Uo(t,e,r){let i=e.nodeBefore,n=i,s=e.pos-1;for(;!n.isTextblock;s--){if(n.type.spec.isolating)return false;let t=n.lastChild;if(!t)return false;n=t}let o=e.nodeAfter,l=o,u=e.pos+1;for(;!l.isTextblock;u++){if(l.type.spec.isolating)return false;let t=l.firstChild;if(!t)return false;l=t}let f=ge(t.doc,s,u,d.empty);if(!f||f.from!=s||f instanceof _t&&f.slice.size>=u-s)return false;if(r){let e=t.tr.step(f);e.setSelection(Je.create(e.doc,s));r(e.scrollIntoView())}return true}function Wo(t,e,r=false){for(let i=t;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return true;if(r&&i.childCount!=1)return false}return false}const Go=(t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return false;if(i.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):i.parentOffset>0)return false;s=Vo(i)}let o=s&&s.nodeBefore;if(!o||!Fe.isSelectable(o))return false;if(e)e(t.tr.setSelection(Fe.create(t.doc,s.pos-o.nodeSize)).scrollIntoView());return true};function Vo(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Xo(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size))return null;return r}const Yo=(t,e,r)=>{let i=Xo(t,r);if(!i)return false;let n=Zo(i);if(!n)return false;let s=n.nodeAfter;if(dl(t,n,e))return true;if(i.parent.content.size==0&&(Wo(s,"start")||Fe.isSelectable(s))){let r=ge(t.doc,i.before(),i.after(),d.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(Wo(s,"start")?Le.findFrom(i.doc.resolve(i.mapping.map(n.pos)),1):Fe.create(i.doc,i.mapping.map(n.pos)));e(i.scrollIntoView())}return true}}if(s.isAtom&&n.depth==i.depth-1){if(e)e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView());return true}return false};const Qo=(t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return false;if(i.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size)return false;s=Zo(i)}let o=s&&s.nodeAfter;if(!o||!Fe.isSelectable(o))return false;if(e)e(t.tr.setSelection(Fe.create(t.doc,s.pos)).scrollIntoView());return true};function Zo(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let r=t.node(e);if(t.index(e)+1<r.childCount)return t.doc.resolve(t.after(e+1));if(r.type.spec.isolating)break}return null}const tl=(t,e)=>{let r=t.selection,i=r instanceof Fe,n;if(i){if(r.node.isTextblock||!he(t.doc,r.from))return false;n=r.from}else{n=ce(t.doc,r.from,-1);if(n==null)return false}if(e){let r=t.tr.join(n);if(i)r.setSelection(Fe.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize));e(r.scrollIntoView())}return true};const el=(t,e)=>{let r=t.selection,i;if(r instanceof Fe){if(r.node.isTextblock||!he(t.doc,r.to))return false;i=r.to}else{i=ce(t.doc,r.to,1);if(i==null)return false}if(e)e(t.tr.join(i).scrollIntoView());return true};const rl=(t,e)=>{let{$from:r,$to:i}=t.selection;let n=r.blockRange(i),s=n&&Xt(n);if(s==null)return false;if(e)e(t.tr.lift(n,s).scrollIntoView());return true};const il=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function nl(t){for(let e=0;e<t.edgeCount;e++){let{type:r}=t.edge(e);if(r.isTextblock&&!r.hasRequiredAttrs())return r}return null}const sl=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return false;let n=r.node(-1),s=r.indexAfter(-1),o=nl(n.contentMatchAt(s));if(!o||!n.canReplaceWith(s,s,o))return false;if(e){let i=r.after(),n=t.tr.replaceWith(i,i,o.createAndFill());n.setSelection(Le.near(n.doc.resolve(i),1));e(n.scrollIntoView())}return true};const ol=(t,e)=>{let r=t.selection,{$from:i,$to:n}=r;if(r instanceof Ke||i.parent.inlineContent||n.parent.inlineContent)return false;let s=nl(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return false;if(e){let r=(!i.parentOffset&&n.index()<n.parent.childCount?i:n).pos;let o=t.tr.insert(r,s.createAndFill());o.setSelection(Je.create(o.doc,r+1));e(o.scrollIntoView())}return true};const ll=(t,e)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return false;if(r.depth>1&&r.after()!=r.end(-1)){let i=r.before();if(ue(t.doc,i)){if(e)e(t.tr.split(i).scrollIntoView());return true}}let i=r.blockRange(),n=i&&Xt(i);if(n==null)return false;if(e)e(t.tr.lift(i,n).scrollIntoView());return true};function ul(t){return(e,r)=>{let{$from:i,$to:n}=e.selection;if(e.selection instanceof Fe&&e.selection.node.isBlock){if(!i.parentOffset||!ue(e.doc,i.pos))return false;if(r)r(e.tr.split(i.pos).scrollIntoView());return true}if(!i.parent.isBlock)return false;if(r){let s=n.parentOffset==n.parent.content.size;let o=e.tr;if(e.selection instanceof Je||e.selection instanceof Ke)o.deleteSelection();let l=i.depth==0?null:nl(i.node(-1).contentMatchAt(i.indexAfter(-1)));let u=t&&t(n.parent,s);let f=u?[u]:s&&l?[{type:l}]:undefined;let h=ue(o.doc,o.mapping.map(i.pos),1,f);if(!f&&!h&&ue(o.doc,o.mapping.map(i.pos),1,l?[{type:l}]:undefined)){if(l)f=[{type:l}];h=true}if(h){o.split(o.mapping.map(i.pos),1,f);if(!s&&!i.parentOffset&&i.parent.type!=l){let t=o.mapping.map(i.before()),e=o.doc.resolve(t);if(l&&i.node(-1).canReplaceWith(e.index(),e.index()+1,l))o.setNodeMarkup(o.mapping.map(i.before()),l)}}r(o.scrollIntoView())}return true}}const fl=ul();const hl=(t,e)=>{let{$from:r,to:i}=t.selection,n;let s=r.sharedDepth(i);if(s==0)return false;n=r.before(s);if(e)e(t.tr.setSelection(Fe.create(t.doc,n)));return true};const al=(t,e)=>{if(e)e(t.tr.setSelection(new Ke(t.doc)));return true};function cl(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s=e.index();if(!i||!n||!i.type.compatibleContent(n.type))return false;if(!i.content.size&&e.parent.canReplace(s-1,s)){if(r)r(t.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(s,s+1)||!(n.isTextblock||he(t.doc,e.pos)))return false;if(r)r(t.tr.clearIncompatible(e.pos,i.type,i.contentMatchAt(i.childCount)).join(e.pos).scrollIntoView());return true}function dl(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s,o;if(i.type.spec.isolating||n.type.spec.isolating)return false;if(cl(t,e,r))return true;let u=e.parent.canReplace(e.index(),e.index()+1);if(u&&(s=(o=i.contentMatchAt(i.childCount)).findWrapping(n.type))&&o.matchType(s[0]||n.type).validEnd){if(r){let o=e.pos+n.nodeSize,u=l.empty;for(let t=s.length-1;t>=0;t--)u=l.from(s[t].create(null,u));u=l.from(i.copy(u));let f=t.tr.step(new Kt(e.pos-1,o,e.pos,o,new d(u,1,0),s.length,true));let h=o+2*s.length;if(he(f.doc,h))f.join(h);r(f.scrollIntoView())}return true}let f=Le.findFrom(e,1);let h=f&&f.$from.blockRange(f.$to),a=h&&Xt(h);if(a!=null&&a>=e.depth){if(r)r(t.tr.lift(h,a).scrollIntoView());return true}if(u&&Wo(n,"start",true)&&Wo(i,"end")){let s=i,o=[];for(;;){o.push(s);if(s.isTextblock)break;s=s.lastChild}let u=n,f=1;for(;!u.isTextblock;u=u.firstChild)f++;if(s.canReplace(s.childCount,s.childCount,u.content)){if(r){let i=l.empty;for(let t=o.length-1;t>=0;t--)i=l.from(o[t].copy(i));let s=t.tr.step(new Kt(e.pos-o.length,e.pos+n.nodeSize,e.pos+f,e.pos+n.nodeSize-f,new d(i,o.length,0),0,true));r(s.scrollIntoView())}return true}}return false}function pl(t){return function(e,r){let i=e.selection,n=t<0?i.$from:i.$to;let s=n.depth;while(n.node(s).isInline){if(!s)return false;s--}if(!n.node(s).isTextblock)return false;if(r)r(e.tr.setSelection(Je.create(e.doc,t<0?n.start(s):n.end(s))));return true}}const ml=pl(-1);const gl=pl(1);function wl(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection;let o=n.blockRange(s),l=o&&Qt(o,t,e);if(!l)return false;if(i)i(r.tr.wrap(o,l).scrollIntoView());return true}}function bl(t,e=null){return function(r,i){let n=false;for(let i=0;i<r.selection.ranges.length&&!n;i++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[i];r.doc.nodesBetween(s,o,((i,s)=>{if(n)return false;if(!i.isTextblock||i.hasMarkup(t,e))return;if(i.type==t){n=true}else{let e=r.doc.resolve(s),i=e.index();n=e.parent.canReplaceWith(i,i+1,t)}}))}if(!n)return false;if(i){let n=r.tr;for(let i=0;i<r.selection.ranges.length;i++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[i];n.setBlockType(s,o,t,e)}i(n.scrollIntoView())}return true}}function vl(...t){return function(e,r,i){for(let n=0;n<t.length;n++)if(t[n](e,r,i))return true;return false}}let yl=vl(zo,_o,Go);let Ml=vl(zo,Yo,Qo);const kl={Enter:vl(il,ol,ll,fl),"Mod-Enter":sl,Backspace:yl,"Mod-Backspace":yl,"Shift-Backspace":yl,Delete:Ml,"Mod-Delete":Ml,"Mod-a":al};const xl={"Ctrl-h":kl["Backspace"],"Alt-Backspace":kl["Mod-Backspace"],"Ctrl-d":kl["Delete"],"Ctrl-Alt-Backspace":kl["Mod-Delete"],"Alt-Delete":kl["Mod-Delete"],"Alt-d":kl["Mod-Delete"],"Ctrl-a":ml,"Ctrl-e":gl};for(let t in kl)xl[t]=kl[t];typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;function Sl(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection;let o=n.blockRange(s),l=false,u=o;if(!o)return false;if(o.depth>=2&&n.node(o.depth-1).type.compatibleContent(t)&&o.startIndex==0){if(n.index(o.depth-1)==0)return false;let t=r.doc.resolve(o.start-2);u=new C(t,t,o.depth);if(o.endIndex<o.parent.childCount)o=new C(n,r.doc.resolve(s.end(o.depth)),o.depth);l=true}let f=Qt(u,t,e,o);if(!f)return false;if(i)i(Ol(r.tr,o,f,l,t).scrollIntoView());return true}}function Ol(t,e,r,i,n){let s=l.empty;for(let t=r.length-1;t>=0;t--)s=l.from(r[t].type.create(r[t].attrs,s));t.step(new Kt(e.start-(i?2:0),e.end,e.start,e.end,new d(s,0,0),r.length,true));let o=0;for(let t=0;t<r.length;t++)if(r[t].type==n)o=t+1;let u=r.length-o;let f=e.start+r.length-(i?2:0),h=e.parent;for(let r=e.startIndex,i=e.endIndex,n=true;r<i;r++,n=false){if(!n&&ue(t.doc,f,u)){t.split(f,u);f+=2*u}f+=h.child(r).nodeSize}return t}function Tl(t){return function(e,r){let{$from:i,$to:n}=e.selection;let s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;if(!r)return true;if(i.node(s.depth-1).type==t)return El(e,r,t,s);else return Pl(e,r,s)}}function El(t,e,r,i){let n=t.tr,s=i.end,o=i.$to.end(i.depth);if(s<o){n.step(new Kt(s-1,o,s,o,new d(l.from(r.create(null,i.parent.copy())),1,0),1,true));i=new C(n.doc.resolve(i.$from.pos),n.doc.resolve(o),i.depth)}const u=Xt(i);if(u==null)return false;n.lift(i,u);let f=n.mapping.map(s,-1)-1;if(he(n.doc,f))n.join(f);e(n.scrollIntoView());return true}function Pl(t,e,r){let i=t.tr,n=r.parent;for(let t=r.end,e=r.endIndex-1,s=r.startIndex;e>s;e--){t-=n.child(e).nodeSize;i.delete(t-1,t+1)}let s=i.doc.resolve(r.start),o=s.nodeAfter;if(i.mapping.map(r.end)!=r.start+s.nodeAfter.nodeSize)return false;let u=r.startIndex==0,f=r.endIndex==n.childCount;let h=s.node(-1),a=s.index(-1);if(!h.canReplace(a+(u?0:1),a+1,o.content.append(f?l.empty:l.from(n))))return false;let c=s.pos,p=c+o.nodeSize;i.step(new Kt(c-(u?1:0),p+(f?1:0),c+1,p-1,new d((u?l.empty:l.from(n.copy(l.empty))).append(f?l.empty:l.from(n.copy(l.empty))),u?0:1,f?0:1),u?0:1));e(i.scrollIntoView());return true}function Al(t){return function(e,r){let{$from:i,$to:n}=e.selection;let s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;let o=s.startIndex;if(o==0)return false;let u=s.parent,f=u.child(o-1);if(f.type!=t)return false;if(r){let i=f.lastChild&&f.lastChild.type==u.type;let n=l.from(i?t.create():null);let o=new d(l.from(t.create(null,l.from(u.type.create(null,n)))),i?3:1,0);let h=s.start,a=s.end;r(e.tr.step(new Kt(h-(i?3:1),a,h,a,o,1,true)).scrollIntoView())}return true}}function Cl(t){const{state:e,transaction:r}=t;let{selection:i}=r;let{doc:n}=r;let{storedMarks:s}=r;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return i},get doc(){return n},get tr(){i=r.selection;n=r.doc;s=r.storedMarks;return r}}}class Nl{constructor(t){this.editor=t.editor;this.rawCommands=this.editor.extensionManager.commands;this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:r}=this;const{view:i}=e;const{tr:n}=r;const s=this.buildProps(n);return Object.fromEntries(Object.entries(t).map((([t,e])=>{const r=(...t)=>{const r=e(...t)(s);if(!n.getMeta("preventDispatch")&&!this.hasCustomState){i.dispatch(n)}return r};return[t,r]})))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=true){const{rawCommands:r,editor:i,state:n}=this;const{view:s}=i;const o=[];const l=!!t;const u=t||n.tr;const f=()=>{if(!l&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState){s.dispatch(u)}return o.every((t=>t===true))};const h={...Object.fromEntries(Object.entries(r).map((([t,r])=>{const i=(...t)=>{const i=this.buildProps(u,e);const n=r(...t)(i);o.push(n);return h};return[t,i]}))),run:f};return h}createCan(t){const{rawCommands:e,state:r}=this;const i=false;const n=t||r.tr;const s=this.buildProps(n,i);const o=Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...s,dispatch:undefined})])));return{...o,chain:()=>this.createChain(n,i)}}buildProps(t,e=true){const{rawCommands:r,editor:i,state:n}=this;const{view:s}=i;const o={tr:t,editor:i,view:s,state:Cl({state:n,transaction:t}),dispatch:e?()=>undefined:undefined,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map((([t,e])=>[t,(...t)=>e(...t)(o)])))}};return o}}class $l{constructor(){this.callbacks={}}on(t,e){if(!this.callbacks[t]){this.callbacks[t]=[]}this.callbacks[t].push(e);return this}emit(t,...e){const r=this.callbacks[t];if(r){r.forEach((t=>t.apply(this,e)))}return this}off(t,e){const r=this.callbacks[t];if(r){if(e){this.callbacks[t]=r.filter((t=>t!==e))}else{delete this.callbacks[t]}}return this}removeAllListeners(){this.callbacks={}}}function Rl(t,e,r){if(t.config[e]===undefined&&t.parent){return Rl(t.parent,e,r)}if(typeof t.config[e]==="function"){const i=t.config[e].bind({...r,parent:t.parent?Rl(t.parent,e,r):null});return i}return t.config[e]}function Dl(t){const e=t.filter((t=>t.type==="extension"));const r=t.filter((t=>t.type==="node"));const i=t.filter((t=>t.type==="mark"));return{baseExtensions:e,nodeExtensions:r,markExtensions:i}}function Il(t){const e=[];const{nodeExtensions:r,markExtensions:i}=Dl(t);const n=[...r,...i];const s={default:null,rendered:true,renderHTML:null,parseHTML:null,keepOnSplit:true,isRequired:false};t.forEach((t=>{const r={name:t.name,options:t.options,storage:t.storage};const i=Rl(t,"addGlobalAttributes",r);if(!i){return}const n=i();n.forEach((t=>{t.types.forEach((r=>{Object.entries(t.attributes).forEach((([t,i])=>{e.push({type:r,name:t,attribute:{...s,...i}})}))}))}))}));n.forEach((t=>{const r={name:t.name,options:t.options,storage:t.storage};const i=Rl(t,"addAttributes",r);if(!i){return}const n=i();Object.entries(n).forEach((([r,i])=>{const n={...s,...i};if(typeof(n===null||n===void 0?void 0:n.default)==="function"){n.default=n.default()}if((n===null||n===void 0?void 0:n.isRequired)&&(n===null||n===void 0?void 0:n.default)===undefined){delete n.default}e.push({type:t.name,name:r,attribute:n})}))}));return e}function Ll(t,e){if(typeof t==="string"){if(!e.nodes[t]){throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`)}return e.nodes[t]}return t}function Hl(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const r={...t};Object.entries(e).forEach((([t,e])=>{const i=r[t];if(!i){r[t]=e;return}if(t==="class"){const i=e?e.split(" "):[];const n=r[t]?r[t].split(" "):[];const s=i.filter((t=>!n.includes(t)));r[t]=[...n,...s].join(" ")}else if(t==="style"){r[t]=[r[t],e].join("; ")}else{r[t]=e}}));return r}),{})}function jl(t,e){return e.filter((t=>t.attribute.rendered)).map((e=>{if(!e.attribute.renderHTML){return{[e.name]:t.attrs[e.name]}}return e.attribute.renderHTML(t.attrs)||{}})).reduce(((t,e)=>Hl(t,e)),{})}function Bl(t){return typeof t==="function"}function Jl(t,e=undefined,...r){if(Bl(t)){if(e){return t.bind(e)(...r)}return t(...r)}return t}function zl(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Fl(t){if(typeof t!=="string"){return t}if(t.match(/^[+-]?(?:\d*\.)?\d+$/)){return Number(t)}if(t==="true"){return true}if(t==="false"){return false}return t}function _l(t,e){if(t.style){return t}return{...t,getAttrs:r=>{const i=t.getAttrs?t.getAttrs(r):t.attrs;if(i===false){return false}const n=e.reduce(((t,e)=>{const i=e.attribute.parseHTML?e.attribute.parseHTML(r):Fl(r.getAttribute(e.name));if(i===null||i===undefined){return t}return{...t,[e.name]:i}}),{});return{...i,...n}}}}function Kl(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>{if(t==="attrs"&&zl(e)){return false}return e!==null&&e!==undefined})))}function ql(t,e){var r;const i=Il(t);const{nodeExtensions:n,markExtensions:s}=Dl(t);const o=(r=n.find((t=>Rl(t,"topNode"))))===null||r===void 0?void 0:r.name;const l=Object.fromEntries(n.map((r=>{const n=i.filter((t=>t.type===r.name));const s={name:r.name,options:r.options,storage:r.storage,editor:e};const o=t.reduce(((t,e)=>{const i=Rl(e,"extendNodeSchema",s);return{...t,...i?i(r):{}}}),{});const l=Kl({...o,content:Jl(Rl(r,"content",s)),marks:Jl(Rl(r,"marks",s)),group:Jl(Rl(r,"group",s)),inline:Jl(Rl(r,"inline",s)),atom:Jl(Rl(r,"atom",s)),selectable:Jl(Rl(r,"selectable",s)),draggable:Jl(Rl(r,"draggable",s)),code:Jl(Rl(r,"code",s)),defining:Jl(Rl(r,"defining",s)),isolating:Jl(Rl(r,"isolating",s)),attrs:Object.fromEntries(n.map((t=>{var e;return[t.name,{default:(e=t===null||t===void 0?void 0:t.attribute)===null||e===void 0?void 0:e.default}]})))});const u=Jl(Rl(r,"parseHTML",s));if(u){l.parseDOM=u.map((t=>_l(t,n)))}const f=Rl(r,"renderHTML",s);if(f){l.toDOM=t=>f({node:t,HTMLAttributes:jl(t,n)})}const h=Rl(r,"renderText",s);if(h){l.toText=h}return[r.name,l]})));const u=Object.fromEntries(s.map((r=>{const n=i.filter((t=>t.type===r.name));const s={name:r.name,options:r.options,storage:r.storage,editor:e};const o=t.reduce(((t,e)=>{const i=Rl(e,"extendMarkSchema",s);return{...t,...i?i(r):{}}}),{});const l=Kl({...o,inclusive:Jl(Rl(r,"inclusive",s)),excludes:Jl(Rl(r,"excludes",s)),group:Jl(Rl(r,"group",s)),spanning:Jl(Rl(r,"spanning",s)),code:Jl(Rl(r,"code",s)),attrs:Object.fromEntries(n.map((t=>{var e;return[t.name,{default:(e=t===null||t===void 0?void 0:t.attribute)===null||e===void 0?void 0:e.default}]})))});const u=Jl(Rl(r,"parseHTML",s));if(u){l.parseDOM=u.map((t=>_l(t,n)))}const f=Rl(r,"renderHTML",s);if(f){l.toDOM=t=>f({mark:t,HTMLAttributes:jl(t,n)})}return[r.name,l]})));return new et({topNode:o,nodes:l,marks:u})}function Ul(t,e){return e.nodes[t]||e.marks[t]||null}function Wl(t,e){if(Array.isArray(e)){return e.some((e=>{const r=typeof e==="string"?e:e.name;return r===t.name}))}return e}const Gl=(t,e=500)=>{let r="";const i=t.parentOffset;t.parent.nodesBetween(Math.max(0,i-e),i,((t,e,n,s)=>{var o,l;const u=((l=(o=t.type.spec).toText)===null||l===void 0?void 0:l.call(o,{node:t,pos:e,parent:n,index:s}))||t.textContent||"%leaf%";r+=u.slice(0,Math.max(0,i-e))}));return r};function Vl(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Xl{constructor(t){this.find=t.find;this.handler=t.handler}}const Yl=(t,e)=>{if(Vl(e)){return e.exec(t)}const r=e(t);if(!r){return null}const i=[r.text];i.index=r.index;i.input=t;i.data=r.data;if(r.replaceWith){if(!r.text.includes(r.replaceWith)){console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".')}i.push(r.replaceWith)}return i};function Ql(t){var e;const{editor:r,from:i,to:n,text:s,rules:o,plugin:l}=t;const{view:u}=r;if(u.composing){return false}const f=u.state.doc.resolve(i);if(f.parent.type.spec.code||!!((e=f.nodeBefore||f.nodeAfter)===null||e===void 0?void 0:e.marks.find((t=>t.type.spec.code)))){return false}let h=false;const a=Gl(f)+s;o.forEach((t=>{if(h){return}const e=Yl(a,t.find);if(!e){return}const o=u.state.tr;const f=Cl({state:u.state,transaction:o});const c={from:i-(e[0].length-s.length),to:n};const{commands:d,chain:p,can:m}=new Nl({editor:r,state:f});const g=t.handler({state:f,range:c,match:e,commands:d,chain:p,can:m});if(g===null||!o.steps.length){return}o.setMeta(l,{transform:o,from:i,to:n,text:s});u.dispatch(o);h=true}));return h}function Zl(t){const{editor:e,rules:r}=t;const i=new nr({state:{init(){return null},apply(t,n){const s=t.getMeta(i);if(s){return s}const o=t.getMeta("applyInputRules");const l=!!o;if(l){setTimeout((()=>{const{from:t,text:n}=o;const s=t+n.length;Ql({editor:e,from:t,to:s,text:n,rules:r,plugin:i})}))}return t.selectionSet||t.docChanged?null:n}},props:{handleTextInput(t,n,s,o){return Ql({editor:e,from:n,to:s,text:o,rules:r,plugin:i})},handleDOMEvents:{compositionend:t=>{setTimeout((()=>{const{$cursor:n}=t.state.selection;if(n){Ql({editor:e,from:n.pos,to:n.pos,text:"",rules:r,plugin:i})}}));return false}},handleKeyDown(t,n){if(n.key!=="Enter"){return false}const{$cursor:s}=t.state.selection;if(s){return Ql({editor:e,from:s.pos,to:s.pos,text:"\n",rules:r,plugin:i})}return false}},isInputRules:true});return i}function tu(t){return typeof t==="number"}class eu{constructor(t){this.find=t.find;this.handler=t.handler}}const ru=(t,e,r)=>{if(Vl(e)){return[...t.matchAll(e)]}const i=e(t,r);if(!i){return[]}return i.map((e=>{const r=[e.text];r.index=e.index;r.input=t;r.data=e.data;if(e.replaceWith){if(!e.text.includes(e.replaceWith)){console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".')}r.push(e.replaceWith)}return r}))};function iu(t){const{editor:e,state:r,from:i,to:n,rule:s,pasteEvent:o,dropEvent:l}=t;const{commands:u,chain:f,can:h}=new Nl({editor:e,state:r});const a=[];r.doc.nodesBetween(i,n,((t,e)=>{if(!t.isTextblock||t.type.spec.code){return}const c=Math.max(i,e);const d=Math.min(n,e+t.content.size);const p=t.textBetween(c-e,d-e,undefined,"");const m=ru(p,s.find,o);m.forEach((t=>{if(t.index===undefined){return}const e=c+t.index+1;const i=e+t[0].length;const n={from:r.tr.mapping.map(e),to:r.tr.mapping.map(i)};const d=s.handler({state:r,range:n,match:t,commands:u,chain:f,can:h,pasteEvent:o,dropEvent:l});a.push(d)}))}));const c=a.every((t=>t!==null));return c}const nu=t=>{var e;const r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});(e=r.clipboardData)===null||e===void 0?void 0:e.setData("text/html",t);return r};function su(t){const{editor:e,rules:r}=t;let i=null;let n=false;let s=false;let o=typeof ClipboardEvent!=="undefined"?new ClipboardEvent("paste"):null;let l=typeof DragEvent!=="undefined"?new DragEvent("drop"):null;const u=({state:t,from:r,to:i,rule:n,pasteEvt:s})=>{const u=t.tr;const f=Cl({state:t,transaction:u});const h=iu({editor:e,state:f,from:Math.max(r-1,0),to:i.b-1,rule:n,pasteEvent:s,dropEvent:l});if(!h||!u.steps.length){return}l=typeof DragEvent!=="undefined"?new DragEvent("drop"):null;o=typeof ClipboardEvent!=="undefined"?new ClipboardEvent("paste"):null;return u};const f=r.map((t=>new nr({view(t){const e=e=>{var r;i=((r=t.dom.parentElement)===null||r===void 0?void 0:r.contains(e.target))?t.dom.parentElement:null};window.addEventListener("dragstart",e);return{destroy(){window.removeEventListener("dragstart",e)}}},props:{handleDOMEvents:{drop:(t,e)=>{s=i===t.dom.parentElement;l=e;return false},paste:(t,e)=>{var r;const i=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/html");o=e;n=!!(i===null||i===void 0?void 0:i.includes("data-pm-slice"));return false}}},appendTransaction:(e,r,i)=>{const l=e[0];const f=l.getMeta("uiEvent")==="paste"&&!n;const h=l.getMeta("uiEvent")==="drop"&&!s;const a=l.getMeta("applyPasteRules");const c=!!a;if(!f&&!h&&!c){return}if(c){const{from:e,text:r}=a;const n=e+r.length;const s=nu(r);return u({rule:t,state:i,from:e,to:{b:n},pasteEvt:s})}const d=r.doc.content.findDiffStart(i.doc.content);const p=r.doc.content.findDiffEnd(i.doc.content);if(!tu(d)||!p||d===p.b){return}return u({rule:t,state:i,from:d,to:p,pasteEvt:o})}})));return f}function ou(t){const e=t.filter(((e,r)=>t.indexOf(e)!==r));return[...new Set(e)]}class lu{constructor(t,e){this.splittableMarks=[];this.editor=e;this.extensions=lu.resolve(t);this.schema=ql(this.extensions,e);this.setupExtensions()}static resolve(t){const e=lu.sort(lu.flatten(t));const r=ou(e.map((t=>t.name)));if(r.length){console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`)}return e}static flatten(t){return t.map((t=>{const e={name:t.name,options:t.options,storage:t.storage};const r=Rl(t,"addExtensions",e);if(r){return[t,...this.flatten(r())]}return t})).flat(10)}static sort(t){const e=100;return t.sort(((t,r)=>{const i=Rl(t,"priority")||e;const n=Rl(r,"priority")||e;if(i>n){return-1}if(i<n){return 1}return 0}))}get commands(){return this.extensions.reduce(((t,e)=>{const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Ul(e.name,this.schema)};const i=Rl(e,"addCommands",r);if(!i){return t}return{...t,...i()}}),{})}get plugins(){const{editor:t}=this;const e=lu.sort([...this.extensions].reverse());const r=[];const i=[];const n=e.map((e=>{const n={name:e.name,options:e.options,storage:e.storage,editor:t,type:Ul(e.name,this.schema)};const s=[];const o=Rl(e,"addKeyboardShortcuts",n);let l={};if(e.type==="mark"&&e.config.exitable){l.ArrowRight=()=>bh.handleExit({editor:t,mark:e})}if(o){const e=Object.fromEntries(Object.entries(o()).map((([e,r])=>[e,()=>r({editor:t})])));l={...l,...e}}const u=Bo(l);s.push(u);const f=Rl(e,"addInputRules",n);if(Wl(e,t.options.enableInputRules)&&f){r.push(...f())}const h=Rl(e,"addPasteRules",n);if(Wl(e,t.options.enablePasteRules)&&h){i.push(...h())}const a=Rl(e,"addProseMirrorPlugins",n);if(a){const t=a();s.push(...t)}return s})).flat();return[Zl({editor:t,rules:r}),...su({editor:t,rules:i}),...n]}get attributes(){return Il(this.extensions)}get nodeViews(){const{editor:t}=this;const{nodeExtensions:e}=Dl(this.extensions);return Object.fromEntries(e.filter((t=>!!Rl(t,"addNodeView"))).map((e=>{const r=this.attributes.filter((t=>t.type===e.name));const i={name:e.name,options:e.options,storage:e.storage,editor:t,type:Ll(e.name,this.schema)};const n=Rl(e,"addNodeView",i);if(!n){return[]}const s=(i,s,o,l)=>{const u=jl(i,r);return n()({editor:t,node:i,getPos:o,decorations:l,HTMLAttributes:u,extension:e})};return[e.name,s]})))}setupExtensions(){this.extensions.forEach((t=>{var e;this.editor.extensionStorage[t.name]=t.storage;const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Ul(t.name,this.schema)};if(t.type==="mark"){const i=(e=Jl(Rl(t,"keepOnSplit",r)))!==null&&e!==void 0?e:true;if(i){this.splittableMarks.push(t.name)}}const i=Rl(t,"onBeforeCreate",r);const n=Rl(t,"onCreate",r);const s=Rl(t,"onUpdate",r);const o=Rl(t,"onSelectionUpdate",r);const l=Rl(t,"onTransaction",r);const u=Rl(t,"onFocus",r);const f=Rl(t,"onBlur",r);const h=Rl(t,"onDestroy",r);if(i){this.editor.on("beforeCreate",i)}if(n){this.editor.on("create",n)}if(s){this.editor.on("update",s)}if(o){this.editor.on("selectionUpdate",o)}if(l){this.editor.on("transaction",l)}if(u){this.editor.on("focus",u)}if(f){this.editor.on("blur",f)}if(h){this.editor.on("destroy",h)}}))}}function uu(t){return Object.prototype.toString.call(t).slice(8,-1)}function fu(t){if(uu(t)!=="Object"){return false}return t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function hu(t,e){const r={...t};if(fu(t)&&fu(e)){Object.keys(e).forEach((i=>{if(fu(e[i])){if(!(i in t)){Object.assign(r,{[i]:e[i]})}else{r[i]=hu(t[i],e[i])}}else{Object.assign(r,{[i]:e[i]})}}))}return r}class au{constructor(t={}){this.type="extension";this.name="extension";this.parent=null;this.child=null;this.config={name:this.name,defaultOptions:{}};this.config={...this.config,...t};this.name=this.config.name;if(t.defaultOptions&&Object.keys(t.defaultOptions).length>0){console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`)}this.options=this.config.defaultOptions;if(this.config.addOptions){this.options=Jl(Rl(this,"addOptions",{name:this.name}))}this.storage=Jl(Rl(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new au(t)}configure(t={}){const e=this.extend();e.parent=this.parent;e.options=hu(this.options,t);e.storage=Jl(Rl(e,"addStorage",{name:e.name,options:e.options}));return e}extend(t={}){const e=new au({...this.config,...t});e.parent=this;this.child=e;e.name=t.name?t.name:e.parent.name;if(t.defaultOptions){console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`)}e.options=Jl(Rl(e,"addOptions",{name:e.name}));e.storage=Jl(Rl(e,"addStorage",{name:e.name,options:e.options}));return e}}function cu(t,e,r){const{from:i,to:n}=e;const{blockSeparator:s="\n\n",textSerializers:o={}}=r||{};let l="";t.nodesBetween(i,n,((t,r,u,f)=>{var h;if(t.isBlock&&r>i){l+=s}const a=o===null||o===void 0?void 0:o[t.type.name];if(a){if(u){l+=a({node:t,pos:r,parent:u,index:f,range:e})}return false}if(t.isText){l+=(h=t===null||t===void 0?void 0:t.text)===null||h===void 0?void 0:h.slice(Math.max(i,r)-r,n-r)}}));return l}function du(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}const pu=au.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:undefined}},addProseMirrorPlugins(){return[new nr({key:new lr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this;const{state:e,schema:r}=t;const{doc:i,selection:n}=e;const{ranges:s}=n;const o=Math.min(...s.map((t=>t.$from.pos)));const l=Math.max(...s.map((t=>t.$to.pos)));const u=du(r);const f={from:o,to:l};return cu(i,f,{...this.options.blockSeparator!==undefined?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}});const mu=()=>({editor:t,view:e})=>{requestAnimationFrame((()=>{var r;if(!t.isDestroyed){e.dom.blur();(r=window===null||window===void 0?void 0:window.getSelection())===null||r===void 0?void 0:r.removeAllRanges()}}));return true};const gu=(t=false)=>({commands:e})=>e.setContent("",t);const wu=()=>({state:t,tr:e,dispatch:r})=>{const{selection:i}=e;const{ranges:n}=i;if(!r){return true}n.forEach((({$from:r,$to:i})=>{t.doc.nodesBetween(r.pos,i.pos,((t,r)=>{if(t.type.isText){return}const{doc:i,mapping:n}=e;const s=i.resolve(n.map(r));const o=i.resolve(n.map(r+t.nodeSize));const l=s.blockRange(o);if(!l){return}const u=Xt(l);if(t.type.isTextblock){const{defaultType:t}=s.parent.contentMatchAt(s.index());e.setNodeMarkup(l.start,t)}if(u||u===0){e.lift(l,u)}}))}));return true};const bu=t=>e=>t(e);const vu=()=>({state:t,dispatch:e})=>ol(t,e);const yu=(t,e)=>({editor:r,tr:i})=>{const{state:n}=r;const s=n.doc.slice(t.from,t.to);i.deleteRange(t.from,t.to);const o=i.mapping.map(e);i.insert(o,s.content);i.setSelection(new Je(i.doc.resolve(o-1)));return true};const Mu=()=>({tr:t,dispatch:e})=>{const{selection:r}=t;const i=r.$anchor.node();if(i.content.size>0){return false}const n=t.selection.$anchor;for(let r=n.depth;r>0;r-=1){const s=n.node(r);if(s.type===i.type){if(e){const e=n.before(r);const i=n.after(r);t.delete(e,i).scrollIntoView()}return true}}return false};const ku=t=>({tr:e,state:r,dispatch:i})=>{const n=Ll(t,r.schema);const s=e.selection.$anchor;for(let t=s.depth;t>0;t-=1){const r=s.node(t);if(r.type===n){if(i){const r=s.before(t);const i=s.after(t);e.delete(r,i).scrollIntoView()}return true}}return false};const xu=t=>({tr:e,dispatch:r})=>{const{from:i,to:n}=t;if(r){e.delete(i,n)}return true};const Su=()=>({state:t,dispatch:e})=>zo(t,e);const Ou=()=>({commands:t})=>t.keyboardShortcut("Enter");const Tu=()=>({state:t,dispatch:e})=>sl(t,e);function Eu(t,e,r={strict:true}){const i=Object.keys(e);if(!i.length){return true}return i.every((i=>{if(r.strict){return e[i]===t[i]}if(Vl(e[i])){return e[i].test(t[i])}return e[i]===t[i]}))}function Pu(t,e,r={}){return t.find((t=>t.type===e&&Eu(t.attrs,r)))}function Au(t,e,r={}){return!!Pu(t,e,r)}function Cu(t,e,r={}){if(!t||!e){return}let i=t.parent.childAfter(t.parentOffset);if(t.parentOffset===i.offset&&i.offset!==0){i=t.parent.childBefore(t.parentOffset)}if(!i.node){return}const n=Pu([...i.node.marks],e,r);if(!n){return}let s=i.index;let o=t.start()+i.offset;let l=s+1;let u=o+i.node.nodeSize;Pu([...i.node.marks],e,r);while(s>0&&n.isInSet(t.parent.child(s-1).marks)){s-=1;o-=t.parent.child(s).nodeSize}while(l<t.parent.childCount&&Au([...t.parent.child(l).marks],e,r)){u+=t.parent.child(l).nodeSize;l+=1}return{from:o,to:u}}function Nu(t,e){if(typeof t==="string"){if(!e.marks[t]){throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`)}return e.marks[t]}return t}const $u=(t,e={})=>({tr:r,state:i,dispatch:n})=>{const s=Nu(t,i.schema);const{doc:o,selection:l}=r;const{$from:u,from:f,to:h}=l;if(n){const t=Cu(u,s,e);if(t&&t.from<=f&&t.to>=h){const e=Je.create(o,t.from,t.to);r.setSelection(e)}}return true};const Ru=t=>e=>{const r=typeof t==="function"?t(e):t;for(let t=0;t<r.length;t+=1){if(r[t](e)){return true}}return false};function Du(t){return t instanceof Je}function Iu(t=0,e=0,r=0){return Math.min(Math.max(t,e),r)}function Lu(t,e=null){if(!e){return null}const r=Le.atStart(t);const i=Le.atEnd(t);if(e==="start"||e===true){return r}if(e==="end"){return i}const n=r.from;const s=i.to;if(e==="all"){return Je.create(t,Iu(0,n,s),Iu(t.content.size,n,s))}return Je.create(t,Iu(e,n,s),Iu(e,n,s))}function Hu(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const ju=(t=null,e={})=>({editor:r,view:i,tr:n,dispatch:s})=>{e={scrollIntoView:true,...e};const o=()=>{if(Hu()){i.dom.focus()}requestAnimationFrame((()=>{if(!r.isDestroyed){i.focus();if(e===null||e===void 0?void 0:e.scrollIntoView){r.commands.scrollIntoView()}}}))};if(i.hasFocus()&&t===null||t===false){return true}if(s&&t===null&&!Du(r.state.selection)){o();return true}const l=Lu(n.doc,t)||r.state.selection;const u=r.state.selection.eq(l);if(s){if(!u){n.setSelection(l)}if(u&&n.storedMarks){n.setStoredMarks(n.storedMarks)}o()}return true};const Bu=(t,e)=>r=>t.every(((t,i)=>e(t,{...r,index:i})));const Ju=(t,e)=>({tr:r,commands:i})=>i.insertContentAt({from:r.selection.from,to:r.selection.to},t,e);const zu=t=>{const e=t.childNodes;for(let r=e.length-1;r>=0;r-=1){const i=e[r];if(i.nodeType===3&&i.nodeValue&&/^(\n\s\s|\n)$/.test(i.nodeValue)){t.removeChild(i)}else if(i.nodeType===1){zu(i)}}return t};function Fu(t){const e=`<body>${t}</body>`;const r=(new window.DOMParser).parseFromString(e,"text/html").body;return zu(r)}function _u(t,e,r){r={slice:true,parseOptions:{},...r};const i=typeof t==="object"&&t!==null;const n=typeof t==="string";if(i){try{const r=Array.isArray(t)&&t.length>0;if(r){return l.fromArray(t.map((t=>e.nodeFromJSON(t))))}return e.nodeFromJSON(t)}catch(i){console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i);return _u("",e,r)}}if(n){const i=st.fromSchema(e);return r.slice?i.parseSlice(Fu(t),r.parseOptions).content:i.parse(Fu(t),r.parseOptions)}return _u("",e,r)}function Ku(t,e,r){const i=t.steps.length-1;if(i<e){return}const n=t.steps[i];if(!(n instanceof _t||n instanceof Kt)){return}const s=t.mapping.maps[i];let o=0;s.forEach(((t,e,r,i)=>{if(o===0){o=i}}));t.setSelection(Le.near(t.doc.resolve(o),r))}const qu=t=>t.toString().startsWith("<");const Uu=(t,e,r)=>({tr:i,dispatch:n,editor:s})=>{if(n){r={parseOptions:{},updateSelection:true,applyInputRules:false,applyPasteRules:false,...r};const n=_u(e,s.schema,{parseOptions:{preserveWhitespace:"full",...r.parseOptions}});if(n.toString()==="<>"){return true}let{from:o,to:l}=typeof t==="number"?{from:t,to:t}:{from:t.from,to:t.to};let u=true;let f=true;const h=qu(n)?n:[n];h.forEach((t=>{t.check();u=u?t.isText&&t.marks.length===0:false;f=f?t.isBlock:false}));if(o===l&&f){const{parent:t}=i.doc.resolve(o);const e=t.isTextblock&&!t.type.spec.code&&!t.childCount;if(e){o-=1;l+=1}}let a;if(u){if(Array.isArray(e)){a=e.map((t=>t.text||"")).join("")}else if(typeof e==="object"&&!!e&&!!e.text){a=e.text}else{a=e}i.insertText(a,o,l)}else{a=n;i.replaceWith(o,l,a)}if(r.updateSelection){Ku(i,i.steps.length-1,-1)}if(r.applyInputRules){i.setMeta("applyInputRules",{from:o,text:a})}if(r.applyPasteRules){i.setMeta("applyPasteRules",{from:o,text:a})}}return true};const Wu=()=>({state:t,dispatch:e})=>tl(t,e);const Gu=()=>({state:t,dispatch:e})=>el(t,e);const Vu=()=>({state:t,dispatch:e})=>_o(t,e);const Xu=()=>({state:t,dispatch:e})=>Yo(t,e);const Yu=()=>({tr:t,state:e,dispatch:r})=>{try{const i=ce(e.doc,e.selection.$from.pos,-1);if(i===null||i===undefined){return false}t.join(i,2);if(r){r(t)}return true}catch{return false}};const Qu=()=>({state:t,dispatch:e,tr:r})=>{try{const i=ce(t.doc,t.selection.$from.pos,+1);if(i===null||i===undefined){return false}r.join(i,2);if(e){e(r)}return true}catch(t){return false}};const Zu=()=>({state:t,dispatch:e})=>Ko(t,e);const tf=()=>({state:t,dispatch:e})=>qo(t,e);function ef(){return typeof navigator!=="undefined"?/Mac/.test(navigator.platform):false}function rf(t){const e=t.split(/-(?!$)/);let r=e[e.length-1];if(r==="Space"){r=" "}let i;let n;let s;let o;for(let t=0;t<e.length-1;t+=1){const r=e[t];if(/^(cmd|meta|m)$/i.test(r)){o=true}else if(/^a(lt)?$/i.test(r)){i=true}else if(/^(c|ctrl|control)$/i.test(r)){n=true}else if(/^s(hift)?$/i.test(r)){s=true}else if(/^mod$/i.test(r)){if(Hu()||ef()){o=true}else{n=true}}else{throw new Error(`Unrecognized modifier name: ${r}`)}}if(i){r=`Alt-${r}`}if(n){r=`Ctrl-${r}`}if(o){r=`Meta-${r}`}if(s){r=`Shift-${r}`}return r}const nf=t=>({editor:e,view:r,tr:i,dispatch:n})=>{const s=rf(t).split(/-(?!$)/);const o=s.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t)));const l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:true,cancelable:true});const u=e.captureTransaction((()=>{r.someProp("handleKeyDown",(t=>t(r,l)))}));u===null||u===void 0?void 0:u.steps.forEach((t=>{const e=t.map(i.mapping);if(e&&n){i.maybeStep(e)}}));return true};function sf(t,e,r={}){const{from:i,to:n,empty:s}=t.selection;const o=e?Ll(e,t.schema):null;const l=[];t.doc.nodesBetween(i,n,((t,e)=>{if(t.isText){return}const r=Math.max(i,e);const s=Math.min(n,e+t.nodeSize);l.push({node:t,from:r,to:s})}));const u=n-i;const f=l.filter((t=>{if(!o){return true}return o.name===t.node.type.name})).filter((t=>Eu(t.node.attrs,r,{strict:false})));if(s){return!!f.length}const h=f.reduce(((t,e)=>t+e.to-e.from),0);return h>=u}const of=(t,e={})=>({state:r,dispatch:i})=>{const n=Ll(t,r.schema);const s=sf(r,n,e);if(!s){return false}return rl(r,i)};const lf=()=>({state:t,dispatch:e})=>ll(t,e);const uf=t=>({state:e,dispatch:r})=>{const i=Ll(t,e.schema);return Tl(i)(e,r)};const ff=()=>({state:t,dispatch:e})=>il(t,e);function hf(t,e){if(e.nodes[t]){return"node"}if(e.marks[t]){return"mark"}return null}function af(t,e){const r=typeof e==="string"?[e]:e;return Object.keys(t).reduce(((e,i)=>{if(!r.includes(i)){e[i]=t[i]}return e}),{})}const cf=(t,e)=>({tr:r,state:i,dispatch:n})=>{let s=null;let o=null;const l=hf(typeof t==="string"?t:t.name,i.schema);if(!l){return false}if(l==="node"){s=Ll(t,i.schema)}if(l==="mark"){o=Nu(t,i.schema)}if(n){r.selection.ranges.forEach((t=>{i.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,i)=>{if(s&&s===t.type){r.setNodeMarkup(i,undefined,af(t.attrs,e))}if(o&&t.marks.length){t.marks.forEach((n=>{if(o===n.type){r.addMark(i,i+t.nodeSize,o.create(af(n.attrs,e)))}}))}}))}))}return true};const df=()=>({tr:t,dispatch:e})=>{if(e){t.scrollIntoView()}return true};const pf=()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size});const mf=()=>({state:t,dispatch:e})=>Go(t,e);const gf=()=>({state:t,dispatch:e})=>Qo(t,e);const wf=()=>({state:t,dispatch:e})=>hl(t,e);const bf=()=>({state:t,dispatch:e})=>gl(t,e);const vf=()=>({state:t,dispatch:e})=>ml(t,e);function yf(t,e,r={}){return _u(t,e,{slice:false,parseOptions:r})}const Mf=(t,e=false,r={})=>({tr:i,editor:n,dispatch:s})=>{const{doc:o}=i;const l=yf(t,n.schema,r);if(s){i.replaceWith(0,o.content.size,l).setMeta("preventUpdate",!e)}return true};function kf(t,e){const r=Nu(e,t.schema);const{from:i,to:n,empty:s}=t.selection;const o=[];if(s){if(t.storedMarks){o.push(...t.storedMarks)}o.push(...t.selection.$head.marks())}else{t.doc.nodesBetween(i,n,(t=>{o.push(...t.marks)}))}const l=o.find((t=>t.type.name===r.name));if(!l){return{}}return{...l.attrs}}function xf(t){for(let e=0;e<t.edgeCount;e+=1){const{type:r}=t.edge(e);if(r.isTextblock&&!r.hasRequiredAttrs()){return r}}return null}function Sf(t,e){for(let r=t.depth;r>0;r-=1){const i=t.node(r);if(e(i)){return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:i}}}}function Of(t){return e=>Sf(e.$from,t)}function Tf(t,e){const r=yt.fromSchema(e).serializeFragment(t);const i=document.implementation.createHTMLDocument();const n=i.createElement("div");n.appendChild(r);return n.innerHTML}function Ef(t,e){const r={from:0,to:t.content.size};return cu(t,r,e)}function Pf(t,e){const r=Ll(e,t.schema);const{from:i,to:n}=t.selection;const s=[];t.doc.nodesBetween(i,n,(t=>{s.push(t)}));const o=s.reverse().find((t=>t.type.name===r.name));if(!o){return{}}return{...o.attrs}}function Af(t,e){const r=hf(typeof e==="string"?e:e.name,t.schema);if(r==="node"){return Pf(t,e)}if(r==="mark"){return kf(t,e)}return{}}function Cf(t,e,r){const i=[];if(t===e){r.resolve(t).marks().forEach((e=>{const n=r.resolve(t-1);const s=Cu(n,e.type);if(!s){return}i.push({mark:e,...s})}))}else{r.nodesBetween(t,e,((t,e)=>{if(!t||(t===null||t===void 0?void 0:t.nodeSize)===undefined){return}i.push(...t.marks.map((r=>({from:e,to:e+t.nodeSize,mark:r}))))}))}return i}function Nf(t,e,r){return Object.fromEntries(Object.entries(r).filter((([r])=>{const i=t.find((t=>t.type===e&&t.name===r));if(!i){return false}return i.attribute.keepOnSplit})))}function $f(t,e,r={}){const{empty:i,ranges:n}=t.selection;const s=e?Nu(e,t.schema):null;if(i){return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>{if(!s){return true}return s.name===t.type.name})).find((t=>Eu(t.attrs,r,{strict:false})))}let o=0;const l=[];n.forEach((({$from:e,$to:r})=>{const i=e.pos;const n=r.pos;t.doc.nodesBetween(i,n,((t,e)=>{if(!t.isText&&!t.marks.length){return}const r=Math.max(i,e);const s=Math.min(n,e+t.nodeSize);const u=s-r;o+=u;l.push(...t.marks.map((t=>({mark:t,from:r,to:s}))))}))}));if(o===0){return false}const u=l.filter((t=>{if(!s){return true}return s.name===t.mark.type.name})).filter((t=>Eu(t.mark.attrs,r,{strict:false}))).reduce(((t,e)=>t+e.to-e.from),0);const f=l.filter((t=>{if(!s){return true}return t.mark.type!==s&&t.mark.type.excludes(s)})).reduce(((t,e)=>t+e.to-e.from),0);const h=u>0?u+f:u;return h>=o}function Rf(t,e,r={}){if(!e){return sf(t,null,r)||$f(t,null,r)}const i=hf(e,t.schema);if(i==="node"){return sf(t,e,r)}if(i==="mark"){return $f(t,e,r)}return false}function Df(t,e){const{nodeExtensions:r}=Dl(e);const i=r.find((e=>e.name===t));if(!i){return false}const n={name:i.name,options:i.options,storage:i.storage};const s=Jl(Rl(i,"group",n));if(typeof s!=="string"){return false}return s.split(" ").includes("list")}function If(t){var e;const r=(e=t.type.createAndFill())===null||e===void 0?void 0:e.toJSON();const i=t.toJSON();return JSON.stringify(r)===JSON.stringify(i)}function Lf(t,e,r){var i;const{selection:n}=e;let s=null;if(Du(n)){s=n.$cursor}if(s){const e=(i=t.storedMarks)!==null&&i!==void 0?i:s.marks();return!!r.isInSet(e)||!e.some((t=>t.type.excludes(r)))}const{ranges:o}=n;return o.some((({$from:e,$to:i})=>{let n=e.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):false;t.doc.nodesBetween(e.pos,i.pos,((t,e,i)=>{if(n){return false}if(t.isInline){const e=!i||i.type.allowsMarkType(r);const s=!!r.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(r)));n=e&&s}return!n}));return n}))}const Hf=(t,e={})=>({tr:r,state:i,dispatch:n})=>{const{selection:s}=r;const{empty:o,ranges:l}=s;const u=Nu(t,i.schema);if(n){if(o){const t=kf(i,u);r.addStoredMark(u.create({...t,...e}))}else{l.forEach((t=>{const n=t.$from.pos;const s=t.$to.pos;i.doc.nodesBetween(n,s,((t,i)=>{const o=Math.max(i,n);const l=Math.min(i+t.nodeSize,s);const f=t.marks.find((t=>t.type===u));if(f){t.marks.forEach((t=>{if(u===t.type){r.addMark(o,l,u.create({...t.attrs,...e}))}}))}else{r.addMark(o,l,u.create(e))}}))}))}}return Lf(i,r,u)};const jf=(t,e)=>({tr:r})=>{r.setMeta(t,e);return true};const Bf=(t,e={})=>({state:r,dispatch:i,chain:n})=>{const s=Ll(t,r.schema);if(!s.isTextblock){console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.');return false}return n().command((({commands:t})=>{const i=bl(s,e)(r);if(i){return true}return t.clearNodes()})).command((({state:t})=>bl(s,e)(t,i))).run()};const Jf=t=>({tr:e,dispatch:r})=>{if(r){const{doc:r}=e;const i=Iu(t,0,r.content.size);const n=Fe.create(r,i);e.setSelection(n)}return true};const zf=t=>({tr:e,dispatch:r})=>{if(r){const{doc:r}=e;const{from:i,to:n}=typeof t==="number"?{from:t,to:t}:t;const s=Je.atStart(r).from;const o=Je.atEnd(r).to;const l=Iu(i,s,o);const u=Iu(n,s,o);const f=Je.create(r,l,u);e.setSelection(f)}return true};const Ff=t=>({state:e,dispatch:r})=>{const i=Ll(t,e.schema);return Al(i)(e,r)};function _f(t,e){const r=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(r){const i=r.filter((t=>e===null||e===void 0?void 0:e.includes(t.type.name)));t.tr.ensureMarks(i)}}const Kf=({keepMarks:t=true}={})=>({tr:e,state:r,dispatch:i,editor:n})=>{const{selection:s,doc:o}=e;const{$from:l,$to:u}=s;const f=n.extensionManager.attributes;const h=Nf(f,l.node().type.name,l.node().attrs);if(s instanceof Fe&&s.node.isBlock){if(!l.parentOffset||!ue(o,l.pos)){return false}if(i){if(t){_f(r,n.extensionManager.splittableMarks)}e.split(l.pos).scrollIntoView()}return true}if(!l.parent.isBlock){return false}if(i){const i=u.parentOffset===u.parent.content.size;if(s instanceof Je){e.deleteSelection()}const o=l.depth===0?undefined:xf(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=i&&o?[{type:o,attrs:h}]:undefined;let a=ue(e.doc,e.mapping.map(l.pos),1,f);if(!f&&!a&&ue(e.doc,e.mapping.map(l.pos),1,o?[{type:o}]:undefined)){a=true;f=o?[{type:o,attrs:h}]:undefined}if(a){e.split(e.mapping.map(l.pos),1,f);if(o&&!i&&!l.parentOffset&&l.parent.type!==o){const t=e.mapping.map(l.before());const r=e.doc.resolve(t);if(l.node(-1).canReplaceWith(r.index(),r.index()+1,o)){e.setNodeMarkup(e.mapping.map(l.before()),o)}}}if(t){_f(r,n.extensionManager.splittableMarks)}e.scrollIntoView()}return true};const qf=t=>({tr:e,state:r,dispatch:i,editor:n})=>{var s;const o=Ll(t,r.schema);const{$from:u,$to:f}=r.selection;const h=r.selection.node;if(h&&h.isBlock||u.depth<2||!u.sameParent(f)){return false}const a=u.node(-1);if(a.type!==o){return false}const c=n.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==o||u.index(-2)!==u.node(-2).childCount-1){return false}if(i){let t=l.empty;const r=u.index(-1)?1:u.index(-2)?2:3;for(let e=u.depth-r;e>=u.depth-3;e-=1){t=l.from(u.node(e).copy(t))}const i=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3;const n=Nf(c,u.node().type.name,u.node().attrs);const f=((s=o.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(n))||undefined;t=t.append(l.from(o.createAndFill(null,f)||undefined));const h=u.before(u.depth-(r-1));e.replace(h,u.after(-i),new d(t,4-r,0));let a=-1;e.doc.nodesBetween(h,e.doc.content.size,((t,e)=>{if(a>-1){return false}if(t.isTextblock&&t.content.size===0){a=e+1}}));if(a>-1){e.setSelection(Je.near(e.doc.resolve(a)))}e.scrollIntoView()}return true}const p=f.pos===u.end()?a.contentMatchAt(0).defaultType:null;const m=Nf(c,a.type.name,a.attrs);const g=Nf(c,u.node().type.name,u.node().attrs);e.delete(u.pos,f.pos);const w=p?[{type:o,attrs:m},{type:p,attrs:g}]:[{type:o,attrs:m}];if(!ue(e.doc,u.pos,2)){return false}if(i){const{selection:t,storedMarks:s}=r;const{splittableMarks:o}=n.extensionManager;const l=s||t.$to.parentOffset&&t.$from.marks();e.split(u.pos,2,w).scrollIntoView();if(!l||!i){return true}const f=l.filter((t=>o.includes(t.type.name)));e.ensureMarks(f)}return true};const Uf=(t,e)=>{const r=Of((t=>t.type===e))(t.selection);if(!r){return true}const i=t.doc.resolve(Math.max(0,r.pos-1)).before(r.depth);if(i===undefined){return true}const n=t.doc.nodeAt(i);const s=r.node.type===(n===null||n===void 0?void 0:n.type)&&he(t.doc,r.pos);if(!s){return true}t.join(r.pos);return true};const Wf=(t,e)=>{const r=Of((t=>t.type===e))(t.selection);if(!r){return true}const i=t.doc.resolve(r.start).after(r.depth);if(i===undefined){return true}const n=t.doc.nodeAt(i);const s=r.node.type===(n===null||n===void 0?void 0:n.type)&&he(t.doc,i);if(!s){return true}t.join(i);return true};const Gf=(t,e,r,i={})=>({editor:n,tr:s,state:o,dispatch:l,chain:u,commands:f,can:h})=>{const{extensions:a,splittableMarks:c}=n.extensionManager;const d=Ll(t,o.schema);const p=Ll(e,o.schema);const{selection:m,storedMarks:g}=o;const{$from:w,$to:b}=m;const v=w.blockRange(b);const y=g||m.$to.parentOffset&&m.$from.marks();if(!v){return false}const M=Of((t=>Df(t.type.name,a)))(m);if(v.depth>=1&&M&&v.depth-M.depth<=1){if(M.node.type===d){return f.liftListItem(p)}if(Df(M.node.type.name,a)&&d.validContent(M.node.content)&&l){return u().command((()=>{s.setNodeMarkup(M.pos,d);return true})).command((()=>Uf(s,d))).command((()=>Wf(s,d))).run()}}if(!r||!y||!l){return u().command((()=>{const t=h().wrapInList(d,i);if(t){return true}return f.clearNodes()})).wrapInList(d,i).command((()=>Uf(s,d))).command((()=>Wf(s,d))).run()}return u().command((()=>{const t=h().wrapInList(d,i);const e=y.filter((t=>c.includes(t.type.name)));s.ensureMarks(e);if(t){return true}return f.clearNodes()})).wrapInList(d,i).command((()=>Uf(s,d))).command((()=>Wf(s,d))).run()};const Vf=(t,e={},r={})=>({state:i,commands:n})=>{const{extendEmptyMarkRange:s=false}=r;const o=Nu(t,i.schema);const l=$f(i,o,e);if(l){return n.unsetMark(o,{extendEmptyMarkRange:s})}return n.setMark(o,e)};const Xf=(t,e,r={})=>({state:i,commands:n})=>{const s=Ll(t,i.schema);const o=Ll(e,i.schema);const l=sf(i,s,r);if(l){return n.setNode(o)}return n.setNode(s,r)};const Yf=(t,e={})=>({state:r,commands:i})=>{const n=Ll(t,r.schema);const s=sf(r,n,e);if(s){return i.lift(n)}return i.wrapIn(n,e)};const Qf=()=>({state:t,dispatch:e})=>{const r=t.plugins;for(let i=0;i<r.length;i+=1){const n=r[i];let s;if(n.spec.isInputRules&&(s=n.getState(t))){if(e){const e=t.tr;const r=s.transform;for(let t=r.steps.length-1;t>=0;t-=1){e.step(r.steps[t].invert(r.docs[t]))}if(s.text){const r=e.doc.resolve(s.from).marks();e.replaceWith(s.from,s.to,t.schema.text(s.text,r))}else{e.delete(s.from,s.to)}}return true}}return false};const Zf=()=>({tr:t,dispatch:e})=>{const{selection:r}=t;const{empty:i,ranges:n}=r;if(i){return true}if(e){n.forEach((e=>{t.removeMark(e.$from.pos,e.$to.pos)}))}return true};const th=(t,e={})=>({tr:r,state:i,dispatch:n})=>{var s;const{extendEmptyMarkRange:o=false}=e;const{selection:l}=r;const u=Nu(t,i.schema);const{$from:f,empty:h,ranges:a}=l;if(!n){return true}if(h&&o){let{from:t,to:e}=l;const i=(s=f.marks().find((t=>t.type===u)))===null||s===void 0?void 0:s.attrs;const n=Cu(f,u,i);if(n){t=n.from;e=n.to}r.removeMark(t,e,u)}else{a.forEach((t=>{r.removeMark(t.$from.pos,t.$to.pos,u)}))}r.removeStoredMark(u);return true};const eh=(t,e={})=>({tr:r,state:i,dispatch:n})=>{let s=null;let o=null;const l=hf(typeof t==="string"?t:t.name,i.schema);if(!l){return false}if(l==="node"){s=Ll(t,i.schema)}if(l==="mark"){o=Nu(t,i.schema)}if(n){r.selection.ranges.forEach((t=>{const n=t.$from.pos;const l=t.$to.pos;i.doc.nodesBetween(n,l,((t,i)=>{if(s&&s===t.type){r.setNodeMarkup(i,undefined,{...t.attrs,...e})}if(o&&t.marks.length){t.marks.forEach((s=>{if(o===s.type){const u=Math.max(i,n);const f=Math.min(i+t.nodeSize,l);r.addMark(u,f,o.create({...s.attrs,...e}))}}))}}))}))}return true};const rh=(t,e={})=>({state:r,dispatch:i})=>{const n=Ll(t,r.schema);return wl(n,e)(r,i)};const ih=(t,e={})=>({state:r,dispatch:i})=>{const n=Ll(t,r.schema);return Sl(n,e)(r,i)};var nh=Object.freeze({__proto__:null,blur:mu,clearContent:gu,clearNodes:wu,command:bu,createParagraphNear:vu,cut:yu,deleteCurrentNode:Mu,deleteNode:ku,deleteRange:xu,deleteSelection:Su,enter:Ou,exitCode:Tu,extendMarkRange:$u,first:Ru,focus:ju,forEach:Bu,insertContent:Ju,insertContentAt:Uu,joinUp:Wu,joinDown:Gu,joinBackward:Vu,joinForward:Xu,joinItemBackward:Yu,joinItemForward:Qu,joinTextblockBackward:Zu,joinTextblockForward:tf,keyboardShortcut:nf,lift:of,liftEmptyBlock:lf,liftListItem:uf,newlineInCode:ff,resetAttributes:cf,scrollIntoView:df,selectAll:pf,selectNodeBackward:mf,selectNodeForward:gf,selectParentNode:wf,selectTextblockEnd:bf,selectTextblockStart:vf,setContent:Mf,setMark:Hf,setMeta:jf,setNode:Bf,setNodeSelection:Jf,setTextSelection:zf,sinkListItem:Ff,splitBlock:Kf,splitListItem:qf,toggleList:Gf,toggleMark:Vf,toggleNode:Xf,toggleWrap:Yf,undoInputRule:Qf,unsetAllMarks:Zf,unsetMark:th,updateAttributes:eh,wrapIn:rh,wrapInList:ih});const sh=au.create({name:"commands",addCommands(){return{...nh}}});const oh=au.create({name:"editable",addProseMirrorPlugins(){return[new nr({key:new lr("editable"),props:{editable:()=>this.editor.options.editable}})]}});const lh=au.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new nr({key:new lr("focusEvents"),props:{handleDOMEvents:{focus:(e,r)=>{t.isFocused=true;const i=t.state.tr.setMeta("focus",{event:r}).setMeta("addToHistory",false);e.dispatch(i);return false},blur:(e,r)=>{t.isFocused=false;const i=t.state.tr.setMeta("blur",{event:r}).setMeta("addToHistory",false);e.dispatch(i);return false}}}})]}});const uh=au.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:r,doc:i}=e;const{empty:n,$anchor:s}=r;const{pos:o,parent:l}=s;const u=s.parent.isTextblock&&o>0?e.doc.resolve(o-1):s;const f=u.parent.type.spec.isolating;const h=s.pos-s.parentOffset;const a=f&&u.parent.childCount===1?h===s.pos:Le.atStart(i).from===o;if(!n||!l.type.isTextblock||l.textContent.length||!a||a&&s.parent.type.name==="paragraph"){return false}return t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()]));const e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()]));const r=()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()]));const i={Enter:r,"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()};const n={...i};const s={...i,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};if(Hu()||ef()){return s}return n},addProseMirrorPlugins(){return[new nr({key:new lr("clearDocument"),appendTransaction:(t,e,r)=>{const i=t.some((t=>t.docChanged))&&!e.doc.eq(r.doc);if(!i){return}const{empty:n,from:s,to:o}=e.selection;const l=Le.atStart(e.doc).from;const u=Le.atEnd(e.doc).to;const f=s===l&&o===u;if(n||!f){return}const h=r.doc.textBetween(0,r.doc.content.size," "," ").length===0;if(!h){return}const a=r.tr;const c=Cl({state:r,transaction:a});const{commands:d}=new Nl({editor:this.editor,state:c});d.clearNodes();if(!a.steps.length){return}return a}})]}});const fh=au.create({name:"tabindex",addProseMirrorPlugins(){return[new nr({key:new lr("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class hh{constructor(t,e,r=false,i=null){this.currentNode=null;this.actualDepth=null;this.isBlock=r;this.resolvedPos=t;this.editor=e;this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!==null&&t!==void 0?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from;let r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}e=this.from+1;r=this.to-1}this.editor.commands.insertContentAt({from:e,to:r},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){if(this.isBlock){return this.pos}return this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){if(this.isBlock){return this.pos+this.size}return this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0){return null}const t=this.resolvedPos.start(this.resolvedPos.depth-1);const e=this.resolvedPos.doc.resolve(t);return new hh(e,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));if(t.depth!==this.depth){t=this.resolvedPos.doc.resolve(this.from-3)}return new hh(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));if(t.depth!==this.depth){t=this.resolvedPos.doc.resolve(this.to+3)}return new hh(t,this.editor)}get children(){const t=[];this.node.content.forEach(((e,r)=>{const i=e.isBlock&&!e.isTextblock;const n=this.pos+r+1;const s=this.resolvedPos.doc.resolve(n);if(!i&&s.depth<=this.depth){return}const o=new hh(s,this.editor,i,i?e:null);if(i){o.actualDepth=this.depth+1}t.push(new hh(s,this.editor,i,i?e:null))}));return t}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let r=null;let i=this.parent;while(i&&!r){if(i.node.type.name===t){if(Object.keys(e).length>0);else{r=i}}i=i.parent}return r}querySelector(t,e={}){return this.querySelectorAll(t,e,true)[0]||null}querySelectorAll(t,e={},r=false){let i=[];if(!this.children||this.children.length===0){return i}const n=Object.keys(e);this.children.forEach((s=>{if(r&&i.length>0){return}if(s.node.type.name===t){const t=n.every((t=>e[t]===s.node.attrs[t]));if(t){i.push(s)}}if(r&&i.length>0){return}i=i.concat(s.querySelectorAll(t,e,r))}));return i}setAttribute(t){const e=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,t).setTextSelection(e.from).run()}}const ah=`.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}`;function ch(t,e,r){const i=document.querySelector(`style[data-tiptap-style${r?`-${r}`:""}]`);if(i!==null){return i}const n=document.createElement("style");if(e){n.setAttribute("nonce",e)}n.setAttribute(`data-tiptap-style${r?`-${r}`:""}`,"");n.innerHTML=t;document.getElementsByTagName("head")[0].appendChild(n);return n}class dh extends $l{constructor(t={}){super();this.isFocused=false;this.extensionStorage={};this.options={element:document.createElement("div"),content:"",injectCSS:true,injectNonce:undefined,extensions:[],autofocus:false,editable:true,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:true,enablePasteRules:true,enableCoreExtensions:true,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null};this.isCapturingTransaction=false;this.capturedTransaction=null;this.setOptions(t);this.createExtensionManager();this.createCommandManager();this.createSchema();this.on("beforeCreate",this.options.onBeforeCreate);this.emit("beforeCreate",{editor:this});this.createView();this.injectCSS();this.on("create",this.options.onCreate);this.on("update",this.options.onUpdate);this.on("selectionUpdate",this.options.onSelectionUpdate);this.on("transaction",this.options.onTransaction);this.on("focus",this.options.onFocus);this.on("blur",this.options.onBlur);this.on("destroy",this.options.onDestroy);window.setTimeout((()=>{if(this.isDestroyed){return}this.commands.focus(this.options.autofocus);this.emit("create",{editor:this})}),0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){if(this.options.injectCSS&&document){this.css=ch(ah,this.options.injectNonce)}}setOptions(t={}){this.options={...this.options,...t};if(!this.view||!this.state||this.isDestroyed){return}if(this.options.editorProps){this.view.setProps(this.options.editorProps)}this.view.updateState(this.state)}setEditable(t,e=true){this.setOptions({editable:t});if(e){this.emit("update",{editor:this,transaction:this.state.tr})}}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,e){const r=Bl(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t];const i=this.state.reconfigure({plugins:r});this.view.updateState(i)}unregisterPlugin(t){if(this.isDestroyed){return}const e=typeof t==="string"?`${t}$`:t.key;const r=this.state.reconfigure({plugins:this.state.plugins.filter((t=>!t.key.startsWith(e)))});this.view.updateState(r)}createExtensionManager(){var t,e;const r=this.options.enableCoreExtensions?[oh,pu.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)===null||t===void 0?void 0:t.clipboardTextSerializer)===null||e===void 0?void 0:e.blockSeparator}),sh,lh,uh,fh]:[];const i=[...r,...this.options.extensions].filter((t=>["extension","node","mark"].includes(t===null||t===void 0?void 0:t.type)));this.extensionManager=new lu(i,this)}createCommandManager(){this.commandManager=new Nl({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const t=yf(this.options.content,this.schema,this.options.parseOptions);const e=Lu(t,this.options.autofocus);this.view=new yo(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:rr.create({doc:t,selection:e||undefined})});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r);this.createNodeViews();this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=true;t();this.isCapturingTransaction=false;const e=this.capturedTransaction;this.capturedTransaction=null;return e}dispatchTransaction(t){if(this.view.isDestroyed){return}if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach((t=>{var e;return(e=this.capturedTransaction)===null||e===void 0?void 0:e.step(t)}));return}const e=this.state.apply(t);const r=!this.state.selection.eq(e.selection);this.view.updateState(e);this.emit("transaction",{editor:this,transaction:t});if(r){this.emit("selectionUpdate",{editor:this,transaction:t})}const i=t.getMeta("focus");const n=t.getMeta("blur");if(i){this.emit("focus",{editor:this,event:i.event,transaction:t})}if(n){this.emit("blur",{editor:this,event:n.event,transaction:t})}if(!t.docChanged||t.getMeta("preventUpdate")){return}this.emit("update",{editor:this,transaction:t})}getAttributes(t){return Af(this.state,t)}isActive(t,e){const r=typeof t==="string"?t:null;const i=typeof t==="string"?e:t;return Rf(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Tf(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:r={}}=t||{};return Ef(this.state.doc,{blockSeparator:e,textSerializers:{...du(this.schema),...r}})}get isEmpty(){return If(this.state.doc)}getCharacterCount(){console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.');return this.state.doc.content.size-2}destroy(){this.emit("destroy");if(this.view){this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var t;return!((t=this.view)===null||t===void 0?void 0:t.docView)}$node(t,e){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(t,e))||null}$nodes(t,e){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new hh(e,this)}get $doc(){return this.$pos(0)}}function ph(t){return new Xl({find:t.find,handler:({state:e,range:r,match:i})=>{const n=Jl(t.getAttributes,undefined,i);if(n===false||n===null){return null}const{tr:s}=e;const o=i[i.length-1];const l=i[0];if(o){const i=l.search(/\S/);const u=r.from+l.indexOf(o);const f=u+o.length;const h=Cf(r.from,r.to,e.doc).filter((e=>{const r=e.mark.type.excluded;return r.find((r=>r===t.type&&r!==e.mark.type))})).filter((t=>t.to>u));if(h.length){return null}if(f<r.to){s.delete(f,r.to)}if(u>r.from){s.delete(r.from+i,u)}const a=r.from+i+o.length;s.addMark(r.from+i,a,t.type.create(n||{}));s.removeStoredMark(t.type)}}})}function mh(t){return new Xl({find:t.find,handler:({state:e,range:r,match:i})=>{const n=Jl(t.getAttributes,undefined,i)||{};const{tr:s}=e;const o=r.from;let l=r.to;const u=t.type.create(n);if(i[1]){const t=i[0].lastIndexOf(i[1]);let e=o+t;if(e>l){e=l}else{l=e+i[1].length}const r=i[0][i[0].length-1];s.insertText(r,o+i[0].length-1);s.replaceWith(e,l,u)}else if(i[0]){s.insert(o-1,t.type.create(n)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()}})}function gh(t){return new Xl({find:t.find,handler:({state:e,range:r,match:i})=>{const n=e.doc.resolve(r.from);const s=Jl(t.getAttributes,undefined,i)||{};if(!n.node(-1).canReplaceWith(n.index(-1),n.indexAfter(-1),t.type)){return null}e.tr.delete(r.from,r.to).setBlockType(r.from,r.from,t.type,s)}})}function wh(t){return new Xl({find:t.find,handler:({state:e,range:r,match:i,chain:n})=>{const s=Jl(t.getAttributes,undefined,i)||{};const o=e.tr.delete(r.from,r.to);const l=o.doc.resolve(r.from);const u=l.blockRange();const f=u&&Qt(u,t.type,s);if(!f){return null}o.wrap(u,f);if(t.keepMarks&&t.editor){const{selection:r,storedMarks:i}=e;const{splittableMarks:n}=t.editor.extensionManager;const s=i||r.$to.parentOffset&&r.$from.marks();if(s){const t=s.filter((t=>n.includes(t.type.name)));o.ensureMarks(t)}}if(t.keepAttributes){const e=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";n().updateAttributes(e,s).run()}const h=o.doc.resolve(r.from-1).nodeBefore;if(h&&h.type===t.type&&he(o.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(i,h))){o.join(r.from-1)}}})}class bh{constructor(t={}){this.type="mark";this.name="mark";this.parent=null;this.child=null;this.config={name:this.name,defaultOptions:{}};this.config={...this.config,...t};this.name=this.config.name;if(t.defaultOptions&&Object.keys(t.defaultOptions).length>0){console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`)}this.options=this.config.defaultOptions;if(this.config.addOptions){this.options=Jl(Rl(this,"addOptions",{name:this.name}))}this.storage=Jl(Rl(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new bh(t)}configure(t={}){const e=this.extend();e.options=hu(this.options,t);e.storage=Jl(Rl(e,"addStorage",{name:e.name,options:e.options}));return e}extend(t={}){const e=new bh({...this.config,...t});e.parent=this;this.child=e;e.name=t.name?t.name:e.parent.name;if(t.defaultOptions){console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`)}e.options=Jl(Rl(e,"addOptions",{name:e.name}));e.storage=Jl(Rl(e,"addStorage",{name:e.name,options:e.options}));return e}static handleExit({editor:t,mark:e}){const{tr:r}=t.state;const i=t.state.selection.$from;const n=i.pos===i.end();if(n){const n=i.marks();const s=!!n.find((t=>(t===null||t===void 0?void 0:t.type.name)===e.name));if(!s){return false}const o=n.find((t=>(t===null||t===void 0?void 0:t.type.name)===e.name));if(o){r.removeStoredMark(o)}r.insertText(" ",i.pos);t.view.dispatch(r);return true}return false}}class vh{constructor(t={}){this.type="node";this.name="node";this.parent=null;this.child=null;this.config={name:this.name,defaultOptions:{}};this.config={...this.config,...t};this.name=this.config.name;if(t.defaultOptions&&Object.keys(t.defaultOptions).length>0){console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`)}this.options=this.config.defaultOptions;if(this.config.addOptions){this.options=Jl(Rl(this,"addOptions",{name:this.name}))}this.storage=Jl(Rl(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new vh(t)}configure(t={}){const e=this.extend();e.options=hu(this.options,t);e.storage=Jl(Rl(e,"addStorage",{name:e.name,options:e.options}));return e}extend(t={}){const e=new vh({...this.config,...t});e.parent=this;this.child=e;e.name=t.name?t.name:e.parent.name;if(t.defaultOptions){console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`)}e.options=Jl(Rl(e,"addOptions",{name:e.name}));e.storage=Jl(Rl(e,"addStorage",{name:e.name,options:e.options}));return e}}function yh(t){return new eu({find:t.find,handler:({state:e,range:r,match:i,pasteEvent:n})=>{const s=Jl(t.getAttributes,undefined,i,n);if(s===false||s===null){return null}const{tr:o}=e;const l=i[i.length-1];const u=i[0];let f=r.to;if(l){const i=u.search(/\S/);const n=r.from+u.indexOf(l);const h=n+l.length;const a=Cf(r.from,r.to,e.doc).filter((e=>{const r=e.mark.type.excluded;return r.find((r=>r===t.type&&r!==e.mark.type))})).filter((t=>t.to>n));if(a.length){return null}if(h<r.to){o.delete(h,r.to)}if(n>r.from){o.delete(r.from+i,n)}f=r.from+i+l.length;o.addMark(r.from+i,f,t.type.create(s||{}));o.removeStoredMark(t.type)}}})}const Mh=au.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize"}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t===null||t===void 0?void 0:t.node)||this.editor.state.doc;const r=(t===null||t===void 0?void 0:t.mode)||this.options.mode;if(r==="textSize"){const t=e.textBetween(0,e.content.size,undefined," ");return t.length}return e.nodeSize};this.storage.words=t=>{const e=(t===null||t===void 0?void 0:t.node)||this.editor.state.doc;const r=e.textBetween(0,e.content.size," "," ");const i=r.split(" ").filter((t=>t!==""));return i.length}},addProseMirrorPlugins(){return[new nr({key:new lr("characterCount"),filterTransaction:(t,e)=>{const r=this.options.limit;if(!t.docChanged||r===0||r===null||r===undefined){return true}const i=this.storage.characters({node:e.doc});const n=this.storage.characters({node:t.doc});if(n<=r){return true}if(i>r&&n>r&&n<=i){return true}if(i>r&&n>r&&n>i){return false}const s=t.getMeta("paste");if(!s){return false}const o=t.selection.$head.pos;const l=n-r;const u=o-l;const f=o;t.deleteRange(u,f);const h=this.storage.characters({node:t.doc});if(h>r){return false}return true}})]}});const kh=au.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:true,considerAnyAsEmpty:false,showOnlyCurrent:true,includeChildren:false}},addProseMirrorPlugins(){return[new nr({key:new lr("placeholder"),props:{decorations:({doc:t,selection:e})=>{var r;const i=this.editor.isEditable||!this.options.showOnlyWhenEditable;const{anchor:n}=e;const s=[];if(!i){return null}const{firstChild:o}=t.content;const l=o&&o.type.isLeaf;const u=o&&o.isAtom;const f=this.options.considerAnyAsEmpty?true:o&&o.type.name===((r=t.type.contentMatch.defaultType)===null||r===void 0?void 0:r.name);const h=t.content.childCount<=1&&o&&f&&(o.nodeSize<=2&&(!l||!u));t.descendants(((t,e)=>{const r=n>=e&&n<=e+t.nodeSize;const i=!t.isLeaf&&!t.childCount;if((r||!this.options.showOnlyCurrent)&&i){const i=[this.options.emptyNodeClass];if(h){i.push(this.options.emptyEditorClass)}const n=Hs.node(e,e+t.nodeSize,{class:i.join(" "),"data-placeholder":typeof this.options.placeholder==="function"?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:r}):this.options.placeholder});s.push(n)}return this.options.includeChildren}));return Js.create(t,s)}}})]}});const xh=/^\s*>\s$/;const Sh=vh.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:true,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Hl(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[wh({find:xh,type:this.type})]}});const Oh=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/;const Th=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g;const Eh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/;const Ph=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g;const Ah=bh.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",Hl(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ph({find:Oh,type:this.type}),ph({find:Eh,type:this.type})]},addPasteRules(){return[yh({find:Th,type:this.type}),yh({find:Ph,type:this.type})]}});const Ch=vh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:true,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Hl(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});const Nh=bh.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>{const e=t.hasAttribute("style");if(!e){return false}return{}}}]},renderHTML({HTMLAttributes:t}){return["span",Hl(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const r=kf(t,this.type);const i=Object.entries(r).some((([,t])=>!!t));if(i){return true}return e.unsetMark(this.name)}}}});const $h=/^\s*([-+*])\s$/;const Rh=vh.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:false,keepAttributes:false}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Hl(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>{if(this.options.keepAttributes){return e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ch.name,this.editor.getAttributes(Nh.name)).run()}return t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=wh({find:$h,type:this.type});if(this.options.keepMarks||this.options.keepAttributes){t=wh({find:$h,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Nh.name),editor:this.editor})}return[t]}});const Dh=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/;const Ih=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g;const Lh=bh.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:true,exitable:true,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Hl(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ph({find:Dh,type:this.type})]},addPasteRules(){return[yh({find:Ih,type:this.type})]}});const Hh=/^```([a-z]+)?[\s\n]$/;const jh=/^~~~([a-z]+)?[\s\n]$/;const Bh=vh.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:true,exitOnArrowDown:true,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:true,defining:true,addAttributes(){return{language:{default:null,parseHTML:t=>{var e;const{languageClassPrefix:r}=this.options;const i=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]];const n=i.filter((t=>t.startsWith(r))).map((t=>t.replace(r,"")));const s=n[0];if(!s){return null}return s},rendered:false}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Hl(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection;const r=e.pos===1;if(!t||e.parent.type.name!==this.name){return false}if(r||!e.parent.textContent.length){return this.editor.commands.clearNodes()}return false},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter){return false}const{state:e}=t;const{selection:r}=e;const{$from:i,empty:n}=r;if(!n||i.parent.type!==this.type){return false}const s=i.parentOffset===i.parent.nodeSize-2;const o=i.parent.textContent.endsWith("\n\n");if(!s||!o){return false}return t.chain().command((({tr:t})=>{t.delete(i.pos-2,i.pos);return true})).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown){return false}const{state:e}=t;const{selection:r,doc:i}=e;const{$from:n,empty:s}=r;if(!s||n.parent.type!==this.type){return false}const o=n.parentOffset===n.parent.nodeSize-2;if(!o){return false}const l=n.after();if(l===undefined){return false}const u=i.nodeAt(l);if(u){return false}return t.commands.exitCode()}}},addInputRules(){return[gh({find:Hh,type:this.type,getAttributes:t=>({language:t[1]})}),gh({find:jh,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new nr({key:new lr("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData){return false}if(this.editor.isActive(this.type.name)){return false}const r=e.clipboardData.getData("text/plain");const i=e.clipboardData.getData("vscode-editor-data");const n=i?JSON.parse(i):undefined;const s=n===null||n===void 0?void 0:n.mode;if(!r||!s){return false}const{tr:o}=t.state;if(t.state.selection.from===t.state.doc.nodeSize-(1+t.state.selection.$to.depth*2)){o.insert(t.state.selection.from-1,this.type.create({language:s}))}else{o.replaceSelectionWith(this.type.create({language:s}))}o.setSelection(Je.near(o.doc.resolve(Math.max(0,o.selection.from-2))));o.insertText(r.replace(/\r\n?/g,"\n"));o.setMeta("paste",true);t.dispatch(o);return true}}})]}});const Jh=vh.create({name:"doc",topNode:true,content:"block+"});function zh(t={}){return new nr({view(e){return new Fh(e,t)}})}class Fh{constructor(t,e){var r;this.editorView=t;this.cursorPos=null;this.element=null;this.timeout=-1;this.width=(r=e.width)!==null&&r!==void 0?r:1;this.color=e.color===false?undefined:e.color||"black";this.class=e.class;this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let r=t=>{this[e](t)};t.dom.addEventListener(e,r);return{name:e,handler:r}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc){if(this.cursorPos>t.state.doc.content.size)this.setCursor(null);else this.updateOverlay()}}setCursor(t){if(t==this.cursorPos)return;this.cursorPos=t;if(t==null){this.element.parentNode.removeChild(this.element);this.element=null}else{this.updateOverlay()}}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos);let e=!t.parent.inlineContent,r;if(e){let e=t.nodeBefore,i=t.nodeAfter;if(e||i){let t=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(t){let n=t.getBoundingClientRect();let s=e?n.bottom:n.top;if(e&&i)s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;r={left:n.left,right:n.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!r){let t=this.editorView.coordsAtPos(this.cursorPos);r={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let i=this.editorView.dom.offsetParent;if(!this.element){this.element=i.appendChild(document.createElement("div"));if(this.class)this.element.className=this.class;this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;";if(this.color){this.element.style.backgroundColor=this.color}}this.element.classList.toggle("prosemirror-dropcursor-block",e);this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let n,s;if(!i||i==document.body&&getComputedStyle(i).position=="static"){n=-pageXOffset;s=-pageYOffset}else{let t=i.getBoundingClientRect();n=t.left-i.scrollLeft;s=t.top-i.scrollTop}this.element.style.left=r.left-n+"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(t){clearTimeout(this.timeout);this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});let r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside);let i=r&&r.type.spec.disableDropCursor;let n=typeof i=="function"?i(this.editorView,e,t):i;if(e&&!n){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=me(this.editorView.state.doc,t,this.editorView.dragging.slice);if(e!=null)t=e}this.setCursor(t);this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){if(t.target==this.editorView.dom||!this.editorView.dom.contains(t.relatedTarget))this.setCursor(null)}}const _h=au.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:undefined}},addProseMirrorPlugins(){return[zh(this.options)]}});class Kh extends Le{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return Kh.valid(r)?new Kh(r):Le.near(r)}content(){return d.empty}eq(t){return t instanceof Kh&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Kh(t.resolve(e.pos))}getBookmark(){return new qh(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!Uh(t)||!Wh(t))return false;let r=e.type.spec.allowGapCursor;if(r!=null)return r;let i=e.contentMatchAt(t.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(t,e,r=false){t:for(;;){if(!r&&Kh.valid(t))return t;let i=t.pos,n=null;for(let r=t.depth;;r--){let s=t.node(r);if(e>0?t.indexAfter(r)<s.childCount:t.index(r)>0){n=s.child(e>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0){return null}i+=e;let o=t.doc.resolve(i);if(Kh.valid(o))return o}for(;;){let s=e>0?n.firstChild:n.lastChild;if(!s){if(n.isAtom&&!n.isText&&!Fe.isSelectable(n)){t=t.doc.resolve(i+n.nodeSize*e);r=false;continue t}break}n=s;i+=e;let o=t.doc.resolve(i);if(Kh.valid(o))return o}return null}}}Kh.prototype.visible=false;Kh.findFrom=Kh.findGapCursorFrom;Le.jsonID("gapcursor",Kh);class qh{constructor(t){this.pos=t}map(t){return new qh(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Kh.valid(e)?new Kh(e):Le.near(e)}}function Uh(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),i=t.node(e);if(r==0){if(i.type.spec.isolating)return true;continue}for(let t=i.child(r-1);;t=t.lastChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function Wh(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),i=t.node(e);if(r==i.childCount){if(i.type.spec.isolating)return true;continue}for(let t=i.child(r);;t=t.firstChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function Gh(){return new nr({props:{decorations:Zh,createSelectionBetween(t,e,r){return e.pos==r.pos&&Kh.valid(r)?new Kh(r):null},handleClick:Yh,handleKeyDown:Vh,handleDOMEvents:{beforeinput:Qh}}})}const Vh=Jo({ArrowLeft:Xh("horiz",-1),ArrowRight:Xh("horiz",1),ArrowUp:Xh("vert",-1),ArrowDown:Xh("vert",1)});function Xh(t,e){const r=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(t,i,n){let s=t.selection;let o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Je){if(!n.endOfTextblock(r)||o.depth==0)return false;l=false;o=t.doc.resolve(e>0?o.after():o.before())}let u=Kh.findGapCursorFrom(o,e,l);if(!u)return false;if(i)i(t.tr.setSelection(new Kh(u)));return true}}function Yh(t,e,r){if(!t||!t.editable)return false;let i=t.state.doc.resolve(e);if(!Kh.valid(i))return false;let n=t.posAtCoords({left:r.clientX,top:r.clientY});if(n&&n.inside>-1&&Fe.isSelectable(t.state.doc.nodeAt(n.inside)))return false;t.dispatch(t.state.tr.setSelection(new Kh(i)));return true}function Qh(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Kh))return false;let{$from:r}=t.state.selection;let i=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!i)return false;let n=l.empty;for(let t=i.length-1;t>=0;t--)n=l.from(i[t].createAndFill(null,n));let s=t.state.tr.replace(r.pos,r.pos,new d(n,0,0));s.setSelection(Je.near(s.doc.resolve(r.pos+1)));t.dispatch(s);return false}function Zh(t){if(!(t.selection instanceof Kh))return null;let e=document.createElement("div");e.className="ProseMirror-gapcursor";return Js.create(t.doc,[Hs.widget(t.selection.head,e,{key:"gapcursor"})])}const ta=au.create({name:"gapCursor",addProseMirrorPlugins(){return[Gh()]},extendNodeSchema(t){var e;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Jl(Rl(t,"allowGapCursor",r)))!==null&&e!==void 0?e:null}}});const ea=vh.create({name:"hardBreak",addOptions(){return{keepMarks:true,HTMLAttributes:{}}},inline:true,group:"inline",selectable:false,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Hl(this.options.HTMLAttributes,t)]},renderText(){return"\n"},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:r,editor:i})=>t.first([()=>t.exitCode(),()=>t.command((()=>{const{selection:t,storedMarks:n}=r;if(t.$from.parent.type.spec.isolating){return false}const{keepMarks:s}=this.options;const{splittableMarks:o}=i.extensionManager;const l=n||t.$to.parentOffset&&t.$from.marks();return e().insertContent({type:this.name}).command((({tr:t,dispatch:e})=>{if(e&&l&&s){const e=l.filter((t=>o.includes(t.type.name)));t.ensureMarks(e)}return true})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});const ra=vh.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:true,addAttributes(){return{level:{default:1,rendered:false}}},parseHTML(){return this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}})))},renderHTML({node:t,HTMLAttributes:e}){const r=this.options.levels.includes(t.attrs.level);const i=r?t.attrs.level:this.options.levels[0];return[`h${i}`,Hl(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>{if(!this.options.levels.includes(t.level)){return false}return e.setNode(this.name,t)},toggleHeading:t=>({commands:e})=>{if(!this.options.levels.includes(t.level)){return false}return e.toggleNode(this.name,"paragraph",t)}}},addKeyboardShortcuts(){return this.options.levels.reduce(((t,e)=>({...t,...{[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}})),{})},addInputRules(){return this.options.levels.map((t=>gh({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}})))}});var ia=200;var na=function t(){};na.prototype.append=function t(e){if(!e.length){return this}e=na.from(e);return!this.length&&e||e.length<ia&&this.leafAppend(e)||this.length<ia&&e.leafPrepend(this)||this.appendInner(e)};na.prototype.prepend=function t(e){if(!e.length){return this}return na.from(e).append(this)};na.prototype.appendInner=function t(e){return new oa(this,e)};na.prototype.slice=function t(e,r){if(e===void 0)e=0;if(r===void 0)r=this.length;if(e>=r){return na.empty}return this.sliceInner(Math.max(0,e),Math.min(this.length,r))};na.prototype.get=function t(e){if(e<0||e>=this.length){return undefined}return this.getInner(e)};na.prototype.forEach=function t(e,r,i){if(r===void 0)r=0;if(i===void 0)i=this.length;if(r<=i){this.forEachInner(e,r,i,0)}else{this.forEachInvertedInner(e,r,i,0)}};na.prototype.map=function t(e,r,i){if(r===void 0)r=0;if(i===void 0)i=this.length;var n=[];this.forEach((function(t,r){return n.push(e(t,r))}),r,i);return n};na.from=function t(e){if(e instanceof na){return e}return e&&e.length?new sa(e):na.empty};var sa=function(t){function e(e){t.call(this);this.values=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;var r={length:{configurable:true},depth:{configurable:true}};e.prototype.flatten=function t(){return this.values};e.prototype.sliceInner=function t(r,i){if(r==0&&i==this.length){return this}return new e(this.values.slice(r,i))};e.prototype.getInner=function t(e){return this.values[e]};e.prototype.forEachInner=function t(e,r,i,n){for(var s=r;s<i;s++){if(e(this.values[s],n+s)===false){return false}}};e.prototype.forEachInvertedInner=function t(e,r,i,n){for(var s=r-1;s>=i;s--){if(e(this.values[s],n+s)===false){return false}}};e.prototype.leafAppend=function t(r){if(this.length+r.length<=ia){return new e(this.values.concat(r.flatten()))}};e.prototype.leafPrepend=function t(r){if(this.length+r.length<=ia){return new e(r.flatten().concat(this.values))}};r.length.get=function(){return this.values.length};r.depth.get=function(){return 0};Object.defineProperties(e.prototype,r);return e}(na);na.empty=new sa([]);var oa=function(t){function e(e,r){t.call(this);this.left=e;this.right=r;this.length=e.length+r.length;this.depth=Math.max(e.depth,r.depth)+1}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.flatten=function t(){return this.left.flatten().concat(this.right.flatten())};e.prototype.getInner=function t(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)};e.prototype.forEachInner=function t(e,r,i,n){var s=this.left.length;if(r<s&&this.left.forEachInner(e,r,Math.min(i,s),n)===false){return false}if(i>s&&this.right.forEachInner(e,Math.max(r-s,0),Math.min(this.length,i)-s,n+s)===false){return false}};e.prototype.forEachInvertedInner=function t(e,r,i,n){var s=this.left.length;if(r>s&&this.right.forEachInvertedInner(e,r-s,Math.max(i,s)-s,n+s)===false){return false}if(i<s&&this.left.forEachInvertedInner(e,Math.min(r,s),i,n)===false){return false}};e.prototype.sliceInner=function t(e,r){if(e==0&&r==this.length){return this}var i=this.left.length;if(r<=i){return this.left.slice(e,r)}if(e>=i){return this.right.slice(e-i,r-i)}return this.left.slice(e,i).append(this.right.slice(0,r-i))};e.prototype.leafAppend=function t(r){var i=this.right.leafAppend(r);if(i){return new e(this.left,i)}};e.prototype.leafPrepend=function t(r){var i=this.left.leafPrepend(r);if(i){return new e(i,this.right)}};e.prototype.appendInner=function t(r){if(this.left.depth>=Math.max(this.right.depth,r.depth)+1){return new e(this.left,new e(this.right,r))}return new e(this,r)};return e}(na);const la=500;class ua{constructor(t,e){this.items=t;this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--){let t=this.items.get(r-1);if(t.selection){--r;break}}let i,n;if(e){i=this.remapping(r,this.items.length);n=i.maps.length}let s=t.tr;let o,l;let u=[],f=[];this.items.forEach(((t,e)=>{if(!t.step){if(!i){i=this.remapping(r,e+1);n=i.maps.length}n--;f.push(t);return}if(i){f.push(new ha(t.map));let e=t.step.map(i.slice(n)),r;if(e&&s.maybeStep(e).doc){r=s.mapping.maps[s.mapping.maps.length-1];u.push(new ha(r,undefined,undefined,u.length+f.length))}n--;if(r)i.appendMap(r,n)}else{s.maybeStep(t.step)}if(t.selection){o=i?t.selection.map(i.slice(n)):t.selection;l=new ua(this.items.slice(0,r).append(f.reverse().concat(u)),this.eventCount-1);return false}}),this.items.length,0);return{remaining:l,transform:s,selection:o}}addTransform(t,e,r,i){let n=[],s=this.eventCount;let o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let r=0;r<t.steps.length;r++){let u=t.steps[r].invert(t.docs[r]);let f=new ha(t.mapping.maps[r],u,e),h;if(h=l&&l.merge(f)){f=h;if(r)n.pop();else o=o.slice(0,o.length-1)}n.push(f);if(e){s++;e=undefined}if(!i)l=f}let u=s-r.depth;if(u>ca){o=fa(o,u);s-=u}return new ua(o.append(n),s)}remapping(t,e){let r=new Dt;this.items.forEach(((e,i)=>{let n=e.mirrorOffset!=null&&i-e.mirrorOffset>=t?r.maps.length-e.mirrorOffset:undefined;r.appendMap(e.map,n)}),t,e);return r}addMaps(t){if(this.eventCount==0)return this;return new ua(this.items.append(t.map((t=>new ha(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-e);let n=t.mapping;let s=t.steps.length;let o=this.eventCount;this.items.forEach((t=>{if(t.selection)o--}),i);let l=e;this.items.forEach((e=>{let i=n.getMirror(--l);if(i==null)return;s=Math.min(s,i);let u=n.maps[i];if(e.step){let s=t.steps[i].invert(t.docs[i]);let f=e.selection&&e.selection.map(n.slice(l+1,i));if(f)o++;r.push(new ha(u,s,f))}else{r.push(new ha(u))}}),i);let u=[];for(let t=e;t<s;t++)u.push(new ha(n.maps[t]));let f=this.items.slice(0,i).append(u).append(r);let h=new ua(f,o);if(h.emptyItemCount()>la)h=h.compress(this.items.length-r.length);return h}emptyItemCount(){let t=0;this.items.forEach((e=>{if(!e.step)t++}));return t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length;let i=[],n=0;this.items.forEach(((s,o)=>{if(o>=t){i.push(s);if(s.selection)n++}else if(s.step){let t=s.step.map(e.slice(r)),o=t&&t.getMap();r--;if(o)e.appendMap(o,r);if(t){let l=s.selection&&s.selection.map(e.slice(r));if(l)n++;let u=new ha(o.invert(),t,l),f,h=i.length-1;if(f=i.length&&i[h].merge(u))i[h]=f;else i.push(u)}}else if(s.map){r--}}),this.items.length,0);return new ua(na.from(i.reverse()),n)}}ua.empty=new ua(na.empty,0);function fa(t,e){let r;t.forEach(((t,i)=>{if(t.selection&&e--==0){r=i;return false}}));return t.slice(r)}class ha{constructor(t,e,r,i){this.map=t;this.step=e;this.selection=r;this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new ha(e.getMap().invert(),e,this.selection)}}}class aa{constructor(t,e,r,i,n){this.done=t;this.undone=e;this.prevRanges=r;this.prevTime=i;this.prevComposition=n}}const ca=20;function da(t,e,r,i){let n=r.getMeta(Ma),s;if(n)return n.historyState;if(r.getMeta(ka))t=new aa(t.done,t.undone,null,0,-1);let o=r.getMeta("appendedTransaction");if(r.steps.length==0){return t}else if(o&&o.getMeta(Ma)){if(o.getMeta(Ma).redo)return new aa(t.done.addTransform(r,undefined,i,ya(e)),t.undone,ma(r.mapping.maps[r.steps.length-1]),t.prevTime,t.prevComposition);else return new aa(t.done,t.undone.addTransform(r,undefined,i,ya(e)),null,t.prevTime,t.prevComposition)}else if(r.getMeta("addToHistory")!==false&&!(o&&o.getMeta("addToHistory")===false)){let n=r.getMeta("composition");let s=t.prevTime==0||!o&&t.prevComposition!=n&&(t.prevTime<(r.time||0)-i.newGroupDelay||!pa(r,t.prevRanges));let l=o?ga(t.prevRanges,r.mapping):ma(r.mapping.maps[r.steps.length-1]);return new aa(t.done.addTransform(r,s?e.selection.getBookmark():undefined,i,ya(e)),ua.empty,l,r.time,n==null?t.prevComposition:n)}else if(s=r.getMeta("rebased")){return new aa(t.done.rebased(r,s),t.undone.rebased(r,s),ga(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}else{return new aa(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),ga(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}}function pa(t,e){if(!e)return false;if(!t.docChanged)return true;let r=false;t.mapping.maps[0].forEach(((t,i)=>{for(let n=0;n<e.length;n+=2)if(t<=e[n+1]&&i>=e[n])r=true}));return r}function ma(t){let e=[];t.forEach(((t,r,i,n)=>e.push(i,n)));return e}function ga(t,e){if(!t)return null;let r=[];for(let i=0;i<t.length;i+=2){let n=e.map(t[i],1),s=e.map(t[i+1],-1);if(n<=s)r.push(n,s)}return r}function wa(t,e,r){let i=ya(e);let n=Ma.get(e).spec.config;let s=(r?t.undone:t.done).popEvent(e,i);if(!s)return null;let o=s.selection.resolve(s.transform.doc);let l=(r?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),n,i);let u=new aa(r?l:s.remaining,r?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Ma,{redo:r,historyState:u})}let ba=false,va=null;function ya(t){let e=t.plugins;if(va!=e){ba=false;va=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){ba=true;break}}return ba}const Ma=new lr("history");const ka=new lr("closeHistory");function xa(t={}){t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500};return new nr({key:Ma,state:{init(){return new aa(ua.empty,ua.empty,null,0,-1)},apply(e,r,i){return da(r,i,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(t,e){let r=e.inputType;let i=r=="historyUndo"?Oa:r=="historyRedo"?Ta:null;if(!i)return false;e.preventDefault();return i(t.state,t.dispatch)}}}})}function Sa(t,e){return(r,i)=>{let n=Ma.getState(r);if(!n||(t?n.undone:n.done).eventCount==0)return false;if(i){let s=wa(n,r,t);if(s)i(e?s.scrollIntoView():s)}return true}}const Oa=Sa(false,true);const Ta=Sa(true,true);const Ea=au.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Oa(t,e),redo:()=>({state:t,dispatch:e})=>Ta(t,e)}},addProseMirrorPlugins(){return[xa(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});const Pa=vh.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Hl(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{const{$to:r}=e.selection;const i=t();if(r.parentOffset===0){i.insertContentAt(Math.max(r.pos-2,0),{type:this.name})}else{i.insertContent({type:this.name})}return i.command((({tr:t,dispatch:e})=>{var r;if(e){const{$to:e}=t.selection;const i=e.end();if(e.nodeAfter){if(e.nodeAfter.isTextblock){t.setSelection(Je.create(t.doc,e.pos+1))}else if(e.nodeAfter.isBlock){t.setSelection(Fe.create(t.doc,e.pos))}else{t.setSelection(Je.create(t.doc,e.pos))}}else{const n=(r=e.parent.type.contentMatch.defaultType)===null||r===void 0?void 0:r.create();if(n){t.insert(i,n);t.setSelection(Je.create(t.doc,i+1))}}t.scrollIntoView()}return true})).run()}}},addInputRules(){return[mh({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});const Aa=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/;const Ca=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g;const Na=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/;const $a=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g;const Ra=bh.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Hl(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ph({find:Aa,type:this.type}),ph({find:Na,type:this.type})]},addPasteRules(){return[yh({find:Ca,type:this.type}),yh({find:$a,type:this.type})]}});const Da=vh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:true,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Hl(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});const Ia=vh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:true,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Hl(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});const La=bh.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>{const e=t.hasAttribute("style");if(!e){return false}return{}}}]},renderHTML({HTMLAttributes:t}){return["span",Hl(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const r=kf(t,this.type);const i=Object.entries(r).some((([,t])=>!!t));if(i){return true}return e.unsetMark(this.name)}}}});const Ha=/^(\d+)\.\s$/;const ja=vh.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:false,keepAttributes:false}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...r}=t;return e===1?["ol",Hl(this.options.HTMLAttributes,r),0]:["ol",Hl(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>{if(this.options.keepAttributes){return e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ia.name,this.editor.getAttributes(La.name)).run()}return t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=wh({find:Ha,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});if(this.options.keepMarks||this.options.keepAttributes){t=wh({find:Ha,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(La.name)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})}return[t]}});const Ba=vh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Hl(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});const Ja=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/;const za=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g;const Fa=bh.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:false,getAttrs:t=>t.includes("line-through")?{}:false}]},renderHTML({HTMLAttributes:t}){return["s",Hl(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ph({find:Ja,type:this.type})]},addPasteRules(){return[yh({find:za,type:this.type})]}});const _a=vh.create({name:"text",group:"inline"});const Ka=au.create({name:"starterKit",addExtensions(){var t,e,r,i,n,s,o,l,u,f,h,a,c,d,p,m,g,w;const b=[];if(this.options.blockquote!==false){b.push(Sh.configure((t=this.options)===null||t===void 0?void 0:t.blockquote))}if(this.options.bold!==false){b.push(Ah.configure((e=this.options)===null||e===void 0?void 0:e.bold))}if(this.options.bulletList!==false){b.push(Rh.configure((r=this.options)===null||r===void 0?void 0:r.bulletList))}if(this.options.code!==false){b.push(Lh.configure((i=this.options)===null||i===void 0?void 0:i.code))}if(this.options.codeBlock!==false){b.push(Bh.configure((n=this.options)===null||n===void 0?void 0:n.codeBlock))}if(this.options.document!==false){b.push(Jh.configure((s=this.options)===null||s===void 0?void 0:s.document))}if(this.options.dropcursor!==false){b.push(_h.configure((o=this.options)===null||o===void 0?void 0:o.dropcursor))}if(this.options.gapcursor!==false){b.push(ta.configure((l=this.options)===null||l===void 0?void 0:l.gapcursor))}if(this.options.hardBreak!==false){b.push(ea.configure((u=this.options)===null||u===void 0?void 0:u.hardBreak))}if(this.options.heading!==false){b.push(ra.configure((f=this.options)===null||f===void 0?void 0:f.heading))}if(this.options.history!==false){b.push(Ea.configure((h=this.options)===null||h===void 0?void 0:h.history))}if(this.options.horizontalRule!==false){b.push(Pa.configure((a=this.options)===null||a===void 0?void 0:a.horizontalRule))}if(this.options.italic!==false){b.push(Ra.configure((c=this.options)===null||c===void 0?void 0:c.italic))}if(this.options.listItem!==false){b.push(Da.configure((d=this.options)===null||d===void 0?void 0:d.listItem))}if(this.options.orderedList!==false){b.push(ja.configure((p=this.options)===null||p===void 0?void 0:p.orderedList))}if(this.options.paragraph!==false){b.push(Ba.configure((m=this.options)===null||m===void 0?void 0:m.paragraph))}if(this.options.strike!==false){b.push(Fa.configure((g=this.options)===null||g===void 0?void 0:g.strike))}if(this.options.text!==false){b.push(_a.configure((w=this.options)===null||w===void 0?void 0:w.text))}return b}});const qa='@charset "UTF-8";\n:host {\n display: block;\n}\n\n.ProseMirror p.is-editor-empty:first-child::before {\n color: var(--sc-input-placeholder-color);\n content: attr(data-placeholder);\n float: left;\n height: 0;\n pointer-events: none;\n}\n\n.ProseMirror [class~=lead] {\n color: var(--sc-input-color);\n font-size: var(--sc-input-spacing-small);\n line-height: 1.6;\n margin-top: 1.2em;\n margin-bottom: 1.2em;\n}\n\n.ProseMirror a {\n position: relative;\n}\n\n.ProseMirror a::before {\n content: "";\n position: absolute;\n bottom: -0.3em;\n left: 0;\n right: 0;\n height: 3px;\n width: 100%;\n @apply bg-gradient-to-r bg-gradient-teal transition-transform duration-200 transform;\n pointer-events: none;\n}\n\n.ProseMirror a:hover::before,\n.ProseMirror a:focus::before {\n transform: scaleX(0.95);\n}\n\n.ProseMirror strong {\n font-weight: 600;\n}\n\n.ProseMirror ol {\n counter-reset: list-counter;\n margin-top: var(--sc-input-spacing-small);\n margin-bottom: var(--sc-input-spacing-small);\n}\n\n.ProseMirror ol > li {\n position: relative;\n}\n\n.ProseMirror ul > li {\n position: relative;\n}\n\n.ProseMirror ul > li::before {\n content: "";\n position: absolute;\n background-color: var(--sc-color-gray-400);\n border-radius: 50%;\n width: 0.375em;\n height: 0.375em;\n top: 0.6875em;\n left: -1rem;\n}\n\n.ProseMirror hr {\n border-color: var(--sc-color-gray-400);\n border-top-width: 1px;\n margin-top: 3em;\n margin-bottom: 3em;\n}\n\n.ProseMirror blockquote {\n font-weight: 500;\n font-style: italic;\n color: #1a202c;\n border-left-width: 0.25rem;\n border-left-color: var(--sc-color-gray-400);\n quotes: "“" "”" "‘" "’";\n margin-top: 1.6em;\n margin-bottom: 1.6em;\n padding-left: 1em;\n}\n\n.ProseMirror blockquote p:first-of-type::before {\n content: open-quote;\n}\n\n.ProseMirror blockquote p:last-of-type::after {\n content: close-quote;\n}\n\n.ProseMirror h1 {\n font-weight: 800;\n font-size: 2.25em;\n margin-top: 0;\n margin-bottom: 0.8888889em;\n line-height: 1.1111111;\n}\n\n.ProseMirror h2 {\n font-weight: 700;\n font-size: 1.5em;\n margin-top: 2em;\n margin-bottom: 1em;\n line-height: 1.3333333;\n}\n\n.ProseMirror h3 {\n font-weight: 600;\n font-size: var(--sc-input-spacing-small);\n margin-top: 1.6em;\n margin-bottom: 0.6em;\n line-height: 1.6;\n}\n\n.ProseMirror h4 {\n font-weight: 600;\n margin-top: 1.5em;\n margin-bottom: 0.5em;\n line-height: 1.5;\n}\n\n.ProseMirror figure figcaption {\n color: var(--sc-color-gray-600);\n font-size: 0.875em;\n line-height: 1.4285714;\n margin-top: 0.8571429em;\n}\n\n.ProseMirror code {\n color: var(--sc-color-gray-900);\n font-weight: 600;\n font-size: 0.875em;\n}\n\n.ProseMirror code::before {\n content: "`";\n}\n\n.ProseMirror code::after {\n content: "`";\n}\n\n.ProseMirror pre {\n color: var(--sc-color-gray-300);\n background-color: var(--sc-color-gray-800);\n overflow-x: auto;\n font-size: 0.875em;\n line-height: 1.7142857;\n margin-top: 1.7142857em;\n margin-bottom: 1.7142857em;\n border-radius: 0.375rem;\n padding-top: 0.8571429em;\n padding-right: 1.1428571em;\n padding-bottom: 0.8571429em;\n padding-left: 1.1428571em;\n}\n\n.ProseMirror pre code {\n background-color: transparent;\n border-width: 0;\n border-radius: 0;\n padding: 0;\n font-weight: 400;\n color: inherit;\n font-size: inherit;\n font-family: inherit;\n line-height: inherit;\n}\n\n.ProseMirror pre code::before {\n content: "";\n}\n\n.ProseMirror pre code::after {\n content: "";\n}\n\n.ProseMirror table {\n width: 100%;\n table-layout: auto;\n text-align: left;\n margin-top: 2em;\n margin-bottom: 2em;\n font-size: 0.875em;\n line-height: 1.7142857;\n}\n\n.ProseMirror thead {\n color: #1a202c;\n font-weight: 600;\n border-bottom-width: 1px;\n border-bottom-color: var(--sc-color-gray-400);\n}\n\n.ProseMirror thead th {\n vertical-align: bottom;\n padding-right: 0.5714286em;\n padding-bottom: 0.5714286em;\n padding-left: 0.5714286em;\n}\n\n.ProseMirror tbody tr {\n border-bottom-width: 1px;\n border-bottom-color: var(--sc-color-gray-400);\n}\n\n.ProseMirror tbody tr:last-child {\n border-bottom-width: 0;\n}\n\n.ProseMirror tbody td {\n vertical-align: top;\n padding-top: 0.5714286em;\n padding-right: 0.5714286em;\n padding-bottom: 0.5714286em;\n padding-left: 0.5714286em;\n}\n\n.ProseMirror {\n font-size: var(--sc-font-size-medium);\n color: var(--sc-input-color);\n line-height: 1.75;\n}\n\n.ProseMirror p {\n margin-top: var(--sc-input-spacing-small);\n margin-bottom: var(--sc-input-spacing-small);\n}\n\n.ProseMirror img {\n margin-top: 2em;\n margin-bottom: 2em;\n}\n\n.ProseMirror video {\n margin-top: 2em;\n margin-bottom: 2em;\n}\n\n.ProseMirror figure {\n margin-top: 2em;\n margin-bottom: 2em;\n}\n\n.ProseMirror figure > * {\n margin-top: 0;\n margin-bottom: 0;\n}\n\n.ProseMirror h2 code {\n font-size: 0.875em;\n}\n\n.ProseMirror h3 code {\n font-size: 0.9em;\n}\n\n.ProseMirror ul {\n margin-top: var(--sc-input-spacing-small);\n margin-bottom: var(--sc-input-spacing-small);\n list-style: none;\n}\n\n.ProseMirror li {\n margin-top: 0.5em;\n margin-bottom: 0.5em;\n}\n\n.ProseMirror ol > li:before {\n left: 0;\n}\n\n.ProseMirror > ul > li p {\n margin-top: 0.75em;\n margin-bottom: 0.75em;\n}\n\n.ProseMirror > ul > li > *:first-child {\n margin-top: var(--sc-input-spacing-small);\n}\n\n.ProseMirror > ul > li > *:last-child {\n margin-bottom: var(--sc-input-spacing-small);\n}\n\n.ProseMirror > ol > li > *:first-child {\n margin-top: var(--sc-input-spacing-small);\n}\n\n.ProseMirror > ol > li > *:last-child {\n margin-bottom: var(--sc-input-spacing-small);\n}\n\n.ProseMirror ul ul,\n.ProseMirror ul ol,\n.ProseMirror ol ul,\n.ProseMirror ol ol {\n margin-top: 0.75em;\n margin-bottom: 0.75em;\n}\n\n.ProseMirror hr + * {\n margin-top: 0;\n}\n\n.ProseMirror h2 + * {\n margin-top: 0;\n}\n\n.ProseMirror h3 + * {\n margin-top: 0;\n}\n\n.ProseMirror h4 + * {\n margin-top: 0;\n}\n\n.ProseMirror thead th:first-child {\n padding-left: 0;\n}\n\n.ProseMirror thead th:last-child {\n padding-right: 0;\n}\n\n.ProseMirror tbody td:first-child {\n padding-left: 0;\n}\n\n.ProseMirror tbody td:last-child {\n padding-right: 0;\n}\n\n.ProseMirror > :first-child {\n margin-top: 0;\n}\n\n.ProseMirror > :last-child {\n margin-bottom: 0;\n}\n\n.editor-base {\n position: relative;\n width: 100%;\n font-family: var(--sc-input-font-family);\n font-weight: var(--sc-input-font-weight);\n line-height: var(--sc-line-height-normal);\n letter-spacing: var(--sc-input-letter-spacing);\n vertical-align: middle;\n transition: var(--sc-transition-fast) color, var(--sc-transition-fast) border, var(--sc-transition-fast) box-shadow, var(--sc-transition-fast) background-color;\n cursor: text;\n background-color: var(--sc-input-background-color);\n border: solid var(--sc-input-border-width) var(--sc-input-border-color);\n}\n\n[contenteditable] {\n position: relative;\n outline: none;\n width: 100%;\n box-sizing: border-box;\n border-top: solid var(--sc-input-border-width) var(--sc-input-border-color);\n padding: var(--sc-input-spacing-medium);\n overflow-y: auto;\n max-height: var(--sc-rich-text-max-height, none);\n}\n\n.menu {\n display: flex;\n line-height: 0;\n gap: var(--sc-spacing-xx-small);\n padding: var(--sc-spacing-x-small);\n}\n\n.editor-base {\n display: grid;\n gap: 0;\n}\n\n.right {\n margin-left: auto;\n}\n\n.textarea__char-limit-warning {\n margin-top: var(--sc-input-spacing-small);\n color: var(--sc-input-help-text-color);\n font-size: var(--sc-input-help-text-font-size-medium);\n}';const Ua=qa;let Wa=0;const Ga=class{constructor(r){t(this,r);this.scChange=e(this,"scChange",7);this.scInput=e(this,"scInput",7);this.scBlur=e(this,"scBlur",7);this.scFocus=e(this,"scFocus",7);this.inputId=`sc-richtext-${++Wa}`;this.helpId=`sc-richtext-help-text-${Wa}`;this.labelId=`sc-richtext-label-${Wa}`;this.size="medium";this.name=undefined;this.value="";this.label="";this.showLabel=true;this.help="";this.placeholder=undefined;this.maxlength=undefined;this.disabled=false;this.readonly=false;this.required=false;this.updatedAt=Date.now();this.hasFocus=undefined}componentDidLoad(){if(this.editor)return;this.editor=new dh({element:this.element,extensions:[Ka,kh.configure({placeholder:this.placeholder}),...(this===null||this===void 0?void 0:this.maxlength)>0?[Mh.configure({limit:this.maxlength,mode:"nodeSize"})]:[]],content:this.value,onCreate:({editor:t})=>{this.value=t.getHTML()},onUpdate:({editor:t})=>{this.value=t.getHTML();this.scInput.emit();this.scChange.emit()},onSelectionUpdate:()=>{this.updatedAt=Date.now()},onFocus:()=>{this.handleFocus()},onBlur:()=>{this.handleBlur()}})}handleFocus(){this.hasFocus=true;this.scFocus.emit()}handleBlur(){this.hasFocus=false;this.scBlur.emit()}isActive(t,e={}){var r,i;return(i=(r=this.editor)===null||r===void 0?void 0:r.isActive)===null||i===void 0?void 0:i.call(r,t,e)}toggleHeading(t){this.editor.chain().toggleHeading(t).focus().run()}toggleBold(){this.editor.chain().toggleBold().focus().run()}toggleItalic(){this.editor.chain().toggleItalic().focus().run()}can(t){var e,r,i,n,s,o,l,u,f;return(f=(u=(l=(o=(s=(n=(i=(r=(e=this.editor)===null||e===void 0?void 0:e.can())===null||r===void 0?void 0:r.chain)===null||i===void 0?void 0:i.call(r))===null||n===void 0?void 0:n.focus)===null||s===void 0?void 0:s.call(n))===null||o===void 0?void 0:o[t])===null||l===void 0?void 0:l.call(o))===null||u===void 0?void 0:u.run)===null||f===void 0?void 0:f.call(u)}run(t){var e,r,i,n,s,o,l,u;return(u=(l=(o=(s=(n=(i=(r=(e=this.editor)===null||e===void 0?void 0:e.chain)===null||r===void 0?void 0:r.call(e))===null||i===void 0?void 0:i.focus)===null||n===void 0?void 0:n.call(i))===null||s===void 0?void 0:s[t])===null||o===void 0?void 0:o.call(s))===null||l===void 0?void 0:l.run)===null||u===void 0?void 0:u.call(l)}remainingCharacters(){var t,e;if(!this.maxlength)return 1e3;return this.maxlength-(((e=(t=this===null||this===void 0?void 0:this.editor)===null||t===void 0?void 0:t.storage)===null||e===void 0?void 0:e.characterCount.characters())||0)}handleKeyDown(t){if(t.key==="n"){t.stopPropagation()}}render(){var t,e,n,s,o,l,u,f;return r(i,{key:"1502f61c74a235b700738198947bb1f1fcc3a2d7"},r("sc-form-control",{key:"4a91ae418eee441f179ad96862c301dd2d99b027",exportparts:"label, help-text, form-control",size:this.size,required:this.required,label:this.label,showLabel:this.showLabel,help:this.help,inputId:this.inputId,helpId:this.helpId,labelId:this.labelId,name:this.name},r("div",{key:"b7852b025cc3dceaeff5b1976fbc30a5dd8d7bfc",part:"base",class:{"editor-base":true,"editor--focused":this.hasFocus}},r("div",{key:"e44acfd542a4e3bb865e6259a67f4991a219ad17",class:"menu"},r("sc-button",{key:"acba5c7b3a4a3936b3b0bc7d933c4b41f8fdbe4b",size:"small",type:((e=(t=this.editor)===null||t===void 0?void 0:t.isActive)===null||e===void 0?void 0:e.call(t,"bold"))?"default":"text",onClick:()=>this.run("toggleBold"),disabled:!this.can("toggleBold")},r("sc-icon",{key:"0a5769de7884c9a8e9c8fd04c3d98222888247d4",name:"bold"})),r("sc-button",{key:"33849d3a4ae6fd108e8cde701e462019fceae4c2",size:"small",type:((s=(n=this.editor)===null||n===void 0?void 0:n.isActive)===null||s===void 0?void 0:s.call(n,"italic"))?"default":"text",onClick:()=>this.run("toggleItalic"),disabled:!this.can("toggleItalic")},r("sc-icon",{key:"07975c07663a327e0cdb7cbd5ce1c443d2b08430",name:"italic"})),r("sc-button",{key:"356c7b0d26b2543ff2576ffbe0b3d27da218f0bf",size:"small",type:((l=(o=this.editor)===null||o===void 0?void 0:o.isActive)===null||l===void 0?void 0:l.call(o,"bulletList"))?"default":"text",onClick:()=>this.run("toggleBulletList")},r("sc-icon",{key:"3174d28a175f006fb84e47c3c6efb1dec2765a37",name:"list"})),r("sc-button",{key:"bc774c1bf8f96f882ed72f382d9e160b912edf70",size:"small",type:((f=(u=this.editor)===null||u===void 0?void 0:u.isActive)===null||f===void 0?void 0:f.call(u,"strike"))?"default":"text",onClick:()=>this.run("toggleStrike")},r("sc-icon",{key:"4f07ce4b7e324a9b79fe11b5ac8db93219906f90",name:"minus"})),r("sc-button",{key:"657a1b79d088d79a00b6d7545f136417589d4bf1",class:"right",size:"small",type:"text",onClick:()=>this.run("undo"),disabled:!this.can("undo")},r("sc-icon",{key:"3372a462df046ab418ccedb4d820362cc1932c77",name:"corner-up-left"})),r("sc-button",{key:"4203776abc9e0b7baa39b0c1348558a2588dab2d",size:"small",type:"text",onClick:()=>this.run("redo"),disabled:!this.can("redo")},r("sc-icon",{key:"4dc7669e49fd6efdd78de6950015b38d90322a66",name:"corner-up-right"}))),r("div",{key:"9a2efd36dcb3f84cf15cb9c737ec33b2cbefcf8e",part:"editor",class:{editor:true},ref:t=>this.element=t})),this.remainingCharacters()<20&&r("div",{key:"ccaa002f4ee3abee57ecf2f906a3ed0fcfffd504",class:"textarea__char-limit-warning"},wp.i18n.sprintf(wp.i18n.__("%d characters remaining","surecart"),this.remainingCharacters()))))}};Ga.style=Ua;export{Ga as sc_rich_text}; //# sourceMappingURL=p-34d36635.entry.js.map