oficina / mapa Public
File too large to show in full — download it above (showing a truncated preview below).
| 1 | function H(n){this.content=n}H.prototype={constructor:H,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),o=r.content.slice();return i==-1?o.push(t||n,e):(o[i+1]=e,t&&(o[i]=t)),new H(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new H(t)},addToStart:function(n,e){return new H([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new H(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),o=r.find(n);return i.splice(o==-1?i.length:o,0,e,t),new H(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=H.from(n),n.size?new H(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=H.from(n),n.size?new H(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=H.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};H.from=function(n){if(n instanceof H)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new H(e)};var wi=H;function Ys(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){let s=i.text,l=o.text,a=0;for(;s[a]==l[a];a++)t++;return a&&a<s.length&&a<l.length&&Zs(s.charCodeAt(a-1))&&Xs(s.charCodeAt(a))&&t--,t}if(i.content.size||o.content.size){let s=Ys(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function Gs(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=s.text,u=l.text,f=c.length,d=u.length;for(;f>0&&d>0&&c[f-1]==u[d-1];)f--,d--,t--,r--;return f&&d&&f<c.length&&Zs(c.charCodeAt(f-1))&&Xs(c.charCodeAt(f))&&(t++,r++),{a:t,b:r}}if(s.content.size||l.content.size){let c=Gs(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function Xs(n){return n>=56320&&n<57344}function Zs(n){return n>=55296&&n<56320}var b=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,o){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,i+l,o||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new n(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let o=0,s=0;s<t;o++){let l=this.content[o],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=a}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,o)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Ys(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Gs(this,e,t,r)}findIndex(e){if(e==0)return Zn(0,e);if(e==this.size)return Zn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),o=r+i.nodeSize;if(o>=e)return o==e?Zn(t+1,o):Zn(t,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 n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(t||(t=e.slice(0,i)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};b.empty=new b([],0);var Si={index:0,offset:0};function Zn(n,e){return Si.index=n,Si.offset=e,Si}function tr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!tr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!tr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var T=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;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&&tr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};T.none=[];var Ge=class extends Error{},x=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=el(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Qs(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(b.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new n(e,r,i)}};x.empty=new x(b.empty,0,0);function Qs(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Qs(o.content,e-i-1,t-i-1)))}function el(n,e,t,r,i,o){let{index:s,offset:l}=n.findIndex(e),a=n.maybeChild(s);if(l==e||a.isText)return o&&r<=0&&i<=0&&!o.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=el(a.content,e-l-1,t,s==0?r-1:0,s==n.childCount-1?i-1:0,a);return c&&n.replaceChild(s,a.copy(c))}function zf(n,e,t){if(t.openStart>n.depth)throw new Ge("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ge("Inconsistent open depths");return tl(n,e,t,0)}function tl(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let s=tl(n,e,t,r+1);return o.copy(o.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return ut(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=$f(t,n);return ut(o,rl(n,s,l,e,r))}else return ut(o,nr(n,e,r))}function nl(n,e){if(!e.type.compatibleContent(n.type))throw new Ge("Cannot join "+e.type.name+" onto "+n.type.name)}function Ci(n,e,t){let r=n.node(t);return nl(r,e.node(t)),r}function ct(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function an(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(ct(n.nodeAfter,r),o++));for(let l=o;l<s;l++)ct(i.child(l),r);e&&e.depth==t&&e.textOffset&&ct(e.nodeBefore,r)}function ut(n,e){if(!n.type.validContent(e))throw new Ge("Invalid content for node "+n.type.name);return n.copy(e)}function rl(n,e,t,r,i){let o=n.depth>i&&Ci(n,e,i+1),s=r.depth>i&&Ci(t,r,i+1),l=[];return an(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(nl(o,s),ct(ut(o,rl(n,e,t,r,i+1)),l)):(o&&ct(ut(o,nr(n,e,i+1)),l),an(e,t,i,l),s&&ct(ut(s,nr(t,r,i+1)),l)),an(r,null,i,l),new b(l)}function nr(n,e,t){let r=[];if(an(null,n,t,r),n.depth>t){let i=Ci(n,e,t+1);ct(ut(i,nr(n,e,t+1)),r)}return an(e,null,t,r),new b(r)}function $f(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(b.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var rr=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return T.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new ft(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(r.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new n(t,r,o)}static resolveCached(e,t){let r=Vs.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==t)return s}else Vs.set(e,r=new Mi);let i=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%Ff,i}},Mi=class{constructor(){this.elts=[],this.i=0}},Ff=12,Vs=new WeakMap,ft=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Vf=Object.create(null),Se=class n{constructor(e,t,r,i=T.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||b.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&tr(this.attrs,t||e.defaultAttrs||Vf)&&T.sameSet(this.marks,r||T.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return x.empty;let i=this.resolve(e),o=this.resolve(t),s=r?0:i.sharedDepth(t),l=i.start(s),c=i.node(s).content.cut(i.pos-l,o.pos-l);return new x(c,i.depth-s,o.depth-s)}replace(e,t,r){return zf(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return rr.resolveCached(this,e)}resolveNoCache(e){return rr.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),il(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=b.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=T.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!T.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=b.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};Se.prototype.text=void 0;var Oi=class n extends Se{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):il(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function il(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var dt=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Di(e,t);if(r.next==null)return n.empty;let i=ol(r);r.next&&r.err("Unexpected trailing text");let o=Uf(Hf(i));return _f(o,r),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,r=e.childCount){let i=this;for(let o=t;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function o(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return b.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:f}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let d=o(f,l.concat(u));if(d)return d}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:a}=o.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(` |
| 2 | `)}};dt.empty=new dt(!0);var Di=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function ol(n){let e=[];do e.push(Wf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Wf(n){let e=[];do e.push(qf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function qf(n){let e=Jf(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Kf(n,e);else break;return e}function Ws(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Kf(n,e){let t=Ws(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ws(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function jf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Jf(n){if(n.eat("(")){let e=ol(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=jf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Hf(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=t();i(o(s.expr,a),u),a=u}if(s.max==-1)i(o(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=t();r(a,u),i(o(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function sl(n,e){return e-n}function qs(n,e){let t=[];return r(e),t.sort(sl);function r(i){let o=n[i];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(i);for(let s=0;s<o.length;s++){let{term:l,to:a}=o[s];!l&&t.indexOf(a)==-1&&r(a)}}}function Uf(n){let e=Object.create(null);return t(qs(n,0));function t(r){let i=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);qs(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new dt(r.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(sl);o.next.push({type:i[s][0],next:e[l.join(",")]||t(l)})}return o}}function _f(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],o=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];s.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ll(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function al(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let o=n[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function cl(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${r}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}function ul(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Ti(n,r,e[r]);return t}var ir=class n{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=ul(e,r.attrs),this.defaultAttrs=ll(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==dt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:al(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Se(this,this.computeAttrs(e),b.from(t),T.setFrom(r))}createChecked(e=null,t,r){return t=b.from(t),this.checkContent(t),new Se(this,this.computeAttrs(e),t,T.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=b.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(b.empty,!0);return o?new Se(this,e,t.append(o),T.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){cl(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:T.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,s)=>r[o]=new n(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Yf(n,e,t){let r=t.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}var Ti=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Yf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},un=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=ul(e,i.attrs),this.excluded=null;let o=ll(this.attrs);this.instance=o?new T(this,o):null}create(e=null){return!e&&this.instance?this.instance:new T(this,al(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new n(o,i++,t,s)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){cl(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},or=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=wi.from(e.nodes),t.marks=wi.from(e.marks||{}),this.nodes=ir.compile(this.spec.nodes,this),this.marks=un.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=dt.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?Ks(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:Ks(this,s.split(" "))}this.nodeFromJSON=i=>Se.fromJSON(this,i),this.markFromJSON=i=>T.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ir){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Oi(r,r.defaultAttrs,e,T.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function Ks(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],o=n.marks[i],s=o;if(o)t.push(o);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Gf(n){return n.tag!=null}function Xf(n){return n.style!=null}var fn=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(Gf(i))this.tags.push(i);else if(Xf(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new sr(this,t,!1);return r.addAll(e,T.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new sr(this,t,!0);return r.addAll(e,T.none,t.from,t.to),x.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(ed(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,t,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<o)break}t.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Js(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Js(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},fl={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},Zf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},dl={ol:!0,ul:!0},dn=1,Ai=2,cn=4;function js(n,e,t){return e!=null?(e?dn:0)|(e==="full"?Ai:0):n&&n.whitespace=="pre"?dn|Ai:t&~cn}var zt=class{constructor(e,t,r,i,o,s){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=T.none,this.match=o||(s&cn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(b.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&dn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=b.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(b.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!fl.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},sr=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=js(null,t.preserveWhitespace,0)|(r?cn:0);i?o=new zt(i.type,i.attrs,T.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new zt(null,null,T.none,!0,null,s):o=new zt(e.schema.topNodeType,null,T.none,!0,null,s),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,o=i.options&Ai?"full":this.localPreserveWS||(i.options&dn)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,` |
| 3 | `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;dl.hasOwnProperty(s)&&this.parser.normalizeLists&&Qf(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Zf.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(fl.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=a&&a.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` |
| 4 | `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(o,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,r){let i,o;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=T.none;for(let l of i.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):Hs(l.type,e.type))&&(s=l.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,r,i){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,i)),o}enterInner(e,t,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=js(e,o,s.options);s.options&cn&&s.content.length==0&&(l|=cn);let a=T.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Hs(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new zt(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=dn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function Qf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&dl.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function ed(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Js(n){let e={};for(let t in n)e[t]=n[t];return e}function Hs(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}var re=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Qn(t).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let l=0,a=0;for(;l<o.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)i=o.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,t);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){if(e.isText)return Qn(t).createTextNode(e.text);let{dom:r,contentDOM:i}=er(Qn(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&er(Qn(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:er(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Us(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Us(e.marks)}};function Us(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Qn(n){return n.document||window.document}var _s=new WeakMap;function td(n){let e=_s.get(n);return e===void 0&&_s.set(n,e=nd(n)),e}function nd(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function er(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=td(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):f=="style"&&a.style?a.style.cssText=c[f]:a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof d=="string")a.appendChild(n.createTextNode(d));else{let{dom:h,contentDOM:p}=er(n,d,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var hl="http://www.w3.org/2000/svg",rd={page:["M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z","M14 2v4a2 2 0 0 0 2 2h4","M9 13h6","M9 17h4"],"page-plus":["M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z","M14 2v4a2 2 0 0 0 2 2h4","M9 15h6","M12 12v6"],calendar:["M8 2v4","M16 2v4","M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z","M3 10h18"],block:["M13 4v16","M17 4v16","M19 4H9.5a4.5 4.5 0 0 0 0 9H13"],embed:["M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z","m3.3 7 8.7 5 8.7-5","M12 22V12"]};function pl(n){return[`${hl} svg`,{"mapa-i":"",viewBox:"0 0 24 24","aria-hidden":"true"},...rd[n].map(e=>[`${hl} path`,{d:e}])]}function id(n){return n?.emoji?["span",{"mapa-i":"","mapa-icon":"","aria-hidden":"true"},n.emoji]:n?.image&&/^[0-9a-z]{1,13}$/u.test(n.image)?["img",{"mapa-i":"","mapa-icon":"",src:`/i/${n.image}`,alt:"",width:"16",height:"16",loading:"lazy",decoding:"async"}]:null}function lr({href:n,kind:e,title:t,label:r,icon:i,look:o,shown:s,note:l}){let a={href:n,"mapa-chip":e};t&&(a.title=t),a["aria-label"]=r;let c=["a",a,id(o)||pl(i),s];return l&&c.push(["span",{"mapa-chip-note":""},l]),c}function Ei({target:n,anchor:e,shown:t},r){let i=t||n;if(r.broken)return["span",{"mapa-chip":"broken"},i];if(r.day)return od(t,r);if(r.pending)return lr({href:r.href,kind:"pending",icon:"page-plus",shown:i,label:`${i}, page not written yet`});let o=r.title||n,s={href:r.href,kind:"team",icon:"page",shown:i,label:`${i}, team page`,look:r.icon};return r.alias&&(s.title=`Now called ${o}`,s.label=`${i}, now called ${o}`),e&&(s.kind=s.icon="block",s.look=null,s.label=`${i}, a block in ${o}`),e&&r.blockGone&&(s.kind="block gone",s.label=`${i}, block removed from ${o}`,s.note="block removed"),lr(s)}function od(n,e){return lr(n?{href:e.href,kind:"date",icon:"calendar",shown:n,label:`${n}, your note for ${e.day}`}:{href:e.href,kind:"date",icon:"calendar",shown:e.day,label:`${e.day}, your note`})}function ml(n){return["span",{"mapa-chip":"embed",role:"img","aria-label":`${n}, embedded item, not shown yet`},pl("embed"),n]}var sd=/^[A-Za-z0-9\-_.~!$&'()*+,;=:[\]<>"]$/u,ld=/^[A-Za-z0-9\-._:~!$&'()*+,;=%@]$/u,gl=/^[0-9A-Fa-f]$/u;function yl(n){if(ad(n)>2048)return!1;let e=n.slice(0,8).toLowerCase();return!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("mailto:")?!1:Re(n)}function ad(n){return new TextEncoder().encode(n).length}function Re(n){let e=cd(n);if(e===null)return!1;switch(e.scheme){case"http":case"https":return e.host!==""&&!e.host.startsWith("[");case"mailto":return e.opaque!==""}return!1}function cd(n){let e=n.indexOf("#"),t=e<0?n:n.slice(0,e),r=e<0?"":n.slice(e+1),i=ud(t);return i===null||r!==""&&!Ni(r)?null:i}function ud(n){if(/[\x00-\x1f\x7f]/u.test(n))return null;if(n==="*")return{scheme:"",host:"",opaque:""};let e=fd(n);if(e===null)return null;let t=e.rest,r={scheme:e.name.toLowerCase(),host:"",opaque:""};if(t.endsWith("?")&&t.split("?").length===2?t=t.slice(0,-1):t.includes("?")&&(t=t.slice(0,t.indexOf("?"))),!t.startsWith("/")){if(r.scheme!=="")return r.opaque=t,r;if(t.split("/")[0].includes(":"))return null}if((r.scheme!==""||!t.startsWith("///"))&&t.startsWith("//")){let i=t.slice(2);t="";let o=i.indexOf("/");o>=0&&(t=i.slice(o),i=i.slice(0,o));let s=dd(r.scheme,i);if(s===null)return null;r.host=s}return Ni(t)?r:null}function fd(n){for(let e=0;e<n.length;e++){let t=n[e];if(!/^[A-Za-z]$/u.test(t)){if(/^[0-9+\-.]$/u.test(t)){if(e===0)return{name:"",rest:n};continue}return t===":"?e===0?null:{name:n.slice(0,e),rest:n.slice(e+1)}:{name:"",rest:n}}}return{name:"",rest:n}}function dd(n,e){let t=e.lastIndexOf("@"),r=hd(n,t<0?e:e.slice(t+1));if(r===null||t<0)return r;let i=e.slice(0,t);for(let o of i)if(!ld.test(o))return null;return Ni(i)?r:null}function hd(n,e){let t=e.lastIndexOf("[");if(t>0)return null;if(t===0)return"[";let r=e.indexOf(":");if(r!==-1){let i=e.lastIndexOf(":");if(i!==r&&n!=="http"&&n!=="https"&&(r=i),!/^:[0-9]*$/u.test(e.slice(r)))return null}return pd(e)?e:null}function pd(n){for(let e=0;e<n.length;e++){let t=n[e];if(t==="%"){if(!bl(n,e)||parseInt(n[e+1],16)<8&&n.slice(e,e+3)!=="%25")return!1;e+=2}else if(t.charCodeAt(0)<128&&!sd.test(t))return!1}return!0}function Ni(n){for(let e=0;e<n.length;e++)if(n[e]==="%"){if(!bl(n,e))return!1;e+=2}return!0}function bl(n,e){return e+2<n.length&&gl.test(n[e+1])&&gl.test(n[e+2])}var hn="paragraph",Be="heading",R="item",ie="code",oe="quote",Ce="rule",Me="columns",Oe="column",Xe="column_end",mt="columns_end",fr=2,gd="text",Pi="code",gt="wiki",cr="web",pn="embed",Ze="image",ur=1e3,X="/i/",yd=/^[0-9a-z]{1,13}$/u;function mn(n){return yd.test(n)}var pt="[^\\t\\n\\f\\r ]",Ol=new RegExp(`^(#{1,6})[ \\t]+${pt}`,"u"),gn=/^([ \t]*)([-*+]|[0-9]{1,9}[.)])[ \t]+/u,Le=/^ {0,3}(```|~~~)/u,Ri=/^ {0,3}(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/u,Dl=/[ \t]\^([A-Za-z0-9-]{1,40})[ \t]*$/u,bd=/^https?:\/\/[^\t\n\f\r <>()[\]]+[^\t\n\f\r <>()[\].,;:!?'"]/u,xd=/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/u,kd=/^\[([ xX])\][ \t]+/u,xl=/[\t\n\v\f\r \u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]/u;function V(n){let e=0,t=n.length;for(;e<t&&xl.test(n[e]);)e++;for(;t>e&&xl.test(n[t-1]);)t--;return n.slice(e,t)}function yn(n,e){let t=0;for(;t<n.length&&e.includes(n[t]);)t++;return n.slice(t)}function dr(n){let e=0;for(let t of n){let r=t.codePointAt(0);e+=r<128?1:r<2048?2:r<65536?3:4}return e}function ge(n){let e=yt(n),t=e.length;for(;t>0&&` |
| 5 | `.includes(e[t-1]);)t--;return e.slice(0,t)}function yt(n){return n.replaceAll(`\r |
| 6 | `,` |
| 7 | `).replaceAll("\r",` |
| 8 | `)}function ee(n){let e=yt(n).split(` |
| 9 | `),t=[0],r=[0];for(let i of e)t.push(t[t.length-1]+dr(i)+1),r.push(r[r.length-1]+i.length+1);return Tl(e,t,r,0,e.length,Cd(e))}function Tl(n,e,t,r,i,o){let s=n.slice(0,i),l=[];for(let a=r;a<i;){if(V(s[a])===""){a++;continue}let c=o?.get(a);if(c){l.push(...Dd(n,e,t,c)),a=c.close+1;continue}let[u,f]=Td(s,a);u.marker=vd(u),u.start=e[a],u.end=u.start+dr(u.source),u.from=t[a],u.to=u.from+u.source.length,u.column=0,l.push(u),a=f}return l}var wd=/^(:{4,})[ \t]+columns[ \t]*$/u,Sd=/^(:{3,})[ \t]+column[ \t]*$/u,Al=/^[ \t]*:::/u;function Li(n){return Al.test(n)}function ye(n){return n===Me||n===Oe||n===Xe||n===mt}function El(n,e){let t=n.replace(/[ \t]+$/u,"");return t.length===e&&/^:+$/u.test(t)}var Bi=n=>V(n)==="";function Cd(n){let e=new Map,t="";for(let r=0;r<n.length;r++){let i=n[r];if(t!==""){Qe(i,t)&&(t="");continue}let o=Le.exec(i);if(o){t=o[1];continue}if(r>0&&!Bi(n[r-1]))continue;let s=Md(n,r);s&&(e.set(r,s),r=s.close)}return e}function Md(n,e){let t=wd.exec(n[e]);if(!t)return null;let r=t[1].length,i={open:e,close:0,columns:[]};for(let o=kl(n,e+1);o<n.length;){let s=n[o];if(El(s,r)){let c=o+1===n.length||Bi(n[o+1]),u=i.columns.length;return i.close=o,c&&u>=2&&u<=4?i:null}let l=Sd.exec(s);if(!l||l[1].length>=r||i.columns.length===4)return null;let a=Od(n,o+1,l[1].length);if(a<0)return null;i.columns.push([o,a]),o=kl(n,a+1)}return null}function Od(n,e,t){let r="";for(let i=e;i<n.length;i++){let o=n[i];if(r!=="")Qe(o,r)&&(r="");else if(Le.test(o))r=Le.exec(o)[1];else{if(El(o,t))return i;if(Al.test(o))return-1}}return-1}function kl(n,e){for(;e<n.length&&Bi(n[e]);)e++;return e}function ar(n,e,t,r,i,o){let s=$t(n,e[i],{column:o});return s.start=t[i],s.end=s.start+dr(s.source),s.from=r[i],s.to=s.from+s.source.length,s}function Dd(n,e,t,r){let i=ar(Me,n,e,t,r.open,0);i.level=r.columns.length;let o=[i];return r.columns.forEach(([s,l],a)=>{let c=a+1;o.push(ar(Oe,n,e,t,s,c));for(let u of Tl(n,e,t,s+1,l,null))u.column=c,o.push(u);o.push(ar(Xe,n,e,t,l,c))}),o.push(ar(mt,n,e,t,r.close,0)),o}function $t(n,e,t={}){return{kind:n,source:e,level:0,ordered:!1,marker:"",column:0,...t}}function Td(n,e){let t=n[e];if(Le.test(t))return Ad(n,e);let r=Ol.exec(t);return r?[$t(Be,t,{level:r[1].length}),e+1]:Ri.test(t)?[$t(Ce,t),e+1]:gn.test(t)?Ed(n,e):vi(t)?wl(n,e,oe,vi):wl(n,e,hn,Nl)}function Ad(n,e){let t=Le.exec(n[e])[1],r=e+1;for(;r<n.length&&!yn(n[r]," ").startsWith(t);)r++;return r<n.length&&r++,[$t(ie,n.slice(e,r).join(` |
| 10 | `)),r]}function Ed(n,e){let t=gn.exec(n[e]),r=t[1].replaceAll(" "," "),i=e+1;for(;i<n.length&&Nl(n[i]);)i++;return[$t(R,n.slice(e,i).join(` |
| 11 | `),{level:Math.floor(r.length/2),ordered:!/[-*+]/u.test(t[2])}),i]}function wl(n,e,t,r){let i=e+1;for(;i<n.length&&r(n[i]);)i++;return[$t(t,n.slice(e,i).join(` |
| 12 | `)),i]}function vi(n){return yn(n," ").startsWith(">")}function Nl(n){return V(n)!==""&&!Nd(n)}function Nd(n){return Le.test(n)||Ol.test(n)||Ri.test(n)||gn.test(n)||vi(n)}function vd(n){if(n.kind===ie||n.kind===Ce||ye(n.kind))return"";let e=n.source.slice(n.source.lastIndexOf(` |
| 13 | `)+1),t=Dl.exec(e);return t?t[1]:""}function zi(n){let e=n.source;if(ye(n.kind))return"";switch(n.kind){case ie:return Id(e);case Be:e=yn(e,"# ");break;case R:e=e.replace(gn,"");break;case oe:e=Pd(e);break}return n.marker!==""&&(e=e.replace(Dl,"")),e}function Id(n){let e=n.split(` |
| 14 | `);return e.length<=1?"":(Le.test(e[e.length-1])&&(e=e.slice(0,-1)),e.slice(1).join(` |
| 15 | `))}function Pd(n){return n.split(` |
| 16 | `).map(e=>(e=yn(e," "),e.startsWith(">")&&(e=e.slice(1)),e.startsWith(" ")?e.slice(1):e)).join(` |
| 17 | `)}function vl(n){let e=gn.exec(n.source),t={indent:e[1],bullet:null,number:null,delim:null};return n.ordered?(t.number=e[2].slice(0,-1),t.delim=e[2].slice(-1)):t.bullet=e[2],t}function Il(n){let e=kd.exec(n);return e?[n.slice(e[0].length),e[1]]:[n,null]}function ze(n){let e=new Ii(n),t=[],r="",i=()=>{r!==""&&t.push(ht(gd,{text:r,source:r})),r=""};for(let o=0;o<n.length;){let[s,l]=Bd(e,o);if(l===0){r+=n[o],o++;continue}i(),s.source=n.slice(o,o+l),t.push(s),o+=l}return i(),t}function ht(n,e){return{kind:n,text:"",target:"",anchor:"",url:"",source:"",...e}}var Ii=class{constructor(e){this.text=e,this.tables={}}next(e,t){var r;return t>=this.text.length?-1:((r=this.tables)[e]??(r[e]=Ld(this.text,Rd[e])),this.tables[e][t])}},Rd={label:(n,e)=>n[e]==="]"||n[e]===` |
| 18 | `,address:(n,e)=>`) |
| 19 | \f\r `.includes(n[e]),close:(n,e)=>n[e]==="]"&&n[e+1]==="]",open:(n,e)=>n[e]==="["||n[e]===` |
| 20 | `};function Ld(n,e){let t=new Int32Array(n.length),r=-1;for(let i=n.length-1;i>=0;i--)e(n,i)&&(r=i),t[i]=r;return t}function Bd(n,e){let t=n.text;if(t[e]==="`")return Fd(t.slice(e));if(t.startsWith("![[",e)){let r=Pl(n,e+3);if(r>=0)return[ht(pn,{text:t.slice(e,e+r+5)}),r+5]}else{if(t.startsWith("![",e))return $d(n,e);if(t.startsWith("[[",e))return Vd(n,e);if(t[e]==="["){let r=zd(n,e);if(r&&yl(r.url))return[ht(cr,{text:r.text,url:r.url}),r.width]}else if(t[e]==="h"&&Wd(t,e)){let r=bd.exec(t.slice(e));if(r)return[ht(cr,{text:r[0],url:r[0]}),r[0].length]}}return[null,0]}function zd(n,e){let t=n.text,r=n.next("label",e+1);if(r<=e+1||t[r]!=="]"||t[r+1]!=="(")return null;let i=n.next("address",r+2);return i<=r+2||t[i]!==")"||i-(r+2)>2048?null:{text:t.slice(e+1,r),url:t.slice(r+2,i),width:i+1-e}}function $d(n,e){let t=n.text,r=n.next("label",e+2);if(r<0||t[r]!=="]"||t[r+1]!=="("||r-(e+2)>ur||dr(t.slice(e+2,r))>ur)return[null,0];let i=n.next("open",e+2);if(i>=0&&i<r)return[null,0];let o=n.next("address",r+2);if(o<0||t[o]!==")")return[null,0];let s=t.slice(r+2,o);if(!s.startsWith(X))return[null,0];let l=s.slice(X.length);return mn(l)?[ht(Ze,{text:t.slice(e+2,r),target:l,url:s}),o+1-e]:[null,0]}function Fd(n){let e=n.slice(1).indexOf("`");return e<=0?[null,0]:[ht(Pi,{text:n.slice(1,e+1)}),e+2]}function Sl(n,e){let t=n.indexOf(e);return t<0?[n,""]:[n.slice(0,t),n.slice(t+1)]}function Vd(n,e){let t=Pl(n,e+2);if(t<0)return[null,0];let r=n.text.slice(e+2,e+t+2),[i,o]=Sl(r,"|"),s;if([i,s]=Sl(i,"#"),i=V(i),i==="")return[null,0];let l=ht(gt,{target:i,text:V(o)});return s.startsWith("^")&&(l.anchor=V(s.slice(1))),[l,t+4]}function Pl(n,e){let t=n.next("close",e);if(t<0)return-1;let r=n.next("open",e);return r>=0&&r<t?-1:t-e}function Wd(n,e){return e===0||` |
| 21 | (`.includes(n[e-1])}function $i(n){return xd.test(n)}function hr(n){return Le.test(n)}function Rl(n){return Ri.test(n)}function Ft(n){return Le.exec(n)?.[1]??null}function Qe(n,e){return yn(n," ").startsWith(e)}function W(n){if(!$i(n))return!1;let[e,t,r]=n.split("-").map(Number);if(t<1||t>12||r<1)return!1;let o=[31,e%4===0&&(e%100!==0||e%400===0)?29:28,31,30,31,30,31,31,30,31,30,31];return r<=o[t-1]}var qd=new RegExp(`\\*\\*\\*(${pt}(?:[^*]*?${pt})?)\\*\\*\\*`,"gu"),Kd=new RegExp(`\\*\\*(${pt}(?:[^*]*?${pt})?)\\*\\*`,"gu"),jd=new RegExp(`\\*(${pt}(?:[^*]*?${pt})?)\\*`,"gu"),Jd=/<\/?(?:em|strong)>/gu,Hd=/\n[ \t]*/gu;function Ud(n){return n.replace(/[&'<>"]/gu,e=>({"&":"&","'":"'","<":"<",">":">",'"':"""})[e])}function _d(n){return n.replace(/&(?:amp|#39|lt|gt|#34);/gu,e=>({"&":"&","'":"'","<":"<",">":">",""":'"'})[e])}function Ll(n){let e=Ud(n);e=e.replace(qd,"<em><strong>$1</strong></em>"),e=e.replace(Kd,"<strong>$1</strong>"),e=e.replace(jd,"<em>$1</em>");let t=[],r=0,i=0,o=0;for(let s of e.matchAll(Jd)){Cl(t,e.slice(o,s.index),r>0,i>0);let l=s[0][1]==="/"?-1:1;s[0].endsWith("em>")?r+=l:i+=l,o=s.index+s[0].length}return Cl(t,e.slice(o),r>0,i>0),t}function Cl(n,e,t,r){let i=0;for(let o of e.matchAll(Hd))Ml(n,e.slice(i,o.index),t,r),n.push({kind:"break",indent:o[0].slice(1),em:t,strong:r}),i=o.index+o[0].length;Ml(n,e.slice(i),t,r)}function Ml(n,e,t,r){e!==""&&n.push({kind:"text",text:_d(e),em:t,strong:r})}function Bl({id:n,alt:e},t){return t?.available?["img",{src:X+n,alt:e??"",width:String(t.width),height:String(t.height),loading:"lazy",decoding:"async"}]:["span",{"mapa-image":"unavailable"},"Image not available"]}function zl(n){return n.isTextblock&&n.childCount===1&&n.firstChild.type.name==="image"}function pr(n){return n.attrs.marker?{id:`b-${n.attrs.marker}`}:{}}var $l={origin:{default:null},marker:{default:null}},Yd={doc:{content:"block+"},paragraph:{group:"block flow",content:"inline*",attrs:{...$l},parseDOM:[{tag:"p"}],toDOM:n=>["p",pr(n),0]},heading:{group:"block flow",content:"inline*",defining:!0,attrs:{...$l,level:{default:1},source:{default:null}},parseDOM:[1,2,3,4,5,6].map(n=>({tag:`h${n}`,attrs:{level:Math.max(n-1,1)}})),toDOM:n=>[`h${Math.min(n.attrs.level+1,6)}`,pr(n),0]},bullet_list:{group:"block flow",content:"list_item+",parseDOM:[{tag:"ul"}],toDOM:()=>["ul",0]},ordered_list:{group:"block flow",content:"list_item+",parseDOM:[{tag:"ol"}],toDOM:()=>["ol",0]},list_item:{content:"paragraph (bullet_list | ordered_list)*",defining:!0,attrs:{marker:{default:null},indent:{default:""},bullet:{default:"-"},number:{default:null},delim:{default:null},task:{default:!1},checked:{default:null}},parseDOM:[{tag:"li",getAttrs:n=>{let e=n.getAttribute("mapa-task");return e==="open"?{task:!0,checked:" "}:e==="done"?{task:!0,checked:"x"}:{}}}],toDOM:n=>{let e=pr(n);return n.attrs.task&&(e["mapa-task"]=n.attrs.checked===" "?"open":"done"),["li",e,0]}},blockquote:{group:"block flow",content:"paragraph",defining:!0,attrs:{marker:{default:null},prefix:{default:null}},parseDOM:[{tag:"blockquote"}],toDOM:n=>["blockquote",pr(n),0]},code_block:{group:"block flow",content:"text*",marks:"",code:!0,defining:!0,attrs:{origin:{default:null},fence:{default:"```"},info:{default:""},closed:{default:!0},close:{default:"```"}},parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>["pre",["code",0]]},columns:{group:"block",content:"column{2,4}",defining:!0,attrs:{fence:{default:4},openOrigin:{default:null},closeOrigin:{default:null}},parseDOM:[{tag:"div[mapa-columns]"}],toDOM:n=>["div",{"mapa-columns":String(n.childCount)},0]},column:{content:"flow+",isolating:!0,defining:!0,attrs:{fence:{default:3},openOrigin:{default:null},closeOrigin:{default:null}},parseDOM:[{tag:"div[mapa-column]"}],toDOM:()=>["div",{"mapa-column":""},0]},horizontal_rule:{group:"block flow",attrs:{origin:{default:null},source:{default:"---"}},parseDOM:[{tag:"hr"}],toDOM:()=>["hr"]},text:{group:"inline"},hard_break:{inline:!0,group:"inline",selectable:!1,attrs:{indent:{default:""}},parseDOM:[{tag:"br"}],toDOM:()=>["br"]}},Gd={link:{attrs:{href:{},bare:{default:!1}},inclusive:!1,excludes:"em strong code",parseDOM:[{tag:"a[href]",getAttrs:n=>Re(n.getAttribute("href"))?{href:n.getAttribute("href")}:!1}],toDOM:n=>["a",{href:n.attrs.href,rel:"noopener noreferrer"},0]},em:{parseDOM:[{tag:"em"},{tag:"i"},{style:"font-style=italic"}],toDOM:()=>["em",0]},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:n=>n.style?.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[6-9]\d{2,})$/u.test(n)&&null}],toDOM:()=>["strong",0]},code:{excludes:"_",parseDOM:[{tag:"code"}],toDOM:()=>["code",0]}};function Fi(n){let e="";for(let t of n.childNodes)t.nodeType===3&&(e+=t.nodeValue);return e.trim()}function Xd(n,e){let t={inline:!0,group:"inline",atom:!0,selectable:!0};return{wikilink:{...t,attrs:{target:{},anchor:{default:""},shown:{default:""},source:{default:null},origin:{default:null}},parseDOM:[{tag:"a[mapa-chip]",priority:60,getAttrs:r=>{if(/^\/d\/([0-9]{4}-[0-9]{2}-[0-9]{2})$/u.exec(r.getAttribute("href")??""))return!1;let o=Fi(r);return o===""?!1:{target:o}}}],toDOM:r=>Ei(r.attrs,n(r.attrs.target,r.attrs.anchor))},datelink:{...t,attrs:{date:{},anchor:{default:""},shown:{default:""},source:{default:null},origin:{default:null}},parseDOM:[{tag:"a[mapa-chip]",priority:61,getAttrs:r=>{let i=/^\/d\/([0-9]{4}-[0-9]{2}-[0-9]{2})$/u.exec(r.getAttribute("href")??"");return i&&W(i[1])?{date:i[1]}:!1}}],toDOM:r=>Ei({...r.attrs,target:r.attrs.date},n(r.attrs.date,r.attrs.anchor))},embed:{...t,attrs:{ref:{},source:{default:null},origin:{default:null}},parseDOM:[{tag:'span[mapa-chip="embed"]',priority:60,getAttrs:r=>Fi(r)===""?!1:{ref:Fi(r)}}],toDOM:r=>ml(r.attrs.ref)},image:{...t,draggable:!0,attrs:{id:{},alt:{default:""},source:{default:null},origin:{default:null}},parseDOM:[{tag:"img[src]",getAttrs:r=>{let i=r.getAttribute("src")??"",o=i.startsWith(X)?i.slice(X.length):"";return mn(o)?{id:o,alt:Vi(r.getAttribute("alt")??"")}:!1}}],toDOM:r=>Bl(r.attrs,e(r.attrs.id))}}}function Vi(n){let e="",t=0;for(let r of n.replace(/[[\]\r\n]/gu,"")){let i=r.codePointAt(0),o=i<128?1:i<2048?2:i<65536?3:4;if(t+o>1e3)break;t+=o,e+=r}return e}var Zd=()=>null,Qd=n=>({href:`/new?title=${encodeURIComponent(n)}`,pending:!0});function mr(n=Qd,e=Zd){return new or({nodes:{...Yd,...Xd(n,e)},marks:Gd})}var Wl=65535,ql=Math.pow(2,16);function eh(n,e){return n+e*ql}function Fl(n){return n&Wl}function th(n){return(n-(n&Wl))/ql}var Kl=1,jl=2,gr=4,Jl=8,kn=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Jl)>0}get deletedBefore(){return(this.delInfo&(Kl|gr))>0}get deletedAfter(){return(this.delInfo&(jl|gr))>0}get deletedAcross(){return(this.delInfo&gr)>0}},$e=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=Fl(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+th(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+s],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,h=a+i+(d<0?0:u);if(r)return h;let p=e==(t<0?a:f)?null:eh(l/3,e-a),m=e==a?jl:e==f?Kl:gr;return(t<0?e!=a:e!=f)&&(m|=Jl),new kn(h,m,p)}i+=u-c}return r?e+i:new kn(e+i,0,null)}touches(e,t){let r=0,i=Fl(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};$e.empty=new $e([]);var wn=class n{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new kn(e,i,null)}},Wi=Object.create(null),L=class{getMap(){return $e.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Wi[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Wi)throw new RangeError("Duplicate use of step JSON ID "+e);return Wi[e]=t,t.prototype.jsonID=e,t}},q=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,i){try{return n.ok(e.replace(t,r,i))}catch(o){if(o instanceof Ge)return n.fail(o.message);throw o}}};function Hi(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let o=n.child(i);o.content.size&&(o=o.copy(Hi(o.content,e,o))),o.isInline&&(o=e(o,t,i)),r.push(o)}return b.fromArray(r)}var Sn=class n extends L{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new x(Hi(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,o)}invert(){return new bt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};L.jsonID("addMark",Sn);var bt=class n extends L{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new x(Hi(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,r)}invert(){return new Sn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};L.jsonID("removeMark",bt);var Cn=class n extends L{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new x(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new n(this.pos,t.marks[i]);return new n(this.pos,this.mark)}}return new Vt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};L.jsonID("addNodeMark",Cn);var Vt=class n extends L{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new x(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Cn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};L.jsonID("removeNodeMark",Vt);var te=class n extends L{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&ji(e,this.from,this.to)?q.fail("Structure replace would overwrite content"):q.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new $e([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new n(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?x.empty:new x(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?x.empty:new x(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new n(t.from,t.to,x.fromJSON(e,t.slice),!!t.structure)}};te.MAP_BIAS=1;L.jsonID("replace",te);var B=class n extends L{constructor(e,t,r,i,o,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(ji(e,this.from,this.gapFrom)||ji(e,this.gapTo,this.to)))return q.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return q.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?q.fromReplace(e,this.from,this.to,r):q.fail("Content does not fit in gap")}getMap(){return new $e([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 n(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||o>r.pos?null:new n(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,x.fromJSON(e,t.slice),t.insert,!!t.structure)}};L.jsonID("replaceAround",B);function ji(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function nh(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(f);for(let m=0;m<f.length;m++)f[m].isInSet(p)||(s&&s.to==d&&s.mark.eq(f[m])?s.to=h:i.push(s=new bt(d,h,f[m])));l&&l.to==d?l.to=h:o.push(l=new Sn(d,h,r))}}),i.forEach(a=>n.step(a)),o.forEach(a=>n.step(a))}function rh(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof un){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==o-1&&f.eq(i[h].style)&&(d=p)}d?(d.to=c,d.step=o):i.push({style:f,from:Math.max(l,e),to:c,step:o})}}}),i.forEach(s=>n.step(new bt(s.from,s.to,s.style)))}function Ui(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)s.push(new te(l,u,x.empty));else{r=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||n.step(new bt(l,u,c.marks[d]));if(i&&c.isText&&t.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new x(b.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new te(l+d.index,l+d.index+d[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(b.empty,!0);n.replace(l,l,new x(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function ih(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function qt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,o=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-o;if(r<n.depth&&s.canReplace(l,a,t))return r;if(r==0||s.type.spec.isolating||!ih(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function oh(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,c=l,u=b.empty,f=0;for(let p=o,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,u=b.from(r.node(p).copy(u)),f++):a--;let d=b.empty,h=0;for(let p=o,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,d=b.from(i.node(p).copy(d)),h++):c++;n.step(new B(a,c,s,l,new x(u.append(d),f,h),u.size-f,!0))}function Kt(n,e,t=null,r=n){let i=sh(n,e),o=i&&lh(r,e);return o?i.map(Vl).concat({type:e,attrs:t}).concat(o.map(Vl)):null}function Vl(n){return{type:n,attrs:null}}function sh(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(r,i,s)?o:null}function lh(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function ah(n,e,t){let r=b.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=b.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new B(i,o,i,o,new x(r,0,0),t.length,!0))}function ch(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,a)&&uh(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Ul(n,s,l,o),Ui(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let u=n.mapping.slice(o),f=u.map(l,1),d=u.map(l+s.nodeSize,1);return n.step(new B(f,d,f+1,d-1,new x(b.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Hl(n,s,l,o),!1}})}function Hl(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Ul(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+o);n.replaceWith(s,s+1,e.type.schema.text(` |
| 22 | `))}})}function uh(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function fh(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new B(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new x(b.from(s),0,0),1,!0))}function et(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>o;c--,u--){let f=i.node(c),d=i.index(c);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(d,f.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function dh(n,e,t=1,r){let i=n.doc.resolve(e),o=b.empty,s=b.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){o=b.from(i.node(l).copy(o));let u=r&&r[c];s=b.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}n.step(new te(e,e,new x(o.append(s),t,t),!0))}function Mn(n,e){let t=n.resolve(e),r=t.index();return ph(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function hh(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?n.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(o.marks))return!1}return t.validEnd}function ph(n,e){return!!(n&&e&&!n.isLeaf&&hh(n,e))}function mh(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,o=n.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Ul(n,u.node(),u.before(),l)}s.inlineContent&&Ui(n,e+t-1,s,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new te(c,a.map(e+t,-1),x.empty,!0)),r===!0){let u=n.doc.resolve(c);Hl(n,u.node(),u.before(),n.steps.length)}return n}function gh(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function kr(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(o==1)u=c.canReplace(a,a,i);else{let f=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function wr(n,e,t=e,r=x.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return _l(i,o,r)?new te(e,t,r):new Ji(i,o,r).fit()}function _l(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Ji=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=b.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=b.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new x(o,s,l);return e>-1?new B(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new te(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=qi(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(s?c.matchType(s.type)||(f=c.fillBefore(b.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=qi(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new x(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=qi(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new x(bn(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new x(bn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m<o.length;m++)this.openFrontierNode(o[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)u.push(i.child(m));f=f.matchFragment(i)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=f.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(f=g,u.push(Yl(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=xn(this.placed,t,b.from(u)),this.frontier[t].match=f,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?x.empty:new x(bn(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new x(bn(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ki(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Ki(e,t,i,r,o);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Ki(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=xn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=xn(this.placed,this.depth,b.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=xn(this.placed,this.frontier.length,t))}};function bn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(bn(n.firstChild.content,e-1,t)))}function xn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(xn(n.lastChild.content,e-1,t)))}function qi(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Yl(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Yl(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(b.empty,!0)))),n.copy(r)}function Ki(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!yh(t,o.content,s)?l:null}function yh(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function bh(n){return n.spec.defining||n.spec.definingForContent}function xh(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),o=n.doc.resolve(t);if(_l(i,o,r))return n.step(new te(e,t,r));let s=Xl(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let d=i.depth,h=i.pos-1;d>0;d--,h--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==h&&s.splice(1,0,-d)}let a=s.indexOf(l),c=[],u=r.openStart;for(let d=r.content,h=0;;h++){let p=d.firstChild;if(c.push(p),h==r.openStart)break;d=p.content}for(let d=u-1;d>=0;d--){let h=c[d],p=bh(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=d;else if(p||!h.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let h=(d+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<s.length;m++){let g=s[(m+a)%s.length],y=!0;g<0&&(y=!1,g=-g);let C=i.node(g-1),O=i.index(g-1);if(C.canReplaceWith(O,O,p.type,p.marks))return n.replace(i.before(g),y?o.after(g):t,new x(Gl(r.content,0,r.openStart,h),h,r.openEnd))}}let f=n.steps.length;for(let d=s.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let h=s[d];h<0||(e=i.before(h),t=o.after(h))}}function Gl(n,e,t,r,i){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(Gl(o.content,e+1,t,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(b.empty,!0))}return n}function kh(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=gh(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new x(b.from(r),0,0))}function wh(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let s=r.sharedDepth(t),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>s;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);r=n.doc.resolve(e),i=n.doc.resolve(t)}}let o=Xl(r,i);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function Xl(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(o<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}var yr=class n extends L{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return q.fromReplace(e,this.pos,this.pos+1,new x(b.from(i),0,t.isLeaf?0:1))}getMap(){return $e.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};L.jsonID("attr",yr);var br=class n extends L{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return q.ok(r)}getMap(){return $e.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};L.jsonID("docAttr",br);var Wt=class extends Error{};Wt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Wt.prototype=Object.create(Error.prototype);Wt.prototype.constructor=Wt;Wt.prototype.name="TransformError";var xr=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new wn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Wt(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}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((o,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=x.empty){let i=wr(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new x(b.from(r),0,0))}delete(e,t){return this.replace(e,t,x.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return xh(this,e,t,r),this}replaceRangeWith(e,t,r){return kh(this,e,t,r),this}deleteRange(e,t){return wh(this,e,t),this}lift(e,t){return oh(this,e,t),this}join(e,t=1){return mh(this,e,t),this}wrap(e,t){return ah(this,e,t),this}setBlockType(e,t=e,r,i=null){return ch(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return fh(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new yr(e,t,r)),this}setDocAttribute(e,t){return this.step(new br(e,t)),this}addNodeMark(e,t){return this.step(new Cn(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof T)t.isInSet(r.marks)&&this.step(new Vt(e,t));else{let i=r.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new Vt(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return dh(this,e,t,r),this}addMark(e,t,r){return nh(this,e,t,r),this}removeMark(e,t,r){return rh(this,e,t,r),this}clearIncompatible(e,t,r){return Ui(this,e,t,r),this}};var _i=Object.create(null),M=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Jt(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=x.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?x.empty:t),l==0&&ea(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),ea(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new k(e):jt(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?jt(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):jt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new se(e.node(0))}static atStart(e){return jt(e,e,0,0,1)||new se(e)}static atEnd(e){return jt(e,e,e.content.size,e.childCount,-1)||new se(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=_i[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in _i)throw new RangeError("Duplicate use of selection JSON ID "+e);return _i[e]=t,t.prototype.jsonID=e,t}getBookmark(){return k.between(this.$anchor,this.$head).getBookmark()}};M.prototype.visible=!0;var Jt=class{constructor(e,t){this.$from=e,this.$to=t}},Zl=!1;function Ql(n){!Zl&&!n.parent.inlineContent&&(Zl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var k=class n extends M{constructor(e,t=e){Ql(e),Ql(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return M.near(r);let i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(e,t=x.empty){if(super.replace(e,t),t==x.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Cr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=M.findFrom(t,r,!0)||M.findFrom(t,-r,!0);if(o)t=o.$head;else return M.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(M.findFrom(e,-r,!0)||M.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new n(e,t)}};M.jsonID("text",k);var Cr=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return k.between(e.resolve(this.anchor),e.resolve(this.head))}},w=class n extends M{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),o=e.resolve(i);return r?M.near(o):new n(o)}content(){return new x(b.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Gi(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};w.prototype.visible=!1;M.jsonID("node",w);var Gi=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Cr(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&w.isSelectable(r)?new w(t):M.near(t)}},se=class n extends M{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=x.empty){if(t==x.empty){e.delete(0,e.doc.content.size);let r=M.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return Sh}};M.jsonID("all",se);var Sh={map(){return this},resolve(n){return new se(n)}};function jt(n,e,t,r,i,o=!1){if(e.inlineContent)return k.create(n,t);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&w.isSelectable(l))return w.create(n,t-(i<0?l.nodeSize:0))}else{let a=jt(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function ea(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof te||i instanceof B))return;let o=n.mapping.maps[r],s;o.forEach((l,a,c,u)=>{s==null&&(s=u)}),n.setSelection(M.near(n.doc.resolve(s),t))}var ta=1,Sr=2,na=4,Xi=class extends xr{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|ta)&~Sr,this.storedMarks=null,this}get selectionSet(){return(this.updated&ta)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Sr,this}ensureMarks(e){return T.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Sr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Sr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||T.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(M.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=na,this}get scrolledIntoView(){return(this.updated&na)>0}};function ra(n,e){return!e||!n?n:n.bind(e)}var xt=class{constructor(e,t,r){this.name=e,this.init=ra(t.init,r),this.apply=ra(t.apply,r)}},Ch=[new xt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new xt("selection",{init(n,e){return n.selection||M.atStart(e.doc)},apply(n){return n.selection}}),new xt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new xt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],On=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ch.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new xt(r.key,r.spec.state,r))})}},Mr=class n{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,c=i?i[s].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),o=!0}i&&(i[s]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Xi(this)}static create(e){let t=new On(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new On(this.schema,e.plugins),r=t.fields,i=new n(t);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new On(e.schema,e.plugins),o=new n(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=Se.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=M.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function ia(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ia(i,e,{})),t[r]=i}return t}var S=class{constructor(e){this.spec=e,this.props={},e.props&&ia(e.props,this,this.props),this.key=e.key?e.key.key:oa("plugin")}getState(e){return e[this.key]}},Yi=Object.create(null);function oa(n){return n in Yi?n+"$"+ ++Yi[n]:(Yi[n]=0,n+"$")}var N=class{constructor(e="key"){this.key=oa(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var K=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Yt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},no=null,Ve=function(n,e,t){let r=no||(no=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Mh=function(){no=null},Tt=function(n,e,t,r){return t&&(sa(n,e,t,r,-1)||sa(n,e,t,r,1))},Oh=/^(img|br|input|textarea|hr)$/i;function sa(n,e,t,r,i){for(var o;;){if(n==t&&e==r)return!0;if(e==(i<0?0:ue(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Rn(n)||Oh.test(n.nodeName)||n.contentEditable=="false")return!1;e=K(n)+(i<0?0:1),n=s}else if(n.nodeType==1){let s=n.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else n=s,e=i<0?ue(n):0}else return!1}}function ue(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Dh(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ue(n)}else if(n.parentNode&&!Rn(n))e=K(n),n=n.parentNode;else return null}}function Th(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Rn(n))e=K(n)+1,n=n.parentNode;else return null}}function Ah(n,e,t){for(let r=e==0,i=e==ue(n);r||i;){if(n==t)return!0;let o=K(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==ue(n)}}function Rn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}var Br=function(n){return n.focusNode&&Tt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function kt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Eh(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Nh(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(ue(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(ue(r.startContainer),r.startOffset)}}}var De=typeof navigator<"u"?navigator:null,la=typeof document<"u"?document:null,ot=De&&De.userAgent||"",ro=/Edge\/(\d+)/.exec(ot),Ba=/MSIE \d/.exec(ot),io=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ot),ne=!!(Ba||io||ro),rt=Ba?document.documentMode:io?+io[1]:ro?+ro[1]:0,fe=!ne&&/gecko\/(\d+)/i.test(ot);fe&&+(/Firefox\/(\d+)/.exec(ot)||[0,0])[1];var oo=!ne&&/Chrome\/(\d+)/.exec(ot),j=!!oo,za=oo?+oo[1]:0,_=!ne&&!!De&&/Apple Computer/.test(De.vendor),Gt=_&&(/Mobile\/\w+/.test(ot)||!!De&&De.maxTouchPoints>2),ce=Gt||(De?/Mac/.test(De.platform):!1),$a=De?/Win/.test(De.platform):!1,We=/Android \d/.test(ot),Ln=!!la&&"webkitFontSmoothing"in la.documentElement.style,vh=Ln?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ih(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Fe(n,e){return typeof n=="number"?n:n[e]}function Ph(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function aa(n,e,t){if(!so(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(s.nodeType!=1){s=Yt(s);continue}let l=s,a=l==o.body,c=a?Ih(o):Ph(l),u=0,f=0;if(e.top<c.top+Fe(r,"top")?f=-(c.top-e.top+Fe(i,"top")):e.bottom>c.bottom-Fe(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Fe(i,"top")-c.top:e.bottom-c.bottom+Fe(i,"bottom")),e.left<c.left+Fe(r,"left")?u=-(c.left-e.left+Fe(i,"left")):e.right>c.right-Fe(r,"right")&&(u=e.right-c.right+Fe(i,"right")),u||f)if(a)o.defaultView.scrollBy(u,f);else{let h=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let m=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let d=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:Yt(s)}}function Rh(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(o,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Fa(n.dom)}}function Fa(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Yt(r));return e}function Lh({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Va(t,r==0?0:r-e)}function Va(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:o}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}var Ht=null;function Bh(n){if(n.setActive)return n.setActive();if(Ht)return n.focus(Ht);let e=Fa(n);n.focus(Ht==null?{get preventScroll(){return Ht={preventScroll:!0},!0}}:void 0),Ht||(Ht=!1,Va(e,0))}function Wa(n,e){let t,r=2e8,i,o=0,s=e.top,l=e.top,a,c;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let d;if(u.nodeType==1)d=u.getClientRects();else if(u.nodeType==3)d=Ve(u).getClientRects();else continue;for(let h=0;h<d.length;h++){let p=d[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){t=u,r=m,i=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&m&&(o=f+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=f+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?zh(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:Wa(t,i)}function zh(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=tt(r,1);if(s.top!=s.bottom&&Co(e,s)){i={node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function Co(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function $h(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Fh(n,e,t){let{node:r,offset:i}=Wa(e,t),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function Vh(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function qa(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),o=i;;){let s=n.childNodes[o];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Co(e,c))return qa(s,e,c)}}if((o=(o+1)%r)==i)break}return n}function Wh(n,e){let t=n.dom.ownerDocument,r,i=0,o=Nh(t,e.left,e.top);o&&({node:r,offset:i}=o);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=n.dom.getBoundingClientRect();if(!Co(e,c)||(s=qa(n.dom,e,c),!s))return null}if(_)for(let c=s;r&&c;c=Yt(c))c.draggable&&(r=void 0);if(s=$h(s,e),r){if(fe&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let c;Ln&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=Vh(n,r,i,e))}l==null&&(l=Fh(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function so(n){return n.top<n.bottom||n.left<n.right}function tt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(so(r))return r}return Array.prototype.find.call(t,so)||n.getBoundingClientRect()}var qh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ka(n,e,t){let{node:r,offset:i,atom:o}=n.docView.domFromPos(e,t<0?-1:1),s=Ln||fe;if(r.nodeType==3)if(s&&(qh.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=tt(Ve(r,i,i),t);if(fe&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=tt(Ve(r,i-1,i-1),-1);if(c.top==a.top){let u=tt(Ve(r,i,i+1),-1);if(u.top!=a.top)return Dn(u,u.left<c.left)}}return a}else{let a=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Dn(tt(Ve(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==ue(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Zi(a.getBoundingClientRect(),!1)}if(o==null&&i<ue(r)){let a=r.childNodes[i];if(a.nodeType==1)return Zi(a.getBoundingClientRect(),!0)}return Zi(r.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==ue(r))){let a=r.childNodes[i-1],c=a.nodeType==3?Ve(a,ue(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Dn(tt(c,1),!1)}if(o==null&&i<ue(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ve(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return Dn(tt(c,-1),!0)}return Dn(tt(r.nodeType==3?Ve(r):r,-t),t>=0)}function Dn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Zi(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function ja(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Kh(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return ja(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Ka(n,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ve(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var jh=/[\u0590-\u08ac]/;function Jh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return l?!jh.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:ja(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),g}):r.pos==r.start()||r.pos==r.end()}var ca=null,ua=null,fa=!1;function Hh(n,e,t){return ca==e&&ua==t?fa:(ca=e,ua=t,fa=t=="up"||t=="down"?Kh(n,e,t):Jh(n,e,t))}var de=0,da=1,wt=2,be=3,At=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=de,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>K(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],l=o+s.size;if(l>e||s instanceof Tr){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Or&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?K(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?K(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(i==-1&&e<=c){let u=s+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=K(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=K(f.dom);break}t+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(o>p&&s<g)return m.setSelection(e-p-m.border,t-p-m.border,r,i);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((fe||_)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(f=!!(p&&h.nodeValue[p-1]==` |
| 23 | `),f&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:K(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];f=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(fe&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||f&&_)&&Tt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Tt(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(f&&fe)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&t>=r:e<s&&t>r){let l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?wt:da,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=be:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?wt:be}r=s}this.dirty=wt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?wt:da;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Or=class extends At{constructor(e,t,r,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.hasAttribute("contenteditable")||(s.contentEditable="false"),s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==de&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},lo=class extends At{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Ct=class n extends At{constructor(e,t,r,i,o){super(e,[],r,i),this.mark=t,this.spec=o}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=re.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&be||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=be&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=de){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=de}}slice(e,t,r){let i=n.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;t<s&&(o=fo(o,t,s,r)),e>0&&(o=fo(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},it=class n extends At{constructor(e,t,r,i,o,s,l){super(e,[],o,s),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,o,s){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,f=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=re.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=Ua(u,r,t),c?a=new ao(e,t,r,i,u,f||null,d,c):t.isText?new Dr(e,t,r,i,u,d):new n(e,t,r,i,u,f||null,d)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let i=this.children[r];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(i=>i.nodeType==1&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));r?t.contentElement=r:t.getContent=()=>b.empty}}return t}matchesNode(e,t,r){return this.dirty==de&&e.eq(this.node)&&Ar(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new uo(this,s&&s.node,e);Gh(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?T.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,i)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e,d);let h;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,f,h,e)||a.updateNextNode(c,u,f,e,d,i)||a.addNode(c,u,f,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==wt)&&(s&&this.protectLocalComposition(e,s),Ja(this.contentDOM,this.children,e),Gt&&Xh(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof k)||r<t||i>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 s=o.nodeValue,l=Zh(this.node.content,s,r-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new lo(this,o,t,i);e.input.compositionNodes.push(s),this.children=fo(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==be||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=de}updateOuterDeco(e){if(Ar(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Ha(this.dom,this.nodeDOM,co(this.outerDeco,this.node,t),co(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function ha(n,e,t,r,i){Ua(r,e,n);let o=new it(void 0,n,e,t,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}var Dr=class n extends it{constructor(e,t,r,i,o,s){super(e,t,r,i,o,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==be||this.dirty!=de&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=de||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=de,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=be)}get domAtom(){return!1}isText(e){return this.node.text==e}},Tr=class extends At{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==de&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},ao=class extends it{constructor(e,t,r,i,o,s,l,a){super(e,t,r,i,o,s,l),this.spec=a}update(e,t,r,i){if(this.dirty==be)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Ja(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=pa(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(s instanceof Ct){let a=r?r.previousSibling:n.lastChild;Ja(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=pa(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}var An=function(n){n&&(this.nodeName=n)};An.prototype=Object.create(null);var St=[new An];function co(n,e,t){if(n.length==0)return St;let r=t?St[0]:new An,i=[r];for(let o=0;o<n.length;o++){let s=n[o].type.attrs;if(s){s.nodeName&&i.push(r=new An(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&i.length==1&&i.push(r=new An(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function Ha(n,e,t,r){if(t==St&&r==St)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],l=t[o];if(o){let a;l&&l.nodeName==s.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=St[0]),i=a}Uh(i,l||St[0],s)}return i}function Uh(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&n.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&n.classList.add(i[o]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function Ua(n,e,t){return Ha(n,n,St,co(e,t,n.nodeType!=1))}function Ar(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function pa(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var uo=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=_h(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,i){let o=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;o<l&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=de,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let f=this.top.children[u];if(f.matchesMark(e[s])&&!this.isLocked(f.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof Ct&&u.dirty!=be&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=Ct.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,r,i,o){let s=this.top.children[i];return s.dirty==be&&s.dom==s.contentDOM&&(s.dirty=wt),s.update(e,t,r,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof it){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,f,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=be&&Ar(t,a.outerDeco));if(!d&&a.update(e,t,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,e,t,r,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=wt,f.updateChildren(i,s+1),f.dirty=de),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ar(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=it.create(this.top,t,r,i,o,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,i,o){let s=it.create(this.top,e,t,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new Or(this.top,e,t,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ct;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Dr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((_||j)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Tr(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function _h(n,e){let t=e,r=t.children.length,i=n.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Ct)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function Yh(n,e){return n.type.side-e.type.side}function Gh(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,f;for(;s<i.length&&i[s].to==o;){let g=i[s++];g.widget&&(u?(f||(f=[u])).push(g):u=g)}if(u)if(f){f.sort(Yh);for(let g=0;g<f.length;g++)t(f[g],c,!!a)}else t(u,c,!!a);let d,h;if(a)h=-1,d=a,a=null;else if(c<n.childCount)h=c,d=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=o&&l.splice(g--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let p=o+d.nodeSize;if(d.isText){let g=p;s<i.length&&i[s].from<g&&(g=i[s].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=d.cut(g-o),d=d.cut(0,g-o),p=g,h=-1)}else for(;s<i.length&&i[s].to<p;)s++;let m=d.isInline&&!d.isLeaf?l.filter(g=>!g.inline):l.slice();r(d,m,e.forChild(o,d),h),o=p}}function Xh(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Zh(n,e,t,r){for(let i=0,o=0;i<n.childCount&&o<=r;){let s=n.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<n.childCount;){let c=n.child(i++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function fo(n,e,t,r,i){let o=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,u=l+=a.size;c>=t||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),i&&(o.push(i),i=void 0),u>t&&o.push(a.slice(t-c,a.size,r)))}return o}function Mo(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Br(t)){for(a=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&w.isSelectable(f)&&i.parent&&!(f.isInline&&Ah(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new w(s==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=s,d=s;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,s]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(s)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!o?1:-1;c=Oo(n,u,l,f)}return c}function _a(n){return n.editable?n.hasFocus():Ga(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ke(n,e=!1){let t=n.state.selection;if(Ya(n,t),!_a(n))return;let r=n.input.mouseDown;if(!e&&j&&r){let i=n.domSelectionRange(),o=n.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&Tt(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)&&r.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)ep(n);else{let{anchor:i,head:o}=t,s,l;ma&&!(t instanceof k)&&(t.$from.parent.inlineContent||(s=ga(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=ga(n,t.to))),n.docView.setSelection(i,o,n,e),ma&&(s&&ya(s),l&&ya(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Qh(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}var ma=_||j&&za<63;function ga(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,o=r?t.childNodes[r-1]:null;if(_&&i&&i.contentEditable=="false")return Qi(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Qi(i);if(o)return Qi(o)}}function Qi(n){return n.contentEditable="true",_&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ya(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Qh(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!_a(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function ep(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,K(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&ne&&rt<=11&&(t.disabled=!0,t.disabled=!1)}function Ya(n,e){if(e instanceof w){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ba(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ba(n)}function ba(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Oo(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||k.between(e,t,r)}function xa(n){return n.editable&&!n.hasFocus()?!1:Ga(n)}function Ga(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function tp(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Tt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function ho(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&M.findFrom(o,e)}function nt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ka(n,e,t){let r=n.state.selection;if(r instanceof k)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return nt(n,new k(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=ho(n.state,e);return i&&i instanceof w?nt(n,i):!1}else if(!(ce&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?w.isSelectable(o)?nt(n,new w(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Ln?nt(n,new k(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof w&&r.node.isInline)return nt(n,new k(e>0?r.$to:r.$from));{let i=ho(n.state,e);return i?nt(n,i):!1}}}function Er(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function En(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Ut(n,e){return e<0?np(n):rp(n)}function np(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(fe&&t.nodeType==1&&r<Er(t)&&En(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(En(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Xa(t))break;{let l=t.previousSibling;for(;l&&En(l,-1);)i=t.parentNode,o=K(l),l=l.previousSibling;if(l)t=l,r=Er(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?po(n,t,r):i&&po(n,i,o)}function rp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Er(t),o,s;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(En(l,1))o=t,s=++r;else break}else{if(Xa(t))break;{let l=t.nextSibling;for(;l&&En(l,1);)o=l.parentNode,s=K(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=Er(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}o&&po(n,o,s)}function Xa(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function ip(n,e){for(;n&&e==n.childNodes.length&&!Rn(n);)e=K(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function op(n,e){for(;n&&!e&&!Rn(n);)e=K(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function po(n,e,t){if(e.nodeType!=3){let o,s;(s=ip(e,t))?(e=s,t=0):(o=op(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Br(r)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&Ke(n)},50)}function wa(n,e){let t=n.state.doc.resolve(e);if(!(j||$a)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Sa(n,e,t){let r=n.state.selection;if(r instanceof k&&!r.empty||t.indexOf("s")>-1||ce&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=ho(n.state,e);if(s&&s instanceof w)return nt(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof se?M.near(s,e):M.findFrom(s,e);return l?nt(n,l):!1}return!1}function Ca(n,e){if(!(n.state.selection instanceof k))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function Ma(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function sp(n){if(!_||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Ma(n,r,"true"),setTimeout(()=>Ma(n,r,"false"),20)}return!1}function lp(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ap(n,e){let t=e.keyCode,r=lp(e);if(t==8||ce&&t==72&&r=="c")return Ca(n,-1)||Ut(n,-1);if(t==46&&!e.shiftKey||ce&&t==68&&r=="c")return Ca(n,1)||Ut(n,1);if(t==13||t==27)return!0;if(t==37||ce&&t==66&&r=="c"){let i=t==37?wa(n,n.state.selection.from)=="ltr"?-1:1:-1;return ka(n,i,r)||Ut(n,i)}else if(t==39||ce&&t==70&&r=="c"){let i=t==39?wa(n,n.state.selection.from)=="ltr"?1:-1:1;return ka(n,i,r)||Ut(n,i)}else{if(t==38||ce&&t==80&&r=="c")return Sa(n,-1,r)||Ut(n,-1);if(t==40||ce&&t==78&&r=="c")return sp(n)||Sa(n,1,r)||Ut(n,1);if(r==(ce?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Do(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=n.someProp("clipboardSerializer")||re.fromSchema(n.state.schema),l=rc(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=nc[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` |
| 24 | |
| 25 | `);return{dom:a,text:d,slice:e}}function Za(n,e,t,r,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,o||r,n)}),o)return l=new x(b.from(n.state.schema.text(e.replace(/\r\n?/g,` |
| 26 | `))),0,0),n.someProp("transformPasted",d=>{l=d(l,n,!0)}),l;let f=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(f)l=f;else{let d=i.marks(),{schema:h}=n.state,p=re.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),s=dp(t),Ln&&hp(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||fn.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!cp.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=pp(Oa(l,+u[1],+u[2]),u[4]);else if(l=x.maxOpen(up(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=Oa(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n,a)}),l}var cp=/^(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 up(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&ec(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=tc(s[s.length-1],o.length));let u=Qa(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return b.from(s)}return n}function Qa(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,b.from(n));return n}function ec(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let o=ec(n,e,t,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(b.from(Qa(t,n,i+1))))}}function tc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,tc(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(b.empty,!0);return n.copy(t.append(r))}function mo(n,e,t,r,i,o){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(o=0),i<r-1&&(l=mo(l,e,t,r,i+1,o)),i>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(b.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function Oa(n,e,t){return e<n.openStart&&(n=new x(mo(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new x(mo(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var nc={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function rc(){return document.implementation.createHTMLDocument("title")}var Tn=null;function fp(n){let e=window.trustedTypes;if(!e)return n;if(!Tn){if(Tn=e.defaultPolicy)try{return Tn.createHTML(n)}catch{}Tn=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Tn.createHTML(n)}function dp(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=rc(),r=t.body,i=/<([a-z][^>\s]+)/i.exec(n),o;if((o=i&&nc[i[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=fp(n),o)for(let s=0;s<o.length;s++)r=r.querySelector(o[s])||r;for(let s=0;s<t.styleSheets.length;s++){let l=t.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let f=0;f<u.length;f++)u[f].style.cssText+=c.style.cssText}}}return r}function hp(n){let e=n.querySelectorAll(j?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function pp(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:o,openEnd:s}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{a.checkAttrs(r[l+1])}catch{break}i=b.from(a.create(r[l+1],i)),o++,s++}return new x(i,o,s)}var Z={},Q={},mp={touchstart:!0,touchmove:!0},go=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function gp(n){for(let e in Z){let t=Z[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{bp(n,r)&&!To(n,r)&&(n.editable||!(r.type in Q))&&t(n,r)},mp[e]?{passive:!0}:void 0)}_&&n.dom.addEventListener("input",()=>null),yo(n)}function qe(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function yp(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function yo(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>To(n,r))})}function To(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function bp(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function xp(n,e){!To(n,e)&&Z[e.type]&&(n.editable||!(e.type in Q))&&Z[e.type](n,e)}Q.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!sc(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(We&&j&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Gt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,kt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ap(n,t)?t.preventDefault():qe(n,"key")};Q.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Q.keypress=(n,e)=>{let t=e;if(sc(n)||!t.charCode||t.ctrlKey&&!t.altKey||ce&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof k)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i,o))&&n.dispatch(o()),t.preventDefault()}};function Bn(n){return{left:n.clientX,top:n.clientY}}function kp(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ao(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,l=>s>o.depth?l(n,t,o.nodeAfter,o.before(s),i,!0):l(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function zn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function wp(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&w.isSelectable(r)?(zn(n,new w(t),"pointer"),!0):!1}function Sp(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof w&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(w.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(zn(n,w.create(n.state.doc,i),"pointer"),!0):!1}function Cp(n,e,t,r,i){return Ao(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?Sp(n,t):wp(n,t))}function Mp(n,e,t,r){return Ao(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Op(n,e,t,r){return Ao(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Dp(n,t,r)}function Dp(n,e,t){if(t.button!=0)return!1;let r=ic(n,e,!0),i=n.state.doc;return r?(zn(n,r,"pointer"),r instanceof k&&i.eq(n.state.doc)&&(n.input.mouseDown=new xo(n,r)),!0):!1}function ic(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?k.create(r,0,r.content.size):null;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)return k.create(r,l+1,l+1+s.content.size);if(t&&w.isSelectable(s))return w.create(r,l)}return null}function Eo(n){return vr(n)}var oc=ce?"metaKey":"ctrlKey";Z.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Eo(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&kp(t,n.input.lastClick)&&!t[oc]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let s=n.posAtCoords(Bn(t));s&&(o=="singleClick"?n.input.mouseDown=new bo(n,s,t,!!r):(o=="doubleClick"?Mp:Op)(n,s.pos,s.inside,t)?t.preventDefault():qe(n,"pointer"))};var Nr=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},bo=class extends Nr{constructor(e,t,r,i){super(e),this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[oc],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,s=u.depth?u.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof w&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&fe&&!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()),qe(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||Ke(this.view)})}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(Bn(e))),this.updateAllowDefault(e),this.allowDefault||!t?qe(this.view,"pointer"):Cp(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||_&&this.mightDrag&&!this.mightDrag.node.isAtom||j&&!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)?(zn(this.view,M.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):qe(this.view,"pointer")}move(e){this.updateAllowDefault(e),qe(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},xo=class extends Nr{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),qe(this.view,"pointer");let t=this.view.posAtCoords(Bn(e)),r=t&&ic(this.view,t.inside,!1);if(!r)return;let{doc:i}=this.view.state,o=this.startSelection,[s,l]=r.from<o.from?[o.to,r.from]:[o.from,r.to];zn(this.view,k.create(i,s,l),"pointer")}};Z.touchstart=n=>{n.input.lastTouch=Date.now(),Eo(n),qe(n,"pointer")};Z.touchmove=n=>{n.input.lastTouch=Date.now(),qe(n,"pointer")};Z.contextmenu=n=>Eo(n);function sc(n,e){return n.composing?!0:_&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Tp=We?5e3:-1;Q.compositionstart=Q.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof k&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||j&&$a&&Ap(n)))n.markCursor=n.state.storedMarks||t.marks(),vr(n,!0),n.markCursor=null;else if(vr(n,!e.selection.empty),fe&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}lc(n,Tp)};function Ap(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Q.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,lc(n,20))};function lc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>vr(n),e))}function ac(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Ep(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Dh(e.focusNode,e.focusOffset),r=Th(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function vr(n,e=!1){if(!(We&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),ac(n),e||n.docView&&n.docView.dirty){let t=Mo(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Np(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Nn=ne&&rt<15||Gt&&vh<604;Z.copy=Q.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=Nn?null:t.clipboardData,s=r.content(),{dom:l,text:a}=Do(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Np(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function vp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Ip(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?vn(n,r.value,null,i,e):vn(n,r.textContent,r.innerHTML,i,e)},50)}function vn(n,e,t,r,i){let o=Za(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||x.empty)))return!0;if(!o)return!1;let s=vp(o),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function cc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Q.paste=(n,e)=>{let t=e;if(n.composing&&!We)return;let r=Nn?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&vn(n,cc(r),r.getData("text/html"),i,t)?t.preventDefault():Ip(n,t)};var Ir=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Pp=ce?"altKey":"ctrlKey";function uc(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Pp]}Z.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(Bn(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof w?i.to-1:i.to))){if(r&&r.mightDrag)s=w.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(s=w.create(n.state.doc,f.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=Do(n,l);(!t.dataTransfer.files.length||!j||za>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Nn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Nn||t.dataTransfer.setData("text/plain",c),n.dragging=new Ir(u,uc(n,t),s)};Z.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Q.dragover=Q.dragenter=(n,e)=>e.preventDefault();Q.drop=(n,e)=>{try{Rp(n,e,n.dragging)}finally{n.dragging=null}};function Rp(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Bn(e));if(!r)return;let i=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",h=>{o=h(o,n,!1)}):o=Za(n,cc(e.dataTransfer),Nn?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&uc(n,e));if(n.someProp("handleDrop",h=>h(n,e,o||x.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?kr(n.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(s){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(f))return;let d=a.doc.resolve(c);if(u&&w.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new w(d));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(Oo(n,d,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Z.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ke(n)},20))};Z.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Z.beforeinput=(n,e)=>{if(We&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,kt(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Q)Z[n]=Q[n];function In(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var Pr=class n{constructor(e,t){this.toDOM=e,this.spec=t||Ot,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new E(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&In(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Mt=class n{constructor(e,t){this.attrs=e,this.spec=t||Ot}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new E(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&In(this.attrs,e.attrs)&&In(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},ko=class n{constructor(e,t){this.attrs=e,this.spec=t||Ot}map(e,t,r,i){let o=e.mapResult(t.from+i,1);if(o.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=o.pos?null:new E(o.pos-r,s.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),o;return i==t.from&&!(o=e.child(r)).isText&&i+o.nodeSize==t.to}eq(e){return this==e||e instanceof n&&In(this.attrs,e.attrs)&&In(this.spec,e.spec)}destroy(){}},E=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new Pr(t,r))}static inline(e,t,r,i){return new n(e,t,new Mt(r,i))}static node(e,t,r,i){return new n(e,t,new ko(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Mt}get widget(){return this.type instanceof Pr}},_t=[],Ot={},A=class n{constructor(e,t){this.local=e.length?e:_t,this.children=t.length?t:_t}static create(e,t){return t.length?Lr(t,e,0,Ot):U}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,i+l,o)}}map(e,t,r){return this==U||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Ot)}mapInner(e,t,r,i,o){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(s||(s=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?Lp(this.children,s||[],e,t,r,i,o):s?new n(s.sort(Dt),_t):U}add(e,t){return t.length?this==U?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=dc(t,l,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<a;)o+=3;i[o]==a?i[o+2]=i[o+2].addInner(l,u,c+1):i.splice(o,0,a,a+l.nodeSize,Lr(u,l,c+1,Ot)),o+=3}});let s=fc(o?hc(t):t,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new n(s.length?this.local.concat(s).sort(Dt):this.local,i||this.children)}remove(e){return e.length==0||this==U?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,l=r[o]+t,a=r[o+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,l+1);c!=U?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<i.length;l++)i[l].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new n(i,r):U}forChild(e,t){if(this==U)return this;if(t.isLeaf)return n.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof Mt){let c=Math.max(o,a.from)-o,u=Math.min(s,a.to)-o;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new n(i.sort(Dt),_t);return r?new Rr([l,r]):l}return r||U}eq(e){if(this==e)return!0;if(!(e instanceof n)||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 No(this.localsInner(e))}localsInner(e){if(this==U)return _t;if(e.inlineContent||!this.local.some(Mt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Mt||t.push(this.local[r]);return t}forEachSet(e){e(this)}};A.empty=new A([],[]);A.removeOverlap=No;var U=A.empty,Rr=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(i=>i.map(e,t,Ot));return n.from(r)}forChild(e,t){if(t.isLeaf)return A.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=U&&(o instanceof n?r=r.concat(o.members):r.push(o))}return n.from(r)}eq(e){if(!(e instanceof n)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!t)t=o;else{r&&(t=t.slice(),r=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?No(r?t:t.sort(Dt)):_t}static from(e){switch(e.length){case 0:return U;case 1:return e[0];default:return new n(e.every(t=>t instanceof A)?e:e.reduce((t,r)=>t.concat(r instanceof A?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Lp(n,e,t,r,i,o,s){let l=n.slice();for(let c=0,u=o;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,h,p,m)=>{let g=m-p-(h-d);for(let y=0;y<l.length;y+=3){let C=l[y+1];if(C<0||d>C+u-f)continue;let O=l[y]+u-f;h>=O?l[y+1]=d<=O?-2:-1:d>=u&&g&&(l[y]+=g,l[y+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+o),f=u-i;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+o,-1),h=d-i,{index:p,offset:m}=r.content.findIndex(f),g=r.maybeChild(p);if(g&&m==f&&m+g.nodeSize==h){let y=l[c+2].mapInner(t,g,u+1,n[c]+o+1,s);y!=U?(l[c]=f,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Bp(l,n,e,t,i,o,s),u=Lr(c,r,0,s);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new A(e.sort(Dt),l)}function fc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new E(i.from+e,i.to+e,i.type))}return t}function Bp(n,e,t,r,i,o,s){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,i,c);f?t.push(f):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+o+1);return t}function dc(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let o=0,s;o<n.length;o++)(s=n[o])&&s.from>t&&s.to<r&&((i||(i=[])).push(s),n[o]=null);return i}function hc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Lr(n,e,t,r){let i=[],o=!1;e.forEach((l,a)=>{let c=dc(n,l,a+t);if(c){o=!0;let u=Lr(c,l,t+a+1,r);u!=U&&i.push(a,a+l.nodeSize,u)}});let s=fc(o?hc(n):n,-t).sort(Dt);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new A(s,i):U}function Dt(n,e){return n.from-e.from||n.to-e.to}function No(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==n&&(e=n.slice()),e[i]=o.copy(o.from,r.to),Da(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,o.from),Da(e,i,r.copy(o.from,r.to)));break}}}return e}function Da(n,e,t){for(;e<n.length&&Dt(t,n[e])>0;)e++;n.splice(e,0,t)}function eo(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=U&&e.push(r)}),n.cursorWrapper&&e.push(A.create(n.state.doc,[n.cursorWrapper.deco])),Rr.from(e)}var zp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},$p=ne&&rt<=11,wo=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},So=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new wo,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);ne&&rt<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():_&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),$p&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,zp)),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(xa(this.view)){if(this.suppressingSelectionUpdates)return Ke(this.view);if(ne&&rt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Tt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=Yt(o))t.add(o);for(let o=e.anchorNode;o;o=Yt(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&xa(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],a);f&&(o=o<0?f.from:Math.min(f.from,o),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||j&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let f=u.nextSibling;for(;f&&f.nodeType==1;){if(f.contentEditable=="false"){u.parentNode.removeChild(u);break}f=f.firstChild}}}else if(fe&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let h=d.parentNode;h&&h.nodeName=="LI"&&(!f||Wp(e,f)!=h)&&d.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Br(r)&&(c=Mo(e))&&c.eq(M.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ke(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),Fp(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,qp(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ke(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(ne&&rt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d)}let s=i&&i.parentNode==e.target?K(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?K(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Ta=new WeakMap,Aa=!1;function Fp(n){if(!Ta.has(n)&&(Ta.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=fe,Aa)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."),Aa=!0}}function Ea(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return Tt(s.node,s.offset,i,o)&&([t,r,i,o]=[i,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:o}}function Vp(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Ea(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ea(n,t):null}function Wp(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function qp(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(o,l.firstChild),r==o&&n.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function Kp(n,e,t,r){let{node:i,fromOffset:o,toOffset:s,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSelectionRange(),u,f=c.anchorNode;if(f&&n.dom.contains(f.nodeType==1?f:f.parentNode)&&(u=[{node:f,offset:c.anchorOffset}],Br(c)||u.push({node:c.focusNode,offset:c.focusOffset})),j&&n.input.lastKeyCode===8)for(let y=s;y>o;y--){let C=i.childNodes[y-1],O=C.pmViewDesc;if(C.nodeName=="BR"&&!O){s=y;break}if(!O||O.size)break}let d=n.state.doc,h=n.someProp("domParser")||fn.fromSchema(n.state.schema),p=d.resolve(l),m=null,g=h.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:jp(r),context:p});if(u&&u[0].pos!=null){let y=u[0].pos,C=u[1]&&u[1].pos;C==null&&(C=y),m={anchor:y+l,head:C+l}}return{doc:g,sel:m,from:l,to:a}}var jp=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(_&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||_&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Jp=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Hp(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let D=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,v=Mo(n,D);if(v&&!n.state.selection.eq(v)){if(j&&We&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Bf=>Bf(n,kt(13,"Enter"))))return;let F=n.state.tr.setSelection(v);D=="pointer"?F.setMeta("pointer",!0):D=="key"&&F.scrollIntoView(),o&&F.setMeta("composition",o),n.dispatch(F)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Kp(n,e,t,i),u=n.state.doc,f=u.slice(c.from,c.to),d,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,h="end"):(d=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=Yp(f.content,c.doc.content,c.from,d,h);if(p&&n.input.domChangeCount++,(Gt&&n.input.lastIOSEnter>Date.now()-225||We)&&i.some(D=>D.nodeType==1&&!Jp.test(D.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",D=>D(n,kt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof k&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let D=Na(n,n.state.doc,c.sel);if(D&&!D.eq(n.state.selection)){let v=n.state.tr.setSelection(D);o&&v.setMeta("composition",o),n.dispatch(v)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof k&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ne&&rt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=u.resolve(p.start),C=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Gt&&n.input.lastIOSEnter>Date.now()-225&&(!C||i.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!C&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&n.someProp("handleKeyDown",D=>D(n,kt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&_p(u,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",D=>D(n,kt(8,"Backspace")))){We&&j&&n.domObserver.suppressSelectionUpdates();return}j&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),We&&!C&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(D){return D(n,kt(13,"Enter"))})},20));let O=p.start,$=p.endA,me=D=>{let v=D||n.state.tr.replace(O,$,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let F=Na(n,v.doc,c.sel);F&&!(j&&n.composing&&F.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(F.head==O||F.head==v.mapping.map($)-1)||ne&&F.empty&&F.head==O)&&v.setSelection(F)}return o&&v.setMeta("composition",o),v.scrollIntoView()},ae;if(C)if(m.pos==g.pos){ne&&rt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ke(n),20));let D=me(n.state.tr.delete(O,$)),v=u.resolve(p.start).marksAcross(u.resolve(p.endA));v&&D.ensureMarks(v),n.dispatch(D)}else if(p.endA==p.endB&&(ae=Up(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let D=me(n.state.tr);ae.type=="add"?D.addMark(O,$,ae.mark):D.removeMark(O,$,ae.mark),n.dispatch(D)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let D=m.parent.textBetween(m.parentOffset,g.parentOffset),v=()=>me(n.state.tr.insertText(D,O,$));n.someProp("handleTextInput",F=>F(n,O,$,D,v))||n.dispatch(v())}else n.dispatch(me());else n.dispatch(me())}function Na(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Oo(n,e.resolve(t.anchor),e.resolve(t.head))}function Up(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<t.length;u++)o=t[u].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(b.from(c).eq(n))return{mark:l,type:s}}function _p(n,e,t,r,i){if(t-e<=i.pos-r.pos||to(r,!0,!1)<i.pos)return!1;let o=n.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=n.resolve(to(o,!0,!0));return!s.parent.isTextblock||s.pos>t||to(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function to(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Yp(n,e,t,r,i){let o=n.findDiffStart(e,t),s=t+n.size,l=t+e.size;if(o==null)return null;let{a,b:c}=n.findDiffEnd(e,s,l);if(i=="end"){let u=Math.max(0,o-Math.min(a,c));r-=a+u-o}if(a<o&&s<l){let u=r<=o&&r>=a?o-r:0;o-=u,c=o+(c-a),a=o}else if(c<o){let u=r<=o&&r>=c?o-r:0;o-=u,a=o+(a-c),c=o}return{start:o,endA:a,endB:c}}var Pn=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new go,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(La),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Pa(this),Ia(this),this.nodeViews=Ra(this),this.docView=ha(this.state.doc,va(this),eo(this),this.dom,this),this.domObserver=new So(this,(r,i,o,s)=>Hp(this,r,i,o,s)),this.domObserver.start(),gp(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&&yo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(La),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(ac(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ra(this);Xp(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&yo(this),this.editable=Pa(this),Ia(this);let a=eo(this),c=va(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Rh(this);if(s){this.domObserver.stop();let h=f&&(ne||j)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Gp(i.selection,e.selection);if(f){let m=j?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Ep(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=ha(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&tp(this)&&p.delaySelUpdate())?Ke(this,h):(Ya(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&Lh(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof w){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&aa(this,t.getBoundingClientRect(),e)}else aa(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let o=r.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new Ir(e.slice,e.move,i<0?void 0:w.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=t?t(l):l))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(ne){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Bh(this.dom),Ke(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Wh(this,e)}coordsAtPos(e,t=1){return Ka(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Hh(this,t||this.state,e)}pasteHTML(e,t){return vn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return vn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Do(this,e)}destroy(){this.docView&&(yp(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],eo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Mh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return xp(this,e)}domSelectionRange(){let e=this.domSelection();return e?_&&this.root.nodeType===11&&Eh(this.dom.ownerDocument)==this.dom&&Vp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Pn.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function va(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[E.node(0,n.state.doc.content.size,e)]}function Ia(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:E.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Pa(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Gp(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ra(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Xp(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function La(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function pc(n={}){return new S({view(e){return new vo(e,n)}})}var vo=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(t){let f=e.nodeBefore,d=e.nodeAfter;if(f||d){let h=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=f?p.bottom:p.top;f&&d&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*s;r={left:f.left-d,right:f.left+d,top:f.top,bottom:f.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=a.getBoundingClientRect(),d=f.width/a.offsetWidth,h=f.height/a.offsetHeight;c=f.left-a.scrollLeft*d,u=f.top-a.scrollTop*h}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(!t||o)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=kr(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var je={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:"'"},$r={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Zp=typeof navigator<"u"&&/Mac/.test(navigator.platform),Qp=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(I=0;I<10;I++)je[48+I]=je[96+I]=String(I);var I;for(I=1;I<=24;I++)je[I+111]="F"+I;var I;for(I=65;I<=90;I++)je[I]=String.fromCharCode(I+32),$r[I]=String.fromCharCode(I);var I;for(zr in je)$r.hasOwnProperty(zr)||($r[zr]=je[zr]);var zr;function mc(n){var e=Zp&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Qp&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?$r:je)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var em=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),tm=typeof navigator<"u"&&/Win/.test(navigator.platform);function nm(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))em?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function rm(n){let e=Object.create(null);for(let t in n)e[nm(t)]=n[t];return e}function Io(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Po(n){return new S({props:{handleKeyDown:Ro(n)}})}function Ro(n){let e=rm(n);return function(t,r){let i=mc(r),o,s=e[Io(i,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Io(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(tm&&r.ctrlKey&&r.altKey)&&(o=je[r.keyCode])&&o!=i){let l=e[Io(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Y=class n extends M{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):M.near(r)}content(){return x.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new Lo(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!im(e)||!om(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(n.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!w.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(n.valid(l))return l}return null}}};Y.prototype.visible=!1;Y.findFrom=Y.findGapCursorFrom;M.jsonID("gapcursor",Y);var Lo=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Y.valid(t)?new Y(t):M.near(t)}};function gc(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function im(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||gc(i.type))return!0;if(i.inlineContent)return!1}}return!0}function om(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||gc(i.type))return!0;if(i.inlineContent)return!1}}return!0}function yc(){return new S({props:{decorations:cm,createSelectionBetween(n,e,t){return e.pos==t.pos&&Y.valid(t)?new Y(t):null},handleClick:lm,handleKeyDown:sm,handleDOMEvents:{beforeinput:am}}})}var sm=Ro({ArrowLeft:Fr("horiz",-1),ArrowRight:Fr("horiz",1),ArrowUp:Fr("vert",-1),ArrowDown:Fr("vert",1)});function Fr(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof k){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Y.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new Y(c))),!0):!1}}function lm(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Y.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&w.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Y(r))),!0)}function am(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Y))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=b.empty;for(let s=r.length-1;s>=0;s--)i=b.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new x(i,0,0));return o.setSelection(k.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function cm(n){if(!(n.selection instanceof Y))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",A.create(n.doc,[E.widget(n.selection.head,e,{key:"gapcursor"})])}var Et=null;function bc(n){Et=n??null}var Vr=(n,e)=>e?String(n).padStart(2,"0"):String(n);function um(n,e){switch(e){case"h12":return n%12===0?12:n%12;case"h11":return n%12;case"h24":return n===0?24:n}return n}function fm(n,e){let t="";for(let r of n.parts)switch(r.t){case"lit":t+=r.v;break;case"weekday":t+=n.weekdays[e.weekday];break;case"month":t+=n.months[e.month-1];break;case"monthNumber":t+=Vr(e.month,r.pad);break;case"day":t+=Vr(e.day,r.pad);break;case"year":t+=String(e.year);break;case"hour":t+=Vr(um(e.hour,r.cycle),r.pad);break;case"minute":t+=Vr(e.minute,!0);break;case"period":t+=n.periods[e.hour<12?0:1];break}return t}function dm(n){let[e,t,r]=n.split("-").map(Number),i=new Date(0);return i.setUTCFullYear(e,t-1,r),{year:e,month:t,day:r,weekday:i.getUTCDay(),hour:0,minute:0}}function xc(n,e,t=Et){let r=t?.patterns?.[n];return r?fm(r,dm(e)):e}function Xt(n,e=new Date().getFullYear(),t=Et){return xc(Number(n.slice(0,4))===e?"day":"dayYear",n,t)}function kc(n,e=Et){return xc("monthYear",`${n.slice(0,7)}-01`,e)}function Bo(n=Et){return n?.firstDay??1}function wc(n=Et){let e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],t=n?.weekdays??e,r=n?.narrow??e.map(i=>i[0]);return Array.from({length:7},(i,o)=>{let s=(Bo(n)+o)%7;return{name:t[s],letter:r[s]}})}function Sc(n=Et){return n?.order??"dmy"}function $n(n,e,t){return Qt(n,ee(e),t)}function Qt(n,e,t={}){let r=t.origin??(()=>null),i=Mc(n,e,0,e.length,r),o=i[i.length-1];return t.trailing!==!1&&(!o||o.type!==n.nodes.paragraph)&&i.push(n.nodes.paragraph.create()),n.nodes.doc.create(null,i)}function Mc(n,e,t,r,i){let o=[];for(let s=t;s<r;){if(e[s].kind===R){let[l,a]=ym(n,e,s,i,r);o.push(...l),s=a;continue}if(e[s].kind===Me){let[l,a]=hm(n,e,s,i);o.push(l),s=a;continue}o.push(pm(n,e[s],i(s))),s++}return o}var Cc=n=>/^[ \t]*(:+)/u.exec(n)[1].length;function hm(n,e,t,r){let i=[],o=t+1;for(;o<e.length&&e[o].kind===Oe;){let l=o+1;for(;l<e.length&&e[l].kind!==Xe;)l++;let a=Mc(n,e,o+1,l,r);i.push(n.nodes.column.create({fence:Cc(e[o].source),openOrigin:r(o),closeOrigin:r(l)},a.length?a:[n.nodes.paragraph.create()])),o=l+1}return[n.nodes.columns.create({fence:Cc(e[t].source),openOrigin:r(t),closeOrigin:r(o)},i),o+1]}function pm(n,e,t){let r=e.marker||null,i=zi(e);switch(e.kind){case Be:return n.nodes.heading.create({origin:t,marker:r,level:e.level,source:e.source},Zt(n,i));case ie:return mm(n,e,i,t);case Ce:return n.nodes.horizontal_rule.create({origin:t,source:e.source});case oe:return n.nodes.blockquote.create({marker:r,prefix:gm(e.source)},n.nodes.paragraph.create({origin:t},Zt(n,i)))}return n.nodes.paragraph.create({origin:t,marker:r},Zt(n,i))}function mm(n,e,t,r){let i=e.source.split(` |
| 27 | `),o=/^( {0,3}(?:`{3,}|~{3,}))(.*)$/su.exec(i[0]),s=i[i.length-1];return n.nodes.code_block.create({origin:r,fence:o[1],info:o[2],closed:i.length>1&&Qe(s,Ft(i[0])),close:i.length>1&&hr(s)?s:null},t===""?null:n.text(t))}function gm(n){return n.split(` |
| 28 | `).map(e=>/^ *> ?/u.exec(e)?.[0]??"")}function ym(n,e,t,r,i=e.length){let o=[],s=[],l=t;for(;l<i&&e[l].kind===R;l++){let a=e[l],c=Math.min(a.level,s.length);s.length=Math.min(s.length,c+1);let u=a.ordered?"ordered_list":"bullet_list";if(s.length===c+1&&s[c].kind!==u&&(s.length=c),s.length!==c+1){let f={kind:u,items:[]};c===0?o.push(f):s[c-1].items.at(-1).lists.push(f),s.push(f)}s[c].items.push({block:a,lists:[],origin:r(l)})}return[o.map(a=>Oc(n,a)),l]}function Oc(n,e){return n.nodes[e.kind].create(null,e.items.map(t=>bm(n,t)))}function bm(n,{block:e,lists:t,origin:r}){let[i,o]=Il(zi(e)),s={marker:e.marker||null,...vl(e),task:o!==null,checked:o},l=n.nodes.paragraph.create({origin:r},Zt(n,i));return n.nodes.list_item.create(s,[l,...t.map(a=>Oc(n,a))])}function Zt(n,e){let t=[];for(let r of ze(e))switch(r.kind){case Pi:t.push(n.text(r.text,[n.marks.code.create()]));break;case cr:t.push(n.text(r.text,[n.marks.link.create({href:r.url,bare:!r.source.startsWith("[")})]));break;case gt:t.push(xm(n,r));break;case pn:t.push(n.nodes.embed.create({ref:r.text.slice(3,-2),source:r.source}));break;case Ze:t.push(n.nodes.image.create({id:r.target,alt:r.text,source:r.source}));break;default:t.push(...km(n,r.text))}return t}function xm(n,e){let t={anchor:e.anchor,shown:e.text,source:e.source};return W(e.target)?n.nodes.datelink.create({...t,date:e.target}):n.nodes.wikilink.create({...t,target:e.target})}function km(n,e){return Ll(e).map(t=>{let r=T.setFrom([...t.em?[n.marks.em.create()]:[],...t.strong?[n.marks.strong.create()]:[]]);return t.kind==="break"?n.nodes.hard_break.create({indent:t.indent},null,r):n.text(t.text,r)})}var Dc=new Set(["bullet_list","ordered_list"]);function ke(n){let e=[];return n.forEach((t,r)=>Tc(t,r,e)),e}function Te(n,e){e.index=n.length,n.push(e)}function $o(n){return n.kind===Me||n.kind===Oe?"openOrigin":n.kind===Xe||n.kind===mt?"closeOrigin":"origin"}function Kr(n){return n.node.attrs[$o(n)]??null}function wm(n,e,t){Te(t,{kind:Me,node:n,pos:e,holder:n,holderPos:e,column:0}),n.forEach((r,i,o)=>{let s=e+1+i,l=o+1;Te(t,{kind:Oe,node:r,pos:s,holder:r,holderPos:s,column:l});let a=t.length;r.forEach((c,u)=>Tc(c,s+1+u,t));for(let c of t.slice(a))c.column=l;Te(t,{kind:Xe,node:r,pos:s,holder:r,holderPos:s,column:l})}),Te(t,{kind:mt,node:n,pos:e,holder:n,holderPos:e,column:0})}function Tc(n,e,t){switch(n.type.name){case"columns":return wm(n,e,t);case"paragraph":return Te(t,{kind:hn,node:n,pos:e,holder:n,holderPos:e});case"heading":return Te(t,{kind:Be,node:n,pos:e,holder:n,holderPos:e});case"code_block":return Te(t,{kind:ie,node:n,pos:e,holder:n,holderPos:e});case"horizontal_rule":return Te(t,{kind:Ce,node:n,pos:e,holder:n,holderPos:e});case"blockquote":n.firstChild?.type.name==="paragraph"&&Te(t,{kind:oe,node:n.firstChild,pos:e+1,holder:n,holderPos:e});return}Dc.has(n.type.name)&&Ac(n,e,0,t)}function Ac(n,e,t,r){n.forEach((i,o,s)=>{let l=e+1+o;i.forEach((a,c,u)=>{let f=l+1+c;u===0&&a.type.name==="paragraph"?Te(r,{kind:R,node:a,pos:f,holder:i,holderPos:l,depth:t,list:n.type.name,listPos:e,listStart:s===0}):Dc.has(a.type.name)&&Ac(a,f,t+1,r)})})}function xe(n){let e=n.holder.attrs;if(ye(n.kind))return JSON.stringify([n.kind,e.fence]);switch(n.kind){case R:return JSON.stringify([R,n.depth,n.list,e.indent,e.bullet,e.number,e.delim,e.task,e.checked,e.marker]);case oe:return JSON.stringify([oe,e.prefix,e.marker])}return n.kind}function Sm(n){let e=n.content.size,t=null;for(let r=n.childCount-1;r>=0;r--){let i=n.child(r);if(i.type.name==="hard_break")t=e-i.nodeSize;else if(!(i.isText&&V(i.text)===""))break;e-=i.nodeSize}return t}function Nt(n){if(n.kind===oe||n.kind===ie||n.kind===Ce)return n.node;let e=Sm(n.node);return e===null?n.node:n.node.copy(n.node.content.cut(0,e))}function Cm(n,e){if(!e)return!1;if(ye(n.kind))return e.node.type===n.node.type&&xe(n)===e.context;let t=n.node;return t!==e.node&&!t.eq(e.node)&&!Fo(Nt(n),e.node)?!1:xe(n)===e.context}function Fo(n,e){if(n.type!==e.type||!n.content.eq(e.content))return!1;for(let t of Object.keys(n.attrs))if(t!=="origin"&&!(t==="source"&&n.type.name==="heading")&&JSON.stringify(n.attrs[t])!==JSON.stringify(e.attrs[t]))return!1;return!0}function Wr(n,{last:e=!0}={}){let t=n.node;switch(n.kind){case hn:{let r=en(Nt(n));return zo(r)?"":r+qr(n)}case Be:{let r=en(Nt(n));return zo(r)?"":Om(t.attrs)+r+qr(n)}case R:return Dm(n);case oe:return Tm(n);case ie:return Am(t,e);case Ce:return Rl(t.attrs.source??"")?t.attrs.source:"---";case Me:case Oe:case Xe:case mt:return Mm(n)}return""}function Mm(n){let e=n.kind===Me||n.kind===mt,t=Number(n.node.attrs.fence),r=e?Number.isInteger(t)&&t>=4?t:4:3,i=n.kind===Me?" columns":n.kind===Oe?" column":"";return":".repeat(r)+i}function zo(n){return V(n)===""}function qr(n){let e=n.holder.attrs.marker;return e&&/^[A-Za-z0-9-]{1,40}$/u.test(e)?` ^${e}`:""}function Om(n){let e=Math.min(Math.max(n.level??1,1),6),t=/^(#{1,6})([ \t]+)/u.exec(n.source??"");return t&&t[1].length===e?t[0]:"#".repeat(e)+" "}function Dm(n){let e=n.holder.attrs,t=en(Nt(n));if(zo(t))return"";let r=/^[ \t]*$/u.test(e.indent??"")?e.indent??"":"",i;n.list==="ordered_list"?i=(/^[0-9]{1,9}$/u.test(e.number??"")?e.number:"1")+(e.delim===")"?")":"."):i=["-","*","+"].includes(e.bullet)?e.bullet:"-";let o=e.task?`[${[" ","x","X"].includes(e.checked)?e.checked:" "}] `:"";return`${r}${i} ${o}${t}${qr(n)}`}function Tm(n){let e=en(n.node);if(e==="")return"";let t=Array.isArray(n.holder.attrs.prefix)?n.holder.attrs.prefix:[];return(e+qr(n)).split(` |
| 29 | `).map((r,i)=>{let o=t[i]??t[0]??"> ";return/^ *> ?$/u.test(o)||(o="> "),!o.endsWith(" ")&&r.startsWith(" ")&&(o+=" "),o+r}).join(` |
| 30 | `)}function Am(n,e){let t=n.attrs,r=/^ {0,3}(?:`{3,}|~{3,})$/u.test(t.fence??"")?t.fence:"```",i=r+String(t.info??"").split(` |
| 31 | `)[0];return n.textContent!==""&&(i+=` |
| 32 | `+n.textContent),t.close!=null&&hr(t.close)&&(i+=` |
| 33 | `+t.close),!e&&!Ec(i)&&(i+=` |
| 34 | `+r.trimStart()),i}function Ec(n){let e=n.split(` |
| 35 | `);return e.length>1&&Qe(e[e.length-1],Ft(e[0]))}function en(n){let e=[];n.forEach(r=>{let i=o=>r.marks.some(s=>s.type.name===o);if(r.isText){let o=r.marks.find(l=>l.type.name==="link"),s=e[e.length-1];i("code")?s?.kind==="code"?s.text+=r.text:e.push({kind:"code",text:r.text}):o?s?.kind==="link"&&s.mark.eq(o)?s.text+=r.text:e.push({kind:"link",text:r.text,mark:o}):e.push({kind:"text",text:r.text,em:i("em"),strong:i("strong")})}else if(r.type.name==="hard_break"){let o=/^[ \t]*/u.exec(r.attrs.indent??"")[0];e.push({kind:"text",text:` |
| 36 | `+o,em:i("em"),strong:i("strong")})}else e.push({kind:"atom",text:Pm(r)})});let t="";for(let r=0;r<e.length;){let i=e[r];if(i.kind==="text"){let o=r;for(;o<e.length&&e[o].kind==="text";)o++;t+=Nm(e.slice(r,o)),r=o;continue}i.kind==="code"?t+="`"+i.text+"`":i.kind==="link"?t+=Em(i):t+=i.text,r++}return yt(t)}function Em({text:n,mark:e}){return e.attrs.bare&&n===e.attrs.href?n:`[${n}](${e.attrs.href})`}function Nm(n){return Nc(n,"em",e=>vm(e),"*")}function vm(n){return Nc(n,"strong",e=>e.map(t=>t.text).join(""),"**")}function Nc(n,e,t,r){let i="";for(let o=0;o<n.length;){let s=o;for(;s<n.length&&n[s][e]===n[o][e];)s++;let l=t(n.slice(o,s));i+=n[o][e]?Im(l,r):l,o=s}return i}function Im(n,e){let t=/^([\t\n\f\r ]*)([^]*?)([\t\n\f\r ]*)$/u.exec(n);return t[2]===""?n:t[1]+e+t[2]+e+t[3]}function Pm(n){let e=n.attrs;return e.source!=null&&Rm(n,e.source)?e.source:n.type.name==="embed"?`![[${e.ref}]]`:n.type.name==="image"?``:`[[${n.type.name==="datelink"?e.date:e.target}${e.anchor?"#^"+e.anchor:""}${e.shown?"|"+e.shown:""}]]`}function Rm(n,e){let t=ze(e);if(t.length!==1||t[0].source!==e)return!1;let r=t[0];if(n.type.name==="embed")return r.kind===pn&&r.text.slice(3,-2)===n.attrs.ref;if(n.type.name==="image")return r.kind===Ze&&r.target===n.attrs.id&&r.text===(n.attrs.alt??"");if(r.kind!==gt)return!1;let i=n.type.name==="datelink";return W(r.target)===i&&r.target===(i?n.attrs.date:n.attrs.target)&&r.anchor===(n.attrs.anchor??"")&&r.text===(n.attrs.shown??"")}function P(n,e,t={}){let r=t.fresh??new Set,i=t.joins??new Set,o=ke(n),s=new Set;for(let f of o){let d=Kr(f);f.origin=d,f.first=d!=null&&!s.has(d),d!=null&&s.add(d),f.entry=f.first?e?.get(d):void 0,f.untouched=!r.has(f.index)&&Cm(f,f.entry),f.text=f.untouched?f.entry.source:Wr(f)}let l=-1;o.forEach((f,d)=>{f.text!==""&&(l=d)});for(let f of o.slice(0,Math.max(l,0)))f.kind===ie&&(f.untouched&&Ec(f.text)||(f.untouched=!1,f.text=Wr(f,{last:!1})));let a=o.filter(f=>f.text!==""),c="";a.forEach((f,d)=>{d===0?t.edges!==!1&&f.entry?.leading!=null&&(c+=f.entry.leading):(f.seam=Lm(a[d-1],f,i.has(f.index)),c+=f.seam),c+=f.text});let u=a[a.length-1];return t.edges!==!1&&u?.entry?.trailing!=null&&(c+=u.entry.trailing),{body:t.raw?yt(c):ge(c),blocks:o,emitted:a}}function Fn(n,e,t){return P(n,e,t).body}function Lm(n,e,t){if(!t&&n.first&&e.first){if(n.entry&&n.entry.next===e.origin&&n.entry.after!=null)return n.entry.after;if(e.entry&&e.entry.prev===n.origin&&e.entry.before!=null)return e.entry.before}return Bm(n.kind,e.kind)}function Bm(n,e){return n===Oe||n===R&&e===R?` |
| 37 | `:` |
| 38 | |
| 39 | `}function Vo(n){let e=new Set;return n.map(t=>{if(t.kind===Be)return`${Be}:${Math.min(Math.max(t.node.attrs.level,1),6)}`;if(t.kind!==R)return t.kind;let r=!e.has(t.listPos);return e.add(t.listPos),`${R}:${t.list}:${t.depth}:${r}`})}function zm(n,e){let t=ke(Qt(n,ee(e),{trailing:!1}));return Vo(t.filter(r=>!(r.kind===hn&&r.column>0&&r.node.childCount===0)))}function vc(n){return Vo(n)}function $m(n,e){let t=Math.min(n.length,e.length);for(let r=0;r<t;r++)if(n[r]!==e[r])return r;return n.length===e.length?-1:t}function jr(n,e){let t=n.type.schema,r=l=>{let a=P(n,e,l);return a.shapes=Vo(a.emitted),a.mismatch=$m(a.shapes,zm(t,a.body)),a},i=new Set,o=new Set,s=r({});for(let l=0;s.mismatch>=0&&l<4;l++){let a=[-1,0,1,2].map(c=>s.emitted[s.mismatch+c]);for(let c of a)c&&(o.add(c.index),l>=2&&i.add(c.index));s=r({fresh:i,joins:o})}if(s.mismatch>=0){let l=new Set(s.blocks.map(a=>a.index));s=r({fresh:l,joins:l})}return{ok:s.mismatch<0,body:s.body,shapes:s.shapes,fixed:o.size>0}}var Jr=class{constructor(){this.issued=0,this.table=new Map}mint(){return++this.issued}get(e){return this.table.get(e)}record(e,t){if(this.table.has(e))throw new Error(`origin ${e} is already recorded`);this.table.set(e,Object.freeze(t))}},st=new N("mapa-fidelity");function tn(n,e,t,r={}){let i=yt(t),o=ee(i),s=o.map(()=>e.mint()),l=Qt(n,o,{origin:f=>s[f],...r}),a=new Map(ke(l).map(f=>[Kr(f),f])),c=s.map(f=>a.get(f)),u=r.edges!==!1;return o.forEach((f,d)=>{let h=o[d-1],p=o[d+1];e.record(s[d],{node:c[d].node,source:f.source,context:xe(c[d]),prev:h?s[d-1]:null,next:p?s[d+1]:null,before:h?i.slice(h.to,f.from):null,after:p?i.slice(f.to,p.from):null,leading:u&&!h?i.slice(0,f.from):null,trailing:u&&!p?i.slice(f.to):null})}),{doc:l,nodes:c,origins:s}}function qo(n,e){let t=new Jr,{doc:r}=tn(n,t,e);return{doc:r,fidelity:t}}function Fm(n,e){return ye(n.kind)||ye(e.kind)?n.kind===e.kind&&xe(n)===xe(e):xe(n)===xe(e)&&Fo(Nt(n),e.node)}function Pc(n,e,t){let r=0;for(;r<n.length&&r<e.length&&t(n[r],e[r]);)r++;let i=0;for(;i<n.length-r&&i<e.length-r&&t(n[n.length-1-i],e[e.length-1-i]);)i++;let o=Vm(n.slice(r,n.length-i),e.slice(r,e.length-i),t);return[...Array.from({length:r},(s,l)=>[l,l]),...o.map(([s,l])=>[s+r,l+r]),...Array.from({length:i},(s,l)=>[n.length-i+l,e.length-i+l])]}function Vm(n,e,t){let r=n.length,i=e.length,o=Array.from({length:r+1},()=>new Int32Array(i+1));for(let l=r-1;l>=0;l--)for(let a=i-1;a>=0;a--)o[l][a]=t(n[l],e[a])?o[l+1][a+1]+1:Math.max(o[l+1][a],o[l][a+1]);let s=[];for(let l=0,a=0;l<r&&a<i;)t(n[l],e[a])?(s.push([l,a]),l++,a++):o[l+1][a]>=o[l][a+1]?l++:a++;return s}function Rc(n,e,t){let r=n.state,{nodes:i,origins:o}=tn(r.schema,e,t),s=i.slice(0,o.length),l=P(r.doc,e).emitted,a=r.tr;for(let[c,u]of Pc(l,s,Fm))a.setNodeAttribute(l[c].pos,$o(l[c]),o[u]);return a.setMeta("addToHistory",!1).setMeta(st,{rebuilt:!0}),n.dispatch(a),{ok:Fn(n.state.doc,e)===ge(t)}}function Wo(n,e){let t=e.topNodeType.create(null,n),{emitted:r}=P(t,null,{raw:!0}),i=vc(r);return JSON.stringify(r.map((o,s)=>[i[s],o.text]))}function Ko(n,e,t,r=null){let i=n.doc.type.schema,o=r?r.node:n.doc,s=r?r.start:0,{doc:l}=tn(i,e,t,r?{trailing:!1,edges:!1}:{}),a=[];o.forEach((m,g)=>{let y=Wo(m,i);y!=="[]"&&a.push({node:m,offset:g+s,key:y})});let c=[];l.forEach(m=>{let g=Wo(m,i);g!=="[]"&&c.push({node:m,key:g})});let u=Pc(a,c,(m,g)=>m.key===g.key),f=[],d=[-1,-1];for(let m of[...u,[a.length,c.length]]){let[g,y]=[d[0]+1,d[1]+1];if(m[0]>g||m[1]>y){let C=g<a.length?a[g].offset:a[a.length-1]?a[a.length-1].offset+a[a.length-1].node.nodeSize:s,O=m[0]>g?a[m[0]-1].offset+a[m[0]-1].node.nodeSize:C;f.push({from:C,to:O,nodes:c.slice(y,m[1]).map($=>$.node)})}d=m}let h=n.selection.head,p=null;for(let m of f.reverse()){p===null&&h>=m.from&&h<=m.to&&(p={left:Wm(n.doc,h,m.to),gap:m});let g=[];n.doc.nodesBetween(m.from,m.to,(y,C)=>(C>=m.from&&Wo(y,i)==="[]"&&g.push(y),!1)),n.replaceWith(m.from,m.to,b.from([...m.nodes,...g])),m.size=[...m.nodes,...g].reduce((y,C)=>y+C.nodeSize,0)}if(p){let m=n.mapping.map(p.gap.from,-1),g=qm(n.doc,m,m+p.gap.size,p.left);n.setSelection(k.near(n.doc.resolve(g),-1))}return n}function Wm(n,e,t){let r=0;return n.nodesBetween(e,t,(i,o)=>{i.isText?r+=Math.min(o+i.nodeSize,t)-Math.max(o,e):i.isInline&&(r+=1)}),r}function qm(n,e,t,r){let i=null,o=[];n.nodesBetween(e,t,(s,l)=>{if(s.isTextblock)return o.push({node:s,pos:l}),!1});for(let{node:s,pos:l}of o.reverse()){let a=s.content.size;if(r<=a){i=l+1+a-r;break}r-=a}return i===null&&(i=o.length?o[o.length-1].pos+1:e),Math.min(Math.max(i,0),n.content.size)}function Hr(n,e,t){let r=Ko(n.state.tr,e,t).setMeta("mapa-applied",!0);return r.docChanged&&n.dispatch(r.scrollIntoView()),Rc(n,e,t)}function jo(n,e){let t=jr(n.state.doc,e);if(t.ok)return{body:t.body,shapes:t.shapes,adopted:!1};Hr(n,e,t.body);let r=jr(n.state.doc,e);return{body:r.body,shapes:r.shapes,adopted:!0}}var Km={paragraph:["marker"],heading:["level","marker"],code_block:["fence","info","closed","close"],list_item:["indent","bullet","number","delim","task","checked","marker"],blockquote:["prefix","marker"]};function Ic(n){return n.kind===R||n.kind===oe?n.holder:n.node}function jm(n,e){if(n.kind===Ce||ye(n.kind))return null;let t=Wr(n);if(t==="")return null;let r=ee(t);if(r.length!==1||r[0].kind!==n.kind)return"structural";let i=ke(Qt(e,r,{trailing:!1}))[0];if(n.kind===R&&i.list!==n.list)return"structural";let o=Ic(n),s=Ic(i),l=[];for(let d of Km[o.type.name]??[])JSON.stringify(o.attrs[d])!==JSON.stringify(s.attrs[d])&&l.push([d,s.attrs[d]]);let a=Nt(n).content,c=i.node.content,u=a.findDiffStart(c);if(u===null&&l.length===0)return null;let f=null;if(u!==null){let{a:d,b:h}=a.findDiffEnd(c),p=u-Math.min(d,h);p>0&&(d+=p,h+=p),f={from:u,to:d,content:c.cut(u,h)}}return{block:n,attrs:l,diff:f,text:t,node:i.node}}function Jm(n,{block:e,attrs:t,diff:r},i){if(r){let s=e.pos+1;n.replaceWith(s+r.from,s+r.to,r.content)}let o=e.kind===R||e.kind===oe?e.holderPos:e.pos;for(let[s,l]of t)n.setNodeAttribute(o,s,l);n.setNodeAttribute(e.pos,"origin",i)}function Hm(n,e,t=null){let r=n.tr;return Lc(r,e,t),r.docChanged?r:null}function Um(n,e){let t=n.blocks.filter(i=>!i.untouched);if(!e)return t;let r=new Map(ke(e).map(i=>[i.node,xe(i)]));return t.filter(i=>!i.first||r.get(i.node)!==xe(i))}function Lc(n,e,t){let r=n.doc.type.schema,i=P(n.doc,e),o=[];for(let f of Um(i,t)){let d=jm(f,r);if(d==="structural"){f.column>0?eg(n,e,f):Ko(n,e,i.body);return}d&&o.push(d)}if(o.length===0)return;let s=new Map(o.map(f=>[f.block,e.mint()])),l=f=>s.get(f)??(f.first?f.origin:null),{emitted:a}=i,c=o.map(({block:f,text:d,node:h})=>{let p=a.indexOf(f),m=a[p-1],g=a[p+1],y=s.get(f);return{origin:y,source:d,node:h.type.create({...h.attrs,origin:y},h.content,h.marks),prev:m?l(m):null,next:g?l(g):null,before:m?f.seam:null,after:g?g.seam:null,leading:p===0?f.entry?.leading??null:null,trailing:p>=0&&!g?f.entry?.trailing??null:null}});for(let f of[...o].reverse())Jm(n,f,s.get(f.block));let u=new Map(ke(n.doc).map(f=>[Kr(f),f]));for(let{origin:f,...d}of c)e.record(f,{...d,context:xe(u.get(f))})}function _m(n,e){let t=s=>{let l=new Map;for(let a of ke(s)){let c=a.holder.attrs.marker;c&&l.set(c,(l.get(c)??0)+1)}return l},r=e?t(e):new Map,i=new Set(e?ke(e).map(s=>s.holder):[]),o=ke(n.doc);for(let[s,l]of t(n.doc)){let a=l-Math.max(r.get(s)??0,1);if(a<=0)continue;let c=o.filter(h=>h.holder.attrs.marker===s),u=c.find(h=>i.has(h.holder))??c[0],f=c.filter(h=>h!==u),d=[...f.filter(h=>!i.has(h.holder)).reverse(),...f.filter(h=>i.has(h.holder)).reverse()];for(let h of d.slice(0,a))n.setNodeAttribute(h.holderPos,"marker",null)}}function Ym(n){return Math.floor(String(n??"").replaceAll(" "," ").length/2)}function Gm(n,e){let t=-1;for(let o of P(n.doc,e).emitted){if(o.kind!==R){t=-1;continue}let s=Ym(o.holder.attrs.indent),l=" ".repeat(o.depth);Math.min(s,t+1)!==o.depth&&o.depth<=t+1&&o.holder.attrs.indent!==l&&n.setNodeAttribute(o.holderPos,"indent",l),t=o.depth}let r=[],i=(o,s)=>{let l=s,a=null;o.forEach(c=>{a&&a.type===c.type&&(c.type.name==="bullet_list"||c.type.name==="ordered_list")&&r.push(l),a=c,l+=c.nodeSize})};i(n.doc,0),n.doc.descendants((o,s)=>{if(o.isTextblock)return!1;i(o,s+1)});for(let o of r.sort((s,l)=>l-s))n.join(o)}function Xm(n,e){let t=P(n.doc,e),r=t.emitted.filter(s=>ye(s.kind)).map(s=>s.kind),i=ee(t.body).filter(s=>ye(s.kind)).map(s=>s.kind);if(r.join()===i.join())return;let o=[];n.doc.descendants((s,l)=>s.isTextblock?(s.type.name!=="code_block"&&Zm(s,l,o),!1):!0);for(let s of o.reverse())n.insertText("\u200B",s)}function Zm(n,e,t){let r="",i=e+1,o=i,s=()=>{Li(r)&&t.push(o+r.indexOf(":"))};n.forEach((l,a)=>{l.type.name==="hard_break"?(s(),r="",o=i+a+l.nodeSize):l.isText?r+=l.text:r+="\uFFFC"}),s()}function Qm(n){let e=n.doc.lastChild;(!e||e.type.name!=="paragraph")&&n.insert(n.doc.content.size,n.doc.type.schema.nodes.paragraph.create())}function Bc(n,e,t=null){let r=n.tr;for(let i=0;i<4;i++){let o=r.doc;if(Lc(r,e,t),Xm(r,e),_m(r,t),Gm(r,e),Qm(r),r.doc===o)break}return r.docChanged?r:null}function Jo(n,e={}){let t=null,r=null,i=()=>e.composing?e.composing():t?.composing??!1;return new S({key:st,state:{init:()=>n,apply:(o,s)=>s},view(o){return t=o,{destroy(){t=null}}},props:{handleDOMEvents:{compositionend(o){return setTimeout(()=>{t===o&&r&&o.dispatch(o.state.tr.setMeta(st,{composed:!0}))},50),!1}}},appendTransaction(o,s,l){if(!o.some(f=>f.docChanged&&!f.getMeta(st)?.rebuilt)&&!r)return null;if(i())return r=r??s.doc,null;let c=r??s.doc;r=null;let u=Bc(l,n,c);return u?u.setMeta(st,{settled:!0}):null}})}function eg(n,e,t){let r=n.doc.resolve(t.pos),i=r.depth;for(;i>0&&r.node(i).type.name!=="column";)i--;if(i===0)return;let o=r.node(i),s=r.before(i)+1,l=n.doc.type.schema,a=l.topNodeType.create(null,o.content),c=tg(P(a,e,{edges:!1,raw:!0}).body);Ko(n,e,c,{node:o,start:s});let u=n.doc.nodeAt(s-1);u&&u.type.name==="column"&&u.childCount===0&&n.insert(s,l.nodes.paragraph.create())}function tg(n){let e=null;return n.split(` |
| 40 | `).map(t=>{if(e)return Qe(t,e)&&(e=null),t;let r=Ft(t);return r?(e=r,t):Li(t)?t.replace(/^([ \t]*):::/u,"$1\u200B:::"):t}).join(` |
| 41 | `)}var Ur=200,J=function(){};J.prototype.append=function(e){return e.length?(e=J.from(e),!this.length&&e||e.length<Ur&&this.leafAppend(e)||this.length<Ur&&e.leafPrepend(this)||this.appendInner(e)):this};J.prototype.prepend=function(e){return e.length?J.from(e).append(this):this};J.prototype.appendInner=function(e){return new ng(this,e)};J.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?J.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};J.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};J.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};J.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};J.from=function(e){return e instanceof J?e:e&&e.length?new zc(e):J.empty};var zc=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Ur)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Ur)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(J);J.empty=new zc([]);var ng=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(J),Ho=J;var rg=500,It=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){i||(i=this.remapping(r,d+1),o=i.maps.length),o--,u.push(f);return}if(i){u.push(new Ae(f.map));let h=f.step.map(i.slice(o)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Ae(p,void 0,void 0,c.length+u.length))),o--,p&&i.appendMap(p,o)}else s.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(o)):f.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),d=new Ae(e.mapping.maps[u],f,t),h;(h=a&&a.merge(d))&&(d=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(d),t&&(s++,t=void 0),i||(a=d)}let c=s-r.depth;return c>og&&(l=ig(l,c),s-=c),new n(l.append(o),s)}remapping(e,t){let r=new wn;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new Ae(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let r=[],i=this.items.length-t,o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},i);let a=t;this.items.forEach(d=>{let h=o.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=o.maps[h];if(d.step){let m=e.steps[h].invert(e.docs[h]),g=d.selection&&d.selection.map(o.slice(a+1,h));g&&l++,r.push(new Ae(p,m,g))}else r.push(new Ae(p))},i);let c=[];for(let d=t;d<s;d++)c.push(new Ae(o.maps[d]));let u=this.items.slice(0,i).append(c).append(r),f=new n(u,l);return f.emptyItemCount()>rg&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&o++;let f=new Ae(c.invert(),a,u),d,h=i.length-1;(d=i.length&&i[h].merge(f))?i[h]=d:i.push(f)}}else s.map&&r--},this.items.length,0),new n(Ho.from(i.reverse()),o)}};It.empty=new It(Ho.empty,0);function ig(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var Ae=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},Ee=class{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}},og=20;function sg(n,e,t,r){let i=t.getMeta(vt),o;if(i)return i.historyState;t.getMeta(Vc)&&(n=new Ee(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(vt))return s.getMeta(vt).redo?new Ee(n.done.addTransform(t,void 0,r,_r(e)),n.undone,$c(t.mapping.maps),n.prevTime,n.prevComposition):new Ee(n.done,n.undone.addTransform(t,void 0,r,_r(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!lg(t,n.prevRanges)),c=s?Uo(n.prevRanges,t.mapping):$c(t.mapping.maps);return new Ee(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,_r(e)),It.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new Ee(n.done.rebased(t,o),n.undone.rebased(t,o),Uo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ee(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Uo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function lg(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function $c(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,o,s)=>e.push(o,s));return e}function Uo(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),o=e.map(n[r+1],-1);i<=o&&t.push(i,o)}return t}function ag(n,e,t){let r=_r(e),i=vt.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),a=new Ee(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(vt,{redo:t,historyState:a})}var _o=!1,Fc=null;function _r(n){let e=n.plugins;if(Fc!=e){_o=!1,Fc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){_o=!0;break}}return _o}function Yo(n){return n.setMeta(Vc,!0)}var vt=new N("history"),Vc=new N("closeHistory");function Wc(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new S({key:vt,state:{init(){return new Ee(It.empty,It.empty,null,0,-1)},apply(e,t,r){return sg(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?Go:r=="historyRedo"?Xo:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function Yr(n,e){return(t,r)=>{let i=vt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=ag(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}var Go=Yr(!1,!0),Xo=Yr(!0,!0),tx=Yr(!1,!1),nx=Yr(!0,!1);function qc(n,e){let t={remote:!1},r=()=>n.view,i=o=>{let s=t.remote;t.remote=!0;try{return o()}finally{t.remote=s}};return t.current=()=>Fn(r().state.doc,e),t.prepare=()=>i(()=>jo(r(),e).body),t.apply=o=>i(()=>{r().dispatch(Yo(r().state.tr));let s=Hr(r(),e,o);return r().dispatch(Yo(r().state.tr)),s}),t}function Ne(n){for(let e=n.depth;e>0;e--)if(n.node(e).type.name==="column")return{layout:n.node(e-1),layoutPos:n.before(e-1),column:n.node(e),columnPos:n.before(e),index:n.index(e-1)};return null}function Kc(n){return n.nodes.column.create(null,n.nodes.paragraph.create())}function cg(n){let{$from:e,$to:t}=n.selection;return e.depth<1?null:{from:e.before(1),to:t.after(1)}}function Zo(n){return(e,t)=>{let r=e.schema;if(Ne(e.selection.$from)||Ne(e.selection.$to))return!1;let i=cg(e);if(!i)return!1;if(t){let o=Gr(e.doc.slice(i.from,i.to).content),s=o.textBetween(0,o.size,"","\uFFFC").trim()!=="",l=r.nodes.column.createChecked(null,o.size?o:r.nodes.paragraph.create()),a=[l];for(let d=1;d<n;d++)a.push(Kc(r));let c=r.nodes.columns.createChecked(null,a),u=e.tr.replaceWith(i.from,i.to,c),f=s?i.from+1+l.nodeSize+1:i.from+2;u.setSelection(k.near(u.doc.resolve(f))),t(u.scrollIntoView())}return!0}}function ug(n,e){let t=Ne(n.selection.$head);if(!t||t.layout.childCount>=4)return!1;if(e){let r=t.columnPos+t.column.nodeSize,i=n.tr.insert(r,Kc(n.schema));i.setSelection(k.near(i.doc.resolve(r+2))),e(i.scrollIntoView())}return!0}function jc(n,e){let t=Ne(n.selection.$head);if(!t)return!1;if(t.layout.childCount<=2)return Jc(n,e);if(e){let r=Hc(t.column.content),i=n.tr.delete(t.columnPos,t.columnPos+t.column.nodeSize),o=t.index>0?t.index-1:0,s=t.layoutPos+1;for(let c=0;c<o;c++)s+=i.doc.nodeAt(t.layoutPos).child(c).nodeSize;let l=i.doc.nodeAt(s),a=t.index>0?s+l.nodeSize-1:s+1;r.size&&i.insert(a,r),i.setSelection(k.near(i.doc.resolve(a))),e(i.scrollIntoView())}return!0}function Jc(n,e){let t=Ne(n.selection.$head);if(!t)return!1;if(e){let r=[];t.layout.forEach(s=>s.forEach(l=>r.push(l)));let i=Hc(b.from(r)),o=n.tr.replaceWith(t.layoutPos,t.layoutPos+t.layout.nodeSize,i.size?i:n.schema.nodes.paragraph.create());o.setSelection(k.near(o.doc.resolve(t.layoutPos+1))),e(o.scrollIntoView())}return!0}function Hc(n){let e=[];return n.forEach(t=>{t.type.name==="paragraph"&&t.content.size===0||e.push(t)}),b.from(e)}function Uc(n,e){let{$head:t,empty:r}=n.selection,i=Ne(t);return!r||!i||!(i.column.childCount===1&&i.column.firstChild.type.name==="paragraph"&&i.column.firstChild.content.size===0)?!1:jc(n,e)}function Qo(n){return(e,t)=>{let r=Ne(e.selection.$head);if(!r)return!1;let i=r.index+n;if(i<0||i>=r.layout.childCount)return!1;if(t){let o=r.layoutPos+1;for(let s=0;s<i;s++)o+=r.layout.child(s).nodeSize;t(e.tr.setSelection(k.near(e.doc.resolve(o+1))).scrollIntoView())}return!0}}function _c(){return{"insert-columns-2":Zo(2),"insert-columns-3":Zo(3),"insert-columns-4":Zo(4),"add-column":ug,"remove-column":jc,"undo-columns":Jc}}function Gr(n){let e=[];return n.forEach(t=>{t.type.name==="columns"?t.forEach(r=>r.forEach(i=>e.push(i))):e.push(t)}),b.from(e)}function es(n){return Ne(n)!==null}function Vn(n){let{$from:e,$to:t,empty:r}=n.selection;if(r)return!1;let i=Ne(e),o=Ne(t);return!i&&!o?!1:!i||!o||i.columnPos!==o.columnPos}function Pt(n,e){if(!Vn(n))return!1;if(e){let{from:t,to:r}=n.selection,i=[];n.doc.nodesBetween(t,r,(s,l,a)=>{if(s.type.name==="columns")return!0;if(s.type.name==="column"){let c=Math.max(t,l+1),u=Math.min(r,l+s.nodeSize-1);return u>c&&i.push({from:c,to:u,column:l}),!1}if(a===n.doc){let c=Math.max(t,l),u=Math.min(r,l+s.nodeSize);u>c&&i.push({from:c,to:u})}return!1});let o=n.tr;for(let s of i.reverse())if(o.delete(o.mapping.map(s.from),o.mapping.map(s.to)),s.column!==void 0){let l=o.mapping.map(s.column),a=o.doc.nodeAt(l);a&&a.content.size===0&&o.insert(l+1,n.schema.nodes.paragraph.create())}o.setSelection(k.near(o.doc.resolve(o.mapping.map(t)))),e(o.scrollIntoView())}return!0}function ts(n){return(e,t)=>{let{$cursor:r}=e.selection;if(!r||r.depth<1||!(n?r.parentOffset===0:r.parentOffset===r.parent.content.size))return!1;let o=r.depth,s=r.index(o-1),a=r.node(o-1).maybeChild(n?s-1:s+1);if(!a||a.type.name!=="columns")return!1;if(t){let c=n?r.before(o)-1:r.after(o)+1,u=n?k.near(e.doc.resolve(c),-1):k.near(e.doc.resolve(c),1);t(e.tr.setSelection(u).scrollIntoView())}return!0}}function Yc(){return new S({props:{handleTextInput(n,e,t,r){return Vn(n.state)?(Pt(n.state,n.dispatch),n.dispatch(n.state.tr.insertText(r).scrollIntoView()),!0):!1},handlePaste(n){return Vn(n.state)&&Pt(n.state,n.dispatch),!1}}})}var ns="application/x-mapa";function rs(n,e,t=n.selection.from,r=n.selection.to,i=""){let s=n.doc.slice(t,r,!0).content,l=s.firstChild;s.childCount===1&&l.type.name==="columns"&&l.childCount===1&&(s=l.firstChild.content);let a=n.schema.topNodeType.create(null,s),{body:c,emitted:u}=P(a,e,{edges:!1,raw:!0}),f=JSON.stringify({v:1,sources:u.map(d=>d.text),seams:u.slice(1).map(d=>d.seam),page:i});return{text:c,mapa:f}}function fg(n){let e;try{e=JSON.parse(n)}catch{return null}if(e?.v!==1||!Array.isArray(e.sources))return null;let t=new Set;for(let r of e.sources){if(typeof r!="string")return null;for(let i of ee(r))if(i.kind!==ie)for(let o of ze(i.source))o.kind===Ze&&t.add(o.target)}return{payload:e,ids:[...t],page:typeof e.page=="string"?e.page:""}}function dg(n,e){let t=n.sources.map(r=>{if(ee(r)[0]?.kind===ie)return r;let i="";for(let o of ze(r)){let s=o.kind===Ze?e[o.target]:null;i+=s?``:o.source}return i});return JSON.stringify({...n,sources:t})}function hg(n){if(!/<img/iu.test(n))return n;let e=new DOMParser().parseFromString(n,"text/html");for(let t of[...e.querySelectorAll("img")]){let r=t.getAttribute("src")??"";if(!r.startsWith(X))if(Re(r)){let i=e.createElement("a");i.setAttribute("href",r),i.textContent=t.getAttribute("alt")||r,t.replaceWith(i)}else t.remove()}return e.body.innerHTML}function pg(n){let e;try{e=JSON.parse(n)}catch{return null}let{sources:t,seams:r}=e??{};if(e?.v!==1||!Array.isArray(t)||!Array.isArray(r)||t.length===0||r.length!==t.length-1||![...t,...r].every(s=>typeof s=="string")||!r.every(s=>/^\n(?:[^\n]*\n)*$/u.test(s)))return null;let i=t.map((s,l)=>(l?r[l-1]:"")+s).join(""),o=ee(i);return o.length!==t.length||o.some((s,l)=>s.source!==t[l])?null:i}function mg(n,e){let{from:t,to:r}=n.selection,i=new Set;for(let o of P(n.doc,e).emitted){let s=o.holder.attrs.marker,l=o.holderPos>=t&&o.holderPos+o.holder.nodeSize<=r;s&&!l&&i.add(s)}return i}function Gc(n,e){let t=[];return n.forEach(r=>{let i=r;!r.isTextblock&&!r.isLeaf&&(i=r.copy(Gc(r.content,e))),i.attrs.marker&&e.has(i.attrs.marker)&&(i=i.type.create({...i.attrs,marker:null},i.content,i.marks)),t.push(i)}),b.from(t)}function Xc(n,e,t){let r=mg(e,t);return r.size===0?n:new x(Gc(n.content,r),n.openStart,n.openEnd)}function is(n,e,t){let r=pg(t);if(r===null)return null;let{doc:i}=tn(n.schema,e,r,{trailing:!1,edges:!1}),o=es(n.selection.$from)?Gr(i.content):i.content,s=Xc(x.maxOpen(o),n,e),{$from:l,empty:a}=n.selection;if(a&&l.depth===1&&l.parent.type.name==="paragraph"&&l.parent.content.size===0){let c=n.tr.replaceWith(l.before(),l.after(),s.content),u=l.before()+s.content.size;return c.setSelection(k.near(c.doc.resolve(u),-1))}return n.tr.replaceSelection(s)}function Zc(n,e){let t=$n(n,e,{trailing:!1});return t.childCount?x.maxOpen(t.content):x.empty}function gg(n,e){let t=e.content,r=t.firstChild;if(!r)return"";r.isInline?t=b.from(n.nodes.paragraph.create(null,t)):r.type.name==="list_item"&&(t=b.from(n.nodes.bullet_list.create(null,t)));try{return P(n.topNodeType.create(null,t),null,{edges:!1,raw:!0}).body}catch{return e.content.textBetween(0,e.content.size,` |
| 42 | |
| 43 | `)}}var yg=new N("mapa-clipboard");function ss(n,e={}){let t=()=>e.page?.()??"",r=(i,o,s)=>{let l=o.clipboardData;if(!l||i.state.selection.empty)return!1;let{text:a,mapa:c}=rs(i.state,n,void 0,void 0,t()),{dom:u}=i.serializeForClipboard(i.state.selection.content());return o.preventDefault(),l.clearData(),l.setData("text/html",u.innerHTML),l.setData("text/plain",a),l.setData(ns,c),s&&Vn(i.state)?Pt(i.state,f=>i.dispatch(f.setMeta("uiEvent","cut"))):s&&i.dispatch(i.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut")),!0};return new S({key:yg,props:{handleDOMEvents:{copy:(i,o)=>r(i,o,!1),cut:(i,o)=>r(i,o,!0)},handlePaste(i,o){let s=o.clipboardData?.getData(ns);if(!s)return!1;let l=fg(s);if(l?.ids.length&&e.copy&&(!l.page||l.page!==t()))return o.preventDefault(),bg(i,n,l,e),!0;let a=is(i.state,n,s);return a?(i.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0):!1},transformPastedHTML:i=>hg(i),clipboardTextSerializer(i,o){return o.state.selection.content().eq(i)?rs(o.state,n).text:gg(o.state.schema,i)},clipboardTextParser(i,o,s,l){return Zc(l.state.schema,i)},transformPasted(i,o){let s=i;if(es(o.state.selection.$from)){let l=!1;i.content.forEach(a=>{l=l||a.type.name==="columns"}),l&&(s=x.maxOpen(Gr(i.content)))}return Xc(s,o.state,n)}}})}async function bg(n,e,t,r){let i=null;try{i=await r.copy(t.ids)}catch{}if(!i||i.status!==200){r.refused?.(i?.json?.refused??"the images could not be copied. Check your connection and try again.");return}r.copied?.(i.json??{});let o=is(n.state,e,dg(t.payload,i.json??{}));o&&n.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste"))}var Qc=32;function nn(n,e){return e?`${n}#^${e}`:n}function xg(n){switch(n?.kind){case"broken":return{broken:!0};case"date":return{href:n.href,day:n.title};case"pending":return{href:n.href,pending:!0};case"team":case"block":return{href:n.href,title:n.title,alias:!!n.alias,icon:n.icon||null};case"block gone":return{href:n.href,title:n.title,alias:!!n.alias,blockGone:!0}}return null}function kg(n,e=new Date().getFullYear()){return $i(n)?W(n)?{href:`/d/${n}`,day:Xt(n,e)}:{broken:!0}:{href:`/new?${new URLSearchParams({title:n}).toString()}`,pending:!0}}var Xr=class{constructor(e={},t=null){this.known=new Map(Object.entries(e)),this.ask=t,this.waiting=new Set,this.asked=new Set,this.watchers=new Set,this.timer=null}answer(e,t=""){let r=nn(e,t),i=xg(this.known.get(r));return i||(this.ask&&!this.asked.has(r)&&(this.waiting.add(r),this.soon()),kg(e))}soon(){this.timer===null&&(this.timer=setTimeout(()=>{this.timer=null,this.flush()},0))}async flush(){let e=[...this.waiting].slice(0,Qc);if(e.length===0)return;for(let i of e)this.waiting.delete(i),this.asked.add(i);this.waiting.size>0&&this.soon();let t;try{t=await this.ask(e)}catch{for(let i of e)this.asked.delete(i);return}let r=new Set;for(let[i,o]of Object.entries(t??{}))this.known.set(i,o),r.add(i);if(r.size)for(let i of this.watchers)i(r)}async lookup(e){let t=e.filter(r=>!this.known.has(r)).slice(0,Qc);if(t.length&&this.ask)try{for(let[r,i]of Object.entries(await this.ask(t)??{}))this.known.set(r,i)}catch{}return Object.fromEntries(e.map(r=>[r,this.known.get(r)]))}watch(e){return this.watchers.add(e),()=>this.watchers.delete(e)}};function ls(n){return n.type.name==="datelink"?nn(n.attrs.date,n.attrs.anchor):nn(n.attrs.target,n.attrs.anchor)}function eu(n){return re.renderSpec(document,n.type.spec.toDOM(n)).dom}var as=class{constructor(e,t){this.node=e,this.dom=eu(e),this.unwatch=t.watch(r=>{r.has(ls(this.node))&&this.redraw()})}redraw(){let e=eu(this.node);if(e.nodeName===this.dom.nodeName){for(let{name:t}of[...this.dom.attributes])t!=="contenteditable"&&!e.hasAttribute(t)&&this.dom.removeAttribute(t);for(let{name:t,value:r}of e.attributes)this.dom.setAttribute(t,r);this.dom.replaceChildren(...e.childNodes)}}update(e){return e.type!==this.node.type||ls(e)!==ls(this.node)||e.attrs.shown!==this.node.attrs.shown?!1:(this.node=e,!0)}ignoreMutation(){return!0}destroy(){this.unwatch()}};function tu(n){let e=t=>new as(t,n);return{wikilink:e,datelink:e}}var nu=1200,wg=120*1e3,Zr=60*1024,ru=3;function Sg(n=()=>Math.random()){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="";for(let r=0;r<24;r++)t+=e[Math.floor(n()*e.length)];return t}var ei=class{constructor(e,t){this.deps=t,this.drafts=e.drafts,this.page=e.page??"",this.token=e.first?(t.token??Sg)():null,this.base=e.draft?e.draft.base:e.base,this.version=e.draft?e.draft.version:"0",this.own=!!e.draft&&this.stored()===e.draft.version,this.closed=!!e.draft&&this.stored("mapa-closing:")===e.draft.version,this.offered=!!e.draft&&!this.own,this.saved=ge(e.source),this.loadedVersion=this.version,this.dirty=!1,this.inflight=null,this.tries=new Map,this.conflict=null,this.gone=!1,this.orphan=!1,this.holding=!1,this.resolving=!1,this.stopped=!1,this.failures=0,this.unacked=null,this.timers={autosave:null,idle:null,retry:null}}get key(){return`mapa-draft:${this.drafts}`}stored(e="mapa-draft:"){try{return this.deps.storage?.get(e+this.drafts)??null}catch{return null}}remember(){try{this.deps.storage?.set(this.key,this.version)}catch{}}forget(){try{this.deps.storage?.remove(this.key)}catch{}}status(e){this.deps.ui?.status?.(e)}later(e,t,r){let i=this.deps.timers??globalThis;this.timers[e]!==null&&i.clearTimeout(this.timers[e]),this.timers[e]=i.setTimeout(()=>{this.timers[e]=null,t()},r)}cancel(e){let t=this.deps.timers??globalThis;this.timers[e]!==null&&t.clearTimeout(this.timers[e]),this.timers[e]=null}changed(){this.stopped||(this.dirty=!0,this.own=!0,this.offered=!1,this.cancel("idle"),this.later("autosave",()=>this.autosave(),this.deps.delay??nu))}unsaved(){return this.dirty||this.deps.editor.current()!==this.saved}committable(){return this.own&&(this.unsaved()||this.version!=="0")}mayCommit(){return!this.conflict&&!this.gone&&!this.holding}hold(){this.holding=!0,this.cancel("idle")}autosave(e=!1){if(this.stopped||this.orphan)return Promise.resolve(!1);if(this.inflight)return this.inflight.then(()=>this.autosave(e));this.cancel("autosave");let t=this.deps.editor.prepare();if(!e&&t===this.saved)return this.dirty=!1,Promise.resolve(!0);this.dirty=!1,this.status("saving");let r=this.token?this.first(t):this.send(t);return this.inflight=r.finally(()=>{this.inflight=null}),this.inflight}async send(e){let t;try{t=await this.deps.post(this.drafts,{base:this.base,version:this.version,body:e})}catch{return this.unacked=e,this.offline()}return t.status===409?(this.stale(t.json),!1):(this.unacked=null,t.status===404?this.orphaned():t.status!==200?this.offline():(this.failures=0,this.stored_(e,t.json),await this.behind(t.json.merge,e),!0))}stored_(e,t){this.version=t.version,this.saved=e,this.own=!0,this.remember(),this.status(this.gone?"draft":"saved"),this.mayCommit()&&this.later("idle",()=>this.commit(),this.deps.idle??wg)}offline(){return this.dirty=!0,this.failures++,this.failures>ru?(this.status("failed"),!1):(this.status("retrying"),this.later("retry",()=>this.autosave(),(this.deps.delay??nu)*2**this.failures),!1)}async first(e){if(V(e)==="")return this.status("idle"),!0;let t;try{t=await this.deps.post("/scratch",{first:this.token,version:this.version,body:e})}catch{return this.offline()}if(t.status===422)return this.status("idle"),!0;if(t.status!==200)return this.offline();this.failures=0;let r=t.json;return this.token=null,this.page=r.page,this.drafts=`/p/${r.page}/draft`,this.deps.replaceURL?.(r.href),r.version===void 0?(this.base=r.revision,this.saved=e,this.status("saved"),!0):(r.revision!==void 0&&(this.base=this.base==="0"?r.revision:this.base),this.stored_(e,r),await this.behind(r.merge,e),!0)}async behind(e,t){if(this.conflict&&!e?.conflict&&this.settled(),!!e){if(e.gone){this.lost();return}if(e.noBase){this.cancel("idle"),this.deps.ui?.notice?.("noBase",{page:this.page});return}if(e.conflict){if(this.cancel("idle"),this.deps.editor.current()!==t){this.later("autosave",()=>this.autosave(!0),0);return}if(this.conflict&&Cg(this.conflict,e)){this.conflict={...this.conflict,version:this.version,sent:t};return}this.conflict={agains |