whoami7 - Manager
:
/
home
/
dataiclx
/
vielorbe.com
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
components
/
Upload File:
files >> //home/dataiclx/vielorbe.com/wp-content/plugins/surecart/dist/components/components/sc-rich-text.js
import{proxyCustomElement,HTMLElement,createEvent,h,Host}from"@stencil/core/internal/client";import{d as defineCustomElement$6}from"./sc-button2.js";import{d as defineCustomElement$5}from"./sc-form-control2.js";import{d as defineCustomElement$4}from"./sc-icon2.js";import{d as defineCustomElement$3}from"./sc-spinner2.js";import{d as defineCustomElement$2}from"./sc-visually-hidden2.js";function OrderedMap(e){this.content=e}function findDiffStart(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(r),i=t.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let e=0;o.text[e]==i.text[e];e++)n++;return n}if(o.content.size||i.content.size){let e=findDiffStart(o.content,i.content,n+1);if(null!=e)return e}n+=o.nodeSize}else n+=o.nodeSize}}function findDiffEnd(e,t,n,r){for(let o=e.childCount,i=t.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let s=e.child(--o),a=t.child(--i),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let e=0,t=Math.min(s.text.length,a.text.length);for(;e<t&&s.text[s.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){let e=findDiffEnd(s.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}OrderedMap.prototype={constructor:OrderedMap,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,o=r.find(e),i=r.content.slice();return-1==o?i.push(n||e,t):(i[o+1]=t,n&&(i[o]=n)),new OrderedMap(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new OrderedMap(n)},addToStart:function(e,t){return new OrderedMap([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new OrderedMap(n)},addBefore:function(e,t,n){var r=this.remove(t),o=r.content.slice(),i=r.find(e);return o.splice(-1==i?o.length:i,0,t,n),new OrderedMap(o)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=OrderedMap.from(e)).size?new OrderedMap(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=OrderedMap.from(e)).size?new OrderedMap(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=OrderedMap.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach((function(t,n){e[t]=n})),e},get size(){return this.content.length>>1}},OrderedMap.from=function(e){if(e instanceof OrderedMap)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new OrderedMap(t)};class Fragment{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,o){for(let i=0,s=0;s<t;i++){let a=this.content[i],l=s+a.nodeSize;if(l>e&&!1!==n(a,r+s,o||null,i)&&a.content.size){let o=s+1;a.nodesBetween(Math.max(0,e-o),Math.min(a.content.size,t-o),n,r+o)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",i=!0;return this.nodesBetween(e,t,((s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=l}),0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)r.push(e.content[o]);return new Fragment(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let o=0,i=0;i<t;o++){let s=this.content[o],a=i+s.nodeSize;a>e&&((i<e||a>t)&&(s=s.isText?s.cut(Math.max(0,e-i),Math.min(s.text.length,t-i)):s.cut(Math.max(0,e-i-1),Math.min(s.content.size,t-i-1))),n.push(s),r+=s.nodeSize),i=a}return new Fragment(n,r)}cutByIndex(e,t){return e==t?Fragment.empty:0==e&&t==this.content.length?this:new Fragment(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new Fragment(r,o)}addToStart(e){return new Fragment([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Fragment(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return findDiffStart(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return findDiffEnd(this,e,t,n)}findIndex(e,t=-1){if(0==e)return retIndex(0,e);if(e==this.size)return retIndex(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=r+this.child(n).nodeSize;if(o>=e)return o==e||t>0?retIndex(n+1,o):retIndex(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((e=>e.toJSON())):null}static fromJSON(e,t){if(!t)return Fragment.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new Fragment(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Fragment.empty;let t,n=0;for(let r=0;r<e.length;r++){let o=e[r];n+=o.nodeSize,r&&o.isText&&e[r-1].sameMarkup(o)?(t||(t=e.slice(0,r)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new Fragment(t||e,n)}static from(e){if(!e)return Fragment.empty;if(e instanceof Fragment)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Fragment([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Fragment.empty=new Fragment([],0);const found={index:0,offset:0};function retIndex(e,t){return found.index=e,found.offset=t,found}function compareDeep(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!compareDeep(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!compareDeep(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Mark$1{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&compareDeep(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return Mark$1.none;if(e instanceof Mark$1)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}Mark$1.none=[];class ReplaceError extends Error{}class Slice{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=insertInto(this.content,e+this.openStart,t);return n&&new Slice(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Slice(removeRange(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Slice.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new Slice(Fragment.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new Slice(e,n,r)}}function removeRange(e,t,n){let{index:r,offset:o}=e.findIndex(t),i=e.maybeChild(r),{index:s,offset:a}=e.findIndex(n);if(o==t||i.isText){if(a!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(removeRange(i.content,t-o-1,n-o-1)))}function insertInto(e,t,n,r){let{index:o,offset:i}=e.findIndex(t),s=e.maybeChild(o);if(i==t||s.isText)return r&&!r.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=insertInto(s.content,t-i-1,n);return a&&e.replaceChild(o,s.copy(a))}function replace(e,t,n){if(n.openStart>e.depth)throw new ReplaceError("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ReplaceError("Inconsistent open depths");return replaceOuter(e,t,n,0)}function replaceOuter(e,t,n,r){let o=e.index(r),i=e.node(r);if(o==t.index(r)&&r<e.depth-n.openStart){let s=replaceOuter(e,t,n,r+1);return i.copy(i.content.replaceChild(o,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:o,end:s}=prepareSliceForReplace(n,e);return close(i,replaceThreeWay(e,o,s,t,r))}{let r=e.parent,o=r.content;return close(r,o.cut(0,e.parentOffset).append(n.content).append(o.cut(t.parentOffset)))}}return close(i,replaceTwoWay(e,t,r))}function checkJoin(e,t){if(!t.type.compatibleContent(e.type))throw new ReplaceError("Cannot join "+t.type.name+" onto "+e.type.name)}function joinable$1(e,t,n){let r=e.node(n);return checkJoin(r,t.node(n)),r}function addNode(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function addRange(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(addNode(e.nodeAfter,r),i++));for(let e=i;e<s;e++)addNode(o.child(e),r);t&&t.depth==n&&t.textOffset&&addNode(t.nodeBefore,r)}function close(e,t){return e.type.checkContent(t),e.copy(t)}function replaceThreeWay(e,t,n,r,o){let i=e.depth>o&&joinable$1(e,t,o+1),s=r.depth>o&&joinable$1(n,r,o+1),a=[];return addRange(null,e,o,a),i&&s&&t.index(o)==n.index(o)?(checkJoin(i,s),addNode(close(i,replaceThreeWay(e,t,n,r,o+1)),a)):(i&&addNode(close(i,replaceTwoWay(e,t,o+1)),a),addRange(t,n,o,a),s&&addNode(close(s,replaceTwoWay(n,r,o+1)),a)),addRange(r,null,o,a),new Fragment(a)}function replaceTwoWay(e,t,n){let r=[];return addRange(null,e,n,r),e.depth>n&&addNode(close(joinable$1(e,t,n+1),replaceTwoWay(e,t,n+1)),r),addRange(t,null,n,r),new Fragment(r)}function prepareSliceForReplace(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(Fragment.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}Slice.empty=new Slice(Fragment.empty,0,0);class ResolvedPos{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Mark$1.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var i=0;i<o.length;i++)!1!==o[i].type.spec.inclusive||r&&o[i].isInSet(r.marks)||(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new NodeRange(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new ResolvedPos(t,n,o)}static resolveCached(e,t){for(let n=0;n<resolveCache.length;n++){let r=resolveCache[n];if(r.pos==t&&r.doc==e)return r}let n=resolveCache[resolveCachePos]=ResolvedPos.resolve(e,t);return resolveCachePos=(resolveCachePos+1)%resolveCacheSize,n}}let resolveCache=[],resolveCachePos=0,resolveCacheSize=12;class NodeRange{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const emptyAttrs=Object.create(null);class Node$1{constructor(e,t,n,r=Mark$1.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||Fragment.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&compareDeep(this.attrs,t||e.defaultAttrs||emptyAttrs)&&Mark$1.sameSet(this.marks,n||Mark$1.none)}copy(e=null){return e==this.content?this:new Node$1(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Node$1(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Slice.empty;let r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new Slice(a,r.depth-i,o.depth-i)}replace(e,t,n){return replace(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return ResolvedPos.resolveCached(this,e)}resolveNoCache(e){return ResolvedPos.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,(e=>(n.isInSet(e.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),wrapMarks(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=Fragment.empty,r=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;e<o;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content);let e=Mark$1.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!Mark$1.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=Fragment.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}Node$1.prototype.text=void 0;class TextNode extends Node$1{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wrapMarks(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new TextNode(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new TextNode(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function wrapMarks(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ContentMatch{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new TokenStream(e,t);if(null==n.next)return ContentMatch.empty;let r=parseExpr(n);n.next&&n.err("Unexpected trailing text");let o=dfa(nfa(r));return checkForDeadEnds(o,n),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function o(i,s){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return Fragment.from(s.map((e=>e.createAndFill())));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=o(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),o=r.match;if(o.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:i,next:s}=o.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map(((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r})).join("\n")}}ContentMatch.empty=new ContentMatch(!0);class TokenStream{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function parseExpr(e){let t=[];do{t.push(parseExprSeq(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function parseExprSeq(e){let t=[];do{t.push(parseExprSubscript(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function parseExprSubscript(e){let t=parseExprAtom(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=parseExprRange(e,t)}return t}function parseNum(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function parseExprRange(e,t){let n=parseNum(e),r=n;return e.eat(",")&&(r="}"!=e.next?parseNum(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function resolveName(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.groups.indexOf(t)>-1&&o.push(r)}return 0==o.length&&e.err("No node type or group '"+t+"' found"),o}function parseExprAtom(e){if(e.eat("(")){let t=parseExpr(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=resolveName(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}function nfa(e){let t=[[]];return o(function e(t,i){if("choice"==t.type)return t.exprs.reduce(((t,n)=>t.concat(e(n,i))),[]);if("seq"!=t.type){if("star"==t.type){let s=n();return r(i,s),o(e(t.expr,s),s),[r(s)]}if("plus"==t.type){let s=n();return o(e(t.expr,i),s),o(e(t.expr,s),s),[r(s)]}if("opt"==t.type)return[r(i)].concat(e(t.expr,i));if("range"==t.type){let s=i;for(let r=0;r<t.min;r++){let r=n();o(e(t.expr,s),r),s=r}if(-1==t.max)o(e(t.expr,s),s);else for(let i=t.min;i<t.max;i++){let i=n();r(s,i),o(e(t.expr,s),i),s=i}return[r(s)]}if("name"==t.type)return[r(i,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=e(t.exprs[r],i);if(r==t.exprs.length-1)return s;o(s,i=n())}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach((e=>e.to=t))}}function cmp(e,t){return t-e}function nullFrom(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e<o.length;e++){let{term:r,to:i}=o[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(cmp)}function dfa(e){let t=Object.create(null);return function n(r){let o=[];r.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<o.length;e++)o[e][0]==t&&(r=o[e][1]);nullFrom(e,n).forEach((e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)}))}))}));let i=t[r.join(",")]=new ContentMatch(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(cmp);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}(nullFrom(e,0))}function checkForDeadEnds(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],o=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!o||n.isText||n.hasRequiredAttrs()||(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function defaultAttrs(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function computeAttrs(e,t){let n=Object.create(null);for(let r in e){let o=t&&t[r];if(void 0===o){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=t.default}n[r]=o}return n}function initAttrs(e){let t=Object.create(null);if(e)for(let n in e)t[n]=new Attribute(e[n]);return t}class NodeType$1{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=initAttrs(n.attrs),this.defaultAttrs=defaultAttrs(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ContentMatch.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:computeAttrs(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Node$1(this,this.computeAttrs(e),Fragment.from(t),Mark$1.setFrom(n))}createChecked(e=null,t,n){return t=Fragment.from(t),this.checkContent(t),new Node$1(this,this.computeAttrs(e),t,Mark$1.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=Fragment.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(Fragment.empty,!0);return o?new Node$1(this,e,t.append(o),Mark$1.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Mark$1.none:e}static compile(e,t){let n=Object.create(null);e.forEach(((e,r)=>n[e]=new NodeType$1(e,t,r)));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class Attribute{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class MarkType{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=initAttrs(r.attrs),this.excluded=null;let o=defaultAttrs(this.attrs);this.instance=o?new Mark$1(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Mark$1(this,computeAttrs(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach(((e,o)=>n[e]=new MarkType(e,r++,t,o))),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class Schema{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=OrderedMap.from(e.nodes),t.marks=OrderedMap.from(e.marks||{}),this.nodes=NodeType$1.compile(this.spec.nodes,this),this.marks=MarkType.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=ContentMatch.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==o?null:o?gatherMarks(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:gatherMarks(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof NodeType$1))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new TextNode(n,n.defaultAttrs,e,Mark$1.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Node$1.fromJSON(this,e)}markFromJSON(e){return Mark$1.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function gatherMarks(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}function isTagRule(e){return null!=e.tag}function isStyleRule(e){return null!=e.style}class DOMParser{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach((e=>{isTagRule(e)?this.tags.push(e):isStyleRule(e)&&this.styles.push(e)})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new ParseContext(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new ParseContext(this,t,!0);return n.addAll(e,t.from,t.to),Slice.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(matches(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach((e=>{n(e=copy(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach((e=>{n(e=copy(e)),e.node||e.ignore||e.mark||(e.node=t)}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new DOMParser(e,DOMParser.schemaRules(e)))}}const blockTags={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},ignoreTags={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},listTags={ol:!0,ul:!0},OPT_PRESERVE_WS=1,OPT_PRESERVE_WS_FULL=2,OPT_OPEN_LEFT=4;function wsOptionsFor(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class NodeContext{constructor(e,t,n,r,o,i,s){this.type=e,this.attrs=t,this.marks=n,this.pendingMarks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=Mark$1.none,this.stashMarks=[],this.match=i||(4&s?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Fragment.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=Fragment.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Fragment.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,n=this.pendingMarks;t<n.length;t++){let r=n[t];(this.type?this.type.allowsMarkType(r.type):markMayApply(r.type,e))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!blockTags.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ParseContext{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0;let r,o=t.topNode,i=wsOptionsFor(null,t.preserveWhitespace,0)|(n?4:0);r=o?new NodeContext(o.type,o.attrs,Mark$1.none,Mark$1.none,!0,t.topMatch||o.type.contentMatch,i):new NodeContext(n?null:e.schema.topNodeType,null,Mark$1.none,Mark$1.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){3==e.nodeType?this.addTextNode(e):1==e.nodeType&&this.addElement(e)}withStyleRules(e,t){let n=e.style;if(!n||!n.length)return t();let r=this.readStyles(e.style);if(!r)return;let[o,i]=r,s=this.top;for(let e=0;e<i.length;e++)this.removePendingMark(i[e],s);for(let e=0;e<o.length;e++)this.addPendingMark(o[e]);t();for(let e=0;e<o.length;e++)this.removePendingMark(o[e],s);for(let e=0;e<i.length;e++)this.addPendingMark(i[e])}addTextNode(e){let t=e.nodeValue,n=this.top;if(2&n.options||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(1&n.options)t=2&n.options?t.replace(/\r\n?/g,"\n"):t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let r=n.content[n.content.length-1],o=e.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let n,r=e.nodeName.toLowerCase();listTags.hasOwnProperty(r)&&this.parser.normalizeLists&&normalizeList(e);let o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(n=this.parser.matchTag(e,this,t));if(o?o.ignore:ignoreTags.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(e=o.skip);let t,n=this.top,i=this.needsBlock;if(blockTags.hasOwnProperty(r))n.content.length&&n.content[0].isInline&&this.open&&(this.open--,n=this.top),t=!0,n.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);o&&o.skip?this.addAll(e):this.withStyleRules(e,(()=>this.addAll(e))),t&&this.sync(n),this.needsBlock=i}else this.withStyleRules(e,(()=>{this.addElementByRule(e,o,!1===o.consuming?n:void 0)}))}leafFallback(e){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"))}ignoreFallback(e){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=Mark$1.none,n=Mark$1.none;for(let r=0,o=e.length;r<o;r++){let o=e.item(r);for(let r;;){let i=this.parser.matchStyle(o,e.getPropertyValue(o),this,r);if(!i)break;if(i.ignore)return null;if(i.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach((e=>{i.clearMark(e)&&(n=e.addToSet(n))})):t=this.parser.schema.marks[i.mark].create(i.attrs).addToSet(t),!1!==i.consuming)break;r=i}}return[t,n]}addElementByRule(e,t,n){let r,o,i;t.node?(o=this.parser.schema.nodes[t.node],o.isLeaf?this.insertNode(o.create(t.attrs))||this.leafFallback(e):r=this.enter(o,t.attrs||null,t.preserveWhitespace)):(i=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(i));let s=this.top;if(o&&o.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e)));else{let n=e;"string"==typeof t.contentElement?n=e.querySelector(t.contentElement):"function"==typeof t.contentElement?n=t.contentElement(e):t.contentElement&&(n=t.contentElement),this.findAround(e,n,!0),this.addAll(n)}r&&this.sync(s)&&this.open--,i&&this.removePendingMark(i,s)}addAll(e,t,n){let r=t||0;for(let o=t?e.childNodes[t]:e.firstChild,i=null==n?null:e.childNodes[n];o!=i;o=o.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(o);this.findAtPoint(e,r)}findPlace(e){let t,n;for(let r=this.open;r>=0;r--){let o=this.nodes[r],i=o.findWrapping(e);if(i&&(!t||t.length>i.length)&&(t=i,n=o,!i.length))break;if(o.solid)break}if(!t)return!1;this.sync(n);for(let e=0;e<t.length;e++)this.enterInner(t[e],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let n=t.activeMarks;for(let r=0;r<e.marks.length;r++)t.type&&!t.type.allowsMarkType(e.marks[r].type)||(n=e.marks[r].addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n){let r=this.findPlace(e.create(t));return r&&this.enterInner(e,t,!0,n),r}enterInner(e,t=null,n=!1,r){this.closeExtra();let o=this.top;o.applyPending(e),o.match=o.match&&o.match.matchType(e);let i=wsOptionsFor(e,r,o.options);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new NodeContext(e,t,o.activeMarks,o.pendingMarks,n,null,i)),this.open++}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!e||e.name!=a&&-1==e.groups.indexOf(a))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}addPendingMark(e){let t=findSameMarkInSet(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let n=this.open;n>=0;n--){let r=this.nodes[n];if(r.pendingMarks.lastIndexOf(e)>-1)r.pendingMarks=e.removeFromSet(r.pendingMarks);else{r.activeMarks=e.removeFromSet(r.activeMarks);let t=r.popFromStashMark(e);t&&r.type&&r.type.allowsMarkType(t.type)&&(r.activeMarks=t.addToSet(r.activeMarks))}if(r==t)break}}}function normalizeList(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&listTags.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}function matches(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function copy(e){let t={};for(let n in e)t[n]=e[n];return t}function markMayApply(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}function findSameMarkInSet(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}class DOMSerializer{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=doc$1(t).createDocumentFragment());let r=n,o=[];return e.forEach((e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=DOMSerializer.renderSpec(doc$1(t),this.nodes[e.type.name](e));if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&DOMSerializer.renderSpec(doc$1(n),r(e,t))}static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,o=t[0],i=o.indexOf(" ");i>0&&(n=o.slice(0,i),o=o.slice(i+1));let s=n?e.createElementNS(n,o):e.createElement(o),a=t[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(let e in a)if(null!=a[e]){let t=e.indexOf(" ");t>0?s.setAttributeNS(e.slice(0,t),e.slice(t+1),a[e]):s.setAttribute(e,a[e])}}for(let o=l;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}{let{dom:t,contentDOM:o}=DOMSerializer.renderSpec(e,i,n);if(s.appendChild(t),o){if(r)throw new RangeError("Multiple content holes");r=o}}}return{dom:s,contentDOM:r}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new DOMSerializer(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=gatherToDOM(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return gatherToDOM(e.marks)}}function gatherToDOM(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function doc$1(e){return e.document||window.document}const lower16=65535,factor16=Math.pow(2,16);function makeRecover(e,t){return e+t*factor16}function recoverIndex(e){return 65535&e}function recoverOffset(e){return(e-(65535&e))/factor16}const DEL_BEFORE=1,DEL_AFTER=2,DEL_ACROSS=4,DEL_SIDE=8;class MapResult{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class StepMap{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&StepMap.empty)return StepMap.empty}recover(e){let t=0,n=recoverIndex(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+recoverOffset(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[s+o],c=this.ranges[s+i],d=a+l;if(e<=d){let o=a+r+((l?e==a?-1:e==d?1:t:t)<0?0:c);if(n)return o;let i=e==(t<0?a:d)?null:makeRecover(s/3,e-a),p=e==a?2:e==d?1:4;return(t<0?e!=a:e!=d)&&(p|=8),new MapResult(o,p,i)}r+=c-l}return n?e+r:new MapResult(e+r,0,null)}touches(e,t){let n=0,r=recoverIndex(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let a=this.ranges[t+o];if(e<=s+a&&t==3*r)return!0;n+=this.ranges[t+i]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),l=this.ranges[r+t],c=this.ranges[r+n];e(s,s+l,a,a+c),o+=c-l}}invert(){return new StepMap(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?StepMap.empty:new StepMap(e<0?[0,-e,0]:[0,0,e])}}StepMap.empty=new StepMap([]);class Mapping{constructor(e=[],t,n=0,r=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=r}slice(e=0,t=this.maps.length){return new Mapping(this.maps,this.mirror,e,t)}copy(){return new Mapping(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new Mapping;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let o=this.maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new MapResult(e,r,null)}}const stepsByID=Object.create(null);class Step{getMap(){return StepMap.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=stepsByID[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in stepsByID)throw new RangeError("Duplicate use of step JSON ID "+e);return stepsByID[e]=t,t.prototype.jsonID=e,t}}class StepResult{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new StepResult(e,null)}static fail(e){return new StepResult(null,e)}static fromReplace(e,t,n,r){try{return StepResult.ok(e.replace(t,n,r))}catch(e){if(e instanceof ReplaceError)return StepResult.fail(e.message);throw e}}}function mapFragment(e,t,n){let r=[];for(let o=0;o<e.childCount;o++){let i=e.child(o);i.content.size&&(i=i.copy(mapFragment(i.content,t,i))),i.isInline&&(i=t(i,n,o)),r.push(i)}return Fragment.fromArray(r)}class AddMarkStep extends Step{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),o=new Slice(mapFragment(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),r),t.openStart,t.openEnd);return StepResult.fromReplace(e,this.from,this.to,o)}invert(){return new RemoveMarkStep(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new AddMarkStep(t.pos,n.pos,this.mark)}merge(e){return e instanceof AddMarkStep&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new AddMarkStep(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new AddMarkStep(t.from,t.to,e.markFromJSON(t.mark))}}Step.jsonID("addMark",AddMarkStep);class RemoveMarkStep extends Step{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Slice(mapFragment(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return StepResult.fromReplace(e,this.from,this.to,n)}invert(){return new AddMarkStep(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new RemoveMarkStep(t.pos,n.pos,this.mark)}merge(e){return e instanceof RemoveMarkStep&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new RemoveMarkStep(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new RemoveMarkStep(t.from,t.to,e.markFromJSON(t.mark))}}Step.jsonID("removeMark",RemoveMarkStep);class AddNodeMarkStep extends Step{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return StepResult.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return StepResult.fromReplace(e,this.pos,this.pos+1,new Slice(Fragment.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new AddNodeMarkStep(this.pos,t.marks[n]);return new AddNodeMarkStep(this.pos,this.mark)}}return new RemoveNodeMarkStep(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new AddNodeMarkStep(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new AddNodeMarkStep(t.pos,e.markFromJSON(t.mark))}}Step.jsonID("addNodeMark",AddNodeMarkStep);class RemoveNodeMarkStep extends Step{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return StepResult.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return StepResult.fromReplace(e,this.pos,this.pos+1,new Slice(Fragment.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new AddNodeMarkStep(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new RemoveNodeMarkStep(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new RemoveNodeMarkStep(t.pos,e.markFromJSON(t.mark))}}Step.jsonID("removeNodeMark",RemoveNodeMarkStep);class ReplaceStep extends Step{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&contentBetween(e,this.from,this.to)?StepResult.fail("Structure replace would overwrite content"):StepResult.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new StepMap([this.from,this.to-this.from,this.slice.size])}invert(e){return new ReplaceStep(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new ReplaceStep(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof ReplaceStep)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Slice.empty:new Slice(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ReplaceStep(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Slice.empty:new Slice(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ReplaceStep(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ReplaceStep(t.from,t.to,Slice.fromJSON(e,t.slice),!!t.structure)}}Step.jsonID("replace",ReplaceStep);class ReplaceAroundStep extends Step{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(contentBetween(e,this.from,this.gapFrom)||contentBetween(e,this.gapTo,this.to)))return StepResult.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return StepResult.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?StepResult.fromReplace(e,this.from,this.to,n):StepResult.fail("Content does not fit in gap")}getMap(){return new StepMap([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ReplaceAroundStep(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new ReplaceAroundStep(t.pos,n.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ReplaceAroundStep(t.from,t.to,t.gapFrom,t.gapTo,Slice.fromJSON(e,t.slice),t.insert,!!t.structure)}}function contentBetween(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function addMark(e,t,n,r){let o,i,s=[],a=[];e.doc.nodesBetween(t,n,((e,l,c)=>{if(!e.isInline)return;let d=e.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,t),p=Math.min(l+e.nodeSize,n),h=r.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(h)||(o&&o.to==c&&o.mark.eq(d[e])?o.to=p:s.push(o=new RemoveMarkStep(c,p,d[e])));i&&i.to==c?i.to=p:a.push(i=new AddMarkStep(c,p,r))}})),s.forEach((t=>e.step(t))),a.forEach((t=>e.step(t)))}function removeMark(e,t,n,r){let o=[],i=0;e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let a=null;if(r instanceof MarkType){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<o.length;e++){let t=o[e];t.step==i-1&&l.eq(o[e].style)&&(n=t)}n?(n.to=r,n.step=i):o.push({style:l,from:Math.max(s,t),to:r,step:i})}}})),o.forEach((t=>e.step(new RemoveMarkStep(t.from,t.to,t.style))))}function clearIncompatible(e,t,n,r=n.contentMatch,o=!0){let i=e.doc.nodeAt(t),s=[],a=t+1;for(let t=0;t<i.childCount;t++){let l=i.child(t),c=a+l.nodeSize,d=r.matchType(l.type);if(d){r=d;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new RemoveMarkStep(a,c,l.marks[t]));if(o&&l.isText&&"pre"!=n.whitespace){let e,t,r=/\r?\n|\r/g;for(;e=r.exec(l.text);)t||(t=new Slice(Fragment.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new ReplaceStep(a+e.index,a+e.index+e[0].length,t))}}else s.push(new ReplaceStep(a,c,Slice.empty));a=c}if(!r.validEnd){let t=r.fillBefore(Fragment.empty,!0);e.replace(a,a,new Slice(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function canCut(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function liftTarget(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let r=e.$from.node(n),o=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(o,i,t))return n;if(0==n||r.type.spec.isolating||!canCut(r,o,i))break}return null}function lift$2(e,t,n){let{$from:r,$to:o,depth:i}=t,s=r.before(i+1),a=o.after(i+1),l=s,c=a,d=Fragment.empty,p=0;for(let e=i,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,d=Fragment.from(r.node(e).copy(d)),p++):l--;let h=Fragment.empty,u=0;for(let e=i,t=!1;e>n;e--)t||o.after(e+1)<o.end(e)?(t=!0,h=Fragment.from(o.node(e).copy(h)),u++):c++;e.step(new ReplaceAroundStep(l,c,s,a,new Slice(d.append(h),p,u),d.size-p,!0))}function findWrapping(e,t,n=null,r=e){let o=findWrappingOutside(e,t),i=o&&findWrappingInside(r,t);return i?o.map(withAttrs).concat({type:t,attrs:n}).concat(i.map(withAttrs)):null}function withAttrs(e){return{type:e,attrs:null}}function findWrappingOutside(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}function findWrappingInside(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;a&&e<o;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}function wrap(e,t,n){let r=Fragment.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Fragment.from(n[e].type.create(n[e].attrs,r))}let o=t.start,i=t.end;e.step(new ReplaceAroundStep(o,i,o,i,new Slice(r,0,0),n.length,!0))}function setBlockType$1(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{if(t.isTextblock&&!t.hasMarkup(r,o)&&canChangeType(e.doc,e.mapping.slice(i).map(n),r)){let s=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?s=!1:!e&&t&&(s=!0)}!1===s&&replaceLinebreaks(e,t,n,i),clearIncompatible(e,e.mapping.slice(i).map(n,1),r,void 0,null===s);let a=e.mapping.slice(i),l=a.map(n,1),c=a.map(n+t.nodeSize,1);return e.step(new ReplaceAroundStep(l,c,l+1,c-1,new Slice(Fragment.from(r.create(o,null,t.marks)),0,0),1,!0)),!0===s&&replaceNewlines(e,t,n,i),!1}}))}function replaceNewlines(e,t,n,r){t.forEach(((o,i)=>{if(o.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(o.text);){let o=e.mapping.slice(r).map(n+1+i+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}}))}function replaceLinebreaks(e,t,n,r){t.forEach(((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(r).map(n+1+i);e.replaceWith(o,o+1,t.type.schema.text("\n"))}}))}function canChangeType(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function setNodeMarkup(e,t,n,r,o){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new ReplaceAroundStep(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new Slice(Fragment.from(s),0,0),1,!0))}function canSplit(e,t,n=1,r){let o=e.resolve(t),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),a=r&&r[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!l.type.validContent(s))return!1}let a=o.indexAfter(i),l=r&&r[0];return o.node(i).canReplaceWith(a,a,l?l.type:o.node(i+1).type)}function split(e,t,n=1,r){let o=e.doc.resolve(t),i=Fragment.empty,s=Fragment.empty;for(let e=o.depth,t=o.depth-n,a=n-1;e>t;e--,a--){i=Fragment.from(o.node(e).copy(i));let t=r&&r[a];s=Fragment.from(t?t.type.create(t.attrs,s):o.node(e).copy(s))}e.step(new ReplaceStep(t,t,new Slice(i.append(s),n,n),!0))}function canJoin(e,t){let n=e.resolve(t),r=n.index();return joinable(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function joinable(e,t){return!(!e||!t||e.isLeaf||!e.canAppend(t))}function joinPoint(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let o,i,s=r.index(e);if(e==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(e+1),s++,i=r.node(e).maybeChild(s)):(o=r.node(e).maybeChild(s-1),i=r.node(e+1)),o&&!o.isTextblock&&joinable(o,i)&&r.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function join(e,t,n){let r=new ReplaceStep(t-n,t+n,Slice.empty,!0);e.step(r)}function insertPoint(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function dropPoint(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),a=!1;if(1==e)a=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);a=e&&s.canReplaceWith(i,i,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function replaceStep(e,t,n=t,r=Slice.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),i=e.resolve(n);return fitsTrivially(o,i,r)?new ReplaceStep(t,n,r):new Fitter(o,i,r).fit()}function fitsTrivially(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}Step.jsonID("replaceAround",ReplaceAroundStep);class Fitter{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Fragment.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=Fragment.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let a=new Slice(o,i,s);return e>-1?new ReplaceAroundStep(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new ReplaceStep(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=contentAt(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let o=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:s,match:a}=this.frontier[e],l=null;if(1==t&&(o?a.matchType(o.type)||(l=a.fillBefore(Fragment.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:l};if(2==t&&o&&(i=a.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:i};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=contentAt(e,t);return!(!r.childCount||r.firstChild.isLeaf||(this.unplaced=new Slice(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),0))}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=contentAt(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new Slice(dropFromFragment(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new Slice(dropFromFragment(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[e]);let i=this.unplaced,s=n?n.content:i.content,a=i.openStart-e,l=0,c=[],{match:d,type:p}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));d=d.matchFragment(r)}let h=s.size+e-(i.content.size-i.openEnd);for(;l<s.childCount;){let e=s.child(l),t=d.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(d=t,c.push(closeNodeStart(e.mark(p.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?h:-1)))}let u=l==s.childCount;u||(h=-1),this.placed=addToFragment(this.placed,t,Fragment.from(c)),this.frontier[t].match=d,u&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<h;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=u?0==e?Slice.empty:new Slice(dropFromFragment(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new Slice(dropFromFragment(i.content,e,l),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!contentAfterFits(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=contentAfterFits(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=contentAfterFits(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=addToFragment(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=addToFragment(this.placed,this.depth,Fragment.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Fragment.empty,!0);e.childCount&&(this.placed=addToFragment(this.placed,this.frontier.length,e))}}function dropFromFragment(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(dropFromFragment(e.firstChild.content,t-1,n)))}function addToFragment(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(addToFragment(e.lastChild.content,t-1,n)))}function contentAt(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function closeNodeStart(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,closeNodeStart(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(Fragment.empty,!0)))),e.copy(r)}function contentAfterFits(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,s);return a&&!invalidMarks(n,i.content,s)?a:null}function invalidMarks(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function definesContent(e){return e.spec.defining||e.spec.definingForContent}function replaceRange(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),i=e.doc.resolve(n);if(fitsTrivially(o,i,r))return e.step(new ReplaceStep(t,n,r));let s=coveredDepths(o,e.doc.resolve(n));0==s[s.length-1]&&s.pop();let a=-(o.depth+1);s.unshift(a);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:o.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],d=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=c[e],n=definesContent(t.type);if(n&&!t.sameMarkup(o.node(Math.abs(a)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+d+1)%(r.openStart+1),p=c[a];if(p)for(let t=0;t<s.length;t++){let c=s[(t+l)%s.length],d=!0;c<0&&(d=!1,c=-c);let h=o.node(c-1),u=o.index(c-1);if(h.canReplaceWith(u,u,p.type,p.marks))return e.replace(o.before(c),d?i.after(c):n,new Slice(closeFragment(r.content,0,r.openStart,a),a,r.openEnd))}}let p=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>p));a--){let e=s[a];e<0||(t=o.before(e),n=i.after(e))}}function closeFragment(e,t,n,r,o){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(closeFragment(o.content,t+1,n,r,o)))}if(t>r){let t=o.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Fragment.empty,!0))}return e}function replaceRangeWith(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=insertPoint(e.doc,t,r.type);null!=o&&(t=n=o)}e.replaceRange(t,n,new Slice(Fragment.from(r),0,0))}function deleteRange$1(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n),i=coveredDepths(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i)return e.delete(r.before(i),n);e.delete(t,n)}function coveredDepths(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class AttrStep extends Step{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return StepResult.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return StepResult.fromReplace(e,this.pos,this.pos+1,new Slice(Fragment.from(r),0,t.isLeaf?0:1))}getMap(){return StepMap.empty}invert(e){return new AttrStep(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new AttrStep(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new AttrStep(t.pos,t.attr,t.value)}}Step.jsonID("attr",AttrStep);class DocAttrStep extends Step{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return StepResult.ok(n)}getMap(){return StepMap.empty}invert(e){return new DocAttrStep(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new DocAttrStep(t.attr,t.value)}}Step.jsonID("docAttr",DocAttrStep);let TransformError=class extends Error{};TransformError=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},TransformError.prototype=Object.create(Error.prototype),TransformError.prototype.constructor=TransformError,TransformError.prototype.name="TransformError";class Transform{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Mapping}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new TransformError(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Slice.empty){let r=replaceStep(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Slice(Fragment.from(n),0,0))}delete(e,t){return this.replace(e,t,Slice.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return replaceRange(this,e,t,n),this}replaceRangeWith(e,t,n){return replaceRangeWith(this,e,t,n),this}deleteRange(e,t){return deleteRange$1(this,e,t),this}lift(e,t){return lift$2(this,e,t),this}join(e,t=1){return join(this,e,t),this}wrap(e,t){return wrap(this,e,t),this}setBlockType(e,t=e,n,r=null){return setBlockType$1(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return setNodeMarkup(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new AttrStep(e,t,n)),this}setDocAttribute(e,t){return this.step(new DocAttrStep(e,t)),this}addNodeMark(e,t){return this.step(new AddNodeMarkStep(e,t)),this}removeNodeMark(e,t){if(!(t instanceof Mark$1)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(!(t=t.isInSet(n.marks)))return this}return this.step(new RemoveNodeMarkStep(e,t)),this}split(e,t=1,n){return split(this,e,t,n),this}addMark(e,t,n){return addMark(this,e,t,n),this}removeMark(e,t,n){return removeMark(this,e,t,n),this}clearIncompatible(e,t,n){return clearIncompatible(this,e,t,n),this}}const classesById=Object.create(null);class Selection{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new SelectionRange(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Slice.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let o=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:l}=i[s],c=e.mapping.slice(o);e.replaceRange(c.map(a.pos),c.map(l.pos),s?Slice.empty:t),0==s&&selectionToInsertionEnd$1(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],a=e.mapping.slice(n),l=a.map(i.pos),c=a.map(s.pos);o?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),selectionToInsertionEnd$1(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new TextSelection(e):findSelectionIn(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?findSelectionIn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):findSelectionIn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new AllSelection(e.node(0))}static atStart(e){return findSelectionIn(e,e,0,0,1)||new AllSelection(e)}static atEnd(e){return findSelectionIn(e,e,e.content.size,e.childCount,-1)||new AllSelection(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=classesById[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in classesById)throw new RangeError("Duplicate use of selection JSON ID "+e);return classesById[e]=t,t.prototype.jsonID=e,t}getBookmark(){return TextSelection.between(this.$anchor,this.$head).getBookmark()}}Selection.prototype.visible=!0;class SelectionRange{constructor(e,t){this.$from=e,this.$to=t}}let warnedAboutTextSelection=!1;function checkTextSelection(e){warnedAboutTextSelection||e.parent.inlineContent||(warnedAboutTextSelection=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class TextSelection extends Selection{constructor(e,t=e){checkTextSelection(e),checkTextSelection(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return Selection.near(n);let r=e.resolve(t.map(this.anchor));return new TextSelection(r.parent.inlineContent?r:n,n)}replace(e,t=Slice.empty){if(super.replace(e,t),t==Slice.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof TextSelection&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new TextBookmark(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new TextSelection(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=Selection.findFrom(t,n,!0)||Selection.findFrom(t,-n,!0);if(!e)return Selection.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(Selection.findFrom(e,-n,!0)||Selection.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new TextSelection(e,t)}}Selection.jsonID("text",TextSelection);class TextBookmark{constructor(e,t){this.anchor=e,this.head=t}map(e){return new TextBookmark(e.map(this.anchor),e.map(this.head))}resolve(e){return TextSelection.between(e.resolve(this.anchor),e.resolve(this.head))}}class NodeSelection extends Selection{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?Selection.near(o):new NodeSelection(o)}content(){return new Slice(Fragment.from(this.node),0,0)}eq(e){return e instanceof NodeSelection&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new NodeBookmark(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new NodeSelection(e.resolve(t.anchor))}static create(e,t){return new NodeSelection(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}NodeSelection.prototype.visible=!1,Selection.jsonID("node",NodeSelection);class NodeBookmark{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new TextBookmark(n,n):new NodeBookmark(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&NodeSelection.isSelectable(n)?new NodeSelection(t):Selection.near(t)}}class AllSelection extends Selection{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Slice.empty){if(t==Slice.empty){e.delete(0,e.doc.content.size);let t=Selection.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new AllSelection(e)}map(e){return new AllSelection(e)}eq(e){return e instanceof AllSelection}getBookmark(){return AllBookmark}}Selection.jsonID("all",AllSelection);const AllBookmark={map(){return this},resolve(e){return new AllSelection(e)}};function findSelectionIn(e,t,n,r,o,i=!1){if(t.inlineContent)return TextSelection.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&NodeSelection.isSelectable(r))return NodeSelection.create(e,n-(o<0?r.nodeSize:0))}else{let t=findSelectionIn(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function selectionToInsertionEnd$1(e,t,n){let r=e.steps.length-1;if(r<t)return;let o,i=e.steps[r];(i instanceof ReplaceStep||i instanceof ReplaceAroundStep)&&(e.mapping.maps[r].forEach(((e,t,n,r)=>{null==o&&(o=r)})),e.setSelection(Selection.near(e.doc.resolve(o),n)))}const UPDATED_SEL=1,UPDATED_MARKS=2,UPDATED_SCROLL=4;class Transaction extends Transform{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return Mark$1.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Mark$1.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.setSelection(Selection.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function bind(e,t){return t&&e?e.bind(t):e}class FieldDesc{constructor(e,t,n){this.name=e,this.init=bind(t.init,n),this.apply=bind(t.apply,n)}}const baseFields=[new FieldDesc("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new FieldDesc("selection",{init(e,t){return e.selection||Selection.atStart(t.doc)},apply(e){return e.selection}}),new FieldDesc("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new FieldDesc("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})];class Configuration{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=baseFields.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new FieldDesc(e.key,e.spec.state,e))}))}}class EditorState{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let a=r?r[i].n:0,l=r?r[i].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new EditorState(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Transaction(this)}static create(e){let t=new Configuration(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new EditorState(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new Configuration(this.schema,e.plugins),n=t.fields,r=new EditorState(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new Configuration(e.schema,e.plugins),o=new EditorState(r);return r.fields.forEach((r=>{if("doc"==r.name)o.doc=Node$1.fromJSON(e.schema,t.doc);else if("selection"==r.name)o.selection=Selection.fromJSON(o.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(o[r.name]=a.fromJSON.call(s,e,t[i],o))}o[r.name]=r.init(e,o)}})),o}}function bindProps(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=bindProps(o,t,{})),n[r]=o}return n}class Plugin{constructor(e){this.spec=e,this.props={},e.props&&bindProps(e.props,this,this.props),this.key=e.key?e.key.key:createKey("plugin")}getState(e){return e[this.key]}}const keys=Object.create(null);function createKey(e){return e in keys?e+"$"+ ++keys[e]:(keys[e]=0,e+"$")}class PluginKey{constructor(e="key"){this.key=createKey(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const domIndex=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},parentNode=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let reusedRange=null;const textRange=function(e,t,n){let r=reusedRange||(reusedRange=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},clearReusedRange=function(){reusedRange=null},isEquivalentPosition=function(e,t,n,r){return n&&(scanFor(e,t,n,r,-1)||scanFor(e,t,n,r,1))},atomElements=/^(img|br|input|textarea|hr)$/i;function scanFor(e,t,n,r,o){for(;;){if(e==n&&t==r)return!0;if(t==(o<0?0:nodeSize(e))){let n=e.parentNode;if(!n||1!=n.nodeType||hasBlockDesc(e)||atomElements.test(e.nodeName)||"false"==e.contentEditable)return!1;t=domIndex(e)+(o<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(o<0?-1:0)]).contentEditable)return!1;t=o<0?nodeSize(e):0}}}function nodeSize(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function textNodeBefore$1(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=nodeSize(e=e.childNodes[t-1])}else{if(!e.parentNode||hasBlockDesc(e))return null;t=domIndex(e),e=e.parentNode}}}function textNodeAfter$1(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||hasBlockDesc(e))return null;t=domIndex(e)+1,e=e.parentNode}}}function isOnEdge(e,t,n){for(let r=0==t,o=t==nodeSize(e);r||o;){if(e==n)return!0;let t=domIndex(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==nodeSize(e)}}function hasBlockDesc(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const selectionCollapsed=function(e){return e.focusNode&&isEquivalentPosition(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function keyEvent(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function deepActiveElement(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function caretFromPoint(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}const nav="undefined"!=typeof navigator?navigator:null,doc="undefined"!=typeof document?document:null,agent=nav&&nav.userAgent||"",ie_edge=/Edge\/(\d+)/.exec(agent),ie_upto10=/MSIE \d/.exec(agent),ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(agent),ie$1=!!(ie_upto10||ie_11up||ie_edge),ie_version=ie_upto10?document.documentMode:ie_11up?+ie_11up[1]:ie_edge?+ie_edge[1]:0,gecko=!ie$1&&/gecko\/(\d+)/i.test(agent);gecko&&(/Firefox\/(\d+)/.exec(agent)||[0,0])[1];const _chrome=!ie$1&&/Chrome\/(\d+)/.exec(agent),chrome=!!_chrome,chrome_version=_chrome?+_chrome[1]:0,safari=!ie$1&&!!nav&&/Apple Computer/.test(nav.vendor),ios=safari&&(/Mobile\/\w+/.test(agent)||!!nav&&nav.maxTouchPoints>2),mac$2=ios||!!nav&&/Mac/.test(nav.platform),windows=!!nav&&/Win/.test(nav.platform),android=/Android \d/.test(agent),webkit=!!doc&&"webkitFontSmoothing"in doc.documentElement.style,webkit_version=webkit?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function windowRect(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function getSide(e,t){return"number"==typeof e?e:e[t]}function clientRect(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function scrollRectIntoView(e,t,n){let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;s=parentNode(s)){if(1!=s.nodeType)continue;let e=s,n=e==i.body,a=n?windowRect(i):clientRect(e),l=0,c=0;if(t.top<a.top+getSide(r,"top")?c=-(a.top-t.top+getSide(o,"top")):t.bottom>a.bottom-getSide(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+getSide(o,"top")-a.top:t.bottom-a.bottom+getSide(o,"bottom")),t.left<a.left+getSide(r,"left")?l=-(a.left-t.left+getSide(o,"left")):t.right>a.right-getSide(r,"right")&&(l=t.right-a.right+getSide(o,"right")),l||c)if(n)i.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let o=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-o,top:t.top-i,right:t.right-o,bottom:t.bottom-i}}if(n||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function storeScrollPos(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=o-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:scrollStack(e.dom)}}function scrollStack(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=parentNode(r));return t}function resetScrollPos({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;restoreScrollStack(n,0==r?0:r-t)}function restoreScrollStack(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let preventScrollSupported=null;function focusPreventScroll(e){if(e.setActive)return e.setActive();if(preventScrollSupported)return e.focus(preventScrollSupported);let t=scrollStack(e);e.focus(null==preventScrollSupported?{get preventScroll(){return preventScrollSupported={preventScroll:!0},!0}}:void 0),preventScrollSupported||(preventScrollSupported=!1,restoreScrollStack(t,0))}function findOffsetInNode(e,t){let n,r,o,i,s=2e8,a=0,l=t.top,c=t.top;for(let d=e.firstChild,p=0;d;d=d.nextSibling,p++){let e;if(1==d.nodeType)e=d.getClientRects();else{if(3!=d.nodeType)continue;e=textRange(d).getClientRects()}for(let h=0;h<e.length;h++){let u=e[h];if(u.top<=l&&u.bottom>=c){l=Math.max(u.bottom,l),c=Math.min(u.top,c);let e=u.left>t.left?u.left-t.left:u.right<t.left?t.left-u.right:0;if(e<s){n=d,s=e,r=e&&3==n.nodeType?{left:u.right<t.left?u.right:u.left,top:t.top}:t,1==d.nodeType&&e&&(a=p+(t.left>=(u.left+u.right)/2?1:0));continue}}else u.top>t.top&&!o&&u.left<=t.left&&u.right>=t.left&&(o=d,i={left:Math.max(u.left,Math.min(u.right,t.left)),top:u.top});!n&&(t.left>=u.right&&t.top>=u.top||t.left>=u.left&&t.top>=u.bottom)&&(a=p+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?findOffsetInText(n,r):!n||s&&1==n.nodeType?{node:e,offset:a}:findOffsetInNode(n,r)}function findOffsetInText(e,t){let n=e.nodeValue.length,r=document.createRange();for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let n=singleRect(r,1);if(n.top!=n.bottom&&inRect(t,n))return{node:e,offset:o+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}function inRect(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function targetKludge(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function posFromElement(e,t,n){let{node:r,offset:o}=findOffsetInNode(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}function posFromCaret(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0);if(!t)return null;if(1==t.dom.nodeType&&(t.node.isBlock&&t.parent||!t.contentDOM)){let e=t.dom.getBoundingClientRect();if(t.node.isBlock&&t.parent&&(!i&&e.left>r.left||e.top>r.top?o=t.posBefore:(!i&&e.right<r.left||e.bottom<r.top)&&(o=t.posAfter),i=!0),!t.contentDOM&&o<0&&!t.node.isText)return(t.node.isBlock?r.top<(e.top+e.bottom)/2:r.left<(e.left+e.right)/2)?t.posBefore:t.posAfter}n=t.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}function elementFromPoint(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let o=e[r];if(inRect(t,o))return elementFromPoint(n,t,o)}}if((i=(i+1)%r)==o)break}return e}function posAtCoords(e,t){let n,r=e.dom.ownerDocument,o=0,i=caretFromPoint(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=e.dom.getBoundingClientRect();if(!inRect(t,n))return null;if(a=elementFromPoint(e.dom,t,n),!a)return null}if(safari)for(let e=a;n&&e;e=parentNode(e))e.draggable&&(n=void 0);if(a=targetKludge(a,t),n){if(gecko&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let r;webkit&&o&&1==n.nodeType&&1==(r=n.childNodes[o-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(s=posFromCaret(e,n,o,t))}null==s&&(s=posFromElement(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function nonZero(e){return e.top<e.bottom||e.left<e.right}function singleRect(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(nonZero(e))return e}return Array.prototype.find.call(n,nonZero)||e.getBoundingClientRect()}const BIDI=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function coordsAtPos(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=webkit||gecko;if(3==r.nodeType){if(!s||!BIDI.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,flattenV(singleRect(textRange(r,e,t),i),i<0)}{let e=singleRect(textRange(r,o,o),n);if(gecko&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=singleRect(textRange(r,o-1,o-1),-1);if(t.top==e.top){let n=singleRect(textRange(r,o,o+1),-1);if(n.top!=e.top)return flattenV(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==nodeSize(r))){let e=r.childNodes[o-1];if(1==e.nodeType)return flattenH(e.getBoundingClientRect(),!1)}if(null==i&&o<nodeSize(r)){let e=r.childNodes[o];if(1==e.nodeType)return flattenH(e.getBoundingClientRect(),!0)}return flattenH(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==nodeSize(r))){let e=r.childNodes[o-1],t=3==e.nodeType?textRange(e,nodeSize(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return flattenV(singleRect(t,1),!1)}if(null==i&&o<nodeSize(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?textRange(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return flattenV(singleRect(t,-1),!0)}return flattenV(singleRect(3==r.nodeType?textRange(r):r,-n),n>=0)}function flattenV(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function flattenH(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function withFlushedState(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}function endOfTextblockVertical(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return withFlushedState(e,t,(()=>{let{node:t}=e.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=coordsAtPos(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=textRange(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0}))}const maybeRTL=/[\u0590-\u08ac]/;function endOfTextblockHorizontal(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=e.domSelection();return maybeRTL.test(r.parent.textContent)&&a.modify?withFlushedState(e,t,(()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:d,focusOffset:p}=e.domSelectionRange(),h=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&o==p;try{a.collapse(i,s),t&&(t!=i||o!=s)&&a.extend&&a.extend(t,o)}catch(e){}return null!=l&&(a.caretBidiLevel=l),h})):"left"==n||"backward"==n?i:s}let cachedState=null,cachedDir=null,cachedResult=!1;function endOfTextblock(e,t,n){return cachedState==t&&cachedDir==n?cachedResult:(cachedState=t,cachedDir=n,cachedResult="up"==n||"down"==n?endOfTextblockVertical(e,t,n):endOfTextblockHorizontal(e,t,n))}const NOT_DIRTY=0,CHILD_DIRTY=1,CONTENT_DIRTY=2,NODE_DIRTY=3;class ViewDesc{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>domIndex(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let o=this.children[n],i=t+o.size;if(i>e||o instanceof TrailingHackViewDesc){r=e-t;break}t=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof WidgetViewDesc&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?domIndex(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?domIndex(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,o=-1;for(let i=n,s=0;;s++){let n=this.children[s],a=i+n.size;if(-1==r&&e<=a){let o=i+n.border;if(e>=o&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=domIndex(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=domIndex(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(o>a&&i<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);a=c}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=n.getSelection(),c=!1;if((gecko||safari)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(c=!(!t||"\n"!=e.nodeValue[t-1]),c&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=a={node:t.parentNode,offset:domIndex(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(gecko&&l.focusNode&&l.focusNode!=a.node&&1==l.focusNode.nodeType){let e=l.focusNode.childNodes[l.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||c&&safari)&&isEquivalentPosition(s.node,s.offset,l.anchorNode,l.anchorOffset)&&isEquivalentPosition(a.node,a.offset,l.focusNode,l.focusOffset))return;let d=!1;if((l.extend||e==t)&&!c){l.collapse(s.node,s.offset);try{e!=t&&l.extend(a.node,a.offset),d=!0}catch(e){}}if(!d){if(e>t){let e=s;s=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class WidgetViewDesc extends ViewDesc{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r))),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class CompositionViewDesc extends ViewDesc{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class MarkViewDesc extends ViewDesc{constructor(e,t,n,r){super(e,[],n,r),this.mark=t}static create(e,t,n,r){let o=r.nodeViews[t.type.name],i=o&&o(t,r,n);return i&&i.dom||(i=DOMSerializer.renderSpec(document,t.type.spec.toDOM(t,n))),new MarkViewDesc(e,t,i.dom,i.contentDOM||i.dom)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=MarkViewDesc.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=replaceNodes(o,t,i,n)),e>0&&(o=replaceNodes(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}}class NodeViewDesc extends ViewDesc{constructor(e,t,n,r,o,i,s,a,l){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,o,i){let s,a=o.nodeViews[t.type.name],l=a&&a(t,o,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i),n,r),c=l&&l.dom,d=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else c||({dom:c,contentDOM:d}=DOMSerializer.renderSpec(document,t.type.spec.toDOM(t)));d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let p=c;return c=applyOuterDeco(c,n,t),l?s=new CustomNodeViewDesc(e,t,n,r,c,d||null,p,l,o,i+1):t.isText?new TextViewDesc(e,t,n,r,c,p,o):new NodeViewDesc(e,t,n,r,c,d||null,p,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Fragment.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&sameOuterDeco(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,a=new ViewTreeUpdater(this,i&&i.node,e);iterDeco(this.node,this.innerDeco,((t,o,i)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!i&&a.syncToMarks(o==this.node.childCount?Mark$1.none:this.node.child(o).marks,n,e),a.placeWidget(t,e,r)}),((t,i,l,c)=>{let d;a.syncToMarks(t.marks,n,e),a.findNodeMatch(t,i,l,c)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(d=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(t,i,l,d,e)||a.updateNextNode(t,i,l,e,c,r)||a.addNode(t,i,l,e,r),r+=t.nodeSize})),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),renderDescs(this.contentDOM,this.children,e),ios&&iosHacks(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof TextSelection)||n<t||r>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,i=findTextInFragment(this.node.content,e,n-t,r-t);return i<0?null:{node:o,pos:i,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new CompositionViewDesc(this,o,t,r);e.input.compositionNodes.push(i),this.children=replaceNodes(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node)||(this.updateInner(e,t,n,r),0))}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(sameOuterDeco(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=patchOuterDeco(this.dom,this.nodeDOM,computeOuterDeco(this.outerDeco,this.node,t),computeOuterDeco(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function docViewDesc(e,t,n,r,o){applyOuterDeco(r,t,e);let i=new NodeViewDesc(void 0,e,t,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class TextViewDesc extends NodeViewDesc{constructor(e,t,n,r,o,i,s){super(e,t,n,r,o,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node)||(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,0))}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),o=document.createTextNode(r.text);return new TextViewDesc(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class TrailingHackViewDesc extends ViewDesc{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class CustomNodeViewDesc extends NodeViewDesc{constructor(e,t,n,r,o,i,s,a,l,c){super(e,t,n,r,o,i,s,l,c),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function renderDescs(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],a=s.dom;if(a.parentNode==e){for(;a!=r;)r=rm(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(a,r);if(s instanceof MarkViewDesc){let t=r?r.previousSibling:e.lastChild;renderDescs(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=rm(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}const OuterDecoLevel=function(e){e&&(this.nodeName=e)};OuterDecoLevel.prototype=Object.create(null);const noDeco=[new OuterDecoLevel];function computeOuterDeco(e,t,n){if(0==e.length)return noDeco;let r=n?noDeco[0]:new OuterDecoLevel,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new OuterDecoLevel(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new OuterDecoLevel(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function patchOuterDeco(e,t,n,r){if(n==noDeco&&r==noDeco)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=noDeco[0]),o=t}patchAttributes(o,s||noDeco[0],i)}return o}function patchAttributes(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function applyOuterDeco(e,t,n){return patchOuterDeco(e,e,noDeco,computeOuterDeco(t,n,1!=e.nodeType))}function sameOuterDeco(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function rm(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class ViewTreeUpdater{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=preMatch(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let r=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++){let n=this.top.children[t];if(n.matchesMark(e[o])&&!this.isLocked(n.dom)){r=t;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=MarkViewDesc.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof NodeViewDesc){let l=this.preMatch.matched.get(a);if(null!=l&&l!=o)return!1;let c,d=a.dom,p=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&sameOuterDeco(t,a.outerDeco));if(!p&&a.update(e,t,n,r))return this.destroyBetween(this.index,s),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(c=this.recreateWrapper(a,e,t,n,r,i)))return this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content))return null;let s=NodeViewDesc.create(this.top,t,n,r,o,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,r,o){let i=NodeViewDesc.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new WidgetViewDesc(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof MarkViewDesc;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof TextViewDesc)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((safari||chrome)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new TrailingHackViewDesc(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function preMatch(e,t){let n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof MarkViewDesc)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}function compareSide(e,t){return e.type.side-t.type.side}function iterDeco(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,p,h,u;for(;s<o.length&&o[s].to==i;){let e=o[s++];e.widget&&(d?(p||(p=[d])).push(e):d=e)}if(d)if(p){p.sort(compareSide);for(let e=0;e<p.length;e++)n(p[e],c,!!l)}else n(d,c,!!l);if(l)u=-1,h=l,l=null;else{if(!(c<e.childCount))break;u=c,h=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=i&&a.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)a.push(o[s++]);let f=i+h.nodeSize;if(h.isText){let e=f;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=h.cut(e-i),h=h.cut(0,e-i),f=e,u=-1)}else for(;s<o.length&&o[s].to<f;)s++;r(h,h.isInline&&!h.isLeaf?a.filter((e=>!e.inline)):a.slice(),t.forChild(i,h),u),i=f}}function iosHacks(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function findTextInFragment(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),a=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;l+=t.text}if(i>=n){if(i>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}function replaceNodes(e,t,n,r,o){let i=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],c=a,d=a+=l.size;c>=n||d<=t?i.push(l):(c<t&&i.push(l.slice(0,t-c,r)),o&&(i.push(o),o=void 0),d>n&&i.push(l.slice(n-c,l.size,r)))}return i}function selectionFromDOM(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=r.resolve(s);if(selectionCollapsed(n)){for(a=c;o&&!o.node;)o=o.parent;let e=o.node;if(o&&e.isAtom&&NodeSelection.isSelectable(e)&&o.parent&&(!e.isInline||!isOnEdge(n.focusNode,n.focusOffset,o.dom))){let e=o.posBefore;l=new NodeSelection(s==e?c:r.resolve(e))}}else{let t=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(t<0)return null;a=r.resolve(t)}return l||(l=selectionBetween(e,a,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)),l}function editorOwnsSelection(e){return e.editable?e.hasFocus():hasSelection(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function selectionToDOM(e,t=!1){let n=e.state.selection;if(syncNodeSelection(e,n),editorOwnsSelection(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&chrome){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&isEquivalentPosition(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)selectCursorWrapper(e);else{let r,o,{anchor:i,head:s}=n;!brokenSelectBetweenUneditable||n instanceof TextSelection||(n.$from.parent.inlineContent||(r=temporarilyEditableNear(e,n.from)),n.empty||n.$from.parent.inlineContent||(o=temporarilyEditableNear(e,n.to))),e.docView.setSelection(i,s,e.root,t),brokenSelectBetweenUneditable&&(r&&resetEditable(r),o&&resetEditable(o)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&removeClassOnSelectionChange(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const brokenSelectBetweenUneditable=safari||chrome&&chrome_version<63;function temporarilyEditableNear(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(safari&&o&&"false"==o.contentEditable)return setEditable(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return setEditable(o);if(i)return setEditable(i)}}function setEditable(e){return e.contentEditable="true",safari&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function resetEditable(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function removeClassOnSelectionChange(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{editorOwnsSelection(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}function selectCursorWrapper(e){let t=e.domSelection(),n=document.createRange(),r=e.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,domIndex(r)+1):n.setEnd(r,0),n.collapse(!1),t.removeAllRanges(),t.addRange(n),!o&&!e.state.selection.visible&&ie$1&&ie_version<=11&&(r.disabled=!0,r.disabled=!1)}function syncNodeSelection(e,t){if(t instanceof NodeSelection){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(clearNodeSelection(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else clearNodeSelection(e)}function clearNodeSelection(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function selectionBetween(e,t,n,r){return e.someProp("createSelectionBetween",(r=>r(e,t,n)))||TextSelection.between(t,n,r)}function hasFocusAndSelection(e){return!(e.editable&&!e.hasFocus())&&hasSelection(e)}function hasSelection(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function anchorInRightPlace(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return isEquivalentPosition(t.node,t.offset,n.anchorNode,n.anchorOffset)}function moveSelectionBlock(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&Selection.findFrom(i,t)}function apply(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function selectHorizontally(e,t,n){let r=e.state.selection;if(!(r instanceof TextSelection)){if(r instanceof NodeSelection&&r.node.isInline)return apply(e,new TextSelection(t>0?r.$to:r.$from));{let n=moveSelectionBlock(e.state,t);return!!n&&apply(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+o.nodeSize*(t<0?-1:1));return apply(e,new TextSelection(r.$anchor,i))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=moveSelectionBlock(e.state,t);return!!(n&&n instanceof NodeSelection)&&apply(e,n)}if(!(mac$2&&n.indexOf("m")>-1)){let n,o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=t<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(NodeSelection.isSelectable(i)?apply(e,new NodeSelection(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):!!webkit&&apply(e,new TextSelection(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function nodeLen(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function isIgnorable(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function skipIgnoredNodes(e,t){return t<0?skipIgnoredNodesBefore(e):skipIgnoredNodesAfter(e)}function skipIgnoredNodesBefore(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;for(gecko&&1==n.nodeType&&r<nodeLen(n)&&isIgnorable(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(isIgnorable(e,-1))o=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(isBlockNode(n))break;{let t=n.previousSibling;for(;t&&isIgnorable(t,-1);)o=n.parentNode,i=domIndex(t),t=t.previousSibling;if(t)n=t,r=nodeLen(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?setSelFocus(e,n,r):o&&setSelFocus(e,o,i)}function skipIgnoredNodesAfter(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=nodeLen(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!isIgnorable(n.childNodes[r],1))break;o=n,i=++r}else{if(isBlockNode(n))break;{let t=n.nextSibling;for(;t&&isIgnorable(t,1);)o=t.parentNode,i=domIndex(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=nodeLen(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}o&&setSelFocus(e,o,i)}function isBlockNode(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function textNodeAfter(e,t){for(;e&&t==e.childNodes.length&&!hasBlockDesc(e);)t=domIndex(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}function textNodeBefore(e,t){for(;e&&!t&&!hasBlockDesc(e);)t=domIndex(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}function setSelFocus(e,t,n){if(3!=t.nodeType){let e,r;(r=textNodeAfter(t,n))?(t=r,n=0):(e=textNodeBefore(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(selectionCollapsed(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout((()=>{e.state==o&&selectionToDOM(e)}),50)}function findDirection(e,t){let n=e.state.doc.resolve(t);if(!chrome&&!windows&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function selectVertically(e,t,n){let r=e.state.selection;if(r instanceof TextSelection&&!r.empty||n.indexOf("s")>-1)return!1;if(mac$2&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=moveSelectionBlock(e.state,t);if(n&&n instanceof NodeSelection)return apply(e,n)}if(!o.parent.inlineContent){let n=t<0?o:i,s=r instanceof AllSelection?Selection.near(n,t):Selection.findFrom(n,t);return!!s&&apply(e,s)}return!1}function stopNativeHorizontalDelete(e,t){if(!(e.state.selection instanceof TextSelection))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function switchEditable(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function safariDownArrowBug(e){if(!safari||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;switchEditable(e,n,"true"),setTimeout((()=>switchEditable(e,n,"false")),20)}return!1}function getMods(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function captureKeyDown(e,t){let n=t.keyCode,r=getMods(t);if(8==n||mac$2&&72==n&&"c"==r)return stopNativeHorizontalDelete(e,-1)||skipIgnoredNodes(e,-1);if(46==n&&!t.shiftKey||mac$2&&68==n&&"c"==r)return stopNativeHorizontalDelete(e,1)||skipIgnoredNodes(e,1);if(13==n||27==n)return!0;if(37==n||mac$2&&66==n&&"c"==r){let t=37==n?"ltr"==findDirection(e,e.state.selection.from)?-1:1:-1;return selectHorizontally(e,t,r)||skipIgnoredNodes(e,t)}if(39==n||mac$2&&70==n&&"c"==r){let t=39==n?"ltr"==findDirection(e,e.state.selection.from)?1:-1:1;return selectHorizontally(e,t,r)||skipIgnoredNodes(e,t)}return 38==n||mac$2&&80==n&&"c"==r?selectVertically(e,-1,r)||skipIgnoredNodes(e,-1):40==n||mac$2&&78==n&&"c"==r?safariDownArrowBug(e)||selectVertically(e,1,r)||skipIgnoredNodes(e,1):r==(mac$2?"m":"c")&&(66==n||73==n||89==n||90==n)}function serializeForClipboard(e,t){e.someProp("transformCopied",(n=>{t=n(t,e)}));let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||DOMSerializer.fromSchema(e.state.schema),a=detachedDoc(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c,d=l.firstChild,p=0;for(;d&&1==d.nodeType&&(c=wrapMap[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),p++}d=l.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${o} ${i}${p?` -${p}`:""} ${JSON.stringify(n)}`),{dom:l,text:e.someProp("clipboardTextSerializer",(n=>n(t,e)))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function parseFromClipboard(e,t,n,r,o){let i,s,a=o.parent.type.spec.code;if(!n&&!t)return null;let l=t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",(n=>{t=n(t,a||r,e)})),a)return t?new Slice(Fragment.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):Slice.empty;let n=e.someProp("clipboardTextParser",(n=>n(t,o,r,e)));if(n)s=n;else{let n=o.marks(),{schema:r}=e.state,s=DOMSerializer.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.text(e,n)))}))}}else e.someProp("transformPastedHTML",(t=>{n=t(n,e)})),i=readHTML(n),webkit&&restoreReplacedSpaces(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let e=+d[3];e>0;e--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||DOMParser.fromSchema(e.state.schema);s=t.parseSlice(i,{preserveWhitespace:!(!l&&!d),context:o,ruleFromNode(e){return"BR"!=e.nodeName||e.nextSibling||!e.parentNode||inlineParents.test(e.parentNode.nodeName)?null:{ignore:!0}}})}if(d)s=addContext(closeSlice(s,+d[1],+d[2]),d[4]);else if(s=Slice.maxOpen(normalizeSiblings(s.content,o),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=closeSlice(s,e,t)}return e.someProp("transformPasted",(t=>{s=t(s,e)})),s}const inlineParents=/^(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 normalizeSiblings(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,o=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach((e=>{if(!i)return;let t,n=o.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&r.length&&addToSibling(n,r,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=closeRight(i[i.length-1],r.length));let t=withWrappers(e,n);i.push(t),o=o.matchType(t.type),r=n}})),i)return Fragment.from(i)}return e}function withWrappers(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Fragment.from(e));return e}function addToSibling(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=addToSibling(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(Fragment.from(withWrappers(n,e,o+1))))}}function closeRight(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,closeRight(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Fragment.empty,!0);return e.copy(n.append(r))}function closeRange(e,t,n,r,o,i){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(i=0),o<r-1&&(a=closeRange(a,t,n,r,o+1,i)),o>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(Fragment.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function closeSlice(e,t,n){return t<e.openStart&&(e=new Slice(closeRange(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Slice(closeRange(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const wrapMap={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 _detachedDoc=null;function detachedDoc(){return _detachedDoc||(_detachedDoc=document.implementation.createHTMLDocument("title"))}function readHTML(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=detachedDoc().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);if((n=o&&wrapMap[o[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join("")),r.innerHTML=e,n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}function restoreReplacedSpaces(e){let t=e.querySelectorAll(chrome?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function addContext(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:o,openStart:i,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;o=Fragment.from(t.create(n[e+1],o)),i++,s++}return new Slice(o,i,s)}const handlers={},editHandlers={},passiveHandlers={touchstart:!0,touchmove:!0};class InputState{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function initInput(e){for(let t in handlers){let n=handlers[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!eventBelongsToView(e,t)||runCustomHandler(e,t)||!e.editable&&t.type in editHandlers||n(e,t)},passiveHandlers[t]?{passive:!0}:void 0)}safari&&e.dom.addEventListener("input",(()=>null)),ensureListeners(e)}function setSelectionOrigin(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function destroyInput(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function ensureListeners(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>runCustomHandler(e,t))}))}function runCustomHandler(e,t){return e.someProp("handleDOMEvents",(n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function eventBelongsToView(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function dispatchEvent(e,t){runCustomHandler(e,t)||!handlers[t.type]||!e.editable&&t.type in editHandlers||handlers[t.type](e,t)}function eventCoords(e){return{left:e.clientX,top:e.clientY}}function isNear(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function runHandlerOnContext(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,(t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1))))return!0;return!1}function updateSelection(e,t,n){e.focused||e.focus();let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function selectClickedLeaf(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&NodeSelection.isSelectable(r))&&(updateSelection(e,new NodeSelection(n),"pointer"),!0)}function selectClickedNode(e,t){if(-1==t)return!1;let n,r,o=e.state.selection;o instanceof NodeSelection&&(n=o.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(NodeSelection.isSelectable(t)){r=n&&o.$from.depth>0&&e>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(e);break}}return null!=r&&(updateSelection(e,NodeSelection.create(e.state.doc,r),"pointer"),!0)}function handleSingleClick(e,t,n,r,o){return runHandlerOnContext(e,"handleClickOn",t,n,r)||e.someProp("handleClick",(n=>n(e,t,r)))||(o?selectClickedNode(e,n):selectClickedLeaf(e,n))}function handleDoubleClick(e,t,n,r){return runHandlerOnContext(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(n=>n(e,t,r)))}function handleTripleClick(e,t,n,r){return runHandlerOnContext(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",(n=>n(e,t,r)))||defaultTripleClick(e,n,r)}function defaultTripleClick(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(updateSelection(e,TextSelection.create(r,0,r.content.size),"pointer"),!0);let o=r.resolve(t);for(let t=o.depth+1;t>0;t--){let n=t>o.depth?o.nodeAfter:o.node(t),i=o.before(t);if(n.inlineContent)updateSelection(e,TextSelection.create(r,i+1,i+1+n.content.size),"pointer");else{if(!NodeSelection.isSelectable(n))continue;updateSelection(e,NodeSelection.create(r,i),"pointer")}return!0}}function forceDOMFlush(e){return endComposition(e)}editHandlers.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!inOrNearComposition(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!android||!chrome||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!ios||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||captureKeyDown(e,n)?n.preventDefault():setSelectionOrigin(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,keyEvent(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},editHandlers.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},editHandlers.keypress=(e,t)=>{let n=t;if(inOrNearComposition(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||mac$2&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof TextSelection&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode);/[\r\n]/.test(t)||e.someProp("handleTextInput",(n=>n(e,r.$from.pos,r.$to.pos,t)))||e.dispatch(e.state.tr.insertText(t).scrollIntoView()),n.preventDefault()}};const selectNodeModifier=mac$2?"metaKey":"ctrlKey";handlers.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=forceDOMFlush(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&isNear(n,e.input.lastClick)&&!n[selectNodeModifier]&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i};let s=e.posAtCoords(eventCoords(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new MouseDown(e,s,n,!!r)):("doubleClick"==i?handleDoubleClick:handleTripleClick)(e,s.pos,s.inside,n)?n.preventDefault():setSelectionOrigin(e,"pointer"))};class MouseDown{constructor(e,t,n,r){let o,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[selectNodeModifier],this.allowDefault=n.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&1==a.dom.nodeType?a.dom:null;let{selection:l}=e.state;(0==n.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||l instanceof NodeSelection&&l.from<=i&&l.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!gecko||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),setSelectionOrigin(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>selectionToDOM(this.view))),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(eventCoords(e))),this.updateAllowDefault(e),this.allowDefault||!t?setSelectionOrigin(this.view,"pointer"):handleSingleClick(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||safari&&this.mightDrag&&!this.mightDrag.node.isAtom||chrome&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(updateSelection(this.view,Selection.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):setSelectionOrigin(this.view,"pointer")}move(e){this.updateAllowDefault(e),setSelectionOrigin(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function inOrNearComposition(e,t){return!!e.composing||!!(safari&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}handlers.touchstart=e=>{e.input.lastTouch=Date.now(),forceDOMFlush(e),setSelectionOrigin(e,"pointer")},handlers.touchmove=e=>{e.input.lastTouch=Date.now(),setSelectionOrigin(e,"pointer")},handlers.contextmenu=e=>forceDOMFlush(e);const timeoutComposition=android?5e3:-1;function scheduleComposeEnd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>endComposition(e)),t))}function clearComposition(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=timestampFromCustomEvent());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function findCompositionNode(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=textNodeBefore$1(t.focusNode,t.focusOffset),r=textNodeAfter$1(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function timestampFromCustomEvent(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function endComposition(e,t=!1){if(!(android&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),clearComposition(e),t||e.docView&&e.docView.dirty){let t=selectionFromDOM(e);return t&&!t.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(t)):e.updateState(e.state),!0}return!1}}function captureCopy(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}editHandlers.compositionstart=editHandlers.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),endComposition(e,!0),e.markCursor=null;else if(endComposition(e),gecko&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){e.domSelection().collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}scheduleComposeEnd(e,timeoutComposition)},editHandlers.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then((()=>e.domObserver.flush())),e.input.compositionID++,scheduleComposeEnd(e,20))};const brokenClipboardAPI=ie$1&&ie_version<15||ios&&webkit_version<604;function sliceSingleNode(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}function capturePaste(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout((()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?doPaste(e,r.value,null,o,t):doPaste(e,r.textContent,r.innerHTML,o,t)}),50)}function doPaste(e,t,n,r,o){let i=parseFromClipboard(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,o,i||Slice.empty))))return!0;if(!i)return!1;let s=sliceSingleNode(i),a=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function getText$1(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}handlers.copy=editHandlers.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=brokenClipboardAPI?null:n.clipboardData,s=r.content(),{dom:a,text:l}=serializeForClipboard(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):captureCopy(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},editHandlers.paste=(e,t)=>{let n=t;if(e.composing&&!android)return;let r=brokenClipboardAPI?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&doPaste(e,getText$1(r),r.getData("text/html"),o,n)?n.preventDefault():capturePaste(e,n)};class Dragging{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const dragCopyModifier=mac$2?"altKey":"ctrlKey";handlers.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o,i=e.state.selection,s=i.empty?null:e.posAtCoords(eventCoords(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof NodeSelection?i.to-1:i.to));else if(r&&r.mightDrag)o=NodeSelection.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=NodeSelection.create(e.state.doc,t.posBefore))}let a=(o||e.state.selection).content(),{dom:l,text:c,slice:d}=serializeForClipboard(e,a);n.dataTransfer.clearData(),n.dataTransfer.setData(brokenClipboardAPI?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",brokenClipboardAPI||n.dataTransfer.setData("text/plain",c),e.dragging=new Dragging(d,!n[dragCopyModifier],o)},handlers.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},editHandlers.dragover=editHandlers.dragenter=(e,t)=>t.preventDefault(),editHandlers.drop=(e,t)=>{let n=t,r=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let o=e.posAtCoords(eventCoords(n));if(!o)return;let i=e.state.doc.resolve(o.pos),s=r&&r.slice;s?e.someProp("transformPasted",(t=>{s=t(s,e)})):s=parseFromClipboard(e,getText$1(n.dataTransfer),brokenClipboardAPI?null:n.dataTransfer.getData("text/html"),!1,i);let a=!(!r||n[dragCopyModifier]);if(e.someProp("handleDrop",(t=>t(e,n,s||Slice.empty,a))))return void n.preventDefault();if(!s)return;n.preventDefault();let l=s?dropPoint(e.state.doc,i.pos,s):i.pos;null==l&&(l=i.pos);let c=e.state.tr;if(a){let{node:e}=r;e?e.replace(c):c.deleteSelection()}let d=c.mapping.map(l),p=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,h=c.doc;if(p?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(h))return;let u=c.doc.resolve(d);if(p&&NodeSelection.isSelectable(s.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new NodeSelection(u));else{let t=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,r,o)=>t=o)),c.setSelection(selectionBetween(e,u,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},handlers.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&selectionToDOM(e)}),20))},handlers.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},handlers.beforeinput=(e,t)=>{if(chrome&&android&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,keyEvent(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in editHandlers)handlers[e]=editHandlers[e];function compareObjs(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class WidgetType{constructor(e,t){this.toDOM=e,this.spec=t||noSpec,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new Decoration(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof WidgetType&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&compareObjs(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class InlineType{constructor(e,t){this.attrs=e,this.spec=t||noSpec}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Decoration(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof InlineType&&compareObjs(this.attrs,e.attrs)&&compareObjs(this.spec,e.spec)}static is(e){return e.type instanceof InlineType}destroy(){}}class NodeType{constructor(e,t){this.attrs=e,this.spec=t||noSpec}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Decoration(o.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}eq(e){return this==e||e instanceof NodeType&&compareObjs(this.attrs,e.attrs)&&compareObjs(this.spec,e.spec)}destroy(){}}class Decoration{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Decoration(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Decoration(e,e,new WidgetType(t,n))}static inline(e,t,n,r){return new Decoration(e,t,new InlineType(n,r))}static node(e,t,n,r){return new Decoration(e,t,new NodeType(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof InlineType}get widget(){return this.type instanceof WidgetType}}const none=[],noSpec={};class DecorationSet{constructor(e,t){this.local=e.length?e:none,this.children=t.length?t:none}static create(e,t){return t.length?buildTree(t,e,0,noSpec):empty}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,r+s,o)}}map(e,t,n){return this==empty||0==e.maps.length?this:this.mapInner(e,t,0,0,n||noSpec)}mapInner(e,t,n,r,o){let i;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,n,r);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?mapChildren(this.children,i||[],e,t,n,r,o):i?new DecorationSet(i.sort(byPos),none):empty}add(e,t){return t.length?this==empty?DecorationSet.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach(((e,i)=>{let s,a=i+n;if(s=takeSpansForNode(t,e,a)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,a+1):r.splice(o,0,i,i+e.nodeSize,buildTree(s,e,a+1,noSpec)),o+=3}}));let i=moveSpans(o?withoutNulls(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new DecorationSet(i.length?this.local.concat(i).sort(byPos):this.local,r||this.children)}remove(e){return 0==e.length||this==empty?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(o,i+1);a!=empty?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new DecorationSet(r,n):empty}forChild(e,t){if(this==empty)return this;if(t.isLeaf)return DecorationSet.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof InlineType){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new DecorationSet(r.sort(byPos),none);return n?new DecorationGroup([e,n]):e}return n||empty}eq(e){if(this==e)return!0;if(!(e instanceof DecorationSet)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return removeOverlap(this.localsInner(e))}localsInner(e){if(this==empty)return none;if(e.inlineContent||!this.local.some(InlineType.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof InlineType||t.push(this.local[e]);return t}}DecorationSet.empty=new DecorationSet([],[]),DecorationSet.removeOverlap=removeOverlap;const empty=DecorationSet.empty;class DecorationGroup{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,noSpec)));return DecorationGroup.from(n)}forChild(e,t){if(t.isLeaf)return DecorationSet.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=empty&&(o instanceof DecorationGroup?n=n.concat(o.members):n.push(o))}return DecorationGroup.from(n)}eq(e){if(!(e instanceof DecorationGroup)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?removeOverlap(n?t:t.sort(byPos)):none}static from(e){switch(e.length){case 0:return empty;case 1:return e[0];default:return new DecorationGroup(e.every((e=>e instanceof DecorationSet))?e:e.reduce(((e,t)=>e.concat(t instanceof DecorationSet?t:t.members)),[]))}}}function mapChildren(e,t,n,r,o,i,s){let a=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach(((e,n,o,i)=>{let s=i-o-(n-e);for(let o=0;o<a.length;o+=3){let i=a[o+1];if(i<0||e>i+t-r)continue;let l=a[o]+t-r;n>=l?a[o+1]=e<=l?-2:-1:e>=t&&s&&(a[o]+=s,a[o+1]+=s)}r+=s})),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+i),d=c-o;if(d<0||d>=r.content.size){l=!0;continue}let p=n.map(e[t+1]+i,-1)-o,{index:h,offset:u}=r.content.findIndex(d),f=r.maybeChild(h);if(f&&u==d&&u+f.nodeSize==p){let r=a[t+2].mapInner(n,f,c+1,e[t]+i+1,s);r!=empty?(a[t]=d,a[t+1]=p,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=buildTree(mapAndGatherRemainingDecorations(a,e,t,n,o,i,s),r,0,s);t=l.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<l.children.length;e+=3){let n=l.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,l.children[e],l.children[e+1],l.children[e+2])}}return new DecorationSet(t.sort(byPos),a)}function moveSpans(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new Decoration(o.from+t,o.to+t,o.type))}return n}function mapAndGatherRemainingDecorations(e,t,n,r,o,i,s){function a(e,t){for(let i=0;i<e.local.length;i++){let a=e.local[i].map(r,o,t);a?n.push(a):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&a(e[n+2],t[n]+i+1);return n}function takeSpansForNode(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function withoutNulls(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function buildTree(e,t,n,r){let o=[],i=!1;t.forEach(((t,s)=>{let a=takeSpansForNode(e,t,s+n);if(a){i=!0;let e=buildTree(a,t,n+s+1,r);e!=empty&&o.push(s,s+t.nodeSize,e)}}));let s=moveSpans(i?withoutNulls(e):e,-n).sort(byPos);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new DecorationSet(s,o):empty}function byPos(e,t){return e.from-t.from||e.to-t.to}function removeOverlap(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),insertAhead(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),insertAhead(t,o+1,i.copy(r.to,i.to)))}}return t}function insertAhead(e,t,n){for(;t<e.length&&byPos(n,e[t])>0;)t++;e.splice(t,0,n)}function viewDecorations(e){let t=[];return e.someProp("decorations",(n=>{let r=n(e.state);r&&r!=empty&&t.push(r)})),e.cursorWrapper&&t.push(DecorationSet.create(e.state.doc,[e.cursorWrapper.deco])),DecorationGroup.from(t)}const observeOptions={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},useCharData=ie$1&&ie_version<=11;class SelectionState{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class DOMObserver{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new SelectionState,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);ie$1&&ie_version<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),useCharData&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,observeOptions)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(hasFocusAndSelection(this.view)){if(this.suppressingSelectionUpdates)return selectionToDOM(this.view);if(ie$1&&ie_version<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&isEquivalentPosition(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=parentNode(t))n.add(t);for(let r=e.anchorNode;r;r=parentNode(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&hasFocusAndSelection(e)&&!this.ignoreSelectionChange(n),o=-1,i=-1,s=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(o=o<0?n.from:Math.min(n.from,o),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(gecko&&a.length){let t=a.filter((e=>"BR"==e.nodeName));if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&blockParent(e,n)==t||r.remove()}}}let l=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&selectionCollapsed(n)&&(l=selectionFromDOM(e))&&l.eq(Selection.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,selectionToDOM(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,i),checkCSS(e)),this.handleDOMChange(o,i,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||selectionToDOM(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++)t.push(e.addedNodes[n]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(ie$1&&ie_version<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?domIndex(r)+1:0,s=n.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?domIndex(o):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let cssChecked=new WeakMap,cssCheckWarned=!1;function checkCSS(e){if(!cssChecked.has(e)&&(cssChecked.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))){if(e.requiresGeckoHackNode=gecko,cssCheckWarned)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."),cssCheckWarned=!0}}function rangeToSelectionRange(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return isEquivalentPosition(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function safariShadowSelectionRange(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return rangeToSelectionRange(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?rangeToSelectionRange(e,n):null}function blockParent(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function parseBetween(e,t,n){let r,{node:o,fromOffset:i,toOffset:s,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:c.anchorOffset}],selectionCollapsed(c)||r.push({node:c.focusNode,offset:c.focusOffset})),chrome&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=o.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let p=e.state.doc,h=e.someProp("domParser")||DOMParser.fromSchema(e.state.schema),u=p.resolve(a),f=null,m=h.parse(o,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=u.parent.type.whitespace||"full",findPositions:r,ruleFromNode:ruleFromNode,context:u});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}function ruleFromNode(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(safari&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||safari&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const isInline=/^(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 readDOMChange(e,t,n,r,o){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=selectionFromDOM(e,t);if(n&&!e.state.selection.eq(n)){if(chrome&&android&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",(t=>t(e,keyEvent(13,"Enter")))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),i&&r.setMeta("composition",i),e.dispatch(r)}return}let s=e.state.doc.resolve(t),a=s.sharedDepth(n);t=s.before(a+1),n=e.state.doc.resolve(n).after(a+1);let l,c,d=e.state.selection,p=parseBetween(e,t,n),h=e.state.doc,u=h.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(l=e.state.selection.to,c="end"):(l=e.state.selection.from,c="start"),e.input.lastKeyCode=null;let f=findDiff(u.content,p.doc.content,p.from,l,c);if((ios&&e.input.lastIOSEnter>Date.now()-225||android)&&o.some((e=>1==e.nodeType&&!isInline.test(e.nodeName)))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",(t=>t(e,keyEvent(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&d instanceof TextSelection&&!d.empty&&d.$head.sameParent(d.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){let t=resolveSelection(e,e.state.doc,p.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);i&&n.setMeta("composition",i),e.dispatch(n)}}return}f={start:d.from,endA:d.to,endB:d.to}}e.input.domChangeCount++,e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof TextSelection&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),ie$1&&ie_version<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>p.from&&" "==p.doc.textBetween(f.start-p.from-1,f.start-p.from+1)&&(f.start--,f.endA--,f.endB--);let m,g=p.doc.resolveNoCache(f.start-p.from),y=p.doc.resolveNoCache(f.endB-p.from),S=h.resolve(f.start),k=g.sameParent(y)&&g.parent.inlineContent&&S.end()>=f.endA;if((ios&&e.input.lastIOSEnter>Date.now()-225&&(!k||o.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!k&&g.pos<p.doc.content.size&&!g.sameParent(y)&&(m=Selection.findFrom(p.doc.resolve(g.pos+1),1,!0))&&m.head==y.pos)&&e.someProp("handleKeyDown",(t=>t(e,keyEvent(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&looksLikeBackspace(h,f.start,f.endA,g,y)&&e.someProp("handleKeyDown",(t=>t(e,keyEvent(8,"Backspace")))))return void(android&&chrome&&e.domObserver.suppressSelectionUpdates());chrome&&android&&f.endB==f.start&&(e.input.lastAndroidDelete=Date.now()),android&&!k&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==f.endA&&(f.endB-=2,y=p.doc.resolveNoCache(f.endB-p.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,keyEvent(13,"Enter"))}))}),20));let b,v,w,x=f.start,M=f.endA;if(k)if(g.pos==y.pos)ie$1&&ie_version<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>selectionToDOM(e)),20)),b=e.state.tr.delete(x,M),v=h.resolve(f.start).marksAcross(h.resolve(f.endA));else if(f.endA==f.endB&&(w=isMarkChange(g.parent.content.cut(g.parentOffset,y.parentOffset),S.parent.content.cut(S.parentOffset,f.endA-S.start()))))b=e.state.tr,"add"==w.type?b.addMark(x,M,w.mark):b.removeMark(x,M,w.mark);else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let t=g.parent.textBetween(g.parentOffset,y.parentOffset);if(e.someProp("handleTextInput",(n=>n(e,x,M,t))))return;b=e.state.tr.insertText(t,x,M)}if(b||(b=e.state.tr.replace(x,M,p.doc.slice(f.start-p.from,f.endB-p.from))),p.sel){let t=resolveSelection(e,b.doc,p.sel);t&&!(chrome&&android&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastAndroidDelete<Date.now()-100)&&(t.head==x||t.head==b.mapping.map(M)-1)||ie$1&&t.empty&&t.head==x)&&b.setSelection(t)}v&&b.ensureMarks(v),i&&b.setMeta("composition",i),e.dispatch(b.scrollIntoView())}function resolveSelection(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:selectionBetween(e,t.resolve(n.anchor),t.resolve(n.head))}function isMarkChange(e,t){let n,r,o,i=e.firstChild.marks,s=t.firstChild.marks,a=i,l=s;for(let e=0;e<s.length;e++)a=s[e].removeFromSet(a);for(let e=0;e<i.length;e++)l=i[e].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",o=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",o=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(o(t.child(e)));if(Fragment.from(c).eq(e))return{mark:r,type:n}}function looksLikeBackspace(e,t,n,r,o){if(n-t<=o.pos-r.pos||skipClosingAndOpening(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(skipClosingAndOpening(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||skipClosingAndOpening(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function skipClosingAndOpening(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}function findDiff(e,t,n,r,o){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==o&&(r-=s+Math.max(0,i-Math.min(s,a))-i),s<i&&e.size<t.size){let e=r<=i&&r>=s?i-r:0;i-=e,i&&i<t.size&&isSurrogatePair(t.textBetween(i-1,i+1))&&(i+=e?1:-1),a=i+(a-s),s=i}else if(a<i){let t=r<=i&&r>=a?i-r:0;i-=t,i&&i<e.size&&isSurrogatePair(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-a),a=i}return{start:i,endA:s,endB:a}}function isSurrogatePair(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class EditorView{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new InputState,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(checkStateComponent),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=getEditable(this),updateCursorWrapper(this),this.nodeViews=buildNodeViews(this),this.docView=docViewDesc(this.state.doc,computeDocDeco(this),viewDecorations(this),this.dom,this),this.domObserver=new DOMObserver(this,((e,t,n,r)=>readDOMChange(this,e,t,n,r))),this.domObserver.start(),initInput(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ensureListeners(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(checkStateComponent),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(clearComposition(this),i=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=buildNodeViews(this);changedNodeViews(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&ensureListeners(this),this.editable=getEditable(this),updateCursorWrapper(this);let a=viewDecorations(this),l=computeDocDeco(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=o||!this.docView.matchesNode(e.doc,l,a);!d&&e.selection.eq(r.selection)||(i=!0);let p="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&storeScrollPos(this);if(i){this.domObserver.stop();let t=d&&(ie$1||chrome)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&selectionContextChanged(r.selection,e.selection);if(d){let n=chrome?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=findCompositionNode(this)),!o&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=docViewDesc(e.doc,l,a,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&anchorInRightPlace(this))?selectionToDOM(this,t):(syncNodeSelection(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():p&&resetScrollPos(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof NodeSelection){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&scrollRectIntoView(this,t.getBoundingClientRect(),e)}else scrollRectIntoView(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Dragging(e.slice,e.move,r<0?void 0:NodeSelection.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(ie$1){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&focusPreventScroll(this.dom),selectionToDOM(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return posAtCoords(this,e)}coordsAtPos(e,t=1){return coordsAtPos(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return endOfTextblock(this,t||this.state,e)}pasteHTML(e,t){return doPaste(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return doPaste(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(destroyInput(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],viewDecorations(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,clearReusedRange())}get isDestroyed(){return null==this.docView}dispatchEvent(e){return dispatchEvent(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return safari&&11===this.root.nodeType&&deepActiveElement(this.dom.ownerDocument)==this.dom&&safariShadowSelectionRange(this,e)||e}domSelection(){return this.root.getSelection()}}function computeDocDeco(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),t.translate||(t.translate="no"),[Decoration.node(0,e.state.doc.content.size,t)]}function updateCursorWrapper(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Decoration.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function getEditable(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function selectionContextChanged(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function buildNodeViews(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function changedNodeViews(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function checkStateComponent(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var base={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:"'"},shift={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},mac$1="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),ie="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),i=0;i<10;i++)base[48+i]=base[96+i]=String(i);for(i=1;i<=24;i++)base[i+111]="F"+i;for(i=65;i<=90;i++)base[i]=String.fromCharCode(i+32),shift[i]=String.fromCharCode(i);for(var code in base)shift.hasOwnProperty(code)||(shift[code]=base[code]);function keyName(e){var t=!(mac$1&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||ie&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?shift:base)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}const mac="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function normalizeKeyName$1(e){let t,n,r,o,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);mac?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function normalize(e){let t=Object.create(null);for(let n in e)t[normalizeKeyName$1(n)]=e[n];return t}function modifiers(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function keymap(e){return new Plugin({props:{handleKeyDown:keydownHandler(e)}})}function keydownHandler(e){let t=normalize(e);return function(e,n){let r,o=keyName(n),i=t[modifiers(o,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==o.length&&" "!=o){if(n.shiftKey){let r=t[modifiers(o,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.shiftKey||n.altKey||n.metaKey||o.charCodeAt(0)>127)&&(r=base[n.keyCode])&&r!=o){let o=t[modifiers(r,n)];if(o&&o(e.state,e.dispatch,e))return!0}}return!1}}const deleteSelection$1=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function atBlockStart(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const joinBackward$1=(e,t,n)=>{let r=atBlockStart(e,n);if(!r)return!1;let o=findCutBefore(r);if(!o){let n=r.blockRange(),o=n&&liftTarget(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(!i.type.spec.isolating&&deleteBarrier(e,o,t))return!0;if(0==r.parent.content.size&&(textblockAt(i,"end")||NodeSelection.isSelectable(i))){let n=replaceStep(e.doc,r.before(),r.after(),Slice.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(textblockAt(i,"end")?Selection.findFrom(r.doc.resolve(r.mapping.map(o.pos,-1)),-1):NodeSelection.create(r.doc,o.pos-i.nodeSize)),t(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1||(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),0))},joinTextblockBackward$1=(e,t,n)=>{let r=atBlockStart(e,n);if(!r)return!1;let o=findCutBefore(r);return!!o&&joinTextblocksAround(e,o,t)},joinTextblockForward$1=(e,t,n)=>{let r=atBlockEnd(e,n);if(!r)return!1;let o=findCutAfter(r);return!!o&&joinTextblocksAround(e,o,t)};function joinTextblocksAround(e,t,n){let r=t.nodeBefore,o=t.pos-1;for(;!r.isTextblock;o--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let i=t.nodeAfter,s=t.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let e=i.firstChild;if(!e)return!1;i=e}let a=replaceStep(e.doc,o,s,Slice.empty);if(!a||a.from!=o||a instanceof ReplaceStep&&a.slice.size>=s-o)return!1;if(n){let t=e.tr.step(a);t.setSelection(TextSelection.create(t.doc,o)),n(t.scrollIntoView())}return!0}function textblockAt(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const selectNodeBackward$1=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=findCutBefore(r)}let s=i&&i.nodeBefore;return!(!s||!NodeSelection.isSelectable(s)||(t&&t(e.tr.setSelection(NodeSelection.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),0))};function findCutBefore(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function atBlockEnd(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const joinForward$1=(e,t,n)=>{let r=atBlockEnd(e,n);if(!r)return!1;let o=findCutAfter(r);if(!o)return!1;let i=o.nodeAfter;if(deleteBarrier(e,o,t))return!0;if(0==r.parent.content.size&&(textblockAt(i,"start")||NodeSelection.isSelectable(i))){let n=replaceStep(e.doc,r.before(),r.after(),Slice.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(textblockAt(i,"start")?Selection.findFrom(r.doc.resolve(r.mapping.map(o.pos)),1):NodeSelection.create(r.doc,r.mapping.map(o.pos))),t(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1||(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),0))},selectNodeForward$1=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=findCutAfter(r)}let s=i&&i.nodeAfter;return!(!s||!NodeSelection.isSelectable(s)||(t&&t(e.tr.setSelection(NodeSelection.create(e.doc,i.pos)).scrollIntoView()),0))};function findCutAfter(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const joinUp$1=(e,t)=>{let n,r=e.selection,o=r instanceof NodeSelection;if(o){if(r.node.isTextblock||!canJoin(e.doc,r.from))return!1;n=r.from}else if(n=joinPoint(e.doc,r.from,-1),null==n)return!1;if(t){let r=e.tr.join(n);o&&r.setSelection(NodeSelection.create(r.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(r.scrollIntoView())}return!0},joinDown$1=(e,t)=>{let n,r=e.selection;if(r instanceof NodeSelection){if(r.node.isTextblock||!canJoin(e.doc,r.to))return!1;n=r.to}else if(n=joinPoint(e.doc,r.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},lift$1=(e,t)=>{let{$from:n,$to:r}=e.selection,o=n.blockRange(r),i=o&&liftTarget(o);return null!=i&&(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)},newlineInCode$1=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))};function defaultBlockAt$1(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const exitCode$1=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=defaultBlockAt$1(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,s.createAndFill());o.setSelection(Selection.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0},createParagraphNear$1=(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof AllSelection||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=defaultBlockAt$1(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(TextSelection.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},liftEmptyBlock$1=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(canSplit(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&liftTarget(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)};function splitBlockAs(e){return(t,n)=>{let{$from:r,$to:o}=t.selection;if(t.selection instanceof NodeSelection&&t.selection.node.isBlock)return!(!r.parentOffset||!canSplit(t.doc,r.pos)||(n&&n(t.tr.split(r.pos).scrollIntoView()),0));if(!r.parent.isBlock)return!1;if(n){let i=o.parentOffset==o.parent.content.size,s=t.tr;(t.selection instanceof TextSelection||t.selection instanceof AllSelection)&&s.deleteSelection();let a=0==r.depth?null:defaultBlockAt$1(r.node(-1).contentMatchAt(r.indexAfter(-1))),l=e&&e(o.parent,i),c=l?[l]:i&&a?[{type:a}]:void 0,d=canSplit(s.doc,s.mapping.map(r.pos),1,c);if(c||d||!canSplit(s.doc,s.mapping.map(r.pos),1,a?[{type:a}]:void 0)||(a&&(c=[{type:a}]),d=!0),d&&(s.split(s.mapping.map(r.pos),1,c),!i&&!r.parentOffset&&r.parent.type!=a)){let e=s.mapping.map(r.before()),t=s.doc.resolve(e);a&&r.node(-1).canReplaceWith(t.index(),t.index()+1,a)&&s.setNodeMarkup(s.mapping.map(r.before()),a)}n(s.scrollIntoView())}return!0}}const splitBlock$1=splitBlockAs(),selectParentNode$1=(e,t)=>{let n,{$from:r,to:o}=e.selection,i=r.sharedDepth(o);return 0!=i&&(n=r.before(i),t&&t(e.tr.setSelection(NodeSelection.create(e.doc,n))),!0)},selectAll$1=(e,t)=>(t&&t(e.tr.setSelection(new AllSelection(e.doc))),!0);function joinMaybeClear(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!canJoin(e.doc,t.pos)||(n&&n(e.tr.clearIncompatible(t.pos,r.type,r.contentMatchAt(r.childCount)).join(t.pos).scrollIntoView()),0)))}function deleteBarrier(e,t,n){let r,o,i=t.nodeBefore,s=t.nodeAfter;if(i.type.spec.isolating||s.type.spec.isolating)return!1;if(joinMaybeClear(e,t,n))return!0;let a=t.parent.canReplace(t.index(),t.index()+1);if(a&&(r=(o=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&o.matchType(r[0]||s.type).validEnd){if(n){let o=t.pos+s.nodeSize,a=Fragment.empty;for(let e=r.length-1;e>=0;e--)a=Fragment.from(r[e].create(null,a));a=Fragment.from(i.copy(a));let l=e.tr.step(new ReplaceAroundStep(t.pos-1,o,t.pos,o,new Slice(a,1,0),r.length,!0)),c=o+2*r.length;canJoin(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let l=Selection.findFrom(t,1),c=l&&l.$from.blockRange(l.$to),d=c&&liftTarget(c);if(null!=d&&d>=t.depth)return n&&n(e.tr.lift(c,d).scrollIntoView()),!0;if(a&&textblockAt(s,"start",!0)&&textblockAt(i,"end")){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let a=s,l=1;for(;!a.isTextblock;a=a.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,a.content)){if(n){let r=Fragment.empty;for(let e=o.length-1;e>=0;e--)r=Fragment.from(o[e].copy(r));n(e.tr.step(new ReplaceAroundStep(t.pos-o.length,t.pos+s.nodeSize,t.pos+l,t.pos+s.nodeSize-l,new Slice(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function selectTextblockSide(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(t.tr.setSelection(TextSelection.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}const selectTextblockStart$1=selectTextblockSide(-1),selectTextblockEnd$1=selectTextblockSide(1);function wrapIn$1(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),a=s&&findWrapping(s,e,t);return!!a&&(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0)}}function setBlockType(e,t=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,((r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}}))}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,e,t)}r(o.scrollIntoView())}return!0}}function chainCommands(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let backspace=chainCommands(deleteSelection$1,joinBackward$1,selectNodeBackward$1),del=chainCommands(deleteSelection$1,joinForward$1,selectNodeForward$1);const pcBaseKeymap={Enter:chainCommands(newlineInCode$1,createParagraphNear$1,liftEmptyBlock$1,splitBlock$1),"Mod-Enter":exitCode$1,Backspace:backspace,"Mod-Backspace":backspace,"Shift-Backspace":backspace,Delete:del,"Mod-Delete":del,"Mod-a":selectAll$1},macBaseKeymap={"Ctrl-h":pcBaseKeymap.Backspace,"Alt-Backspace":pcBaseKeymap["Mod-Backspace"],"Ctrl-d":pcBaseKeymap.Delete,"Ctrl-Alt-Backspace":pcBaseKeymap["Mod-Delete"],"Alt-Delete":pcBaseKeymap["Mod-Delete"],"Alt-d":pcBaseKeymap["Mod-Delete"],"Ctrl-a":selectTextblockStart$1,"Ctrl-e":selectTextblockEnd$1};for(let e in pcBaseKeymap)macBaseKeymap[e]=pcBaseKeymap[e];function wrapInList$1(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),a=!1,l=s;if(!s)return!1;if(s.depth>=2&&o.node(s.depth-1).type.compatibleContent(e)&&0==s.startIndex){if(0==o.index(s.depth-1))return!1;let e=n.doc.resolve(s.start-2);l=new NodeRange(e,e,s.depth),s.endIndex<s.parent.childCount&&(s=new NodeRange(o,n.doc.resolve(i.end(s.depth)),s.depth)),a=!0}let c=findWrapping(l,e,t,s);return!!c&&(r&&r(doWrapInList(n.tr,s,c,a,e).scrollIntoView()),!0)}}function doWrapInList(e,t,n,r,o){let i=Fragment.empty;for(let e=n.length-1;e>=0;e--)i=Fragment.from(n[e].type.create(n[e].attrs,i));e.step(new ReplaceAroundStep(t.start-(r?2:0),t.end,t.start,t.end,new Slice(i,0,0),n.length,!0));let s=0;for(let e=0;e<n.length;e++)n[e].type==o&&(s=e+1);let a=n.length-s,l=t.start+n.length-(r?2:0),c=t.parent;for(let n=t.startIndex,r=t.endIndex,o=!0;n<r;n++,o=!1)!o&&canSplit(e.doc,l,a)&&(e.split(l,a),l+=2*a),l+=c.child(n).nodeSize;return e}function liftListItem$1(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,(t=>t.childCount>0&&t.firstChild.type==e));return!!i&&(!n||(r.node(i.depth-1).type==e?liftToOuterList(t,n,e,i):liftOutOfList(t,n,i)))}}function liftToOuterList(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new ReplaceAroundStep(i-1,s,i,s,new Slice(Fragment.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new NodeRange(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const a=liftTarget(r);if(null==a)return!1;o.lift(r,a);let l=o.mapping.map(i,-1)-1;return canJoin(o.doc,l)&&o.join(l),t(o.scrollIntoView()),!0}function liftOutOfList(e,t,n){let r=e.tr,o=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=o.child(t).nodeSize,r.delete(e-1,e+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?Fragment.empty:Fragment.from(o))))return!1;let p=i.pos,h=p+s.nodeSize;return r.step(new ReplaceAroundStep(p-(a?1:0),h+(l?1:0),p+1,h-1,new Slice((a?Fragment.empty:Fragment.from(o.copy(Fragment.empty))).append(l?Fragment.empty:Fragment.from(o.copy(Fragment.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}function sinkListItem$1(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,(t=>t.childCount>0&&t.firstChild.type==e));if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let a=i.parent,l=a.child(s-1);if(l.type!=e)return!1;if(n){let r=l.lastChild&&l.lastChild.type==a.type,o=Fragment.from(r?e.create():null),s=new Slice(Fragment.from(e.create(null,Fragment.from(a.type.create(null,o)))),r?3:1,0),c=i.start,d=i.end;n(t.tr.step(new ReplaceAroundStep(c-(r?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0}}function createChainableState(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();class CommandManager{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,(...e)=>{const n=t(...e)(i);return o.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(o),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s=[],a=!!e,l=e||o.tr,c={...Object.fromEntries(Object.entries(n).map((([e,n])=>[e,(...e)=>{const r=this.buildProps(l,t),o=n(...e)(r);return s.push(o),c}]))),run:()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||i.dispatch(l),s.every((e=>!0===e)))};return c}createCan(e){const{rawCommands:t,state:n}=this,r=!1,o=e||n.tr,i=this.buildProps(o,r),s=Object.fromEntries(Object.entries(t).map((([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])));return{...s,chain:()=>this.createChain(o,r)}}buildProps(e,t=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s={tr:e,editor:r,view:i,state:createChainableState({state:o,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map((([e,t])=>[e,(...e)=>t(...e)(s)])))}};return s}}class EventEmitter{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach((e=>e.apply(this,t))),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter((e=>e!==t)):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}function getExtensionField(e,t,n){return void 0===e.config[t]&&e.parent?getExtensionField(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind({...n,parent:e.parent?getExtensionField(e.parent,t,n):null}):e.config[t]}function splitExtensions(e){return{baseExtensions:e.filter((e=>"extension"===e.type)),nodeExtensions:e.filter((e=>"node"===e.type)),markExtensions:e.filter((e=>"mark"===e.type))}}function getAttributesFromExtensions(e){const t=[],{nodeExtensions:n,markExtensions:r}=splitExtensions(e),o=[...n,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach((e=>{const n=getExtensionField(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage});n&&n().forEach((e=>{e.types.forEach((n=>{Object.entries(e.attributes).forEach((([e,r])=>{t.push({type:n,name:e,attribute:{...i,...r}})}))}))}))})),o.forEach((e=>{const n={name:e.name,options:e.options,storage:e.storage},r=getExtensionField(e,"addAttributes",n);if(!r)return;const o=r();Object.entries(o).forEach((([n,r])=>{const o={...i,...r};"function"==typeof(null==o?void 0:o.default)&&(o.default=o.default()),(null==o?void 0:o.isRequired)&&void 0===(null==o?void 0:o.default)&&delete o.default,t.push({type:e.name,name:n,attribute:o})}))})),t}function getNodeType(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function mergeAttributes(...e){return e.filter((e=>!!e)).reduce(((e,t)=>{const n={...e};return Object.entries(t).forEach((([e,t])=>{if(n[e])if("class"===e){const r=t?t.split(" "):[],o=n[e]?n[e].split(" "):[],i=r.filter((e=>!o.includes(e)));n[e]=[...o,...i].join(" ")}else n[e]="style"===e?[n[e],t].join("; "):t;else n[e]=t})),n}),{})}function getRenderedAttributes(e,t){return t.filter((e=>e.attribute.rendered)).map((t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]})).reduce(((e,t)=>mergeAttributes(e,t)),{})}function isFunction(e){return"function"==typeof e}function callOrReturn(e,t=void 0,...n){return isFunction(e)?t?e.bind(t)(...n):e(...n):e}function isEmptyObject(e={}){return 0===Object.keys(e).length&&e.constructor===Object}function fromString(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}function injectExtensionAttributesToParseRule(e,t){return e.style?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;const o=t.reduce(((e,t)=>{const r=t.attribute.parseHTML?t.attribute.parseHTML(n):fromString(n.getAttribute(t.name));return null==r?e:{...e,[t.name]:r}}),{});return{...r,...o}}}}function cleanUpSchemaItem(e){return Object.fromEntries(Object.entries(e).filter((([e,t])=>("attrs"!==e||!isEmptyObject(t))&&null!=t)))}function getSchemaByResolvedExtensions(e,t){var n;const r=getAttributesFromExtensions(e),{nodeExtensions:o,markExtensions:i}=splitExtensions(e),s=null===(n=o.find((e=>getExtensionField(e,"topNode"))))||void 0===n?void 0:n.name,a=Object.fromEntries(o.map((n=>{const o=r.filter((e=>e.type===n.name)),i={name:n.name,options:n.options,storage:n.storage,editor:t},s=cleanUpSchemaItem({...e.reduce(((e,t)=>{const r=getExtensionField(t,"extendNodeSchema",i);return{...e,...r?r(n):{}}}),{}),content:callOrReturn(getExtensionField(n,"content",i)),marks:callOrReturn(getExtensionField(n,"marks",i)),group:callOrReturn(getExtensionField(n,"group",i)),inline:callOrReturn(getExtensionField(n,"inline",i)),atom:callOrReturn(getExtensionField(n,"atom",i)),selectable:callOrReturn(getExtensionField(n,"selectable",i)),draggable:callOrReturn(getExtensionField(n,"draggable",i)),code:callOrReturn(getExtensionField(n,"code",i)),defining:callOrReturn(getExtensionField(n,"defining",i)),isolating:callOrReturn(getExtensionField(n,"isolating",i)),attrs:Object.fromEntries(o.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),a=callOrReturn(getExtensionField(n,"parseHTML",i));a&&(s.parseDOM=a.map((e=>injectExtensionAttributesToParseRule(e,o))));const l=getExtensionField(n,"renderHTML",i);l&&(s.toDOM=e=>l({node:e,HTMLAttributes:getRenderedAttributes(e,o)}));const c=getExtensionField(n,"renderText",i);return c&&(s.toText=c),[n.name,s]}))),l=Object.fromEntries(i.map((n=>{const o=r.filter((e=>e.type===n.name)),i={name:n.name,options:n.options,storage:n.storage,editor:t},s=cleanUpSchemaItem({...e.reduce(((e,t)=>{const r=getExtensionField(t,"extendMarkSchema",i);return{...e,...r?r(n):{}}}),{}),inclusive:callOrReturn(getExtensionField(n,"inclusive",i)),excludes:callOrReturn(getExtensionField(n,"excludes",i)),group:callOrReturn(getExtensionField(n,"group",i)),spanning:callOrReturn(getExtensionField(n,"spanning",i)),code:callOrReturn(getExtensionField(n,"code",i)),attrs:Object.fromEntries(o.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),a=callOrReturn(getExtensionField(n,"parseHTML",i));a&&(s.parseDOM=a.map((e=>injectExtensionAttributesToParseRule(e,o))));const l=getExtensionField(n,"renderHTML",i);return l&&(s.toDOM=e=>l({mark:e,HTMLAttributes:getRenderedAttributes(e,o)})),[n.name,s]})));return new Schema({topNode:s,nodes:a,marks:l})}function getSchemaTypeByName(e,t){return t.nodes[e]||t.marks[e]||null}function isExtensionRulesEnabled(e,t){return Array.isArray(t)?t.some((t=>("string"==typeof t?t:t.name)===e.name)):t}const getTextContentFromNodes=(e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,((e,t,o,i)=>{var s,a;const l=(null===(a=(s=e.type.spec).toText)||void 0===a?void 0:a.call(s,{node:e,pos:t,parent:o,index:i}))||e.textContent||"%leaf%";n+=l.slice(0,Math.max(0,r-t))})),n};function isRegExp(e){return"[object RegExp]"===Object.prototype.toString.call(e)}class InputRule{constructor(e){this.find=e.find,this.handler=e.handler}}const inputRuleMatcherHandler=(e,t)=>{if(isRegExp(t))return t.exec(e);const n=t(e);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function run$1(e){var t;const{editor:n,from:r,to:o,text:i,rules:s,plugin:a}=e,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(null===(t=c.nodeBefore||c.nodeAfter)||void 0===t?void 0:t.marks.find((e=>e.type.spec.code))))return!1;let d=!1;const p=getTextContentFromNodes(c)+i;return s.forEach((e=>{if(d)return;const t=inputRuleMatcherHandler(p,e.find);if(!t)return;const s=l.state.tr,c=createChainableState({state:l.state,transaction:s}),h={from:r-(t[0].length-i.length),to:o},{commands:u,chain:f,can:m}=new CommandManager({editor:n,state:c});null!==e.handler({state:c,range:h,match:t,commands:u,chain:f,can:m})&&s.steps.length&&(s.setMeta(a,{transform:s,from:r,to:o,text:i}),l.dispatch(s),d=!0)})),d}function inputRulesPlugin(e){const{editor:t,rules:n}=e,r=new Plugin({state:{init(){return null},apply(e,o){const i=e.getMeta(r);if(i)return i;const s=e.getMeta("applyInputRules");return!!s&&setTimeout((()=>{const{from:e,text:o}=s,i=e+o.length;run$1({editor:t,from:e,to:i,text:o,rules:n,plugin:r})})),e.selectionSet||e.docChanged?null:o}},props:{handleTextInput(e,o,i,s){return run$1({editor:t,from:o,to:i,text:s,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout((()=>{const{$cursor:o}=e.state.selection;o&&run$1({editor:t,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})})),!1)},handleKeyDown(e,o){if("Enter"!==o.key)return!1;const{$cursor:i}=e.state.selection;return!!i&&run$1({editor:t,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}function isNumber(e){return"number"==typeof e}class PasteRule{constructor(e){this.find=e.find,this.handler=e.handler}}const pasteRuleMatcherHandler=(e,t,n)=>{if(isRegExp(t))return[...e.matchAll(t)];const r=t(e,n);return r?r.map((t=>{const n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n})):[]};function run(e){const{editor:t,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:a}=e,{commands:l,chain:c,can:d}=new CommandManager({editor:t,state:n}),p=[];return n.doc.nodesBetween(r,o,((e,t)=>{if(!e.isTextblock||e.type.spec.code)return;const h=Math.max(r,t),u=Math.min(o,t+e.content.size),f=e.textBetween(h-t,u-t,void 0,"");pasteRuleMatcherHandler(f,i.find,s).forEach((e=>{if(void 0===e.index)return;const t=h+e.index+1,r=t+e[0].length,o={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},u=i.handler({state:n,range:o,match:e,commands:l,chain:c,can:d,pasteEvent:s,dropEvent:a});p.push(u)}))})),p.every((e=>null!==e))}const createClipboardPasteEvent=e=>{var t;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null===(t=n.clipboardData)||void 0===t||t.setData("text/html",e),n};function pasteRulesPlugin(e){const{editor:t,rules:n}=e;let r=null,o=!1,i=!1,s="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,a="undefined"!=typeof DragEvent?new DragEvent("drop"):null;const l=({state:e,from:n,to:r,rule:o,pasteEvt:i})=>{const l=e.tr,c=createChainableState({state:e,transaction:l});if(run({editor:t,state:c,from:Math.max(n-1,0),to:r.b-1,rule:o,pasteEvent:i,dropEvent:a})&&l.steps.length)return a="undefined"!=typeof DragEvent?new DragEvent("drop"):null,s="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,l};return n.map((e=>new Plugin({view(e){const t=t=>{var n;r=(null===(n=e.dom.parentElement)||void 0===n?void 0:n.contains(t.target))?e.dom.parentElement:null};return window.addEventListener("dragstart",t),{destroy(){window.removeEventListener("dragstart",t)}}},props:{handleDOMEvents:{drop:(e,t)=>(i=r===e.dom.parentElement,a=t,!1),paste:(e,t)=>{var n;const r=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");return s=t,o=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(t,n,r)=>{const a=t[0],c="paste"===a.getMeta("uiEvent")&&!o,d="drop"===a.getMeta("uiEvent")&&!i,p=a.getMeta("applyPasteRules"),h=!!p;if(!c&&!d&&!h)return;if(h){const{from:t,text:n}=p,o=t+n.length,i=createClipboardPasteEvent(n);return l({rule:e,state:r,from:t,to:{b:o},pasteEvt:i})}const u=n.doc.content.findDiffStart(r.doc.content),f=n.doc.content.findDiffEnd(r.doc.content);return isNumber(u)&&f&&u!==f.b?l({rule:e,state:r,from:u,to:f,pasteEvt:s}):void 0}})))}function findDuplicates(e){const t=e.filter(((t,n)=>e.indexOf(t)!==n));return[...new Set(t)]}class ExtensionManager{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=ExtensionManager.resolve(e),this.schema=getSchemaByResolvedExtensions(this.extensions,t),this.setupExtensions()}static resolve(e){const t=ExtensionManager.sort(ExtensionManager.flatten(e)),n=findDuplicates(t.map((e=>e.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e=>`'${e}'`)).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map((e=>{const t=getExtensionField(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...this.flatten(t())]:e})).flat(10)}static sort(e){return e.sort(((e,t)=>{const n=getExtensionField(e,"priority")||100,r=getExtensionField(t,"priority")||100;return n>r?-1:n<r?1:0}))}get commands(){return this.extensions.reduce(((e,t)=>{const n=getExtensionField(t,"addCommands",{name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:getSchemaTypeByName(t.name,this.schema)});return n?{...e,...n()}:e}),{})}get plugins(){const{editor:e}=this,t=ExtensionManager.sort([...this.extensions].reverse()),n=[],r=[],o=t.map((t=>{const o={name:t.name,options:t.options,storage:t.storage,editor:e,type:getSchemaTypeByName(t.name,this.schema)},i=[],s=getExtensionField(t,"addKeyboardShortcuts",o);let a={};if("mark"===t.type&&t.config.exitable&&(a.ArrowRight=()=>Mark.handleExit({editor:e,mark:t})),s){const t=Object.fromEntries(Object.entries(s()).map((([t,n])=>[t,()=>n({editor:e})])));a={...a,...t}}const l=keymap(a);i.push(l);const c=getExtensionField(t,"addInputRules",o);isExtensionRulesEnabled(t,e.options.enableInputRules)&&c&&n.push(...c());const d=getExtensionField(t,"addPasteRules",o);isExtensionRulesEnabled(t,e.options.enablePasteRules)&&d&&r.push(...d());const p=getExtensionField(t,"addProseMirrorPlugins",o);if(p){const e=p();i.push(...e)}return i})).flat();return[inputRulesPlugin({editor:e,rules:n}),...pasteRulesPlugin({editor:e,rules:r}),...o]}get attributes(){return getAttributesFromExtensions(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=splitExtensions(this.extensions);return Object.fromEntries(t.filter((e=>!!getExtensionField(e,"addNodeView"))).map((t=>{const n=this.attributes.filter((e=>e.type===t.name)),r={name:t.name,options:t.options,storage:t.storage,editor:e,type:getNodeType(t.name,this.schema)},o=getExtensionField(t,"addNodeView",r);return o?[t.name,(r,i,s,a)=>{const l=getRenderedAttributes(r,n);return o()({editor:e,node:r,getPos:s,decorations:a,HTMLAttributes:l,extension:t})}]:[]})))}setupExtensions(){this.extensions.forEach((e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:getSchemaTypeByName(e.name,this.schema)};"mark"===e.type&&(null===(t=callOrReturn(getExtensionField(e,"keepOnSplit",n)))||void 0===t||t)&&this.splittableMarks.push(e.name);const r=getExtensionField(e,"onBeforeCreate",n),o=getExtensionField(e,"onCreate",n),i=getExtensionField(e,"onUpdate",n),s=getExtensionField(e,"onSelectionUpdate",n),a=getExtensionField(e,"onTransaction",n),l=getExtensionField(e,"onFocus",n),c=getExtensionField(e,"onBlur",n),d=getExtensionField(e,"onDestroy",n);r&&this.editor.on("beforeCreate",r),o&&this.editor.on("create",o),i&&this.editor.on("update",i),s&&this.editor.on("selectionUpdate",s),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),c&&this.editor.on("blur",c),d&&this.editor.on("destroy",d)}))}}function getType(e){return Object.prototype.toString.call(e).slice(8,-1)}function isPlainObject(e){return"Object"===getType(e)&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function mergeDeep(e,t){const n={...e};return isPlainObject(e)&&isPlainObject(t)&&Object.keys(t).forEach((r=>{isPlainObject(t[r])?r in e?n[r]=mergeDeep(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})})),n}class Extension{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.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,this.config.addOptions&&(this.options=callOrReturn(getExtensionField(this,"addOptions",{name:this.name}))),this.storage=callOrReturn(getExtensionField(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Extension(e)}configure(e={}){const t=this.extend();return t.parent=this.parent,t.options=mergeDeep(this.options,e),t.storage=callOrReturn(getExtensionField(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Extension({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=callOrReturn(getExtensionField(t,"addOptions",{name:t.name})),t.storage=callOrReturn(getExtensionField(t,"addStorage",{name:t.name,options:t.options})),t}}function getTextBetween(e,t,n){const{from:r,to:o}=t,{blockSeparator:i="\n\n",textSerializers:s={}}=n||{};let a="";return e.nodesBetween(r,o,((e,n,l,c)=>{var d;e.isBlock&&n>r&&(a+=i);const p=null==s?void 0:s[e.type.name];if(p)return l&&(a+=p({node:e,pos:n,parent:l,index:c,range:t})),!1;e.isText&&(a+=null===(d=null==e?void 0:e.text)||void 0===d?void 0:d.slice(Math.max(r,n)-n,o-n))})),a}function getTextSerializersFromSchema(e){return Object.fromEntries(Object.entries(e.nodes).filter((([,e])=>e.spec.toText)).map((([e,t])=>[e,t.spec.toText])))}const ClipboardTextSerializer=Extension.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Plugin({key:new PluginKey("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:o}=t,{ranges:i}=o,s=Math.min(...i.map((e=>e.$from.pos))),a=Math.max(...i.map((e=>e.$to.pos))),l=getTextSerializersFromSchema(n);return getTextBetween(r,{from:s,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),blur=()=>({editor:e,view:t})=>(requestAnimationFrame((()=>{var n;e.isDestroyed||(t.dom.blur(),null===(n=null===window||void 0===window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent=(e=!1)=>({commands:t})=>t.setContent("",e),clearNodes=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:o}=r;return!n||(o.forEach((({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,((e,n)=>{if(e.type.isText)return;const{doc:r,mapping:o}=t,i=r.resolve(o.map(n)),s=r.resolve(o.map(n+e.nodeSize)),a=i.blockRange(s);if(!a)return;const l=liftTarget(a);if(e.type.isTextblock){const{defaultType:e}=i.parent.contentMatchAt(i.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)}))})),!0)},command=e=>t=>e(t),createParagraphNear=()=>({state:e,dispatch:t})=>createParagraphNear$1(e,t),cut=(e,t)=>({editor:n,tr:r})=>{const{state:o}=n,i=o.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const s=r.mapping.map(t);return r.insert(s,i.content),r.setSelection(new TextSelection(r.doc.resolve(s-1))),!0},deleteCurrentNode=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const o=e.selection.$anchor;for(let n=o.depth;n>0;n-=1)if(o.node(n).type===r.type){if(t){const t=o.before(n),r=o.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1},deleteNode=e=>({tr:t,state:n,dispatch:r})=>{const o=getNodeType(e,n.schema),i=t.selection.$anchor;for(let e=i.depth;e>0;e-=1)if(i.node(e).type===o){if(r){const n=i.before(e),r=i.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},deleteRange=e=>({tr:t,dispatch:n})=>{const{from:r,to:o}=e;return n&&t.delete(r,o),!0},deleteSelection=()=>({state:e,dispatch:t})=>deleteSelection$1(e,t),enter=()=>({commands:e})=>e.keyboardShortcut("Enter"),exitCode=()=>({state:e,dispatch:t})=>exitCode$1(e,t);function objectIncludes(e,t,n={strict:!0}){const r=Object.keys(t);return!r.length||r.every((r=>n.strict?t[r]===e[r]:isRegExp(t[r])?t[r].test(e[r]):t[r]===e[r]))}function findMarkInSet(e,t,n={}){return e.find((e=>e.type===t&&objectIncludes(e.attrs,n)))}function isMarkInSet(e,t,n={}){return!!findMarkInSet(e,t,n)}function getMarkRange(e,t,n={}){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(e.parentOffset===r.offset&&0!==r.offset&&(r=e.parent.childBefore(e.parentOffset)),!r.node)return;const o=findMarkInSet([...r.node.marks],t,n);if(!o)return;let i=r.index,s=e.start()+r.offset,a=i+1,l=s+r.node.nodeSize;for(findMarkInSet([...r.node.marks],t,n);i>0&&o.isInSet(e.parent.child(i-1).marks);)i-=1,s-=e.parent.child(i).nodeSize;for(;a<e.parent.childCount&&isMarkInSet([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function getMarkType(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}const extendMarkRange=(e,t={})=>({tr:n,state:r,dispatch:o})=>{const i=getMarkType(e,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:d}=a;if(o){const e=getMarkRange(l,i,t);if(e&&e.from<=c&&e.to>=d){const t=TextSelection.create(s,e.from,e.to);n.setSelection(t)}}return!0},first=e=>t=>{const n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function isTextSelection(e){return e instanceof TextSelection}function minMax(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function resolveFocusPosition(e,t=null){if(!t)return null;const n=Selection.atStart(e),r=Selection.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const o=n.from,i=r.to;return"all"===t?TextSelection.create(e,minMax(0,o,i),minMax(e.content.size,o,i)):TextSelection.create(e,minMax(t,o,i),minMax(t,o,i))}function isiOS(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const focus=(e=null,t={})=>({editor:n,view:r,tr:o,dispatch:i})=>{t={scrollIntoView:!0,...t};const s=()=>{isiOS()&&r.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())}))};if(r.hasFocus()&&null===e||!1===e)return!0;if(i&&null===e&&!isTextSelection(n.state.selection))return s(),!0;const a=resolveFocusPosition(o.doc,e)||n.state.selection,l=n.state.selection.eq(a);return i&&(l||o.setSelection(a),l&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},forEach=(e,t)=>n=>e.every(((e,r)=>t(e,{...n,index:r}))),insertContent=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),removeWhitespaces=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&removeWhitespaces(r)}return e};function elementFromString(e){const t=`<body>${e}</body>`,n=(new window.DOMParser).parseFromString(t,"text/html").body;return removeWhitespaces(n)}function createNodeFromContent(e,t,n){n={slice:!0,parseOptions:{},...n};const r="string"==typeof e;if("object"==typeof e&&null!==e)try{return Array.isArray(e)&&e.length>0?Fragment.fromArray(e.map((e=>t.nodeFromJSON(e)))):t.nodeFromJSON(e)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),createNodeFromContent("",t,n)}if(r){const r=DOMParser.fromSchema(t);return n.slice?r.parseSlice(elementFromString(e),n.parseOptions).content:r.parse(elementFromString(e),n.parseOptions)}return createNodeFromContent("",t,n)}function selectionToInsertionEnd(e,t,n){const r=e.steps.length-1;if(r<t)return;const o=e.steps[r];if(!(o instanceof ReplaceStep||o instanceof ReplaceAroundStep))return;const i=e.mapping.maps[r];let s=0;i.forEach(((e,t,n,r)=>{0===s&&(s=r)})),e.setSelection(Selection.near(e.doc.resolve(s),n))}const isFragment=e=>e.toString().startsWith("<"),insertContentAt=(e,t,n)=>({tr:r,dispatch:o,editor:i})=>{if(o){n={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};const o=createNodeFromContent(t,i.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if("<>"===o.toString())return!0;let s,{from:a,to:l}="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},c=!0,d=!0;if((isFragment(o)?o:[o]).forEach((e=>{e.check(),c=!!c&&e.isText&&0===e.marks.length,d=!!d&&e.isBlock})),a===l&&d){const{parent:e}=r.doc.resolve(a);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(a-=1,l+=1)}c?(s=Array.isArray(t)?t.map((e=>e.text||"")).join(""):"object"==typeof t&&t&&t.text?t.text:t,r.insertText(s,a,l)):(s=o,r.replaceWith(a,l,s)),n.updateSelection&&selectionToInsertionEnd(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:a,text:s}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:a,text:s})}return!0},joinUp=()=>({state:e,dispatch:t})=>joinUp$1(e,t),joinDown=()=>({state:e,dispatch:t})=>joinDown$1(e,t),joinBackward=()=>({state:e,dispatch:t})=>joinBackward$1(e,t),joinForward=()=>({state:e,dispatch:t})=>joinForward$1(e,t),joinItemBackward=()=>({tr:e,state:t,dispatch:n})=>{try{const r=joinPoint(t.doc,t.selection.$from.pos,-1);return null!=r&&(e.join(r,2),n&&n(e),!0)}catch{return!1}},joinItemForward=()=>({state:e,dispatch:t,tr:n})=>{try{const r=joinPoint(e.doc,e.selection.$from.pos,1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},joinTextblockBackward=()=>({state:e,dispatch:t})=>joinTextblockBackward$1(e,t),joinTextblockForward=()=>({state:e,dispatch:t})=>joinTextblockForward$1(e,t);function isMacOS(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function normalizeKeyName(e){const t=e.split(/-(?!$)/);let n,r,o,i,s=t[t.length-1];"Space"===s&&(s=" ");for(let e=0;e<t.length-1;e+=1){const s=t[e];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);isiOS()||isMacOS()?i=!0:r=!0}}return n&&(s=`Alt-${s}`),r&&(s=`Ctrl-${s}`),i&&(s=`Meta-${s}`),o&&(s=`Shift-${s}`),s}const keyboardShortcut=e=>({editor:t,view:n,tr:r,dispatch:o})=>{const i=normalizeKeyName(e).split(/-(?!$)/),s=i.find((e=>!["Alt","Ctrl","Meta","Shift"].includes(e))),a=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction((()=>{n.someProp("handleKeyDown",(e=>e(n,a)))}));return null==l||l.steps.forEach((e=>{const t=e.map(r.mapping);t&&o&&r.maybeStep(t)})),!0};function isNodeActive(e,t,n={}){const{from:r,to:o,empty:i}=e.selection,s=t?getNodeType(t,e.schema):null,a=[];e.doc.nodesBetween(r,o,((e,t)=>{if(e.isText)return;const n=Math.max(r,t),i=Math.min(o,t+e.nodeSize);a.push({node:e,from:n,to:i})}));const l=o-r,c=a.filter((e=>!s||s.name===e.node.type.name)).filter((e=>objectIncludes(e.node.attrs,n,{strict:!1})));return i?!!c.length:c.reduce(((e,t)=>e+t.to-t.from),0)>=l}const lift=(e,t={})=>({state:n,dispatch:r})=>!!isNodeActive(n,getNodeType(e,n.schema),t)&&lift$1(n,r),liftEmptyBlock=()=>({state:e,dispatch:t})=>liftEmptyBlock$1(e,t),liftListItem=e=>({state:t,dispatch:n})=>liftListItem$1(getNodeType(e,t.schema))(t,n),newlineInCode=()=>({state:e,dispatch:t})=>newlineInCode$1(e,t);function getSchemaTypeNameByName(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function deleteProps(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce(((t,r)=>(n.includes(r)||(t[r]=e[r]),t)),{})}const resetAttributes=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const a=getSchemaTypeNameByName("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(i=getNodeType(e,r.schema)),"mark"===a&&(s=getMarkType(e,r.schema)),o&&n.selection.ranges.forEach((e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,((e,r)=>{i&&i===e.type&&n.setNodeMarkup(r,void 0,deleteProps(e.attrs,t)),s&&e.marks.length&&e.marks.forEach((o=>{s===o.type&&n.addMark(r,r+e.nodeSize,s.create(deleteProps(o.attrs,t)))}))}))})),!0)},scrollIntoView=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),selectAll=()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),selectNodeBackward=()=>({state:e,dispatch:t})=>selectNodeBackward$1(e,t),selectNodeForward=()=>({state:e,dispatch:t})=>selectNodeForward$1(e,t),selectParentNode=()=>({state:e,dispatch:t})=>selectParentNode$1(e,t),selectTextblockEnd=()=>({state:e,dispatch:t})=>selectTextblockEnd$1(e,t),selectTextblockStart=()=>({state:e,dispatch:t})=>selectTextblockStart$1(e,t);function createDocument(e,t,n={}){return createNodeFromContent(e,t,{slice:!1,parseOptions:n})}const setContent=(e,t=!1,n={})=>({tr:r,editor:o,dispatch:i})=>{const{doc:s}=r,a=createDocument(e,o.schema,n);return i&&r.replaceWith(0,s.content.size,a).setMeta("preventUpdate",!t),!0};function getMarkAttributes(e,t){const n=getMarkType(t,e.schema),{from:r,to:o,empty:i}=e.selection,s=[];i?(e.storedMarks&&s.push(...e.storedMarks),s.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,o,(e=>{s.push(...e.marks)}));const a=s.find((e=>e.type.name===n.name));return a?{...a.attrs}:{}}function defaultBlockAt(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function findParentNodeClosestToPos(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function findParentNode(e){return t=>findParentNodeClosestToPos(t.$from,e)}function getHTMLFromFragment(e,t){const n=DOMSerializer.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function getText(e,t){return getTextBetween(e,{from:0,to:e.content.size},t)}function getNodeAttributes(e,t){const n=getNodeType(t,e.schema),{from:r,to:o}=e.selection,i=[];e.doc.nodesBetween(r,o,(e=>{i.push(e)}));const s=i.reverse().find((e=>e.type.name===n.name));return s?{...s.attrs}:{}}function getAttributes(e,t){const n=getSchemaTypeNameByName("string"==typeof t?t:t.name,e.schema);return"node"===n?getNodeAttributes(e,t):"mark"===n?getMarkAttributes(e,t):{}}function getMarksBetween(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach((t=>{const o=getMarkRange(n.resolve(e-1),t.type);o&&r.push({mark:t,...o})})):n.nodesBetween(e,t,((e,t)=>{e&&void 0!==(null==e?void 0:e.nodeSize)&&r.push(...e.marks.map((n=>({from:t,to:t+e.nodeSize,mark:n}))))})),r}function getSplittedAttributes(e,t,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=e.find((e=>e.type===t&&e.name===n));return!!r&&r.attribute.keepOnSplit})))}function isMarkActive(e,t,n={}){const{empty:r,ranges:o}=e.selection,i=t?getMarkType(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter((e=>!i||i.name===e.type.name)).find((e=>objectIncludes(e.attrs,n,{strict:!1})));let s=0;const a=[];if(o.forEach((({$from:t,$to:n})=>{const r=t.pos,o=n.pos;e.doc.nodesBetween(r,o,((e,t)=>{if(!e.isText&&!e.marks.length)return;const n=Math.max(r,t),i=Math.min(o,t+e.nodeSize);s+=i-n,a.push(...e.marks.map((e=>({mark:e,from:n,to:i}))))}))})),0===s)return!1;const l=a.filter((e=>!i||i.name===e.mark.type.name)).filter((e=>objectIncludes(e.mark.attrs,n,{strict:!1}))).reduce(((e,t)=>e+t.to-t.from),0),c=a.filter((e=>!i||e.mark.type!==i&&e.mark.type.excludes(i))).reduce(((e,t)=>e+t.to-t.from),0);return(l>0?l+c:l)>=s}function isActive(e,t,n={}){if(!t)return isNodeActive(e,null,n)||isMarkActive(e,null,n);const r=getSchemaTypeNameByName(t,e.schema);return"node"===r?isNodeActive(e,t,n):"mark"===r&&isMarkActive(e,t,n)}function isList(e,t){const{nodeExtensions:n}=splitExtensions(t),r=n.find((t=>t.name===e));if(!r)return!1;const o=callOrReturn(getExtensionField(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof o&&o.split(" ").includes("list")}function isNodeEmpty(e){var t;const n=null===(t=e.type.createAndFill())||void 0===t?void 0:t.toJSON(),r=e.toJSON();return JSON.stringify(n)===JSON.stringify(r)}function canSetMark(e,t,n){var r;const{selection:o}=t;let i=null;if(isTextSelection(o)&&(i=o.$cursor),i){const t=null!==(r=e.storedMarks)&&void 0!==r?r:i.marks();return!!n.isInSet(t)||!t.some((e=>e.type.excludes(n)))}const{ranges:s}=o;return s.some((({$from:t,$to:r})=>{let o=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,((e,t,r)=>{if(o)return!1;if(e.isInline){const t=!r||r.type.allowsMarkType(n),i=!!n.isInSet(e.marks)||!e.marks.some((e=>e.type.excludes(n)));o=t&&i}return!o})),o}))}const setMark=(e,t={})=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=n,{empty:s,ranges:a}=i,l=getMarkType(e,r.schema);if(o)if(s){const e=getMarkAttributes(r,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach((e=>{const o=e.$from.pos,i=e.$to.pos;r.doc.nodesBetween(o,i,((e,r)=>{const s=Math.max(r,o),a=Math.min(r+e.nodeSize,i);e.marks.find((e=>e.type===l))?e.marks.forEach((e=>{l===e.type&&n.addMark(s,a,l.create({...e.attrs,...t}))})):n.addMark(s,a,l.create(t))}))}));return canSetMark(r,n,l)},setMeta=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),setNode=(e,t={})=>({state:n,dispatch:r,chain:o})=>{const i=getNodeType(e,n.schema);return i.isTextblock?o().command((({commands:e})=>!!setBlockType(i,t)(n)||e.clearNodes())).command((({state:e})=>setBlockType(i,t)(e,r))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=minMax(e,0,n.content.size),o=NodeSelection.create(n,r);t.setSelection(o)}return!0},setTextSelection=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:o}="number"==typeof e?{from:e,to:e}:e,i=TextSelection.atStart(n).from,s=TextSelection.atEnd(n).to,a=minMax(r,i,s),l=minMax(o,i,s),c=TextSelection.create(n,a,l);t.setSelection(c)}return!0},sinkListItem=e=>({state:t,dispatch:n})=>sinkListItem$1(getNodeType(e,t.schema))(t,n);function ensureMarks(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter((e=>null==t?void 0:t.includes(e.type.name)));e.tr.ensureMarks(r)}}const splitBlock=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:o})=>{const{selection:i,doc:s}=t,{$from:a,$to:l}=i,c=getSplittedAttributes(o.extensionManager.attributes,a.node().type.name,a.node().attrs);if(i instanceof NodeSelection&&i.node.isBlock)return!(!a.parentOffset||!canSplit(s,a.pos)||(r&&(e&&ensureMarks(n,o.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),0));if(!a.parent.isBlock)return!1;if(r){const r=l.parentOffset===l.parent.content.size;i instanceof TextSelection&&t.deleteSelection();const s=0===a.depth?void 0:defaultBlockAt(a.node(-1).contentMatchAt(a.indexAfter(-1)));let d=r&&s?[{type:s,attrs:c}]:void 0,p=canSplit(t.doc,t.mapping.map(a.pos),1,d);if(d||p||!canSplit(t.doc,t.mapping.map(a.pos),1,s?[{type:s}]:void 0)||(p=!0,d=s?[{type:s,attrs:c}]:void 0),p&&(t.split(t.mapping.map(a.pos),1,d),s&&!r&&!a.parentOffset&&a.parent.type!==s)){const e=t.mapping.map(a.before()),n=t.doc.resolve(e);a.node(-1).canReplaceWith(n.index(),n.index()+1,s)&&t.setNodeMarkup(t.mapping.map(a.before()),s)}e&&ensureMarks(n,o.extensionManager.splittableMarks),t.scrollIntoView()}return!0},splitListItem=e=>({tr:t,state:n,dispatch:r,editor:o})=>{var i;const s=getNodeType(e,n.schema),{$from:a,$to:l}=n.selection,c=n.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;const d=a.node(-1);if(d.type!==s)return!1;const p=o.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==s||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let e=Fragment.empty;const n=a.index(-1)?1:a.index(-2)?2:3;for(let t=a.depth-n;t>=a.depth-3;t-=1)e=Fragment.from(a.node(t).copy(e));const r=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,o=getSplittedAttributes(p,a.node().type.name,a.node().attrs),l=(null===(i=s.contentMatch.defaultType)||void 0===i?void 0:i.createAndFill(o))||void 0;e=e.append(Fragment.from(s.createAndFill(null,l)||void 0));const c=a.before(a.depth-(n-1));t.replace(c,a.after(-r),new Slice(e,4-n,0));let d=-1;t.doc.nodesBetween(c,t.doc.content.size,((e,t)=>{if(d>-1)return!1;e.isTextblock&&0===e.content.size&&(d=t+1)})),d>-1&&t.setSelection(TextSelection.near(t.doc.resolve(d))),t.scrollIntoView()}return!0}const h=l.pos===a.end()?d.contentMatchAt(0).defaultType:null,u=getSplittedAttributes(p,d.type.name,d.attrs),f=getSplittedAttributes(p,a.node().type.name,a.node().attrs);t.delete(a.pos,l.pos);const m=h?[{type:s,attrs:u},{type:h,attrs:f}]:[{type:s,attrs:u}];if(!canSplit(t.doc,a.pos,2))return!1;if(r){const{selection:e,storedMarks:i}=n,{splittableMarks:s}=o.extensionManager,l=i||e.$to.parentOffset&&e.$from.marks();if(t.split(a.pos,2,m).scrollIntoView(),!l||!r)return!0;const c=l.filter((e=>s.includes(e.type.name)));t.ensureMarks(c)}return!0},joinListBackwards=(e,t)=>{const n=findParentNode((e=>e.type===t))(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const o=e.doc.nodeAt(r);return n.node.type!==(null==o?void 0:o.type)||!canJoin(e.doc,n.pos)||(e.join(n.pos),!0)},joinListForwards=(e,t)=>{const n=findParentNode((e=>e.type===t))(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const o=e.doc.nodeAt(r);return n.node.type!==(null==o?void 0:o.type)||!canJoin(e.doc,r)||(e.join(r),!0)},toggleList=(e,t,n,r={})=>({editor:o,tr:i,state:s,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:p,splittableMarks:h}=o.extensionManager,u=getNodeType(e,s.schema),f=getNodeType(t,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:S}=m,k=y.blockRange(S),b=g||m.$to.parentOffset&&m.$from.marks();if(!k)return!1;const v=findParentNode((e=>isList(e.type.name,p)))(m);if(k.depth>=1&&v&&k.depth-v.depth<=1){if(v.node.type===u)return c.liftListItem(f);if(isList(v.node.type.name,p)&&u.validContent(v.node.content)&&a)return l().command((()=>(i.setNodeMarkup(v.pos,u),!0))).command((()=>joinListBackwards(i,u))).command((()=>joinListForwards(i,u))).run()}return n&&b&&a?l().command((()=>{const e=d().wrapInList(u,r),t=b.filter((e=>h.includes(e.type.name)));return i.ensureMarks(t),!!e||c.clearNodes()})).wrapInList(u,r).command((()=>joinListBackwards(i,u))).command((()=>joinListForwards(i,u))).run():l().command((()=>!!d().wrapInList(u,r)||c.clearNodes())).wrapInList(u,r).command((()=>joinListBackwards(i,u))).command((()=>joinListForwards(i,u))).run()},toggleMark=(e,t={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:i=!1}=n,s=getMarkType(e,r.schema);return isMarkActive(r,s,t)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,t)},toggleNode=(e,t,n={})=>({state:r,commands:o})=>{const i=getNodeType(e,r.schema),s=getNodeType(t,r.schema);return isNodeActive(r,i,n)?o.setNode(s):o.setNode(i,n)},toggleWrap=(e,t={})=>({state:n,commands:r})=>{const o=getNodeType(e,n.schema);return isNodeActive(n,o,t)?r.lift(o):r.wrapIn(o,t)},undoInputRule=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const o=n[r];let i;if(o.spec.isInputRules&&(i=o.getState(e))){if(t){const t=e.tr,n=i.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(i.text){const n=t.doc.resolve(i.from).marks();t.replaceWith(i.from,i.to,e.schema.text(i.text,n))}else t.delete(i.from,i.to)}return!0}}return!1},unsetAllMarks=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:o}=n;return r||t&&o.forEach((t=>{e.removeMark(t.$from.pos,t.$to.pos)})),!0},unsetMark=(e,t={})=>({tr:n,state:r,dispatch:o})=>{var i;const{extendEmptyMarkRange:s=!1}=t,{selection:a}=n,l=getMarkType(e,r.schema),{$from:c,empty:d,ranges:p}=a;if(!o)return!0;if(d&&s){let{from:e,to:t}=a;const r=null===(i=c.marks().find((e=>e.type===l)))||void 0===i?void 0:i.attrs,o=getMarkRange(c,l,r);o&&(e=o.from,t=o.to),n.removeMark(e,t,l)}else p.forEach((e=>{n.removeMark(e.$from.pos,e.$to.pos,l)}));return n.removeStoredMark(l),!0},updateAttributes=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const a=getSchemaTypeNameByName("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(i=getNodeType(e,r.schema)),"mark"===a&&(s=getMarkType(e,r.schema)),o&&n.selection.ranges.forEach((e=>{const o=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(o,a,((e,r)=>{i&&i===e.type&&n.setNodeMarkup(r,void 0,{...e.attrs,...t}),s&&e.marks.length&&e.marks.forEach((i=>{if(s===i.type){const l=Math.max(r,o),c=Math.min(r+e.nodeSize,a);n.addMark(l,c,s.create({...i.attrs,...t}))}}))}))})),!0)},wrapIn=(e,t={})=>({state:n,dispatch:r})=>wrapIn$1(getNodeType(e,n.schema),t)(n,r),wrapInList=(e,t={})=>({state:n,dispatch:r})=>wrapInList$1(getNodeType(e,n.schema),t)(n,r);var commands=Object.freeze({__proto__:null,blur:blur,clearContent:clearContent,clearNodes:clearNodes,command:command,createParagraphNear:createParagraphNear,cut:cut,deleteCurrentNode:deleteCurrentNode,deleteNode:deleteNode,deleteRange:deleteRange,deleteSelection:deleteSelection,enter:enter,exitCode:exitCode,extendMarkRange:extendMarkRange,first:first,focus:focus,forEach:forEach,insertContent:insertContent,insertContentAt:insertContentAt,joinUp:joinUp,joinDown:joinDown,joinBackward:joinBackward,joinForward:joinForward,joinItemBackward:joinItemBackward,joinItemForward:joinItemForward,joinTextblockBackward:joinTextblockBackward,joinTextblockForward:joinTextblockForward,keyboardShortcut:keyboardShortcut,lift:lift,liftEmptyBlock:liftEmptyBlock,liftListItem:liftListItem,newlineInCode:newlineInCode,resetAttributes:resetAttributes,scrollIntoView:scrollIntoView,selectAll:selectAll,selectNodeBackward:selectNodeBackward,selectNodeForward:selectNodeForward,selectParentNode:selectParentNode,selectTextblockEnd:selectTextblockEnd,selectTextblockStart:selectTextblockStart,setContent:setContent,setMark:setMark,setMeta:setMeta,setNode:setNode,setNodeSelection:setNodeSelection,setTextSelection:setTextSelection,sinkListItem:sinkListItem,splitBlock:splitBlock,splitListItem:splitListItem,toggleList:toggleList,toggleMark:toggleMark,toggleNode:toggleNode,toggleWrap:toggleWrap,undoInputRule:undoInputRule,unsetAllMarks:unsetAllMarks,unsetMark:unsetMark,updateAttributes:updateAttributes,wrapIn:wrapIn,wrapInList:wrapInList});const Commands=Extension.create({name:"commands",addCommands(){return{...commands}}}),Editable=Extension.create({name:"editable",addProseMirrorPlugins(){return[new Plugin({key:new PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}}),FocusEvents=Extension.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new Plugin({key:new PluginKey("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),Keymap=Extension.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first((({commands:e})=>[()=>e.undoInputRule(),()=>e.command((({tr:t})=>{const{selection:n,doc:r}=t,{empty:o,$anchor:i}=n,{pos:s,parent:a}=i,l=i.parent.isTextblock&&s>0?t.doc.resolve(s-1):i,c=l.parent.type.spec.isolating,d=i.pos-i.parentOffset,p=c&&1===l.parent.childCount?d===i.pos:Selection.atStart(r).from===s;return!(!o||!a.type.isTextblock||a.textContent.length||!p||p&&"paragraph"===i.parent.type.name)&&e.clearNodes()})),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()])),t=()=>this.editor.commands.first((({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},o={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return isiOS()||isMacOS()?o:r},addProseMirrorPlugins(){return[new Plugin({key:new PluginKey("clearDocument"),appendTransaction:(e,t,n)=>{if(!e.some((e=>e.docChanged))||t.doc.eq(n.doc))return;const{empty:r,from:o,to:i}=t.selection,s=Selection.atStart(t.doc).from,a=Selection.atEnd(t.doc).to;if(r||o!==s||i!==a)return;if(0!==n.doc.textBetween(0,n.doc.content.size," "," ").length)return;const l=n.tr,c=createChainableState({state:n,transaction:l}),{commands:d}=new CommandManager({editor:this.editor,state:c});return d.clearNodes(),l.steps.length?l:void 0}})]}}),Tabindex=Extension.create({name:"tabindex",addProseMirrorPlugins(){return[new Plugin({key:new PluginKey("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class NodePos{constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}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 e;return null!==(e=this.actualDepth)&&void 0!==e?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new NodePos(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new NodePos(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new NodePos(e,this.editor)}get children(){const e=[];return this.node.content.forEach(((t,n)=>{const r=t.isBlock&&!t.isTextblock,o=this.pos+n+1,i=this.resolvedPos.doc.resolve(o);if(!r&&i.depth<=this.depth)return;const s=new NodePos(i,this.editor,r,r?t:null);r&&(s.actualDepth=this.depth+1),e.push(new NodePos(i,this.editor,r,r?t:null))})),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;)r.node.type.name===e&&(Object.keys(t).length>0||(n=r)),r=r.parent;return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||0===this.children.length)return r;const o=Object.keys(t);return this.children.forEach((i=>{n&&r.length>0||(i.node.type.name===e&&o.every((e=>t[e]===i.node.attrs[e]))&&r.push(i),n&&r.length>0||(r=r.concat(i.querySelectorAll(e,t,n))))})),r}setAttribute(e){const t=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,e).setTextSelection(t.from).run()}}const style='.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 createStyleTag(e,t,n){const r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(null!==r)return r;const o=document.createElement("style");return t&&o.setAttribute("nonce",t),o.setAttribute("data-tiptap-style"+(n?`-${n}`:""),""),o.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(o),o}class Editor extends EventEmitter{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),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((()=>{this.isDestroyed||(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(){this.options.injectCSS&&document&&(this.css=createStyleTag(style,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&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(e,t){const n=isFunction(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});this.view.updateState(r)}unregisterPlugin(e){if(this.isDestroyed)return;const t="string"==typeof e?`${e}$`:e.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((e=>!e.key.startsWith(t)))});this.view.updateState(n)}createExtensionManager(){var e,t;const n=[...this.options.enableCoreExtensions?[Editable,ClipboardTextSerializer.configure({blockSeparator:null===(t=null===(e=this.options.coreExtensionOptions)||void 0===e?void 0:e.clipboardTextSerializer)||void 0===t?void 0:t.blockSeparator}),Commands,FocusEvents,Keymap,Tabindex]:[],...this.options.extensions].filter((e=>["extension","node","mark"].includes(null==e?void 0:e.type)));this.extensionManager=new ExtensionManager(n,this)}createCommandManager(){this.commandManager=new CommandManager({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=createDocument(this.options.content,this.schema,this.options.parseOptions),t=resolveFocusPosition(e,this.options.autofocus);this.view=new EditorView(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:EditorState.create({doc:e,selection:t||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews(),this.prependClass(),this.view.dom.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach((e=>{var t;return null===(t=this.capturedTransaction)||void 0===t?void 0:t.step(e)})):void(this.capturedTransaction=e);const t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});const r=e.getMeta("focus"),o=e.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),e.docChanged&&!e.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return getAttributes(this.state,e)}isActive(e,t){const n="string"==typeof e?e:null,r="string"==typeof e?t:e;return isActive(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return getHTMLFromFragment(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return getText(this.state.doc,{blockSeparator:t,textSerializers:{...getTextSerializersFromSchema(this.schema),...n}})}get isEmpty(){return isNodeEmpty(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(null===(e=this.view)||void 0===e?void 0:e.docView)}$node(e,t){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new NodePos(t,this)}get $doc(){return this.$pos(0)}}function markInputRule(e){return new InputRule({find:e.find,handler:({state:t,range:n,match:r})=>{const o=callOrReturn(e.getAttributes,void 0,r);if(!1===o||null===o)return null;const{tr:i}=t,s=r[r.length-1],a=r[0];if(s){const r=a.search(/\S/),l=n.from+a.indexOf(s),c=l+s.length;if(getMarksBetween(n.from,n.to,t.doc).filter((t=>t.mark.type.excluded.find((n=>n===e.type&&n!==t.mark.type)))).filter((e=>e.to>l)).length)return null;c<n.to&&i.delete(c,n.to),l>n.from&&i.delete(n.from+r,l);const d=n.from+r+s.length;i.addMark(n.from+r,d,e.type.create(o||{})),i.removeStoredMark(e.type)}}})}function nodeInputRule(e){return new InputRule({find:e.find,handler:({state:t,range:n,match:r})=>{const o=callOrReturn(e.getAttributes,void 0,r)||{},{tr:i}=t,s=n.from;let a=n.to;const l=e.type.create(o);if(r[1]){let e=s+r[0].lastIndexOf(r[1]);e>a?e=a:a=e+r[1].length;const t=r[0][r[0].length-1];i.insertText(t,s+r[0].length-1),i.replaceWith(e,a,l)}else r[0]&&i.insert(s-1,e.type.create(o)).delete(i.mapping.map(s),i.mapping.map(a));i.scrollIntoView()}})}function textblockTypeInputRule(e){return new InputRule({find:e.find,handler:({state:t,range:n,match:r})=>{const o=t.doc.resolve(n.from),i=callOrReturn(e.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,i)}})}function wrappingInputRule(e){return new InputRule({find:e.find,handler:({state:t,range:n,match:r,chain:o})=>{const i=callOrReturn(e.getAttributes,void 0,r)||{},s=t.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),l=a&&findWrapping(a,e.type,i);if(!l)return null;if(s.wrap(a,l),e.keepMarks&&e.editor){const{selection:n,storedMarks:r}=t,{splittableMarks:o}=e.editor.extensionManager,i=r||n.$to.parentOffset&&n.$from.marks();if(i){const e=i.filter((e=>o.includes(e.type.name)));s.ensureMarks(e)}}if(e.keepAttributes){const t="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";o().updateAttributes(t,i).run()}const c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===e.type&&canJoin(s.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,c))&&s.join(n.from-1)}})}class Mark{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.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,this.config.addOptions&&(this.options=callOrReturn(getExtensionField(this,"addOptions",{name:this.name}))),this.storage=callOrReturn(getExtensionField(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Mark(e)}configure(e={}){const t=this.extend();return t.options=mergeDeep(this.options,e),t.storage=callOrReturn(getExtensionField(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Mark({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=callOrReturn(getExtensionField(t,"addOptions",{name:t.name})),t.storage=callOrReturn(getExtensionField(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const o=r.marks();if(!o.find((e=>(null==e?void 0:e.type.name)===t.name)))return!1;const i=o.find((e=>(null==e?void 0:e.type.name)===t.name));return i&&n.removeStoredMark(i),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}}class Node{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.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,this.config.addOptions&&(this.options=callOrReturn(getExtensionField(this,"addOptions",{name:this.name}))),this.storage=callOrReturn(getExtensionField(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Node(e)}configure(e={}){const t=this.extend();return t.options=mergeDeep(this.options,e),t.storage=callOrReturn(getExtensionField(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Node({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=callOrReturn(getExtensionField(t,"addOptions",{name:t.name})),t.storage=callOrReturn(getExtensionField(t,"addStorage",{name:t.name,options:t.options})),t}}function markPasteRule(e){return new PasteRule({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:o})=>{const i=callOrReturn(e.getAttributes,void 0,r,o);if(!1===i||null===i)return null;const{tr:s}=t,a=r[r.length-1],l=r[0];let c=n.to;if(a){const r=l.search(/\S/),o=n.from+l.indexOf(a),d=o+a.length;if(getMarksBetween(n.from,n.to,t.doc).filter((t=>t.mark.type.excluded.find((n=>n===e.type&&n!==t.mark.type)))).filter((e=>e.to>o)).length)return null;d<n.to&&s.delete(d,n.to),o>n.from&&s.delete(n.from+r,o),c=n.from+r+a.length,s.addMark(n.from+r,c,e.type.create(i||{})),s.removeStoredMark(e.type)}}})}const CharacterCount=Extension.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize"}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{const t=(null==e?void 0:e.node)||this.editor.state.doc;return"textSize"===((null==e?void 0:e.mode)||this.options.mode)?t.textBetween(0,t.content.size,void 0," ").length:t.nodeSize},this.storage.words=e=>{const t=(null==e?void 0:e.node)||this.editor.state.doc;return t.textBetween(0,t.content.size," "," ").split(" ").filter((e=>""!==e)).length}},addProseMirrorPlugins(){return[new Plugin({key:new PluginKey("characterCount"),filterTransaction:(e,t)=>{const n=this.options.limit;if(!e.docChanged||0===n||null==n)return!0;const r=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=n)return!0;if(r>n&&o>n&&o<=r)return!0;if(r>n&&o>n&&o>r)return!1;if(!e.getMeta("paste"))return!1;const i=e.selection.$head.pos,s=i-(o-n),a=i;return e.deleteRange(s,a),!(this.storage.characters({node:e.doc})>n)}})]}}),Placeholder=Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,considerAnyAsEmpty:!1,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Plugin({key:new PluginKey("placeholder"),props:{decorations:({doc:e,selection:t})=>{var n;const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=t,i=[];if(!r)return null;const{firstChild:s}=e.content,a=s&&s.type.isLeaf,l=s&&s.isAtom,c=!!this.options.considerAnyAsEmpty||s&&s.type.name===(null===(n=e.type.contentMatch.defaultType)||void 0===n?void 0:n.name),d=e.content.childCount<=1&&s&&c&&s.nodeSize<=2&&(!a||!l);return e.descendants(((e,t)=>{const n=o>=t&&o<=t+e.nodeSize,r=!e.isLeaf&&!e.childCount;if((n||!this.options.showOnlyCurrent)&&r){const r=[this.options.emptyNodeClass];d&&r.push(this.options.emptyEditorClass);const o=Decoration.node(t,t+e.nodeSize,{class:r.join(" "),"data-placeholder":"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:e,pos:t,hasAnchor:n}):this.options.placeholder});i.push(o)}return this.options.includeChildren})),DecorationSet.create(e,i)}}})]}}),inputRegex$4=/^\s*>\s$/,Blockquote=Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[wrappingInputRule({find:inputRegex$4,type:this.type})]}}),starInputRegex$1=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,starPasteRegex$1=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,underscoreInputRegex$1=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,underscorePasteRegex$1=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Bold=Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[markInputRule({find:starInputRegex$1,type:this.type}),markInputRule({find:underscoreInputRegex$1,type:this.type})]},addPasteRules(){return[markPasteRule({find:starPasteRegex$1,type:this.type}),markPasteRule({find:underscorePasteRegex$1,type:this.type})]}}),ListItem$2=Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",mergeAttributes(this.options.HTMLAttributes,e),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)}}}),TextStyle$1=Mark.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:e=>!!e.hasAttribute("style")&&{}}]},renderHTML({HTMLAttributes:e}){return["span",mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:e,commands:t})=>{const n=getMarkAttributes(e,this.type);return!!Object.entries(n).some((([,e])=>!!e))||t.unsetMark(this.name)}}}}),inputRegex$3=/^\s*([-+*])\s$/,BulletList=Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ListItem$2.name,this.editor.getAttributes(TextStyle$1.name)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=wrappingInputRule({find:inputRegex$3,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=wrappingInputRule({find:inputRegex$3,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(TextStyle$1.name),editor:this.editor})),[e]}}),inputRegex$2=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,pasteRegex$1=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,Code=Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[markInputRule({find:inputRegex$2,type:this.type})]},addPasteRules(){return[markPasteRule({find:pasteRegex$1,type:this.type})]}}),backtickInputRegex=/^```([a-z]+)?[\s\n]$/,tildeInputRegex=/^~~~([a-z]+)?[\s\n]$/,CodeBlock=Node.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options;return[...(null===(t=e.firstElementChild)||void 0===t?void 0:t.classList)||[]].filter((e=>e.startsWith(n))).map((e=>e.replace(n,"")))[0]||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",mergeAttributes(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=1===t.pos;return!(!e||t.parent.type.name!==this.name)&&!(!n&&t.parent.textContent.length)&&this.editor.commands.clearNodes()},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith("\n\n");return!(!i||!s)&&e.chain().command((({tr:e})=>(e.delete(r.pos-2,r.pos),!0))).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type)return!1;if(o.parentOffset!==o.parent.nodeSize-2)return!1;const s=o.after();return void 0!==s&&(!r.nodeAt(s)&&e.commands.exitCode())}}},addInputRules(){return[textblockTypeInputRule({find:backtickInputRegex,type:this.type,getAttributes:e=>({language:e[1]})}),textblockTypeInputRule({find:tildeInputRegex,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new Plugin({key:new PluginKey("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=null==o?void 0:o.mode;if(!n||!i)return!1;const{tr:s}=e.state;return e.state.selection.from===e.state.doc.nodeSize-(1+2*e.state.selection.$to.depth)?s.insert(e.state.selection.from-1,this.type.create({language:i})):s.replaceSelectionWith(this.type.create({language:i})),s.setSelection(TextSelection.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.insertText(n.replace(/\r\n?/g,"\n")),s.setMeta("paste",!0),e.dispatch(s),!0}}})]}}),Document=Node.create({name:"doc",topNode:!0,content:"block+"});function dropCursor(e={}){return new Plugin({view(t){return new DropCursorView(t,e)}})}class DropCursorView{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map((t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t)))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent;if(n){let n=t.nodeBefore,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let o=t.getBoundingClientRect(),i=n?o.bottom:o.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),e={left:o.left,right:o.right,top:i-this.width/2,bottom:i+this.width/2}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos);e={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let r,o,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!i||i==document.body&&"static"==getComputedStyle(i).position)r=-pageXOffset,o=-pageYOffset;else{let e=i.getBoundingClientRect();r=e.left-i.scrollLeft,o=e.top-i.scrollTop}this.element.style.left=e.left-r+"px",this.element.style.top=e.top-o+"px",this.element.style.width=e.right-e.left+"px",this.element.style.height=e.bottom-e.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,o="function"==typeof r?r(this.editorView,t,e):r;if(t&&!o){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=dropPoint(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){e.target!=this.editorView.dom&&this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const Dropcursor=Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[dropCursor(this.options)]}});class GapCursor extends Selection{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return GapCursor.valid(n)?new GapCursor(n):Selection.near(n)}content(){return Slice.empty}eq(e){return e instanceof GapCursor&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new GapCursor(e.resolve(t.pos))}getBookmark(){return new GapBookmark(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!closedBefore(e)||!closedAfter(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&GapCursor.valid(e))return e;let r=e.pos,o=null;for(let n=e.depth;;n--){let i=e.node(n);if(t>0?e.indexAfter(n)<i.childCount:e.index(n)>0){o=i.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let s=e.doc.resolve(r);if(GapCursor.valid(s))return s}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!NodeSelection.isSelectable(o)){e=e.doc.resolve(r+o.nodeSize*t),n=!1;continue e}break}o=i,r+=t;let s=e.doc.resolve(r);if(GapCursor.valid(s))return s}return null}}}GapCursor.prototype.visible=!1,GapCursor.findFrom=GapCursor.findGapCursorFrom,Selection.jsonID("gapcursor",GapCursor);class GapBookmark{constructor(e){this.pos=e}map(e){return new GapBookmark(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return GapCursor.valid(t)?new GapCursor(t):Selection.near(t)}}function closedBefore(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0!=n)for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}function closedAfter(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}function gapCursor(){return new Plugin({props:{decorations:drawGapCursor,createSelectionBetween(e,t,n){return t.pos==n.pos&&GapCursor.valid(n)?new GapCursor(n):null},handleClick:handleClick,handleKeyDown:handleKeyDown,handleDOMEvents:{beforeinput:beforeinput}}})}const handleKeyDown=keydownHandler({ArrowLeft:arrow("horiz",-1),ArrowRight:arrow("horiz",1),ArrowUp:arrow("vert",-1),ArrowDown:arrow("vert",1)});function arrow(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,o){let i=e.selection,s=t>0?i.$to:i.$from,a=i.empty;if(i instanceof TextSelection){if(!o.endOfTextblock(n)||0==s.depth)return!1;a=!1,s=e.doc.resolve(t>0?s.after():s.before())}let l=GapCursor.findGapCursorFrom(s,t,a);return!!l&&(r&&r(e.tr.setSelection(new GapCursor(l))),!0)}}function handleClick(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!GapCursor.valid(r))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return!(o&&o.inside>-1&&NodeSelection.isSelectable(e.state.doc.nodeAt(o.inside))||(e.dispatch(e.state.tr.setSelection(new GapCursor(r))),0))}function beforeinput(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof GapCursor))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let o=Fragment.empty;for(let e=r.length-1;e>=0;e--)o=Fragment.from(r[e].createAndFill(null,o));let i=e.state.tr.replace(n.pos,n.pos,new Slice(o,0,0));return i.setSelection(TextSelection.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function drawGapCursor(e){if(!(e.selection instanceof GapCursor))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",DecorationSet.create(e.doc,[Decoration.widget(e.selection.head,t,{key:"gapcursor"})])}const Gapcursor=Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[gapCursor()]},extendNodeSchema(e){var t;return{allowGapCursor:null!==(t=callOrReturn(getExtensionField(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))&&void 0!==t?t:null}}}),HardBreak=Node.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",mergeAttributes(this.options.HTMLAttributes,e)]},renderText(){return"\n"},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command((()=>{const{selection:e,storedMarks:o}=n;if(e.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:s}=r.extensionManager,a=o||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command((({tr:e,dispatch:t})=>{if(t&&a&&i){const t=a.filter((e=>s.includes(e.type.name)));e.ensureMarks(t)}return!0})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Heading=Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map((e=>({tag:`h${e}`,attrs:{level:e}})))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.setNode(this.name,e),toggleHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce(((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})})),{})},addInputRules(){return this.options.levels.map((e=>textblockTypeInputRule({find:new RegExp(`^(#{1,${e}})\\s$`),type:this.type,getAttributes:{level:e}})))}});var GOOD_LEAF_SIZE=200,RopeSequence=function(){};RopeSequence.prototype.append=function(e){return e.length?(e=RopeSequence.from(e),!this.length&&e||e.length<GOOD_LEAF_SIZE&&this.leafAppend(e)||this.length<GOOD_LEAF_SIZE&&e.leafPrepend(this)||this.appendInner(e)):this},RopeSequence.prototype.prepend=function(e){return e.length?RopeSequence.from(e).append(this):this},RopeSequence.prototype.appendInner=function(e){return new Append(this,e)},RopeSequence.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?RopeSequence.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},RopeSequence.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},RopeSequence.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},RopeSequence.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(t,n){return r.push(e(t,n))}),t,n),r},RopeSequence.from=function(e){return e instanceof RopeSequence?e:e&&e.length?new Leaf(e):RopeSequence.empty};var Leaf=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=GOOD_LEAF_SIZE)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=GOOD_LEAF_SIZE)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(RopeSequence);RopeSequence.empty=new Leaf([]);var Append=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&void 0},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(RopeSequence);const max_empty_items=500;class Branch{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}t&&(n=this.remapping(o,this.items.length),r=n.maps.length);let i,s,a=e.tr,l=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return n||(n=this.remapping(o,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new Item(e.map));let t,o=e.step.map(n.slice(r));o&&a.maybeStep(o).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new Item(t,void 0,void 0,l.length+c.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new Branch(this.items.slice(0,o).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:s,transform:a,selection:i}}addTransform(e,t,n,r){let o=[],i=this.eventCount,s=this.items,a=!r&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let l,c=e.steps[n].invert(e.docs[n]),d=new Item(e.mapping.maps[n],c,t);(l=a&&a.merge(d))&&(d=l,n?o.pop():s=s.slice(0,s.length-1)),o.push(d),t&&(i++,t=void 0),r||(a=d)}let l=i-n.depth;return l>DEPTH_OVERFLOW&&(s=cutOffEvents(s,l),i-=l),new Branch(s.append(o),i)}remapping(e,t){let n=new Mapping;return this.items.forEach(((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)}),e,t),n}addMaps(e){return 0==this.eventCount?this:new Branch(this.items.append(e.map((e=>new Item(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach((e=>{e.selection&&s--}),r);let a=t;this.items.forEach((t=>{let r=o.getMirror(--a);if(null==r)return;i=Math.min(i,r);let l=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(a+1,r));c&&s++,n.push(new Item(l,i,c))}else n.push(new Item(l))}),r);let l=[];for(let e=t;e<i;e++)l.push(new Item(o.maps[e]));let c=this.items.slice(0,r).append(l).append(n),d=new Branch(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],o=0;return this.items.forEach(((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let a=i.selection&&i.selection.map(t.slice(n));a&&o++;let l,c=new Item(s.invert(),e,a),d=r.length-1;(l=r.length&&r[d].merge(c))?r[d]=l:r.push(c)}}else i.map&&n--}),this.items.length,0),new Branch(RopeSequence.from(r.reverse()),o)}}function cutOffEvents(e,t){let n;return e.forEach(((e,r)=>{if(e.selection&&0==t--)return n=r,!1})),e.slice(n)}Branch.empty=new Branch(RopeSequence.empty,0);class Item{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Item(t.getMap().invert(),t,this.selection)}}}class HistoryState{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}}const DEPTH_OVERFLOW=20;function applyTransaction(e,t,n,r){let o,i=n.getMeta(historyKey);if(i)return i.historyState;n.getMeta(closeHistoryKey)&&(e=new HistoryState(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(historyKey))return s.getMeta(historyKey).redo?new HistoryState(e.done.addTransform(n,void 0,r,mustPreserveItems(t)),e.undone,rangesFor(n.mapping.maps[n.steps.length-1]),e.prevTime,e.prevComposition):new HistoryState(e.done,e.undone.addTransform(n,void 0,r,mustPreserveItems(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new HistoryState(e.done.rebased(n,o),e.undone.rebased(n,o),mapRanges(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new HistoryState(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),mapRanges(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let o=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!isAdjacentTo(n,e.prevRanges)),a=s?mapRanges(e.prevRanges,n.mapping):rangesFor(n.mapping.maps[n.steps.length-1]);return new HistoryState(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,mustPreserveItems(t)),Branch.empty,a,n.time,null==o?e.prevComposition:o)}}function isAdjacentTo(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,r)=>{for(let o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)})),n}function rangesFor(e){let t=[];return e.forEach(((e,n,r,o)=>t.push(r,o))),t}function mapRanges(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}function histTransaction(e,t,n){let r=mustPreserveItems(t),o=historyKey.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),a=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),l=new HistoryState(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(s).setMeta(historyKey,{redo:n,historyState:l})}let cachedPreserveItems=!1,cachedPreserveItemsPlugins=null;function mustPreserveItems(e){let t=e.plugins;if(cachedPreserveItemsPlugins!=t){cachedPreserveItems=!1,cachedPreserveItemsPlugins=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){cachedPreserveItems=!0;break}}return cachedPreserveItems}const historyKey=new PluginKey("history"),closeHistoryKey=new PluginKey("closeHistory");function history(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Plugin({key:historyKey,state:{init(){return new HistoryState(Branch.empty,Branch.empty,null,0,-1)},apply(t,n,r){return applyTransaction(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?undo:"historyRedo"==n?redo:null;return!!r&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function buildCommand(e,t){return(n,r)=>{let o=historyKey.getState(n);if(!o||0==(e?o.undone:o.done).eventCount)return!1;if(r){let i=histTransaction(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const undo=buildCommand(!1,!0),redo=buildCommand(!0,!0),History=Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>undo(e,t),redo:()=>({state:e,dispatch:t})=>redo(e,t)}},addProseMirrorPlugins(){return[history(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()}}}),HorizontalRule=Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{const{$to:n}=t.selection,r=e();return 0===n.parentOffset?r.insertContentAt(Math.max(n.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command((({tr:e,dispatch:t})=>{var n;if(t){const{$to:t}=e.selection,r=t.end();if(t.nodeAfter)t.nodeAfter.isTextblock?e.setSelection(TextSelection.create(e.doc,t.pos+1)):t.nodeAfter.isBlock?e.setSelection(NodeSelection.create(e.doc,t.pos)):e.setSelection(TextSelection.create(e.doc,t.pos));else{const o=null===(n=t.parent.type.contentMatch.defaultType)||void 0===n?void 0:n.create();o&&(e.insert(r,o),e.setSelection(TextSelection.create(e.doc,r+1)))}e.scrollIntoView()}return!0})).run()}}},addInputRules(){return[nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),starInputRegex=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,starPasteRegex=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,underscoreInputRegex=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,underscorePasteRegex=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Italic=Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[markInputRule({find:starInputRegex,type:this.type}),markInputRule({find:underscoreInputRegex,type:this.type})]},addPasteRules(){return[markPasteRule({find:starPasteRegex,type:this.type}),markPasteRule({find:underscorePasteRegex,type:this.type})]}}),ListItem$1=Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",mergeAttributes(this.options.HTMLAttributes,e),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)}}}),ListItem=Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",mergeAttributes(this.options.HTMLAttributes,e),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)}}}),TextStyle=Mark.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:e=>!!e.hasAttribute("style")&&{}}]},renderHTML({HTMLAttributes:e}){return["span",mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:e,commands:t})=>{const n=getMarkAttributes(e,this.type);return!!Object.entries(n).some((([,e])=>!!e))||t.unsetMark(this.name)}}}}),inputRegex$1=/^(\d+)\.\s$/,OrderedList=Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return 1===t?["ol",mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ListItem.name,this.editor.getAttributes(TextStyle.name)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=wrappingInputRule({find:inputRegex$1,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=wrappingInputRule({find:inputRegex$1,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(TextStyle.name)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),Paragraph=Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),inputRegex=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,pasteRegex=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Strike=Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}]},renderHTML({HTMLAttributes:e}){return["s",mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[markInputRule({find:inputRegex,type:this.type})]},addPasteRules(){return[markPasteRule({find:pasteRegex,type:this.type})]}}),Text=Node.create({name:"text",group:"inline"}),StarterKit=Extension.create({name:"starterKit",addExtensions(){var e,t,n,r,o,i,s,a,l,c,d,p,h,u,f,m,g,y;const S=[];return!1!==this.options.blockquote&&S.push(Blockquote.configure(null===(e=this.options)||void 0===e?void 0:e.blockquote)),!1!==this.options.bold&&S.push(Bold.configure(null===(t=this.options)||void 0===t?void 0:t.bold)),!1!==this.options.bulletList&&S.push(BulletList.configure(null===(n=this.options)||void 0===n?void 0:n.bulletList)),!1!==this.options.code&&S.push(Code.configure(null===(r=this.options)||void 0===r?void 0:r.code)),!1!==this.options.codeBlock&&S.push(CodeBlock.configure(null===(o=this.options)||void 0===o?void 0:o.codeBlock)),!1!==this.options.document&&S.push(Document.configure(null===(i=this.options)||void 0===i?void 0:i.document)),!1!==this.options.dropcursor&&S.push(Dropcursor.configure(null===(s=this.options)||void 0===s?void 0:s.dropcursor)),!1!==this.options.gapcursor&&S.push(Gapcursor.configure(null===(a=this.options)||void 0===a?void 0:a.gapcursor)),!1!==this.options.hardBreak&&S.push(HardBreak.configure(null===(l=this.options)||void 0===l?void 0:l.hardBreak)),!1!==this.options.heading&&S.push(Heading.configure(null===(c=this.options)||void 0===c?void 0:c.heading)),!1!==this.options.history&&S.push(History.configure(null===(d=this.options)||void 0===d?void 0:d.history)),!1!==this.options.horizontalRule&&S.push(HorizontalRule.configure(null===(p=this.options)||void 0===p?void 0:p.horizontalRule)),!1!==this.options.italic&&S.push(Italic.configure(null===(h=this.options)||void 0===h?void 0:h.italic)),!1!==this.options.listItem&&S.push(ListItem$1.configure(null===(u=this.options)||void 0===u?void 0:u.listItem)),!1!==this.options.orderedList&&S.push(OrderedList.configure(null===(f=this.options)||void 0===f?void 0:f.orderedList)),!1!==this.options.paragraph&&S.push(Paragraph.configure(null===(m=this.options)||void 0===m?void 0:m.paragraph)),!1!==this.options.strike&&S.push(Strike.configure(null===(g=this.options)||void 0===g?void 0:g.strike)),!1!==this.options.text&&S.push(Text.configure(null===(y=this.options)||void 0===y?void 0:y.text)),S}}),scRichTextCss='@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}',ScRichTextStyle0=scRichTextCss;let id=0;const ScRichText$1=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.scChange=createEvent(this,"scChange",7),this.scInput=createEvent(this,"scInput",7),this.scBlur=createEvent(this,"scBlur",7),this.scFocus=createEvent(this,"scFocus",7),this.inputId="sc-richtext-"+ ++id,this.helpId=`sc-richtext-help-text-${id}`,this.labelId=`sc-richtext-label-${id}`,this.size="medium",this.name=void 0,this.value="",this.label="",this.showLabel=!0,this.help="",this.placeholder=void 0,this.maxlength=void 0,this.disabled=!1,this.readonly=!1,this.required=!1,this.updatedAt=Date.now(),this.hasFocus=void 0}componentDidLoad(){this.editor||(this.editor=new Editor({element:this.element,extensions:[StarterKit,Placeholder.configure({placeholder:this.placeholder}),...(null==this?void 0:this.maxlength)>0?[CharacterCount.configure({limit:this.maxlength,mode:"nodeSize"})]:[]],content:this.value,onCreate:({editor:e})=>{this.value=e.getHTML()},onUpdate:({editor:e})=>{this.value=e.getHTML(),this.scInput.emit(),this.scChange.emit()},onSelectionUpdate:()=>{this.updatedAt=Date.now()},onFocus:()=>{this.handleFocus()},onBlur:()=>{this.handleBlur()}}))}handleFocus(){this.hasFocus=!0,this.scFocus.emit()}handleBlur(){this.hasFocus=!1,this.scBlur.emit()}isActive(e,t={}){var n,r;return null===(r=null===(n=this.editor)||void 0===n?void 0:n.isActive)||void 0===r?void 0:r.call(n,e,t)}toggleHeading(e){this.editor.chain().toggleHeading(e).focus().run()}toggleBold(){this.editor.chain().toggleBold().focus().run()}toggleItalic(){this.editor.chain().toggleItalic().focus().run()}can(e){var t,n,r,o,i,s,a,l,c;return null===(c=null===(l=null===(a=null===(s=null===(i=null===(o=null===(r=null===(n=null===(t=this.editor)||void 0===t?void 0:t.can())||void 0===n?void 0:n.chain)||void 0===r?void 0:r.call(n))||void 0===o?void 0:o.focus)||void 0===i?void 0:i.call(o))||void 0===s?void 0:s[e])||void 0===a?void 0:a.call(s))||void 0===l?void 0:l.run)||void 0===c?void 0:c.call(l)}run(e){var t,n,r,o,i,s,a,l;return null===(l=null===(a=null===(s=null===(i=null===(o=null===(r=null===(n=null===(t=this.editor)||void 0===t?void 0:t.chain)||void 0===n?void 0:n.call(t))||void 0===r?void 0:r.focus)||void 0===o?void 0:o.call(r))||void 0===i?void 0:i[e])||void 0===s?void 0:s.call(i))||void 0===a?void 0:a.run)||void 0===l?void 0:l.call(a)}remainingCharacters(){var e,t;return this.maxlength?this.maxlength-((null===(t=null===(e=null==this?void 0:this.editor)||void 0===e?void 0:e.storage)||void 0===t?void 0:t.characterCount.characters())||0):1e3}handleKeyDown(e){"n"===e.key&&e.stopPropagation()}render(){var e,t,n,r,o,i,s,a;return h(Host,{key:"3bf321fb977d07358ba624974343bdbe23ac9d38"},h("sc-form-control",{key:"13221a3f297543ab00e106e37edd83134db403e6",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},h("div",{key:"6e795c0dfd470c729b2649dbfbf61b935f9f9c44",part:"base",class:{"editor-base":!0,"editor--focused":this.hasFocus}},h("div",{key:"2c186edc2b39ce8f2dd6c899ca044d1781e3557a",class:"menu"},h("sc-button",{key:"1d8ccb28613627cd4019d580726bec8cc629b3ce",size:"small",type:(null===(t=null===(e=this.editor)||void 0===e?void 0:e.isActive)||void 0===t?void 0:t.call(e,"bold"))?"default":"text",onClick:()=>this.run("toggleBold"),disabled:!this.can("toggleBold")},h("sc-icon",{key:"c6b8889160ccf6794ce433abbf45551f8de6664b",name:"bold"})),h("sc-button",{key:"30716feabc3c402d97ef6704aecde628c53f0d0c",size:"small",type:(null===(r=null===(n=this.editor)||void 0===n?void 0:n.isActive)||void 0===r?void 0:r.call(n,"italic"))?"default":"text",onClick:()=>this.run("toggleItalic"),disabled:!this.can("toggleItalic")},h("sc-icon",{key:"11f5421a4cfc6b1d8c3b133664b183df2e5fd6ea",name:"italic"})),h("sc-button",{key:"4d9ed2ceb37edd4283100230c1c73be0d353ddd1",size:"small",type:(null===(i=null===(o=this.editor)||void 0===o?void 0:o.isActive)||void 0===i?void 0:i.call(o,"bulletList"))?"default":"text",onClick:()=>this.run("toggleBulletList")},h("sc-icon",{key:"cbd320f7fba8bae54b11587292c15602165726d8",name:"list"})),h("sc-button",{key:"5c13e6dacd3d824c8176fa9a74aac31f6339f929",size:"small",type:(null===(a=null===(s=this.editor)||void 0===s?void 0:s.isActive)||void 0===a?void 0:a.call(s,"strike"))?"default":"text",onClick:()=>this.run("toggleStrike")},h("sc-icon",{key:"595c767bd1edb1ad22d5f8b7618db1e865630621",name:"minus"})),h("sc-button",{key:"5a327a2b03444414b880e3ae74c77d176c4c4355",class:"right",size:"small",type:"text",onClick:()=>this.run("undo"),disabled:!this.can("undo")},h("sc-icon",{key:"08aea4aac4d70237087ca4f895e87ab4eec18a7c",name:"corner-up-left"})),h("sc-button",{key:"b6c579c22a59e08511370902d3ac3bda1e3a5d3e",size:"small",type:"text",onClick:()=>this.run("redo"),disabled:!this.can("redo")},h("sc-icon",{key:"bb9a633d81ad65a61150440f57c49e0276ceb022",name:"corner-up-right"}))),h("div",{key:"68ea3c41cfe45f2f1e107f27eb556a232d9899df",part:"editor",class:{editor:!0},ref:e=>this.element=e})),this.remainingCharacters()<20&&h("div",{key:"55105ad6d26d155c7337610248fff06de05d4a75",class:"textarea__char-limit-warning"},wp.i18n.sprintf(wp.i18n.__("%d characters remaining","surecart"),this.remainingCharacters()))))}static get style(){return ScRichTextStyle0}},[1,"sc-rich-text",{size:[513],name:[1],value:[1],label:[1],showLabel:[4,"show-label"],help:[1],placeholder:[1],maxlength:[2],disabled:[516],readonly:[516],required:[516],updatedAt:[32],hasFocus:[32]},[[0,"keydown","handleKeyDown"]]]);function defineCustomElement$1(){"undefined"!=typeof customElements&&["sc-rich-text","sc-button","sc-form-control","sc-icon","sc-spinner","sc-visually-hidden"].forEach((e=>{switch(e){case"sc-rich-text":customElements.get(e)||customElements.define(e,ScRichText$1);break;case"sc-button":customElements.get(e)||defineCustomElement$6();break;case"sc-form-control":customElements.get(e)||defineCustomElement$5();break;case"sc-icon":customElements.get(e)||defineCustomElement$4();break;case"sc-spinner":customElements.get(e)||defineCustomElement$3();break;case"sc-visually-hidden":customElements.get(e)||defineCustomElement$2()}}))}const ScRichText=ScRichText$1,defineCustomElement=defineCustomElement$1;export{ScRichText,defineCustomElement};
Copyright ©2021 || Defacer Indonesia