@pod-os/elements 0.32.1-rc.f28b628.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/pos-add-new-thing_29.cjs.entry.js +2 -1
- package/dist/cjs/pos-markdown-document.cjs.entry.js +2667 -250
- package/dist/cjs/pos-markdown-document.entry.cjs.js.map +1 -1
- package/dist/collection/components/pos-upload/pos-upload.js +2 -1
- package/dist/collection/components/pos-upload/pos-upload.js.map +1 -1
- package/dist/components/pos-markdown-document2.js +2667 -250
- package/dist/components/pos-markdown-document2.js.map +1 -1
- package/dist/components/pos-upload2.js +2 -1
- package/dist/components/pos-upload2.js.map +1 -1
- package/dist/elements/elements.esm.js +1 -1
- package/dist/elements/{p-634ec3ba.entry.js → p-3f3bfccf.entry.js} +2 -2
- package/dist/elements/{p-634ec3ba.entry.js.map → p-3f3bfccf.entry.js.map} +1 -1
- package/dist/elements/p-66ff17ba.entry.js +2 -0
- package/dist/elements/p-66ff17ba.entry.js.map +1 -0
- package/dist/elements/pos-markdown-document.entry.esm.js.map +1 -1
- package/dist/esm/pos-add-new-thing_29.entry.js +2 -1
- package/dist/esm/pos-markdown-document.entry.js +2667 -250
- package/dist/esm/pos-markdown-document.entry.js.map +1 -1
- package/package.json +10 -10
- package/dist/elements/p-300ef87f.entry.js +0 -2
- package/dist/elements/p-300ef87f.entry.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as t,c as e,h as r}from"./p-CTyMYUsB.js";import{r as n,a as i,b as s,c as o,d as l,e as u,f as a,g as f,h,i as c,j as d,k as p,l as m,m as g,n as w,o as b,p as v,q as k,s as y,t as M,u as x,v as O,w as S,x as T,y as E,z as A,A as $,B as R,C,D as L,E as N,F as j,G as P,H as I,I as D,J as H,K as z,L as _,M as B,N as U,O as F,P as q,Q as K,R as W,S as J,T as V,U as G,V as Z,W as Q,X,Y,Z as tt,_ as et,$ as rt,a0 as nt,a1 as it,a2 as st,a3 as ot,a4 as lt,a5 as ut,a6 as at,a7 as ft,a8 as ht,a9 as ct,aa as dt,ab as pt,ac as mt,ad as gt,ae as wt,af as bt,ag as vt,ah as kt,ai as yt,aj as Mt,ak as xt,al as Ot,am as St,an as Tt,ao as Et,ap as At,aq as $t,ar as Rt,as as Ct,at as Lt,au as Nt,av as jt,aw as Pt,ax as It,ay as Dt,az as Ht,aA as zt,aB as _t,aC as Bt,aD as Ut,aE as Ft,aF as qt,aG as Kt,aH as Wt,aI as Jt,aJ as Vt,aK as Gt,aL as Zt,aM as Qt,aN as Xt,aO as Yt,aP as te,aQ as ee,aR as re,aS as ne,aT as ie,aU as se,aV as oe,aW as le,aX as ue}from"./p-CCo3ckDn.js";import"./p-BQSzBvyx.js";function ae(t){this.content=t}ae.prototype={constructor:ae,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?undefined:this.content[e+1]},update:function(t,e,r){var n=r&&r!=t?this.remove(r):this;var i=n.find(t),s=n.content.slice();if(i==-1){s.push(r||t,e)}else{s[i+1]=e;if(r)s[i]=r}return new ae(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var r=this.content.slice();r.splice(e,2);return new ae(r)},addToStart:function(t,e){return new ae([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();r.push(t,e);return new ae(r)},addBefore:function(t,e,r){var n=this.remove(e),i=n.content.slice();var s=n.find(t);i.splice(s==-1?i.length:s,0,e,r);return new ae(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){t=ae.from(t);if(!t.size)return this;return new ae(t.content.concat(this.subtract(t).content))},append:function(t){t=ae.from(t);if(!t.size)return this;return new ae(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=ae.from(t);for(var r=0;r<t.content.length;r+=2)e=e.remove(t.content[r]);return e},toObject:function(){var t={};this.forEach((function(e,r){t[e]=r}));return t},get size(){return this.content.length>>1}};ae.from=function(t){if(t instanceof ae)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new ae(e)};function fe(t,e,r){for(let n=0;;n++){if(n==t.childCount||n==e.childCount)return t.childCount==e.childCount?null:r;let i=t.child(n),s=e.child(n);if(i==s){r+=i.nodeSize;continue}if(!i.sameMarkup(s))return r;if(i.isText&&i.text!=s.text){for(let t=0;i.text[t]==s.text[t];t++)r++;return r}if(i.content.size||s.content.size){let t=fe(i.content,s.content,r+1);if(t!=null)return t}r+=i.nodeSize}}function he(t,e,r,n){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:r,b:n};let o=t.child(--i),l=e.child(--s),u=o.nodeSize;if(o==l){r-=u;n-=u;continue}if(!o.sameMarkup(l))return{a:r,b:n};if(o.isText&&o.text!=l.text){let t=0,e=Math.min(o.text.length,l.text.length);while(t<e&&o.text[o.text.length-t-1]==l.text[l.text.length-t-1]){t++;r--;n--}return{a:r,b:n}}if(o.content.size||l.content.size){let t=he(o.content,l.content,r-1,n-1);if(t)return t}r-=u;n-=u}}class ce{constructor(t,e){this.content=t;this.size=e||0;if(e==null)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,r,n=0,i){for(let s=0,o=0;o<e;s++){let l=this.content[s],u=o+l.nodeSize;if(u>t&&r(l,n+o,i||null,s)!==false&&l.content.size){let i=o+1;l.nodesBetween(Math.max(0,t-i),Math.min(l.content.size,e-i),r,n+i)}o=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,n){let i="",s=true;this.nodesBetween(t,e,((o,l)=>{let u=o.isText?o.text.slice(Math.max(t,l)-l,e-l):!o.isLeaf?"":n?typeof n==="function"?n(o):n:o.type.spec.leafText?o.type.spec.leafText(o):"";if(o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r){if(s)s=false;else i+=r}i+=u}),0);return i}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,n=this.content.slice(),i=0;if(e.isText&&e.sameMarkup(r)){n[n.length-1]=e.withText(e.text+r.text);i=1}for(;i<t.content.length;i++)n.push(t.content[i]);return new ce(n,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let r=[],n=0;if(e>t)for(let i=0,s=0;s<e;i++){let o=this.content[i],l=s+o.nodeSize;if(l>t){if(s<t||l>e){if(o.isText)o=o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s));else o=o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))}r.push(o);n+=o.nodeSize}s=l}return new ce(r,n)}cutByIndex(t,e){if(t==e)return ce.empty;if(t==0&&e==this.content.length)return this;return new ce(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let n=this.content.slice();let i=this.size+e.nodeSize-r.nodeSize;n[t]=e;return new ce(n,i)}addToStart(t){return new ce([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new ce(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return false;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return false;return true}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,r=0;e<this.content.length;e++){let n=this.content[e];t(n,r,e);r+=n.nodeSize}}findDiffStart(t,e=0){return fe(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return he(this,t,e,r)}findIndex(t){if(t==0)return pe(0,t);if(t==this.size)return pe(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,r=0;;e++){let n=this.child(e),i=r+n.nodeSize;if(i>=t){if(i==t)return pe(e+1,i);return pe(e,r)}r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return ce.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new ce(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return ce.empty;let e,r=0;for(let n=0;n<t.length;n++){let i=t[n];r+=i.nodeSize;if(n&&i.isText&&t[n-1].sameMarkup(i)){if(!e)e=t.slice(0,n);e[e.length-1]=i.withText(e[e.length-1].text+i.text)}else if(e){e.push(i)}}return new ce(e||t,r)}static from(t){if(!t)return ce.empty;if(t instanceof ce)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new ce([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ce.empty=new ce([],0);const de={index:0,offset:0};function pe(t,e){de.index=t;de.offset=e;return de}function me(t,e){if(t===e)return true;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return false;let r=Array.isArray(t);if(Array.isArray(e)!=r)return false;if(r){if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!me(t[r],e[r]))return false}else{for(let r in t)if(!(r in e)||!me(t[r],e[r]))return false;for(let r in e)if(!(r in t))return false}return true}let ge=class t{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,r=false;for(let n=0;n<t.length;n++){let i=t[n];if(this.eq(i))return t;if(this.type.excludes(i.type)){if(!e)e=t.slice(0,n)}else if(i.type.excludes(this.type)){return t}else{if(!r&&i.type.rank>this.type.rank){if(!e)e=t.slice(0,n);e.push(this);r=true}if(e)e.push(i)}}if(!e)e=t.slice();if(!r)e.push(this);return e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return true;return false}eq(t){return this==t||this.type==t.type&&me(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[e.type];if(!r)throw new RangeError(`There is no mark type ${e.type} in this schema`);let n=r.create(e.attrs);r.checkAttrs(n.attrs);return n}static sameSet(t,e){if(t==e)return true;if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return false;return true}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return t.none;if(e instanceof t)return[e];let r=e.slice();r.sort(((t,e)=>t.type.rank-e.type.rank));return r}};ge.none=[];class we extends Error{}class be{constructor(t,e,r){this.content=t;this.openStart=e;this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let r=ke(this.content,t+this.openStart,e);return r&&new be(r,this.openStart,this.openEnd)}removeBetween(t,e){return new be(ve(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};if(this.openStart>0)t.openStart=this.openStart;if(this.openEnd>0)t.openEnd=this.openEnd;return t}static fromJSON(t,e){if(!e)return be.empty;let r=e.openStart||0,n=e.openEnd||0;if(typeof r!="number"||typeof n!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new be(ce.fromJSON(t,e.content),r,n)}static maxOpen(t,e=true){let r=0,n=0;for(let n=t.firstChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.firstChild)r++;for(let r=t.lastChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.lastChild)n++;return new be(t,r,n)}}be.empty=new be(ce.empty,0,0);function ve(t,e,r){let{index:n,offset:i}=t.findIndex(e),s=t.maybeChild(n);let{index:o,offset:l}=t.findIndex(r);if(i==e||s.isText){if(l!=r&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(n!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(n,s.copy(ve(s.content,e-i-1,r-i-1)))}function ke(t,e,r,n){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText){if(n&&!n.canReplace(i,i,r))return null;return t.cut(0,e).append(r).append(t.cut(e))}let l=ke(o.content,e-s-1,r,o);return l&&t.replaceChild(i,o.copy(l))}function ye(t,e,r){if(r.openStart>t.depth)throw new we("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new we("Inconsistent open depths");return Me(t,e,r,0)}function Me(t,e,r,n){let i=t.index(n),s=t.node(n);if(i==e.index(n)&&n<t.depth-r.openStart){let o=Me(t,e,r,n+1);return s.copy(s.content.replaceChild(i,o))}else if(!r.content.size){return Ee(s,$e(t,e,n))}else if(!r.openStart&&!r.openEnd&&t.depth==n&&e.depth==n){let n=t.parent,i=n.content;return Ee(n,i.cut(0,t.parentOffset).append(r.content).append(i.cut(e.parentOffset)))}else{let{start:i,end:o}=Re(r,t);return Ee(s,Ae(t,i,o,e,n))}}function xe(t,e){if(!e.type.compatibleContent(t.type))throw new we("Cannot join "+e.type.name+" onto "+t.type.name)}function Oe(t,e,r){let n=t.node(r);xe(n,e.node(r));return n}function Se(t,e){let r=e.length-1;if(r>=0&&t.isText&&t.sameMarkup(e[r]))e[r]=t.withText(e[r].text+t.text);else e.push(t)}function Te(t,e,r,n){let i=(e||t).node(r);let s=0,o=e?e.index(r):i.childCount;if(t){s=t.index(r);if(t.depth>r){s++}else if(t.textOffset){Se(t.nodeAfter,n);s++}}for(let t=s;t<o;t++)Se(i.child(t),n);if(e&&e.depth==r&&e.textOffset)Se(e.nodeBefore,n)}function Ee(t,e){t.type.checkContent(e);return t.copy(e)}function Ae(t,e,r,n,i){let s=t.depth>i&&Oe(t,e,i+1);let o=n.depth>i&&Oe(r,n,i+1);let l=[];Te(null,t,i,l);if(s&&o&&e.index(i)==r.index(i)){xe(s,o);Se(Ee(s,Ae(t,e,r,n,i+1)),l)}else{if(s)Se(Ee(s,$e(t,e,i+1)),l);Te(e,r,i,l);if(o)Se(Ee(o,$e(r,n,i+1)),l)}Te(n,null,i,l);return new ce(l)}function $e(t,e,r){let n=[];Te(null,t,r,n);if(t.depth>r){let i=Oe(t,e,r+1);Se(Ee(i,$e(t,e,r+1)),n)}Te(e,null,r,n);return new ce(n)}function Re(t,e){let r=e.depth-t.openStart,n=e.node(r);let i=n.copy(t.content);for(let t=r-1;t>=0;t--)i=e.node(t).copy(ce.from(i));return{start:i.resolveNoCache(t.openStart+r),end:i.resolveNoCache(i.content.size-t.openEnd-r)}}class Ce{constructor(t,e,r){this.pos=t;this.path=e;this.parentOffset=r;this.depth=e.length/3-1}resolveDepth(t){if(t==null)return this.depth;if(t<0)return this.depth+t;return t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){t=this.resolveDepth(t);return this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){t=this.resolveDepth(t);return t==0?0:this.path[t*3-1]+1}end(t){t=this.resolveDepth(t);return this.start(t)+this.node(t).content.size}before(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],n=t.child(e);return r?t.child(e).cut(r):n}get nodeBefore(){let t=this.index(this.depth);let e=this.pos-this.path[this.path.length-1];if(e)return this.parent.child(t).cut(0,e);return t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[e*3],n=e==0?0:this.path[e*3-1]+1;for(let e=0;e<t;e++)n+=r.child(e).nodeSize;return n}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return ge.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),n=t.maybeChild(e);if(!r){let t=r;r=n;n=t}let i=r.marks;for(var s=0;s<i.length;s++)if(i[s].type.spec.inclusive===false&&(!n||!i[s].isInSet(n.marks)))i=i[s--].removeFromSet(i);return i}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,n=t.parent.maybeChild(t.index());for(var i=0;i<r.length;i++)if(r[i].type.spec.inclusive===false&&(!n||!r[i].isInSet(n.marks)))r=r[i--].removeFromSet(r);return r}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new Pe(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[];let n=0,i=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(i);let o=i-s;r.push(e,t,n+s);if(!o)break;e=e.child(t);if(e.isText)break;i=o-1;n+=s+1}return new Ce(e,r,i)}static resolveCached(t,e){let r=je.get(t);if(r){for(let t=0;t<r.elts.length;t++){let n=r.elts[t];if(n.pos==e)return n}}else{je.set(t,r=new Le)}let n=r.elts[r.i]=Ce.resolve(t,e);r.i=(r.i+1)%Ne;return n}}class Le{constructor(){this.elts=[];this.i=0}}const Ne=12,je=new WeakMap;class Pe{constructor(t,e,r){this.$from=t;this.$to=e;this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Ie=Object.create(null);class De{constructor(t,e,r,n=ge.none){this.type=t;this.attrs=e;this.marks=n;this.content=r||ce.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,r,n=0){this.content.nodesBetween(t,e,r,n,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,r,n){return this.content.textBetween(t,e,r,n)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,r){return this.type==t&&me(this.attrs,e||t.defaultAttrs||Ie)&&ge.sameSet(this.marks,r||ge.none)}copy(t=null){if(t==this.content)return this;return new De(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new De(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){if(t==0&&e==this.content.size)return this;return this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,r=false){if(t==e)return be.empty;let n=this.resolve(t),i=this.resolve(e);let s=r?0:n.sharedDepth(e);let o=n.start(s),l=n.node(s);let u=l.content.cut(n.pos-o,i.pos-o);return new be(u,n.depth-s,i.depth-s)}replace(t,e,r){return ye(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:n}=e.content.findIndex(t);e=e.maybeChild(r);if(!e)return null;if(n==t||e.isText)return e;t-=n+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let n=this.content.child(e-1);return{node:n,index:e-1,offset:r-n.nodeSize}}resolve(t){return Ce.resolveCached(this,t)}resolveNoCache(t){return Ce.resolve(this,t)}rangeHasMark(t,e,r){let n=false;if(e>t)this.nodesBetween(t,e,(t=>{if(r.isInSet(t.marks))n=true;return!n}));return n}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;if(this.content.size)t+="("+this.content.toStringInner()+")";return ze(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,r=ce.empty,n=0,i=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,n,i);let o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return false;for(let t=n;t<i;t++)if(!this.type.allowsMarks(r.child(t).marks))return false;return true}canReplaceWith(t,e,r,n){if(n&&!this.type.allowsMarks(n))return false;let i=this.contentMatchAt(t).matchType(r);let s=i&&i.matchFragment(this.content,e);return s?s.validEnd:false}canAppend(t){if(t.content.size)return this.canReplace(this.childCount,this.childCount,t.content);else return this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);this.type.checkAttrs(this.attrs);let t=ge.none;for(let e=0;e<this.marks.length;e++){let r=this.marks[e];r.type.checkAttrs(r.attrs);t=r.addToSet(t)}if(!ge.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}if(this.content.size)t.content=this.content.toJSON();if(this.marks.length)t.marks=this.marks.map((t=>t.toJSON()));return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let r=undefined;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let n=ce.fromJSON(t,e.content);let i=t.nodeType(e.type).create(e.attrs,n,r);i.type.checkAttrs(i.attrs);return i}}De.prototype.text=undefined;class He extends De{constructor(t,e,r,n){super(t,e,null,n);if(!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return ze(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new He(this.type,this.attrs,this.text,t)}withText(t){if(t==this.text)return this;return new He(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){if(t==0&&e==this.text.length)return this;return this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();t.text=this.text;return t}}function ze(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class _e{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let r=new Be(t,e);if(r.next==null)return _e.empty;let n=Ue(r);if(r.next)r.err("Unexpected trailing text");let i=Xe(Ge(n));Ye(i,r);return i}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,r=t.childCount){let n=this;for(let i=e;n&&i<r;i++)n=n.matchType(t.child(i).type);return n}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!(e.isText||e.hasRequiredAttrs()))return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return true;return false}fillBefore(t,e=false,r=0){let n=[this];function i(s,o){let l=s.matchFragment(t,r);if(l&&(!e||l.validEnd))return ce.from(o.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:r}=s.next[t];if(!(e.isText||e.hasRequiredAttrs())&&n.indexOf(r)==-1){n.push(r);let t=i(r,o.concat(e));if(t)return t}}return null}return i(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);this.wrapCache.push(t,e);return e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];while(r.length){let n=r.shift(),i=n.match;if(i.matchType(t)){let t=[];for(let e=n;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<i.next.length;t++){let{type:s,next:o}=i.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!n.type||o.validEnd)){r.push({match:s.contentMatch,type:s,via:n});e[s.name]=true}}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(r){t.push(r);for(let n=0;n<r.next.length;n++)if(t.indexOf(r.next[n].next)==-1)e(r.next[n].next)}e(this);return t.map(((e,r)=>{let n=r+(e.validEnd?"*":" ")+" ";for(let r=0;r<e.next.length;r++)n+=(r?", ":"")+e.next[r].type.name+"->"+t.indexOf(e.next[r].next);return n})).join("\n")}}_e.empty=new _e(true);class Be{constructor(t,e){this.string=t;this.nodeTypes=e;this.inline=null;this.pos=0;this.tokens=t.split(/\s*(?=\b|\W|$)/);if(this.tokens[this.tokens.length-1]=="")this.tokens.pop();if(this.tokens[0]=="")this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||true)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function Ue(t){let e=[];do{e.push(Fe(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Fe(t){let e=[];do{e.push(qe(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function qe(t){let e=Ve(t);for(;;){if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=We(t,e);else break}return e}function Ke(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function We(t,e){let r=Ke(t),n=r;if(t.eat(",")){if(t.next!="}")n=Ke(t);else n=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:r,max:n,expr:e}}function Je(t,e){let r=t.nodeTypes,n=r[e];if(n)return[n];let i=[];for(let t in r){let n=r[t];if(n.isInGroup(e))i.push(n)}if(i.length==0)t.err("No node type or group '"+e+"' found");return i}function Ve(t){if(t.eat("(")){let e=Ue(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=Je(t,t.next).map((e=>{if(t.inline==null)t.inline=e.isInline;else if(t.inline!=e.isInline)t.err("Mixing inline and block content");return{type:"name",value:e}}));t.pos++;return e.length==1?e[0]:{type:"choice",exprs:e}}else{t.err("Unexpected token '"+t.next+"'")}}function Ge(t){let e=[[]];i(s(t,0),r());return e;function r(){return e.push([])-1}function n(t,r,n){let i={term:n,to:r};e[t].push(i);return i}function i(t,e){t.forEach((t=>t.to=e))}function s(t,e){if(t.type=="choice"){return t.exprs.reduce(((t,r)=>t.concat(s(r,e))),[])}else if(t.type=="seq"){for(let n=0;;n++){let o=s(t.exprs[n],e);if(n==t.exprs.length-1)return o;i(o,e=r())}}else if(t.type=="star"){let o=r();n(e,o);i(s(t.expr,o),o);return[n(o)]}else if(t.type=="plus"){let o=r();i(s(t.expr,e),o);i(s(t.expr,o),o);return[n(o)]}else if(t.type=="opt"){return[n(e)].concat(s(t.expr,e))}else if(t.type=="range"){let o=e;for(let e=0;e<t.min;e++){let e=r();i(s(t.expr,o),e);o=e}if(t.max==-1){i(s(t.expr,o),o)}else{for(let e=t.min;e<t.max;e++){let e=r();n(o,e);i(s(t.expr,o),e);o=e}}return[n(o)]}else if(t.type=="name"){return[n(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function Ze(t,e){return e-t}function Qe(t,e){let r=[];n(e);return r.sort(Ze);function n(e){let i=t[e];if(i.length==1&&!i[0].term)return n(i[0].to);r.push(e);for(let t=0;t<i.length;t++){let{term:e,to:s}=i[t];if(!e&&r.indexOf(s)==-1)n(s)}}}function Xe(t){let e=Object.create(null);return r(Qe(t,0));function r(n){let i=[];n.forEach((e=>{t[e].forEach((({term:e,to:r})=>{if(!e)return;let n;for(let t=0;t<i.length;t++)if(i[t][0]==e)n=i[t][1];Qe(t,r).forEach((t=>{if(!n)i.push([e,n=[]]);if(n.indexOf(t)==-1)n.push(t)}))}))}));let s=e[n.join(",")]=new _e(n.indexOf(t.length-1)>-1);for(let t=0;t<i.length;t++){let n=i[t][1].sort(Ze);s.next.push({type:i[t][0],next:e[n.join(",")]||r(n)})}return s}}function Ye(t,e){for(let r=0,n=[t];r<n.length;r++){let t=n[r],i=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:r,next:o}=t.next[e];s.push(r.name);if(i&&!(r.isText||r.hasRequiredAttrs()))i=false;if(n.indexOf(o)==-1)n.push(o)}if(i)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function tr(t){let e=Object.create(null);for(let r in t){let n=t[r];if(!n.hasDefault)return null;e[r]=n.default}return e}function er(t,e){let r=Object.create(null);for(let n in t){let i=e&&e[n];if(i===undefined){let e=t[n];if(e.hasDefault)i=e.default;else throw new RangeError("No value supplied for attribute "+n)}r[n]=i}return r}function rr(t,e,r,n){for(let n in e)if(!(n in t))throw new RangeError(`Unsupported attribute ${n} for ${r} of type ${n}`);for(let r in t){let n=t[r];if(n.validate)n.validate(e[r])}}function nr(t,e){let r=Object.create(null);if(e)for(let n in e)r[n]=new or(t,n,e[n]);return r}let ir=class t{constructor(t,e,r){this.name=t;this.schema=e;this.spec=r;this.markSet=null;this.groups=r.group?r.group.split(" "):[];this.attrs=nr(t,r.attrs);this.defaultAttrs=tr(this.attrs);this.contentMatch=null;this.inlineContent=null;this.isBlock=!(r.inline||t=="text");this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==_e.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return true;return false}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){if(!t&&this.defaultAttrs)return this.defaultAttrs;else return er(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new De(this,this.computeAttrs(t),ce.from(e),ge.setFrom(r))}createChecked(t=null,e,r){e=ce.from(e);this.checkContent(e);return new De(this,this.computeAttrs(t),e,ge.setFrom(r))}createAndFill(t=null,e,r){t=this.computeAttrs(t);e=ce.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let n=this.contentMatch.matchFragment(e);let i=n&&n.fillBefore(ce.empty,true);if(!i)return null;return new De(this,t,e.append(i),ge.setFrom(r))}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return false;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return false;return true}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){rr(this.attrs,t,"node")}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return true;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return false;return true}allowedMarks(t){if(this.markSet==null)return t;let e;for(let r=0;r<t.length;r++){if(!this.allowsMarkType(t[r].type)){if(!e)e=t.slice(0,r)}else if(e){e.push(t[r])}}return!e?t:e.length?e:ge.none}static compile(e,r){let n=Object.create(null);e.forEach(((e,i)=>n[e]=new t(e,r,i)));let i=r.spec.topNode||"doc";if(!n[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let t in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function sr(t,e,r){let n=r.split("|");return r=>{let i=r===null?"null":typeof r;if(n.indexOf(i)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${t}, got ${i}`)}}class or{constructor(t,e,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default");this.default=r.default;this.validate=typeof r.validate=="string"?sr(t,e,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class lr{constructor(t,e,r,n){this.name=t;this.rank=e;this.schema=r;this.spec=n;this.attrs=nr(t,n.attrs);this.excluded=null;let i=tr(this.attrs);this.instance=i?new ge(this,i):null}create(t=null){if(!t&&this.instance)return this.instance;return new ge(this,er(this.attrs,t))}static compile(t,e){let r=Object.create(null),n=0;t.forEach(((t,i)=>r[t]=new lr(t,n++,e,i)));return r}removeFromSet(t){for(var e=0;e<t.length;e++)if(t[e].type==this){t=t.slice(0,e).concat(t.slice(e+1));e--}return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){rr(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class ur{constructor(t){this.linebreakReplacement=null;this.cached=Object.create(null);let e=this.spec={};for(let r in t)e[r]=t[r];e.nodes=ae.from(t.nodes),e.marks=ae.from(t.marks||{}),this.nodes=ir.compile(this.spec.nodes,this);this.marks=lr.compile(this.spec.marks,this);let r=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],n=e.spec.content||"",i=e.spec.marks;e.contentMatch=r[n]||(r[n]=_e.parse(n,this.nodes));e.inlineContent=e.contentMatch.inlineContent;if(e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet=i=="_"?null:i?ar(this,i.split(" ")):i==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=r==null?[e]:r==""?[]:ar(this,r.split(" "))}this.nodeFromJSON=t=>De.fromJSON(this,t);this.markFromJSON=t=>ge.fromJSON(this,t);this.topNodeType=this.nodes[this.spec.topNode||"doc"];this.cached.wrappings=Object.create(null)}node(t,e=null,r,n){if(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof ir))throw new RangeError("Invalid node type: "+t);else if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")");return t.createChecked(e,r,n)}text(t,e){let r=this.nodes.text;return new He(r,r.defaultAttrs,t,ge.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function ar(t,e){let r=[];for(let n=0;n<e.length;n++){let i=e[n],s=t.marks[i],o=s;if(s){r.push(s)}else{for(let e in t.marks){let n=t.marks[e];if(i=="_"||n.spec.group&&n.spec.group.split(" ").indexOf(i)>-1)r.push(o=n)}}if(!o)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return r}function fr(t){return t.tag!=null}function hr(t){return t.style!=null}class cr{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];let r=this.matchedStyles=[];e.forEach((t=>{if(fr(t)){this.tags.push(t)}else if(hr(t)){let e=/[^=]*/.exec(t.style)[0];if(r.indexOf(e)<0)r.push(e);this.styles.push(t)}}));this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return false;let r=t.nodes[e.node];return r.contentMatch.matchType(r)}))}parse(t,e={}){let r=new yr(this,e,false);r.addAll(t,ge.none,e.from,e.to);return r.finish()}parseSlice(t,e={}){let r=new yr(this,e,true);r.addAll(t,ge.none,e.from,e.to);return be.maxOpen(r.finish())}matchTag(t,e,r){for(let n=r?this.tags.indexOf(r)+1:0;n<this.tags.length;n++){let r=this.tags[n];if(xr(t,r.tag)&&(r.namespace===undefined||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(e===false)continue;r.attrs=e||undefined}return r}}}matchStyle(t,e,r,n){for(let i=n?this.styles.indexOf(n)+1:0;i<this.styles.length;i++){let n=this.styles[i],s=n.style;if(s.indexOf(t)!=0||n.context&&!r.matchesContext(n.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(n.getAttrs){let t=n.getAttrs(e);if(t===false)continue;n.attrs=t||undefined}return n}}static schemaRules(t){let e=[];function r(t){let r=t.priority==null?50:t.priority,n=0;for(;n<e.length;n++){let t=e[n],i=t.priority==null?50:t.priority;if(i<r)break}e.splice(n,0,t)}for(let e in t.marks){let n=t.marks[e].spec.parseDOM;if(n)n.forEach((t=>{r(t=Or(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let n=t.nodes[e].spec.parseDOM;if(n)n.forEach((t=>{r(t=Or(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new cr(t,cr.schemaRules(t)))}}const dr={address:true,article:true,aside:true,blockquote:true,canvas:true,dd:true,div:true,dl:true,fieldset:true,figcaption:true,figure:true,footer:true,form:true,h1:true,h2:true,h3:true,h4:true,h5:true,h6:true,header:true,hgroup:true,hr:true,li:true,noscript:true,ol:true,output:true,p:true,pre:true,section:true,table:true,tfoot:true,ul:true};const pr={head:true,noscript:true,object:true,script:true,style:true,title:true};const mr={ol:true,ul:true};const gr=1,wr=2,br=4;function vr(t,e,r){if(e!=null)return(e?gr:0)|(e==="full"?wr:0);return t&&t.whitespace=="pre"?gr|wr:r&-5}class kr{constructor(t,e,r,n,i,s){this.type=t;this.attrs=e;this.marks=r;this.solid=n;this.options=s;this.content=[];this.activeMarks=ge.none;this.match=i||(s&br?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(ce.from(t));if(e){this.match=this.type.contentMatch.matchFragment(e)}else{let e=this.type.contentMatch,r;if(r=e.findWrapping(t.type)){this.match=e;return r}else{return null}}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&gr)){let t=this.content[this.content.length-1],e;if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let r=t;if(t.text.length==e[0].length)this.content.pop();else this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-e[0].length))}}let e=ce.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(ce.empty,true));return this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){if(this.type)return this.type.inlineContent;if(this.content.length)return this.content[0].isInline;return t.parentNode&&!dr.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class yr{constructor(t,e,r){this.parser=t;this.options=e;this.isOpen=r;this.open=0;this.localPreserveWS=false;let n=e.topNode,i;let s=vr(null,e.preserveWhitespace,0)|(r?br:0);if(n)i=new kr(n.type,n.attrs,ge.none,true,e.topMatch||n.type.contentMatch,s);else if(r)i=new kr(null,null,ge.none,true,null,s);else i=new kr(t.schema.topNodeType,null,ge.none,true,null,s);this.nodes=[i];this.find=e.findPositions;this.needsBlock=false}get top(){return this.nodes[this.open]}addDOM(t,e){if(t.nodeType==3)this.addTextNode(t,e);else if(t.nodeType==1)this.addElement(t,e)}addTextNode(t,e){let r=t.nodeValue;let n=this.top,i=n.options&wr?"full":this.localPreserveWS||(n.options&gr)>0;if(i==="full"||n.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(!i){r=r.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let e=n.content[n.content.length-1];let i=t.previousSibling;if(!e||i&&i.nodeName=="BR"||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))r=r.slice(1)}}else if(i!=="full"){r=r.replace(/\r?\n|\r/g," ")}else{r=r.replace(/\r\n?/g,"\n")}if(r)this.insertNode(this.parser.schema.text(r),e,!/\S/.test(r));this.findInText(t)}else{this.findInside(t)}}addElement(t,e,r){let n=this.localPreserveWS,i=this.top;if(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))this.localPreserveWS=true;let s=t.nodeName.toLowerCase(),o;if(mr.hasOwnProperty(s)&&this.parser.normalizeLists)Mr(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(o=this.parser.matchTag(t,this,r));t:if(l?l.ignore:pr.hasOwnProperty(s)){this.findInside(t);this.ignoreFallback(t,e)}else if(!l||l.skip||l.closeParent){if(l&&l.closeParent)this.open=Math.max(0,this.open-1);else if(l&&l.skip.nodeType)t=l.skip;let r,n=this.needsBlock;if(dr.hasOwnProperty(s)){if(i.content.length&&i.content[0].isInline&&this.open){this.open--;i=this.top}r=true;if(!i.type)this.needsBlock=true}else if(!t.firstChild){this.leafFallback(t,e);break t}let o=l&&l.skip?e:this.readStyles(t,e);if(o)this.addAll(t,o);if(r)this.sync(i);this.needsBlock=n}else{let r=this.readStyles(t,e);if(r)this.addElementByRule(t,l,r,l.consuming===false?o:undefined)}this.localPreserveWS=n}leafFallback(t,e){if(t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent)this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){if(t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent))this.findPlace(this.parser.schema.text("-"),e,true)}readStyles(t,e){let r=t.style;if(r&&r.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let n=this.parser.matchedStyles[t],i=r.getPropertyValue(n);if(i)for(let t=undefined;;){let r=this.parser.matchStyle(n,i,this,t);if(!r)break;if(r.ignore)return null;if(r.clearMark)e=e.filter((t=>!r.clearMark(t)));else e=e.concat(this.parser.schema.marks[r.mark].create(r.attrs));if(r.consuming===false)t=r;else break}}return e}addElementByRule(t,e,r,n){let i,s;if(e.node){s=this.parser.schema.nodes[e.node];if(!s.isLeaf){let t=this.enter(s,e.attrs||null,r,e.preserveWhitespace);if(t){i=true;r=t}}else if(!this.insertNode(s.create(e.attrs),r,t.nodeName=="BR")){this.leafFallback(t,r)}}else{let t=this.parser.schema.marks[e.mark];r=r.concat(t.create(e.attrs))}let o=this.top;if(s&&s.isLeaf){this.findInside(t)}else if(n){this.addElement(t,r,n)}else if(e.getContent){this.findInside(t);e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,r,false)))}else{let n=t;if(typeof e.contentElement=="string")n=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")n=e.contentElement(t);else if(e.contentElement)n=e.contentElement;this.findAround(t,n,true);this.addAll(n,r);this.findAround(t,n,false)}if(i&&this.sync(o))this.open--}addAll(t,e,r,n){let i=r||0;for(let s=r?t.childNodes[r]:t.firstChild,o=n==null?null:t.childNodes[n];s!=o;s=s.nextSibling,++i){this.findAtPoint(t,i);this.addDOM(s,e)}this.findAtPoint(t,i)}findPlace(t,e,r){let n,i;for(let e=this.open,s=0;e>=0;e--){let o=this.nodes[e];let l=o.findWrapping(t);if(l&&(!n||n.length>l.length+s)){n=l;i=o;if(!l.length)break}if(o.solid){if(r)break;s+=2}}if(!n)return null;this.sync(i);for(let t=0;t<n.length;t++)e=this.enterInner(n[t],null,e,false);return e}insertNode(t,e,r){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();if(t)e=this.enterInner(t,null,e)}let n=this.findPlace(t,e,r);if(n){this.closeExtra();let e=this.top;if(e.match)e.match=e.match.matchType(t.type);let r=ge.none;for(let i of n.concat(t.marks))if(e.type?e.type.allowsMarkType(i.type):Sr(i.type,t.type))r=i.addToSet(r);e.content.push(t.mark(r));return true}return false}enter(t,e,r,n){let i=this.findPlace(t.create(e),r,false);if(i)i=this.enterInner(t,e,r,true,n);return i}enterInner(t,e,r,n=false,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let o=vr(t,i,s.options);if(s.options&br&&s.content.length==0)o|=br;let l=ge.none;r=r.filter((e=>{if(s.type?s.type.allowsMarkType(e.type):Sr(e.type,t)){l=e.addToSet(l);return false}return true}));this.nodes.push(new kr(t,e,l,n,null,o));this.open++;return r}closeExtra(t=false){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){this.open=0;this.closeExtra(this.isOpen);return this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t){this.open=e;return true}else if(this.localPreserveWS){this.nodes[e].options|=gr}}return false}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++){if(this.find[r].node==t&&this.find[r].offset==e)this.find[r].pos=this.currentPos}}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node))this.find[e].pos=this.currentPos}}findAround(t,e,r){if(t!=e&&this.find)for(let n=0;n<this.find.length;n++){if(this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)){let t=e.compareDocumentPosition(this.find[n].node);if(t&(r?2:4))this.find[n].pos=this.currentPos}}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].node==t)this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset)}}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/");let r=this.options.context;let n=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type);let i=-(r?r.depth+1:0)+(n?0:1);let s=(t,o)=>{for(;t>=0;t--){let l=e[t];if(l==""){if(t==e.length-1||t==0)continue;for(;o>=i;o--)if(s(t-1,o))return true;return false}else{let t=o>0||o==0&&n?this.nodes[o].type:r&&o>=i?r.node(o-i).type:null;if(!t||t.name!=l&&!t.isInGroup(l))return false;o--}}return true};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function Mr(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&mr.hasOwnProperty(t)&&r){r.appendChild(e);e=r}else if(t=="li"){r=e}else if(t){r=null}}}function xr(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Or(t){let e={};for(let r in t)e[r]=t[r];return e}function Sr(t,e){let r=e.schema.nodes;for(let n in r){let i=r[n];if(!i.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:n,next:i}=t.edge(r);if(n==e)return true;if(s.indexOf(i)<0&&o(i))return true}};if(o(i.contentMatch))return true}}class Tr{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},r){if(!r)r=Ar(e).createDocumentFragment();let n=r,i=[];t.forEach((t=>{if(i.length||t.marks.length){let r=0,s=0;while(r<i.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(i[r][0])||e.type.spec.spanning===false)break;r++;s++}while(r<i.length)n=i.pop()[1];while(s<t.marks.length){let r=t.marks[s++];let o=this.serializeMark(r,t.isInline,e);if(o){i.push([r,n]);n.appendChild(o.dom);n=o.contentDOM||o.dom}}}n.appendChild(this.serializeNodeInner(t,e))}));return r}serializeNodeInner(t,e){let{dom:r,contentDOM:n}=Lr(Ar(e),this.nodes[t.type.name](t),null,t.attrs);if(n){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,n)}return r}serializeNode(t,e={}){let r=this.serializeNodeInner(t,e);for(let n=t.marks.length-1;n>=0;n--){let i=this.serializeMark(t.marks[n],t.isInline,e);if(i){(i.contentDOM||i.dom).appendChild(r);r=i.dom}}return r}serializeMark(t,e,r={}){let n=this.marks[t.type.name];return n&&Lr(Ar(r),n(t,e),null,t.attrs)}static renderSpec(t,e,r=null,n){return Lr(t,e,r,n)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Tr(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=Er(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return Er(t.marks)}}function Er(t){let e={};for(let r in t){let n=t[r].spec.toDOM;if(n)e[r]=n}return e}function Ar(t){return t.document||window.document}const $r=new WeakMap;function Rr(t){let e=$r.get(t);if(e===undefined)$r.set(t,e=Cr(t));return e}function Cr(t){let e=null;function r(t){if(t&&typeof t=="object"){if(Array.isArray(t)){if(typeof t[0]=="string"){if(!e)e=[];e.push(t)}else{for(let e=0;e<t.length;e++)r(t[e])}}else{for(let e in t)r(t[e])}}}r(t);return e}function Lr(t,e,r,n){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(s=Rr(n))&&s.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 o=i.indexOf(" ");if(o>0){r=i.slice(0,o);i=i.slice(o+1)}let l;let u=r?t.createElementNS(r,i):t.createElement(i);let a=e[1],f=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){f=2;for(let t in a)if(a[t]!=null){let e=t.indexOf(" ");if(e>0)u.setAttributeNS(t.slice(0,e),t.slice(e+1),a[t]);else if(t=="style"&&u.style)u.style.cssText=a[t];else u.setAttribute(t,a[t])}}for(let i=f;i<e.length;i++){let s=e[i];if(s===0){if(i<e.length-1||i>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:e,contentDOM:i}=Lr(t,s,r,n);u.appendChild(e);if(i){if(l)throw new RangeError("Multiple content holes");l=i}}}return{dom:u,contentDOM:l}}const Nr=65535;const jr=Math.pow(2,16);function Pr(t,e){return t+e*jr}function Ir(t){return t&Nr}function Dr(t){return(t-(t&Nr))/jr}const Hr=1,zr=2,_r=4,Br=8;class Ur{constructor(t,e,r){this.pos=t;this.delInfo=e;this.recover=r}get deleted(){return(this.delInfo&Br)>0}get deletedBefore(){return(this.delInfo&(Hr|_r))>0}get deletedAfter(){return(this.delInfo&(zr|_r))>0}get deletedAcross(){return(this.delInfo&_r)>0}}class Fr{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&Fr.empty)return Fr.empty}recover(t){let e=0,r=Ir(t);if(!this.inverted)for(let t=0;t<r;t++)e+=this.ranges[t*3+2]-this.ranges[t*3+1];return this.ranges[r*3]+e+Dr(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,r){let n=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?n:0);if(l>t)break;let u=this.ranges[o+i],a=this.ranges[o+s],f=l+u;if(t<=f){let i=!u?e:t==l?-1:t==f?1:e;let s=l+n+(i<0?0:a);if(r)return s;let h=t==(e<0?l:f)?null:Pr(o/3,t-l);let c=t==l?zr:t==f?Hr:_r;if(e<0?t!=l:t!=f)c|=Br;return new Ur(s,c,h)}n+=a-u}return r?t+n:new Ur(t+n,0,null)}touches(t,e){let r=0,n=Ir(e);let i=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?r:0);if(o>t)break;let l=this.ranges[e+i],u=o+l;if(t<=u&&e==n*3)return true;r+=this.ranges[e+s]-l}return false}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let n=0,i=0;n<this.ranges.length;n+=3){let s=this.ranges[n],o=s-(this.inverted?i:0),l=s+(this.inverted?0:i);let u=this.ranges[n+e],a=this.ranges[n+r];t(o,o+u,l,l+a);i+=a-u}}invert(){return new Fr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Fr.empty:new Fr(t<0?[0,-t,0]:[0,0,t])}}Fr.empty=new Fr([]);class qr{constructor(t,e,r=0,n=(t?t.length:0)){this.mirror=e;this.from=r;this.to=n;this._maps=t||[];this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new qr(this._maps,this.mirror,t,e)}appendMap(t,e){if(!this.ownData){this._maps=this._maps.slice();this.mirror=this.mirror&&this.mirror.slice();this.ownData=true}this.to=this._maps.push(t);if(e!=null)this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,r=this._maps.length;e<t._maps.length;e++){let n=t.getMirror(e);this.appendMap(t._maps[e],n!=null&&n<e?r+n:undefined)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){if(!this.mirror)this.mirror=[];this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,r=this._maps.length+t._maps.length;e>=0;e--){let n=t.getMirror(e);this.appendMap(t._maps[e].invert(),n!=null&&n>e?r-n-1:undefined)}}invert(){let t=new qr;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,r){let n=0;for(let r=this.from;r<this.to;r++){let i=this._maps[r],s=i.mapResult(t,e);if(s.recover!=null){let e=this.getMirror(r);if(e!=null&&e>r&&e<this.to){r=e;t=this._maps[e].recover(s.recover);continue}}n|=s.delInfo;t=s.pos}return r?t:new Ur(t,n,null)}}const Kr=Object.create(null);class Wr{getMap(){return Fr.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Kr[e.stepType];if(!r)throw new RangeError(`No step type ${e.stepType} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in Kr)throw new RangeError("Duplicate use of step JSON ID "+t);Kr[t]=e;e.prototype.jsonID=t;return e}}class Jr{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new Jr(t,null)}static fail(t){return new Jr(null,t)}static fromReplace(t,e,r,n){try{return Jr.ok(t.replace(e,r,n))}catch(t){if(t instanceof we)return Jr.fail(t.message);throw t}}}function Vr(t,e,r){let n=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);if(s.content.size)s=s.copy(Vr(s.content,e,s));if(s.isInline)s=e(s,r,i);n.push(s)}return ce.fromArray(n)}class Gr extends Wr{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=t.resolve(this.from);let n=r.node(r.sharedDepth(this.to));let i=new be(Vr(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),n),e.openStart,e.openEnd);return Jr.fromReplace(t,this.from,this.to,i)}invert(){return new Zr(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deleted&&r.deleted||e.pos>=r.pos)return null;return new Gr(e.pos,r.pos,this.mark)}merge(t){if(t instanceof Gr&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Gr(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Gr(e.from,e.to,t.markFromJSON(e.mark))}}Wr.jsonID("addMark",Gr);class Zr extends Wr{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to);let r=new be(Vr(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return Jr.fromReplace(t,this.from,this.to,r)}invert(){return new Gr(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deleted&&r.deleted||e.pos>=r.pos)return null;return new Zr(e.pos,r.pos,this.mark)}merge(t){if(t instanceof Zr&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Zr(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Zr(e.from,e.to,t.markFromJSON(e.mark))}}Wr.jsonID("removeMark",Zr);class Qr extends Wr{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Jr.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Jr.fromReplace(t,this.pos,this.pos+1,new be(ce.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let r=0;r<e.marks.length;r++)if(!e.marks[r].isInSet(t))return new Qr(this.pos,e.marks[r]);return new Qr(this.pos,this.mark)}}return new Xr(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Qr(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Qr(e.pos,t.markFromJSON(e.mark))}}Wr.jsonID("addNodeMark",Qr);class Xr extends Wr{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Jr.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Jr.fromReplace(t,this.pos,this.pos+1,new be(ce.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(!e||!this.mark.isInSet(e.marks))return this;return new Qr(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Xr(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Xr(e.pos,t.markFromJSON(e.mark))}}Wr.jsonID("removeNodeMark",Xr);class Yr extends Wr{constructor(t,e,r,n=false){super();this.from=t;this.to=e;this.slice=r;this.structure=n}apply(t){if(this.structure&&en(t,this.from,this.to))return Jr.fail("Structure replace would overwrite content");return Jr.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Fr([this.from,this.to-this.from,this.slice.size])}invert(t){return new Yr(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deletedAcross&&r.deletedAcross)return null;return new Yr(e.pos,Math.max(e.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof Yr)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let e=this.slice.size+t.slice.size==0?be.empty:new be(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Yr(this.from,this.to+(t.to-t.from),e,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let e=this.slice.size+t.slice.size==0?be.empty:new be(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Yr(t.from,this.to,e,this.structure)}else{return null}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Yr(e.from,e.to,be.fromJSON(t,e.slice),!!e.structure)}}Wr.jsonID("replace",Yr);class tn extends Wr{constructor(t,e,r,n,i,s,o=false){super();this.from=t;this.to=e;this.gapFrom=r;this.gapTo=n;this.slice=i;this.insert=s;this.structure=o}apply(t){if(this.structure&&(en(t,this.from,this.gapFrom)||en(t,this.gapTo,this.to)))return Jr.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Jr.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);if(!r)return Jr.fail("Content does not fit in gap");return Jr.fromReplace(t,this.from,this.to,r)}getMap(){return new Fr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new tn(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);let n=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1);let i=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);if(e.deletedAcross&&r.deletedAcross||n<e.pos||i>r.pos)return null;return new tn(e.pos,r.pos,n,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new tn(e.from,e.to,e.gapFrom,e.gapTo,be.fromJSON(t,e.slice),e.insert,!!e.structure)}}Wr.jsonID("replaceAround",tn);function en(t,e,r){let n=t.resolve(e),i=r-e,s=n.depth;while(i>0&&s>0&&n.indexAfter(s)==n.node(s).childCount){s--;i--}if(i>0){let t=n.node(s).maybeChild(n.indexAfter(s));while(i>0){if(!t||t.isLeaf)return true;t=t.firstChild;i--}}return false}function rn(t,e,r,n){let i=[],s=[];let o,l;t.doc.nodesBetween(e,r,((t,u,a)=>{if(!t.isInline)return;let f=t.marks;if(!n.isInSet(f)&&a.type.allowsMarkType(n.type)){let a=Math.max(u,e),h=Math.min(u+t.nodeSize,r);let c=n.addToSet(f);for(let t=0;t<f.length;t++){if(!f[t].isInSet(c)){if(o&&o.to==a&&o.mark.eq(f[t]))o.to=h;else i.push(o=new Zr(a,h,f[t]))}}if(l&&l.to==a)l.to=h;else s.push(l=new Gr(a,h,n))}}));i.forEach((e=>t.step(e)));s.forEach((e=>t.step(e)))}function nn(t,e,r,n){let i=[],s=0;t.doc.nodesBetween(e,r,((t,o)=>{if(!t.isInline)return;s++;let l=null;if(n instanceof lr){let e=t.marks,r;while(r=n.isInSet(e)){(l||(l=[])).push(r);e=r.removeFromSet(e)}}else if(n){if(n.isInSet(t.marks))l=[n]}else{l=t.marks}if(l&&l.length){let n=Math.min(o+t.nodeSize,r);for(let t=0;t<l.length;t++){let r=l[t],u;for(let t=0;t<i.length;t++){let e=i[t];if(e.step==s-1&&r.eq(i[t].style))u=e}if(u){u.to=n;u.step=s}else{i.push({style:r,from:Math.max(o,e),to:n,step:s})}}}}));i.forEach((e=>t.step(new Zr(e.from,e.to,e.style))))}function sn(t,e,r,n=r.contentMatch,i=true){let s=t.doc.nodeAt(e);let o=[],l=e+1;for(let e=0;e<s.childCount;e++){let u=s.child(e),a=l+u.nodeSize;let f=n.matchType(u.type);if(!f){o.push(new Yr(l,a,be.empty))}else{n=f;for(let e=0;e<u.marks.length;e++)if(!r.allowsMarkType(u.marks[e].type))t.step(new Zr(l,a,u.marks[e]));if(i&&u.isText&&r.whitespace!="pre"){let t,e=/\r?\n|\r/g,n;while(t=e.exec(u.text)){if(!n)n=new be(ce.from(r.schema.text(" ",r.allowedMarks(u.marks))),0,0);o.push(new Yr(l+t.index,l+t.index+t[0].length,n))}}}l=a}if(!n.validEnd){let e=n.fillBefore(ce.empty,true);t.replace(l,l,new be(e,0,0))}for(let e=o.length-1;e>=0;e--)t.step(o[e])}function on(t,e,r){return(e==0||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function ln(t){let e=t.parent;let r=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth;;--e){let n=t.$from.node(e);let i=t.$from.index(e),s=t.$to.indexAfter(e);if(e<t.depth&&n.canReplace(i,s,r))return e;if(e==0||n.type.spec.isolating||!on(n,i,s))break}return null}function un(t,e,r){let{$from:n,$to:i,depth:s}=e;let o=n.before(s+1),l=i.after(s+1);let u=o,a=l;let f=ce.empty,h=0;for(let t=s,e=false;t>r;t--)if(e||n.index(t)>0){e=true;f=ce.from(n.node(t).copy(f));h++}else{u--}let c=ce.empty,d=0;for(let t=s,e=false;t>r;t--)if(e||i.after(t+1)<i.end(t)){e=true;c=ce.from(i.node(t).copy(c));d++}else{a++}t.step(new tn(u,a,o,l,new be(f.append(c),h,d),f.size-h,true))}function an(t,e,r=null,n=t){let i=hn(t,e);let s=i&&cn(n,e);if(!s)return null;return i.map(fn).concat({type:e,attrs:r}).concat(s.map(fn))}function fn(t){return{type:t,attrs:null}}function hn(t,e){let{parent:r,startIndex:n,endIndex:i}=t;let s=r.contentMatchAt(n).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return r.canReplaceWith(n,i,o)?s:null}function cn(t,e){let{parent:r,startIndex:n,endIndex:i}=t;let s=r.child(n);let o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=o.length?o[o.length-1]:e;let u=l.contentMatch;for(let t=n;u&&t<i;t++)u=u.matchType(r.child(t).type);if(!u||!u.validEnd)return null;return o}function dn(t,e,r){let n=ce.empty;for(let t=r.length-1;t>=0;t--){if(n.size){let e=r[t].type.contentMatch.matchFragment(n);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=ce.from(r[t].type.create(r[t].attrs,n))}let i=e.start,s=e.end;t.step(new tn(i,s,i,s,new be(n,0,0),r.length,true))}function pn(t,e,r,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,r,((e,r)=>{let o=typeof i=="function"?i(e):i;if(e.isTextblock&&!e.hasMarkup(n,o)&&wn(t.doc,t.mapping.slice(s).map(r),n)){let i=null;if(n.schema.linebreakReplacement){let t=n.whitespace=="pre",e=!!n.contentMatch.matchType(n.schema.linebreakReplacement);if(t&&!e)i=false;else if(!t&&e)i=true}if(i===false)gn(t,e,r,s);sn(t,t.mapping.slice(s).map(r,1),n,undefined,i===null);let l=t.mapping.slice(s);let u=l.map(r,1),a=l.map(r+e.nodeSize,1);t.step(new tn(u,a,u+1,a-1,new be(ce.from(n.create(o,null,e.marks)),0,0),1,true));if(i===true)mn(t,e,r,s);return false}}))}function mn(t,e,r,n){e.forEach(((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;while(o=l.exec(i.text)){let i=t.mapping.slice(n).map(r+1+s+o.index);t.replaceWith(i,i+1,e.type.schema.linebreakReplacement.create())}}}))}function gn(t,e,r,n){e.forEach(((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let i=t.mapping.slice(n).map(r+1+s);t.replaceWith(i,i+1,e.type.schema.text("\n"))}}))}function wn(t,e,r){let n=t.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,r)}function bn(t,e,r,n,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");if(!r)r=s.type;let o=r.create(n,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!r.validContent(s.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new tn(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new be(ce.from(o),0,0),1,true))}function vn(t,e,r=1,n){let i=t.resolve(e),s=i.depth-r;let o=n&&n[n.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return false;for(let t=i.depth-1,e=r-2;t>s;t--,e--){let r=i.node(t),s=i.index(t);if(r.type.spec.isolating)return false;let o=r.content.cutByIndex(s,r.childCount);let l=n&&n[e+1];if(l)o=o.replaceChild(0,l.type.create(l.attrs));let u=n&&n[e]||r;if(!r.canReplace(s+1,r.childCount)||!u.type.validContent(o))return false}let l=i.indexAfter(s);let u=n&&n[0];return i.node(s).canReplaceWith(l,l,u?u.type:i.node(s+1).type)}function kn(t,e,r=1,n){let i=t.doc.resolve(e),s=ce.empty,o=ce.empty;for(let t=i.depth,e=i.depth-r,l=r-1;t>e;t--,l--){s=ce.from(i.node(t).copy(s));let e=n&&n[l];o=ce.from(e?e.type.create(e.attrs,o):i.node(t).copy(o))}t.step(new Yr(e,e,new be(s.append(o),r,r),true))}function yn(t,e){let r=t.resolve(e),n=r.index();return xn(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function Mn(t,e){if(!e.content.size)t.type.compatibleContent(e.type);let r=t.contentMatchAt(t.childCount);let{linebreakReplacement:n}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i);let o=s.type==n?t.type.schema.nodes.text:s.type;r=r.matchType(o);if(!r)return false;if(!t.type.allowsMarks(s.marks))return false}return r.validEnd}function xn(t,e){return!!(t&&e&&!t.isLeaf&&Mn(t,e))}function On(t,e,r=-1){let n=t.resolve(e);for(let t=n.depth;;t--){let i,s,o=n.index(t);if(t==n.depth){i=n.nodeBefore;s=n.nodeAfter}else if(r>0){i=n.node(t+1);o++;s=n.node(t).maybeChild(o)}else{i=n.node(t).maybeChild(o-1);s=n.node(t+1)}if(i&&!i.isTextblock&&xn(i,s)&&n.node(t).canReplace(o,o+1))return e;if(t==0)break;e=r<0?n.before(t):n.after(t)}}function Sn(t,e,r){let n=null;let{linebreakReplacement:i}=t.doc.type.schema;let s=t.doc.resolve(e-r),o=s.node().type;if(i&&o.inlineContent){let t=o.whitespace=="pre";let e=!!o.contentMatch.matchType(i);if(t&&!e)n=false;else if(!t&&e)n=true}let l=t.steps.length;if(n===false){let n=t.doc.resolve(e+r);gn(t,n.node(),n.before(),l)}if(o.inlineContent)sn(t,e+r-1,o,s.node().contentMatchAt(s.index()),n==null);let u=t.mapping.slice(l),a=u.map(e-r);t.step(new Yr(a,u.map(e+r,-1),be.empty,true));if(n===true){let e=t.doc.resolve(a);mn(t,e.node(),e.before(),t.steps.length)}return t}function Tn(t,e,r){let n=t.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),r))return e;if(n.parentOffset==0)for(let t=n.depth-1;t>=0;t--){let e=n.index(t);if(n.node(t).canReplaceWith(e,e,r))return n.before(t+1);if(e>0)return null}if(n.parentOffset==n.parent.content.size)for(let t=n.depth-1;t>=0;t--){let e=n.indexAfter(t);if(n.node(t).canReplaceWith(e,e,r))return n.after(t+1);if(e<n.node(t).childCount)return null}return null}function En(t,e,r){let n=t.resolve(e);if(!r.content.size)return e;let i=r.content;for(let t=0;t<r.openStart;t++)i=i.firstChild.content;for(let t=1;t<=(r.openStart==0&&r.size?2:1);t++){for(let e=n.depth;e>=0;e--){let r=e==n.depth?0:n.pos<=(n.start(e+1)+n.end(e+1))/2?-1:1;let s=n.index(e)+(r>0?1:0);let o=n.node(e),l=false;if(t==1){l=o.canReplace(s,s,i)}else{let t=o.contentMatchAt(s).findWrapping(i.firstChild.type);l=t&&o.canReplaceWith(s,s,t[0])}if(l)return r==0?n.pos:r<0?n.before(e+1):n.after(e+1)}}return null}function An(t,e,r=e,n=be.empty){if(e==r&&!n.size)return null;let i=t.resolve(e),s=t.resolve(r);if($n(i,s,n))return new Yr(e,r,n);return new Rn(i,s,n).fit()}function $n(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}class Rn{constructor(t,e,r){this.$from=t;this.$to=e;this.unplaced=r;this.frontier=[];this.placed=ce.empty;for(let e=0;e<=t.depth;e++){let r=t.node(e);this.frontier.push({type:r.type,match:r.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=ce.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let t=this.findFittable();if(t)this.placeNodes(t);else this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth;let r=this.$from,n=this.close(t<0?this.$to:r.doc.resolve(t));if(!n)return null;let i=this.placed,s=r.depth,o=n.depth;while(s&&o&&i.childCount==1){i=i.firstChild.content;s--;o--}let l=new be(i,s,o);if(t>-1)return new tn(r.pos,t,this.$to.pos,this.$to.end(),l,e);if(l.size||r.pos!=this.$to.pos)return new Yr(r.pos,n.pos,l);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,n=this.unplaced.openEnd;r<t;r++){let i=e.firstChild;if(e.childCount>1)n=0;if(i.type.spec.isolating&&n<=r){t=r;break}e=i.content}for(let e=1;e<=2;e++){for(let r=e==1?t:this.unplaced.openStart;r>=0;r--){let t,n=null;if(r){n=Nn(this.unplaced.content,r-1).firstChild;t=n.content}else{t=this.unplaced.content}let i=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:s,match:o}=this.frontier[t],l,u=null;if(e==1&&(i?o.matchType(i.type)||(u=o.fillBefore(ce.from(i),false)):n&&s.compatibleContent(n.type)))return{sliceDepth:r,frontierDepth:t,parent:n,inject:u};else if(e==2&&i&&(l=o.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:t,parent:n,wrap:l};if(n&&o.matchType(n.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let n=Nn(t,e);if(!n.childCount||n.firstChild.isLeaf)return false;this.unplaced=new be(t,e+1,Math.max(r,n.size+e>=t.size-r?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let n=Nn(t,e);if(n.childCount<=1&&e>0){let i=t.size-e<=e+n.size;this.unplaced=new be(Cn(t,e-1,1),e-1,i?e-1:r)}else{this.unplaced=new be(Cn(t,e,1),e,r)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:n,wrap:i}){while(this.depth>e)this.closeFrontierNode();if(i)for(let t=0;t<i.length;t++)this.openFrontierNode(i[t]);let s=this.unplaced,o=r?r.content:s.content;let l=s.openStart-t;let u=0,a=[];let{match:f,type:h}=this.frontier[e];if(n){for(let t=0;t<n.childCount;t++)a.push(n.child(t));f=f.matchFragment(n)}let c=o.size+t-(s.content.size-s.openEnd);while(u<o.childCount){let t=o.child(u),e=f.matchType(t.type);if(!e)break;u++;if(u>1||l==0||t.content.size){f=e;a.push(jn(t.mark(h.allowedMarks(t.marks)),u==1?l:0,u==o.childCount?c:-1))}}let d=u==o.childCount;if(!d)c=-1;this.placed=Ln(this.placed,e,ce.from(a));this.frontier[e].match=f;if(d&&c<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let t=0,e=o;t<c;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)});e=t.content}this.unplaced=!d?new be(Cn(s.content,t,u),s.openStart,s.openEnd):t==0?be.empty:new be(Cn(s.content,t-1,1),t-1,c<0?s.openEnd:t-1)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!Pn(this.$to,this.$to.depth,t.type,t.match,false)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:r}=this.$to,n=this.$to.after(r);while(r>1&&n==this.$to.end(--r))++n;return n}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:r,type:n}=this.frontier[e];let i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let s=Pn(t,e,n,r,i);if(!s)continue;for(let r=e-1;r>=0;r--){let{match:e,type:n}=this.frontier[r];let i=Pn(t,r,n,e,true);if(!i||i.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=Ln(this.placed,e.depth,e.fit);t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let e=t.node(r),n=e.type.contentMatch.fillBefore(e.content,true,t.index(r));this.openFrontierNode(e.type,e.attrs,n)}return t}openFrontierNode(t,e=null,r){let n=this.frontier[this.depth];n.match=n.match.matchType(t);this.placed=Ln(this.placed,this.depth,ce.from(t.create(e,r)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(ce.empty,true);if(e.childCount)this.placed=Ln(this.placed,this.frontier.length,e)}}function Cn(t,e,r){if(e==0)return t.cutByIndex(r,t.childCount);return t.replaceChild(0,t.firstChild.copy(Cn(t.firstChild.content,e-1,r)))}function Ln(t,e,r){if(e==0)return t.append(r);return t.replaceChild(t.childCount-1,t.lastChild.copy(Ln(t.lastChild.content,e-1,r)))}function Nn(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function jn(t,e,r){if(e<=0)return t;let n=t.content;if(e>1)n=n.replaceChild(0,jn(n.firstChild,e-1,n.childCount==1?r-1:0));if(e>0){n=t.type.contentMatch.fillBefore(n).append(n);if(r<=0)n=n.append(t.type.contentMatch.matchFragment(n).fillBefore(ce.empty,true))}return t.copy(n)}function Pn(t,e,r,n,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!r.compatibleContent(s.type))return null;let l=n.fillBefore(s.content,true,o);return l&&!In(r,s.content,o)?l:null}function In(t,e,r){for(let n=r;n<e.childCount;n++)if(!t.allowsMarks(e.child(n).marks))return true;return false}function Dn(t){return t.spec.defining||t.spec.definingForContent}function Hn(t,e,r,n){if(!n.size)return t.deleteRange(e,r);let i=t.doc.resolve(e),s=t.doc.resolve(r);if($n(i,s,n))return t.step(new Yr(e,r,n));let o=Un(i,t.doc.resolve(r));if(o[o.length-1]==0)o.pop();let l=-(i.depth+1);o.unshift(l);for(let t=i.depth,e=i.pos-1;t>0;t--,e--){let r=i.node(t).type.spec;if(r.defining||r.definingAsContext||r.isolating)break;if(o.indexOf(t)>-1)l=t;else if(i.before(t)==e)o.splice(1,0,-t)}let u=o.indexOf(l);let a=[],f=n.openStart;for(let t=n.content,e=0;;e++){let r=t.firstChild;a.push(r);if(e==n.openStart)break;t=r.content}for(let t=f-1;t>=0;t--){let e=a[t],r=Dn(e.type);if(r&&!e.sameMarkup(i.node(Math.abs(l)-1)))f=t;else if(r||!e.type.isTextblock)break}for(let e=n.openStart;e>=0;e--){let l=(e+f+1)%(n.openStart+1);let h=a[l];if(!h)continue;for(let e=0;e<o.length;e++){let a=o[(e+u)%o.length],f=true;if(a<0){f=false;a=-a}let c=i.node(a-1),d=i.index(a-1);if(c.canReplaceWith(d,d,h.type,h.marks))return t.replace(i.before(a),f?s.after(a):r,new be(zn(n.content,0,n.openStart,l),l,n.openEnd))}}let h=t.steps.length;for(let l=o.length-1;l>=0;l--){t.replace(e,r,n);if(t.steps.length>h)break;let u=o[l];if(u<0)continue;e=i.before(u);r=s.after(u)}}function zn(t,e,r,n,i){if(e<r){let i=t.firstChild;t=t.replaceChild(0,i.copy(zn(i.content,e+1,r,n,i)))}if(e>n){let e=i.contentMatchAt(0);let r=e.fillBefore(t).append(t);t=r.append(e.matchFragment(r).fillBefore(ce.empty,true))}return t}function _n(t,e,r,n){if(!n.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let i=Tn(t.doc,e,n.type);if(i!=null)e=r=i}t.replaceRange(e,r,new be(ce.from(n),0,0))}function Bn(t,e,r){let n=t.doc.resolve(e),i=t.doc.resolve(r);let s=Un(n,i);for(let e=0;e<s.length;e++){let r=s[e],o=e==s.length-1;if(o&&r==0||n.node(r).type.contentMatch.validEnd)return t.delete(n.start(r),i.end(r));if(r>0&&(o||n.node(r-1).canReplace(n.index(r-1),i.indexAfter(r-1))))return t.delete(n.before(r),i.after(r))}for(let s=1;s<=n.depth&&s<=i.depth;s++){if(e-n.start(s)==n.depth-s&&r>n.end(s)&&i.end(s)-r!=i.depth-s&&n.start(s-1)==i.start(s-1)&&n.node(s-1).canReplace(n.index(s-1),i.index(s-1)))return t.delete(n.before(s),r)}t.delete(e,r)}function Un(t,e){let r=[],n=Math.min(t.depth,e.depth);for(let i=n;i>=0;i--){let n=t.start(i);if(n<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;if(n==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==n-1)r.push(i)}return r}class Fn extends Wr{constructor(t,e,r){super();this.pos=t;this.attr=e;this.value=r}apply(t){let e=t.nodeAt(this.pos);if(!e)return Jr.fail("No node at attribute step's position");let r=Object.create(null);for(let t in e.attrs)r[t]=e.attrs[t];r[this.attr]=this.value;let n=e.type.create(r,null,e.marks);return Jr.fromReplace(t,this.pos,this.pos+1,new be(ce.from(n),0,e.isLeaf?0:1))}getMap(){return Fr.empty}invert(t){return new Fn(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Fn(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.pos!="number"||typeof e.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Fn(e.pos,e.attr,e.value)}}Wr.jsonID("attr",Fn);class qn extends Wr{constructor(t,e){super();this.attr=t;this.value=e}apply(t){let e=Object.create(null);for(let r in t.attrs)e[r]=t.attrs[r];e[this.attr]=this.value;let r=t.type.create(e,t.content,t.marks);return Jr.ok(r)}getMap(){return Fr.empty}invert(t){return new qn(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new qn(e.attr,e.value)}}Wr.jsonID("docAttr",qn);let Kn=class extends Error{};Kn=function t(e){let r=Error.call(this,e);r.__proto__=t.prototype;return r};Kn.prototype=Object.create(Error.prototype);Kn.prototype.constructor=Kn;Kn.prototype.name="TransformError";class Wn{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new qr}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Kn(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);if(!e.failed)this.addStep(t,e.doc);return e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc);this.steps.push(t);this.mapping.appendMap(t.getMap());this.doc=e}replace(t,e=t,r=be.empty){let n=An(this.doc,t,e,r);if(n)this.step(n);return this}replaceWith(t,e,r){return this.replace(t,e,new be(ce.from(r),0,0))}delete(t,e){return this.replace(t,e,be.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){Hn(this,t,e,r);return this}replaceRangeWith(t,e,r){_n(this,t,e,r);return this}deleteRange(t,e){Bn(this,t,e);return this}lift(t,e){un(this,t,e);return this}join(t,e=1){Sn(this,t,e);return this}wrap(t,e){dn(this,t,e);return this}setBlockType(t,e=t,r,n=null){pn(this,t,e,r,n);return this}setNodeMarkup(t,e,r=null,n){bn(this,t,e,r,n);return this}setNodeAttribute(t,e,r){this.step(new Fn(t,e,r));return this}setDocAttribute(t,e){this.step(new qn(t,e));return this}addNodeMark(t,e){this.step(new Qr(t,e));return this}removeNodeMark(t,e){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(e instanceof ge){if(e.isInSet(r.marks))this.step(new Xr(t,e))}else{let n=r.marks,i,s=[];while(i=e.isInSet(n)){s.push(new Xr(t,i));n=i.removeFromSet(n)}for(let t=s.length-1;t>=0;t--)this.step(s[t])}return this}split(t,e=1,r){kn(this,t,e,r);return this}addMark(t,e,r){rn(this,t,e,r);return this}removeMark(t,e,r){nn(this,t,e,r);return this}clearIncompatible(t,e,r){sn(this,t,e,r);return this}}const Jn=Object.create(null);class Vn{constructor(t,e,r){this.$anchor=t;this.$head=e;this.ranges=r||[new Gn(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return false;return true}content(){return this.$from.doc.slice(this.from,this.to,true)}replace(t,e=be.empty){let r=e.content.lastChild,n=null;for(let t=0;t<e.openEnd;t++){n=r;r=r.lastChild}let i=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:u}=s[o],a=t.mapping.slice(i);t.replaceRange(a.map(l.pos),a.map(u.pos),o?be.empty:e);if(o==0)si(t,i,(r?r.isInline:n&&n.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,n=this.ranges;for(let i=0;i<n.length;i++){let{$from:s,$to:o}=n[i],l=t.mapping.slice(r);let u=l.map(s.pos),a=l.map(o.pos);if(i){t.deleteRange(u,a)}else{t.replaceRangeWith(u,a,e);si(t,r,e.isInline?-1:1)}}}static findFrom(t,e,r=false){let n=t.parent.inlineContent?new Xn(t):ii(t.node(0),t.parent,t.pos,t.index(),e,r);if(n)return n;for(let n=t.depth-1;n>=0;n--){let i=e<0?ii(t.node(0),t.node(n),t.before(n+1),t.index(n),e,r):ii(t.node(0),t.node(n),t.after(n+1),t.index(n)+1,e,r);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new ri(t.node(0))}static atStart(t){return ii(t,t,0,0,1)||new ri(t)}static atEnd(t){return ii(t,t,t.content.size,t.childCount,-1)||new ri(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Jn[e.type];if(!r)throw new RangeError(`No selection type ${e.type} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in Jn)throw new RangeError("Duplicate use of selection JSON ID "+t);Jn[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return Xn.between(this.$anchor,this.$head).getBookmark()}}Vn.prototype.visible=true;class Gn{constructor(t,e){this.$from=t;this.$to=e}}let Zn=false;function Qn(t){if(!Zn&&!t.parent.inlineContent){Zn=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class Xn extends Vn{constructor(t,e=t){Qn(t);Qn(e);super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let r=t.resolve(e.map(this.head));if(!r.parent.inlineContent)return Vn.near(r);let n=t.resolve(e.map(this.anchor));return new Xn(n.parent.inlineContent?n:r,r)}replace(t,e=be.empty){super.replace(t,e);if(e==be.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof Xn&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Yn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if(typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Xn(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,r=e){let n=t.resolve(e);return new this(n,r==e?n:t.resolve(r))}static between(t,e,r){let n=t.pos-e.pos;if(!r||n)r=n>=0?1:-1;if(!e.parent.inlineContent){let t=Vn.findFrom(e,r,true)||Vn.findFrom(e,-r,true);if(t)e=t.$head;else return Vn.near(e,r)}if(!t.parent.inlineContent){if(n==0){t=e}else{t=(Vn.findFrom(t,-r,true)||Vn.findFrom(t,r,true)).$anchor;if(t.pos<e.pos!=n<0)t=e}}return new Xn(t,e)}}Vn.jsonID("text",Xn);class Yn{constructor(t,e){this.anchor=t;this.head=e}map(t){return new Yn(t.map(this.anchor),t.map(this.head))}resolve(t){return Xn.between(t.resolve(this.anchor),t.resolve(this.head))}}class ti extends Vn{constructor(t){let e=t.nodeAfter;let r=t.node(0).resolve(t.pos+e.nodeSize);super(t,r);this.node=e}map(t,e){let{deleted:r,pos:n}=e.mapResult(this.anchor);let i=t.resolve(n);if(r)return Vn.near(i);return new ti(i)}content(){return new be(ce.from(this.node),0,0)}eq(t){return t instanceof ti&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ei(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ti(t.resolve(e.anchor))}static create(t,e){return new ti(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}ti.prototype.visible=false;Vn.jsonID("node",ti);class ei{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new Yn(r,r):new ei(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;if(r&&ti.isSelectable(r))return new ti(e);return Vn.near(e)}}class ri extends Vn{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=be.empty){if(e==be.empty){t.delete(0,t.doc.content.size);let e=Vn.atStart(t.doc);if(!e.eq(t.selection))t.setSelection(e)}else{super.replace(t,e)}}toJSON(){return{type:"all"}}static fromJSON(t){return new ri(t)}map(t){return new ri(t)}eq(t){return t instanceof ri}getBookmark(){return ni}}Vn.jsonID("all",ri);const ni={map(){return this},resolve(t){return new ri(t)}};function ii(t,e,r,n,i,s=false){if(e.inlineContent)return Xn.create(t,r);for(let o=n-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let n=e.child(o);if(!n.isAtom){let e=ii(t,n,r+i,i<0?n.childCount:0,i,s);if(e)return e}else if(!s&&ti.isSelectable(n)){return ti.create(t,r-(i<0?n.nodeSize:0))}r+=n.nodeSize*i}return null}function si(t,e,r){let n=t.steps.length-1;if(n<e)return;let i=t.steps[n];if(!(i instanceof Yr||i instanceof tn))return;let s=t.mapping.maps[n],o;s.forEach(((t,e,r,n)=>{if(o==null)o=n}));t.setSelection(Vn.near(t.doc.resolve(o),r))}const oi=1,li=2,ui=4;class ai extends Wn{constructor(t){super(t.doc);this.curSelectionFor=0;this.updated=0;this.meta=Object.create(null);this.time=Date.now();this.curSelection=t.selection;this.storedMarks=t.storedMarks}get selection(){if(this.curSelectionFor<this.steps.length){this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor));this.curSelectionFor=this.steps.length}return this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");this.curSelection=t;this.curSelectionFor=this.steps.length;this.updated=(this.updated|oi)&-3;this.storedMarks=null;return this}get selectionSet(){return(this.updated&oi)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=li;return this}ensureMarks(t){if(!ge.sameSet(this.storedMarks||this.selection.$from.marks(),t))this.setStoredMarks(t);return this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&li)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&-3;this.storedMarks=null}setTime(t){this.time=t;return this}replaceSelection(t){this.selection.replace(this,t);return this}replaceSelectionWith(t,e=true){let r=this.selection;if(e)t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ge.none));r.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,r){let n=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(n.text(t),true)}else{if(r==null)r=e;r=r==null?e:r;if(!t)return this.deleteRange(e,r);let i=this.storedMarks;if(!i){let t=this.doc.resolve(e);i=r==e?t.marks():t.marksAcross(this.doc.resolve(r))}this.replaceRangeWith(e,r,n.text(t,i));if(!this.selection.empty)this.setSelection(Vn.near(this.selection.$to));return this}}setMeta(t,e){this.meta[typeof t=="string"?t:t.key]=e;return this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return false;return true}scrollIntoView(){this.updated|=ui;return this}get scrolledIntoView(){return(this.updated&ui)>0}}function fi(t,e){return!e||!t?t:t.bind(e)}class hi{constructor(t,e,r){this.name=t;this.init=fi(e.init,r);this.apply=fi(e.apply,r)}}const ci=[new hi("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new hi("selection",{init(t,e){return t.selection||Vn.atStart(e.doc)},apply(t){return t.selection}}),new hi("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,n){return n.selection.$cursor?t.storedMarks:null}}),new hi("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class di{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=ci.slice();if(e)e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t);this.pluginsByKey[t.key]=t;if(t.spec.state)this.fields.push(new hi(t.key,t.spec.state,t))}))}}class pi{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=e){let e=this.config.plugins[r];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return false}return true}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),n=null;for(;;){let i=false;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=n?n[s].n:0,u=n?n[s].state:this;let a=l<e.length&&o.spec.appendTransaction.call(o,l?e.slice(l):e,u,r);if(a&&r.filterTransaction(a,s)){a.setMeta("appendedTransaction",t);if(!n){n=[];for(let t=0;t<this.config.plugins.length;t++)n.push(t<s?{state:r,n:e.length}:{state:this,n:0})}e.push(a);r=r.applyInner(a);i=true}if(n)n[s]={state:r,n:e.length}}}if(!i)return{state:r,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new pi(this.config),r=this.config.fields;for(let n=0;n<r.length;n++){let i=r[n];e[i.name]=i.apply(t,this[i.name],this,e)}return e}get tr(){return new ai(this)}static create(t){let e=new di(t.doc?t.doc.type.schema:t.schema,t.plugins);let r=new pi(e);for(let n=0;n<e.fields.length;n++)r[e.fields[n].name]=e.fields[n].init(t,r);return r}reconfigure(t){let e=new di(this.schema,t.plugins);let r=e.fields,n=new pi(e);for(let e=0;e<r.length;e++){let i=r[e].name;n[i]=this.hasOwnProperty(i)?this[i]:r[e].init(t,n)}return n}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks)e.storedMarks=this.storedMarks.map((t=>t.toJSON()));if(t&&typeof t=="object")for(let r in t){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let n=t[r],i=n.spec.state;if(i&&i.toJSON)e[r]=i.toJSON.call(n,this[n.key])}return e}static fromJSON(t,e,r){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let n=new di(t.schema,t.plugins);let i=new pi(n);n.fields.forEach((n=>{if(n.name=="doc"){i.doc=De.fromJSON(t.schema,e.doc)}else if(n.name=="selection"){i.selection=Vn.fromJSON(i.doc,e.selection)}else if(n.name=="storedMarks"){if(e.storedMarks)i.storedMarks=e.storedMarks.map(t.schema.markFromJSON)}else{if(r)for(let s in r){let o=r[s],l=o.spec.state;if(o.key==n.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,s)){i[n.name]=l.fromJSON.call(o,t,e[s],i);return}}i[n.name]=n.init(t,i)}}));return i}}function mi(t,e,r){for(let n in t){let i=t[n];if(i instanceof Function)i=i.bind(e);else if(n=="handleDOMEvents")i=mi(i,e,{});r[n]=i}return r}class gi{constructor(t){this.spec=t;this.props={};if(t.props)mi(t.props,this,this.props);this.key=t.key?t.key.key:bi("plugin")}getState(t){return t[this.key]}}const wi=Object.create(null);function bi(t){if(t in wi)return t+"$"+ ++wi[t];wi[t]=0;return t+"$"}class vi{constructor(t="key"){this.key=bi(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const ki=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function yi(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0))return null;return r}const Mi=(t,e,r)=>{let n=yi(t,r);if(!n)return false;let i=Ai(n);if(!i){let r=n.blockRange(),i=r&&ln(r);if(i==null)return false;if(e)e(t.tr.lift(r,i).scrollIntoView());return true}let s=i.nodeBefore;if(Fi(t,i,e,-1))return true;if(n.parent.content.size==0&&(Ti(s,"end")||ti.isSelectable(s))){for(let r=n.depth;;r--){let o=An(t.doc,n.before(r),n.after(r),be.empty);if(o&&o.slice.size<o.to-o.from){if(e){let r=t.tr.step(o);r.setSelection(Ti(s,"end")?Vn.findFrom(r.doc.resolve(r.mapping.map(i.pos,-1)),-1):ti.create(r.doc,i.pos-s.nodeSize));e(r.scrollIntoView())}return true}if(r==1||n.node(r-1).childCount>1)break}}if(s.isAtom&&i.depth==n.depth-1){if(e)e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView());return true}return false};const xi=(t,e,r)=>{let n=yi(t,r);if(!n)return false;let i=Ai(n);return i?Si(t,i,e):false};const Oi=(t,e,r)=>{let n=$i(t,r);if(!n)return false;let i=Li(n);return i?Si(t,i,e):false};function Si(t,e,r){let n=e.nodeBefore,i=n,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return false;let t=i.lastChild;if(!t)return false;i=t}let o=e.nodeAfter,l=o,u=e.pos+1;for(;!l.isTextblock;u++){if(l.type.spec.isolating)return false;let t=l.firstChild;if(!t)return false;l=t}let a=An(t.doc,s,u,be.empty);if(!a||a.from!=s||a instanceof Yr&&a.slice.size>=u-s)return false;if(r){let e=t.tr.step(a);e.setSelection(Xn.create(e.doc,s));r(e.scrollIntoView())}return true}function Ti(t,e,r=false){for(let n=t;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return true;if(r&&n.childCount!=1)return false}return false}const Ei=(t,e,r)=>{let{$head:n,empty:i}=t.selection,s=n;if(!i)return false;if(n.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):n.parentOffset>0)return false;s=Ai(n)}let o=s&&s.nodeBefore;if(!o||!ti.isSelectable(o))return false;if(e)e(t.tr.setSelection(ti.create(t.doc,s.pos-o.nodeSize)).scrollIntoView());return true};function Ai(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function $i(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size))return null;return r}const Ri=(t,e,r)=>{let n=$i(t,r);if(!n)return false;let i=Li(n);if(!i)return false;let s=i.nodeAfter;if(Fi(t,i,e,1))return true;if(n.parent.content.size==0&&(Ti(s,"start")||ti.isSelectable(s))){let r=An(t.doc,n.before(),n.after(),be.empty);if(r&&r.slice.size<r.to-r.from){if(e){let n=t.tr.step(r);n.setSelection(Ti(s,"start")?Vn.findFrom(n.doc.resolve(n.mapping.map(i.pos)),1):ti.create(n.doc,n.mapping.map(i.pos)));e(n.scrollIntoView())}return true}}if(s.isAtom&&i.depth==n.depth-1){if(e)e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView());return true}return false};const Ci=(t,e,r)=>{let{$head:n,empty:i}=t.selection,s=n;if(!i)return false;if(n.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)return false;s=Li(n)}let o=s&&s.nodeAfter;if(!o||!ti.isSelectable(o))return false;if(e)e(t.tr.setSelection(ti.create(t.doc,s.pos)).scrollIntoView());return true};function Li(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let r=t.node(e);if(t.index(e)+1<r.childCount)return t.doc.resolve(t.after(e+1));if(r.type.spec.isolating)break}return null}const Ni=(t,e)=>{let r=t.selection,n=r instanceof ti,i;if(n){if(r.node.isTextblock||!yn(t.doc,r.from))return false;i=r.from}else{i=On(t.doc,r.from,-1);if(i==null)return false}if(e){let r=t.tr.join(i);if(n)r.setSelection(ti.create(r.doc,i-t.doc.resolve(i).nodeBefore.nodeSize));e(r.scrollIntoView())}return true};const ji=(t,e)=>{let r=t.selection,n;if(r instanceof ti){if(r.node.isTextblock||!yn(t.doc,r.to))return false;n=r.to}else{n=On(t.doc,r.to,1);if(n==null)return false}if(e)e(t.tr.join(n).scrollIntoView());return true};const Pi=(t,e)=>{let{$from:r,$to:n}=t.selection;let i=r.blockRange(n),s=i&&ln(i);if(s==null)return false;if(e)e(t.tr.lift(i,s).scrollIntoView());return true};const Ii=(t,e)=>{let{$head:r,$anchor:n}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(n))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function Di(t){for(let e=0;e<t.edgeCount;e++){let{type:r}=t.edge(e);if(r.isTextblock&&!r.hasRequiredAttrs())return r}return null}const Hi=(t,e)=>{let{$head:r,$anchor:n}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(n))return false;let i=r.node(-1),s=r.indexAfter(-1),o=Di(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return false;if(e){let n=r.after(),i=t.tr.replaceWith(n,n,o.createAndFill());i.setSelection(Vn.near(i.doc.resolve(n),1));e(i.scrollIntoView())}return true};const zi=(t,e)=>{let r=t.selection,{$from:n,$to:i}=r;if(r instanceof ri||n.parent.inlineContent||i.parent.inlineContent)return false;let s=Di(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return false;if(e){let r=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos;let o=t.tr.insert(r,s.createAndFill());o.setSelection(Xn.create(o.doc,r+1));e(o.scrollIntoView())}return true};const _i=(t,e)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return false;if(r.depth>1&&r.after()!=r.end(-1)){let n=r.before();if(vn(t.doc,n)){if(e)e(t.tr.split(n).scrollIntoView());return true}}let n=r.blockRange(),i=n&&ln(n);if(i==null)return false;if(e)e(t.tr.lift(n,i).scrollIntoView());return true};const Bi=(t,e)=>{let{$from:r,to:n}=t.selection,i;let s=r.sharedDepth(n);if(s==0)return false;i=r.before(s);if(e)e(t.tr.setSelection(ti.create(t.doc,i)));return true};function Ui(t,e,r){let n=e.nodeBefore,i=e.nodeAfter,s=e.index();if(!n||!i||!n.type.compatibleContent(i.type))return false;if(!n.content.size&&e.parent.canReplace(s-1,s)){if(r)r(t.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(s,s+1)||!(i.isTextblock||yn(t.doc,e.pos)))return false;if(r)r(t.tr.join(e.pos).scrollIntoView());return true}function Fi(t,e,r,n){let i=e.nodeBefore,s=e.nodeAfter,o,l;let u=i.type.spec.isolating||s.type.spec.isolating;if(!u&&Ui(t,e,r))return true;let a=!u&&e.parent.canReplace(e.index(),e.index()+1);if(a&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(r){let n=e.pos+s.nodeSize,l=ce.empty;for(let t=o.length-1;t>=0;t--)l=ce.from(o[t].create(null,l));l=ce.from(i.copy(l));let u=t.tr.step(new tn(e.pos-1,n,e.pos,n,new be(l,1,0),o.length,true));let a=u.doc.resolve(n+2*o.length);if(a.nodeAfter&&a.nodeAfter.type==i.type&&yn(u.doc,a.pos))u.join(a.pos);r(u.scrollIntoView())}return true}let f=s.type.spec.isolating||n>0&&u?null:Vn.findFrom(e,1);let h=f&&f.$from.blockRange(f.$to),c=h&&ln(h);if(c!=null&&c>=e.depth){if(r)r(t.tr.lift(h,c).scrollIntoView());return true}if(a&&Ti(s,"start",true)&&Ti(i,"end")){let n=i,o=[];for(;;){o.push(n);if(n.isTextblock)break;n=n.lastChild}let l=s,u=1;for(;!l.isTextblock;l=l.firstChild)u++;if(n.canReplace(n.childCount,n.childCount,l.content)){if(r){let n=ce.empty;for(let t=o.length-1;t>=0;t--)n=ce.from(o[t].copy(n));let i=t.tr.step(new tn(e.pos-o.length,e.pos+s.nodeSize,e.pos+u,e.pos+s.nodeSize-u,new be(n,o.length,0),0,true));r(i.scrollIntoView())}return true}}return false}function qi(t){return function(e,r){let n=e.selection,i=t<0?n.$from:n.$to;let s=i.depth;while(i.node(s).isInline){if(!s)return false;s--}if(!i.node(s).isTextblock)return false;if(r)r(e.tr.setSelection(Xn.create(e.doc,t<0?i.start(s):i.end(s))));return true}}const Ki=qi(-1);const Wi=qi(1);function Ji(t,e=null){return function(r,n){let{$from:i,$to:s}=r.selection;let o=i.blockRange(s),l=o&&an(o,t,e);if(!l)return false;if(n)n(r.tr.wrap(o,l).scrollIntoView());return true}}function Vi(t,e=null){return function(r,n){let i=false;for(let n=0;n<r.selection.ranges.length&&!i;n++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[n];r.doc.nodesBetween(s,o,((n,s)=>{if(i)return false;if(!n.isTextblock||n.hasMarkup(t,e))return;if(n.type==t){i=true}else{let e=r.doc.resolve(s),n=e.index();i=e.parent.canReplaceWith(n,n+1,t)}}))}if(!i)return false;if(n){let i=r.tr;for(let n=0;n<r.selection.ranges.length;n++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[n];i.setBlockType(s,o,t,e)}n(i.scrollIntoView())}return true}}typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;function Gi(t,e=null){return function(r,n){let{$from:i,$to:s}=r.selection;let o=i.blockRange(s);if(!o)return false;let l=n?r.tr:null;if(!Zi(l,o,t,e))return false;if(n)n(l.scrollIntoView());return true}}function Zi(t,e,r,n=null){let i=false,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(r)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return false;let t=o.resolve(e.start-2);s=new Pe(t,t,e.depth);if(e.endIndex<e.parent.childCount)e=new Pe(e.$from,o.resolve(e.$to.end(e.depth)),e.depth);i=true}let l=an(s,r,n,e);if(!l)return false;if(t)Qi(t,e,l,i,r);return true}function Qi(t,e,r,n,i){let s=ce.empty;for(let t=r.length-1;t>=0;t--)s=ce.from(r[t].type.create(r[t].attrs,s));t.step(new tn(e.start-(n?2:0),e.end,e.start,e.end,new be(s,0,0),r.length,true));let o=0;for(let t=0;t<r.length;t++)if(r[t].type==i)o=t+1;let l=r.length-o;let u=e.start+r.length-(n?2:0),a=e.parent;for(let r=e.startIndex,n=e.endIndex,i=true;r<n;r++,i=false){if(!i&&vn(t.doc,u,l)){t.split(u,l);u+=2*l}u+=a.child(r).nodeSize}return t}function Xi(t){return function(e,r){let{$from:n,$to:i}=e.selection;let s=n.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;if(!r)return true;if(n.node(s.depth-1).type==t)return Yi(e,r,t,s);else return ts(e,r,s)}}function Yi(t,e,r,n){let i=t.tr,s=n.end,o=n.$to.end(n.depth);if(s<o){i.step(new tn(s-1,o,s,o,new be(ce.from(r.create(null,n.parent.copy())),1,0),1,true));n=new Pe(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth)}const l=ln(n);if(l==null)return false;i.lift(n,l);let u=i.doc.resolve(i.mapping.map(s,-1)-1);if(yn(i.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type)i.join(u.pos);e(i.scrollIntoView());return true}function ts(t,e,r){let n=t.tr,i=r.parent;for(let t=r.end,e=r.endIndex-1,s=r.startIndex;e>s;e--){t-=i.child(e).nodeSize;n.delete(t-1,t+1)}let s=n.doc.resolve(r.start),o=s.nodeAfter;if(n.mapping.map(r.end)!=r.start+s.nodeAfter.nodeSize)return false;let l=r.startIndex==0,u=r.endIndex==i.childCount;let a=s.node(-1),f=s.index(-1);if(!a.canReplace(f+(l?0:1),f+1,o.content.append(u?ce.empty:ce.from(i))))return false;let h=s.pos,c=h+o.nodeSize;n.step(new tn(h-(l?1:0),c+(u?1:0),h+1,c-1,new be((l?ce.empty:ce.from(i.copy(ce.empty))).append(u?ce.empty:ce.from(i.copy(ce.empty))),l?0:1,u?0:1),l?0:1));e(n.scrollIntoView());return true}function es(t){return function(e,r){let{$from:n,$to:i}=e.selection;let s=n.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;let o=s.startIndex;if(o==0)return false;let l=s.parent,u=l.child(o-1);if(u.type!=t)return false;if(r){let n=u.lastChild&&u.lastChild.type==l.type;let i=ce.from(n?t.create():null);let o=new be(ce.from(t.create(null,ce.from(l.type.create(null,i)))),n?3:1,0);let a=s.start,f=s.end;r(e.tr.step(new tn(a-(n?3:1),f,a,f,o,1,true)).scrollIntoView())}return true}}const rs=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const ns=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let is=null;const ss=function(t,e,r){let n=is||(is=document.createRange());n.setEnd(t,r==null?t.nodeValue.length:r);n.setStart(t,e||0);return n};const ls=function(){is=null};const us=function(t,e,r,n){return r&&(fs(t,e,r,n,-1)||fs(t,e,r,n,1))};const as=/^(img|br|input|textarea|hr)$/i;function fs(t,e,r,n,i){var s;for(;;){if(t==r&&e==n)return true;if(e==(i<0?0:hs(t))){let r=t.parentNode;if(!r||r.nodeType!=1||ms(t)||as.test(t.nodeName)||t.contentEditable=="false")return false;e=rs(t)+(i<0?0:1);t=r}else if(t.nodeType==1){let r=t.childNodes[e+(i<0?-1:0)];if(r.nodeType==1&&r.contentEditable=="false"){if((s=r.pmViewDesc)===null||s===void 0?void 0:s.ignoreForSelection)e+=i;else return false}else{t=r;e=i<0?hs(t):0}}else{return false}}}function hs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function cs(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1];e=hs(t)}else if(t.parentNode&&!ms(t)){e=rs(t);t=t.parentNode}else{return null}}}function ds(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e];e=0}else if(t.parentNode&&!ms(t)){e=rs(t)+1;t=t.parentNode}else{return null}}}function ps(t,e,r){for(let n=e==0,i=e==hs(t);n||i;){if(t==r)return true;let e=rs(t);t=t.parentNode;if(!t)return false;n=n&&e==0;i=i&&e==hs(t)}}function ms(t){let e;for(let r=t;r;r=r.parentNode)if(e=r.pmViewDesc)break;return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const gs=function(t){return t.focusNode&&us(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function ws(t,e){let r=document.createEvent("Event");r.initEvent("keydown",true,true);r.keyCode=t;r.key=r.code=e;return r}function bs(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function vs(t,e,r){if(t.caretPositionFromPoint){try{let n=t.caretPositionFromPoint(e,r);if(n)return{node:n.offsetNode,offset:Math.min(hs(n.offsetNode),n.offset)}}catch(t){}}if(t.caretRangeFromPoint){let n=t.caretRangeFromPoint(e,r);if(n)return{node:n.startContainer,offset:Math.min(hs(n.startContainer),n.startOffset)}}}const ks=typeof navigator!="undefined"?navigator:null;const ys=typeof document!="undefined"?document:null;const Ms=ks&&ks.userAgent||"";const xs=/Edge\/(\d+)/.exec(Ms);const Os=/MSIE \d/.exec(Ms);const Ss=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ms);const Ts=!!(Os||Ss||xs);const Es=Os?document.documentMode:Ss?+Ss[1]:xs?+xs[1]:0;const As=!Ts&&/gecko\/(\d+)/i.test(Ms);const $s=!Ts&&/Chrome\/(\d+)/.exec(Ms);const Rs=!!$s;const Cs=$s?+$s[1]:0;const Ls=!Ts&&!!ks&&/Apple Computer/.test(ks.vendor);const Ns=Ls&&(/Mobile\/\w+/.test(Ms)||!!ks&&ks.maxTouchPoints>2);const js=Ns||(ks?/Mac/.test(ks.platform):false);const Ps=ks?/Win/.test(ks.platform):false;const Is=/Android \d/.test(Ms);const Ds=!!ys&&"webkitFontSmoothing"in ys.documentElement.style;const Hs=Ds?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function zs(t){let e=t.defaultView&&t.defaultView.visualViewport;if(e)return{left:0,right:e.width,top:0,bottom:e.height};return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function _s(t,e){return typeof t=="number"?t:t[e]}function Bs(t){let e=t.getBoundingClientRect();let r=e.width/t.offsetWidth||1;let n=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*r,top:e.top,bottom:e.top+t.clientHeight*n}}function Us(t,e,r){let n=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5;let s=t.dom.ownerDocument;for(let o=r||t.dom;;){if(!o)break;if(o.nodeType!=1){o=ns(o);continue}let t=o;let r=t==s.body;let l=r?zs(s):Bs(t);let u=0,a=0;if(e.top<l.top+_s(n,"top"))a=-(l.top-e.top+_s(i,"top"));else if(e.bottom>l.bottom-_s(n,"bottom"))a=e.bottom-e.top>l.bottom-l.top?e.top+_s(i,"top")-l.top:e.bottom-l.bottom+_s(i,"bottom");if(e.left<l.left+_s(n,"left"))u=-(l.left-e.left+_s(i,"left"));else if(e.right>l.right-_s(n,"right"))u=e.right-l.right+_s(i,"right");if(u||a){if(r){s.defaultView.scrollBy(u,a)}else{let r=t.scrollLeft,n=t.scrollTop;if(a)t.scrollTop+=a;if(u)t.scrollLeft+=u;let i=t.scrollLeft-r,s=t.scrollTop-n;e={left:e.left-i,top:e.top-s,right:e.right-i,bottom:e.bottom-s}}}let f=r?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:ns(o)}}function Fs(t){let e=t.dom.getBoundingClientRect(),r=Math.max(0,e.top);let n,i;for(let s=(e.left+e.right)/2,o=r+1;o<Math.min(innerHeight,e.bottom);o+=5){let e=t.root.elementFromPoint(s,o);if(!e||e==t.dom||!t.dom.contains(e))continue;let l=e.getBoundingClientRect();if(l.top>=r-20){n=e;i=l.top;break}}return{refDOM:n,refTop:i,stack:qs(t.dom)}}function qs(t){let e=[],r=t.ownerDocument;for(let n=t;n;n=ns(n)){e.push({dom:n,top:n.scrollTop,left:n.scrollLeft});if(t==r)break}return e}function Ks({refDOM:t,refTop:e,stack:r}){let n=t?t.getBoundingClientRect().top:0;Ws(r,n==0?0:n-e)}function Ws(t,e){for(let r=0;r<t.length;r++){let{dom:n,top:i,left:s}=t[r];if(n.scrollTop!=i+e)n.scrollTop=i+e;if(n.scrollLeft!=s)n.scrollLeft=s}}let Js=null;function Vs(t){if(t.setActive)return t.setActive();if(Js)return t.focus(Js);let e=qs(t);t.focus(Js==null?{get preventScroll(){Js={preventScroll:true};return true}}:undefined);if(!Js){Js=false;Ws(e,0)}}function Gs(t,e){let r,n=2e8,i,s=0;let o=e.top,l=e.top;let u,a;for(let f=t.firstChild,h=0;f;f=f.nextSibling,h++){let t;if(f.nodeType==1)t=f.getClientRects();else if(f.nodeType==3)t=ss(f).getClientRects();else continue;for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=o&&d.bottom>=l){o=Math.max(d.bottom,o);l=Math.min(d.top,l);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<n){r=f;n=t;i=t&&r.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(f.nodeType==1&&t)s=h+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!u&&d.left<=e.left&&d.right>=e.left){u=f;a={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!r&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))s=h+1}}if(!r&&u){r=u;i=a;n=0}if(r&&r.nodeType==3)return Zs(r,i);if(!r||n&&r.nodeType==1)return{node:t,offset:s};return Gs(r,i)}function Zs(t,e){let r=t.nodeValue.length;let n=document.createRange();for(let i=0;i<r;i++){n.setEnd(t,i+1);n.setStart(t,i);let r=io(n,1);if(r.top==r.bottom)continue;if(Qs(e,r))return{node:t,offset:i+(e.left>=(r.left+r.right)/2?1:0)}}return{node:t,offset:0}}function Qs(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Xs(t,e){let r=t.parentNode;if(r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left)return r;return t}function Ys(t,e,r){let{node:n,offset:i}=Gs(e,r),s=-1;if(n.nodeType==1&&!n.firstChild){let t=n.getBoundingClientRect();s=t.left!=t.right&&r.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(n,i,s)}function to(t,e,r,n){let i=-1;for(let r=e,s=false;;){if(r==t.dom)break;let e=t.docView.nearestDesc(r,true),o;if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent||!e.contentDOM)&&((o=e.dom.getBoundingClientRect()).width||o.height)){if(e.node.isBlock&&e.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(e.dom.nodeName)){if(!s&&o.left>n.left||o.top>n.top)i=e.posBefore;else if(!s&&o.right<n.left||o.bottom<n.top)i=e.posAfter;s=true}if(!e.contentDOM&&i<0&&!e.node.isText){let t=e.node.isBlock?n.top<(o.top+o.bottom)/2:n.left<(o.left+o.right)/2;return t?e.posBefore:e.posAfter}}r=e.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,r,-1)}function eo(t,e,r){let n=t.childNodes.length;if(n&&r.top<r.bottom){for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-r.top)/(r.bottom-r.top))-2)),s=i;;){let r=t.childNodes[s];if(r.nodeType==1){let t=r.getClientRects();for(let n=0;n<t.length;n++){let i=t[n];if(Qs(e,i))return eo(r,e,i)}}if((s=(s+1)%n)==i)break}}return t}function ro(t,e){let r=t.dom.ownerDocument,n,i=0;let s=vs(r,e.left,e.top);if(s)({node:n,offset:i}=s);let o=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);let l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let r=t.dom.getBoundingClientRect();if(!Qs(e,r))return null;o=eo(t.dom,e,r);if(!o)return null}if(Ls){for(let t=o;n&&t;t=ns(t))if(t.draggable)n=undefined}o=Xs(o,e);if(n){if(As&&n.nodeType==1){i=Math.min(i,n.childNodes.length);if(i<n.childNodes.length){let t=n.childNodes[i],r;if(t.nodeName=="IMG"&&(r=t.getBoundingClientRect()).right<=e.left&&r.bottom>e.top)i++}}let r;if(Ds&&i&&n.nodeType==1&&(r=n.childNodes[i-1]).nodeType==1&&r.contentEditable=="false"&&r.getBoundingClientRect().top>=e.top)i--;if(n==t.dom&&i==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom)l=t.state.doc.content.size;else if(i==0||n.nodeType!=1||n.childNodes[i-1].nodeName!="BR")l=to(t,n,i,e)}if(l==null)l=Ys(t,o,e);let u=t.docView.nearestDesc(o,true);return{pos:l,inside:u?u.posAtStart-u.border:-1}}function no(t){return t.top<t.bottom||t.left<t.right}function io(t,e){let r=t.getClientRects();if(r.length){let t=r[e<0?0:r.length-1];if(no(t))return t}return Array.prototype.find.call(r,no)||t.getBoundingClientRect()}const so=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function oo(t,e,r){let{node:n,offset:i,atom:s}=t.docView.domFromPos(e,r<0?-1:1);let o=Ds||As;if(n.nodeType==3){if(o&&(so.test(n.nodeValue)||(r<0?!i:i==n.nodeValue.length))){let t=io(ss(n,i,i),r);if(As&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let e=io(ss(n,i-1,i-1),-1);if(e.top==t.top){let r=io(ss(n,i,i+1),-1);if(r.top!=t.top)return lo(r,r.left<e.left)}}return t}else{let t=i,e=i,s=r<0?1:-1;if(r<0&&!i){e++;s=-1}else if(r>=0&&i==n.nodeValue.length){t--;s=1}else if(r<0){t--}else{e++}return lo(io(ss(n,t,e),s),s<0)}}let l=t.state.doc.resolve(e-(s||0));if(!l.parent.inlineContent){if(s==null&&i&&(r<0||i==hs(n))){let t=n.childNodes[i-1];if(t.nodeType==1)return uo(t.getBoundingClientRect(),false)}if(s==null&&i<hs(n)){let t=n.childNodes[i];if(t.nodeType==1)return uo(t.getBoundingClientRect(),true)}return uo(n.getBoundingClientRect(),r>=0)}if(s==null&&i&&(r<0||i==hs(n))){let t=n.childNodes[i-1];let e=t.nodeType==3?ss(t,hs(t)-(o?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return lo(io(e,1),false)}if(s==null&&i<hs(n)){let t=n.childNodes[i];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?ss(t,0,o?0:1):t.nodeType==1?t:null;if(e)return lo(io(e,-1),true)}return lo(io(n.nodeType==3?ss(n):n,-r),r>=0)}function lo(t,e){if(t.width==0)return t;let r=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function uo(t,e){if(t.height==0)return t;let r=e?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function ao(t,e,r){let n=t.state,i=t.root.activeElement;if(n!=e)t.updateState(e);if(i!=t.dom)t.focus();try{return r()}finally{if(n!=e)t.updateState(n);if(i!=t.dom&&i)i.focus()}}function fo(t,e,r){let n=e.selection;let i=r=="up"?n.$from:n.$to;return ao(t,e,(()=>{let{node:e}=t.docView.domFromPos(i.pos,r=="up"?-1:1);for(;;){let r=t.docView.nearestDesc(e,true);if(!r)break;if(r.node.isBlock){e=r.contentDOM||r.dom;break}e=r.dom.parentNode}let n=oo(t,i.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=ss(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let i=e[t];if(i.bottom>i.top+1&&(r=="up"?n.top-i.top>(i.bottom-n.top)*2:i.bottom-n.bottom>(n.bottom-i.top)*2))return false}}return true}))}const ho=/[\u0590-\u08ac]/;function co(t,e,r){let{$head:n}=e.selection;if(!n.parent.isTextblock)return false;let i=n.parentOffset,s=!i,o=i==n.parent.content.size;let l=t.domSelection();if(!l)return n.pos==n.start()||n.pos==n.end();if(!ho.test(n.parent.textContent)||!l.modify)return r=="left"||r=="backward"?s:o;return ao(t,e,(()=>{let{focusNode:e,focusOffset:i,anchorNode:s,anchorOffset:o}=t.domSelectionRange();let u=l.caretBidiLevel;l.modify("move",r,"character");let a=n.depth?t.docView.domAfterPos(n.before()):t.dom;let{focusNode:f,focusOffset:h}=t.domSelectionRange();let c=f&&!a.contains(f.nodeType==1?f:f.parentNode)||e==f&&i==h;try{l.collapse(s,o);if(e&&(e!=s||i!=o)&&l.extend)l.extend(e,i)}catch(t){}if(u!=null)l.caretBidiLevel=u;return c}))}let po=null;let mo=null;let go=false;function wo(t,e,r){if(po==e&&mo==r)return go;po=e;mo=r;return go=r=="up"||r=="down"?fo(t,e,r):co(t,e,r)}const bo=0,vo=1,ko=2,yo=3;class Mo{constructor(t,e,r,n){this.parent=t;this.children=e;this.dom=r;this.contentDOM=n;this.dirty=bo;r.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,r){return false}matchesHack(t){return false}parseRule(){return null}stopEvent(t){return false}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=undefined;if(this.dom.pmViewDesc==this)this.dom.pmViewDesc=undefined;for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,r=this.posAtStart;;e++){let n=this.children[e];if(n==t)return r;r+=n.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,r){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(r<0){let r,n;if(t==this.contentDOM){r=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.previousSibling}while(r&&!((n=r.pmViewDesc)&&n.parent==this))r=r.previousSibling;return r?this.posBeforeChild(n)+n.size:this.posAtStart}else{let r,n;if(t==this.contentDOM){r=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.nextSibling}while(r&&!((n=r.pmViewDesc)&&n.parent==this))r=r.nextSibling;return r?this.posBeforeChild(n):this.posAtEnd}}let n;if(t==this.dom&&this.contentDOM){n=e>rs(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){n=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){n=false;break}if(e.previousSibling)break}if(n==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){n=true;break}if(e.nextSibling)break}}return(n==null?r>0:n)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let r=true,n=t;n;n=n.parentNode){let i=this.getDesc(n),s;if(i&&(!e||i.node)){if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))r=false;else return i}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,r){for(let n=t;n;n=n.parentNode){let i=this.getDesc(n);if(i)return i.localPosFromDOM(t,e,r)}return-1}descAt(t){for(let e=0,r=0;e<this.children.length;e++){let n=this.children[e],i=r+n.size;if(r==t&&i!=r){while(!n.border&&n.children.length){for(let t=0;t<n.children.length;t++){let e=n.children[t];if(e.size){n=e;break}}}return n}if(t<i)return n.descAt(t-r-n.border);r=i}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,n=0;for(let e=0;r<this.children.length;r++){let i=this.children[r],s=e+i.size;if(s>t||i instanceof $o){n=t-e;break}e=s}if(n)return this.children[r].domFromPos(n-this.children[r].border,e);for(let t;r&&!(t=this.children[r-1]).size&&t instanceof xo&&t.side>=0;r--){}if(e<=0){let t,n=true;for(;;r--,n=false){t=r?this.children[r-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&n&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?rs(t.dom)+1:0}}else{let t,n=true;for(;;r++,n=false){t=r<this.children.length?this.children[r]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&n&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?rs(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let n=-1,i=-1;for(let s=r,o=0;;o++){let r=this.children[o],l=s+r.size;if(n==-1&&t<=l){let i=s+r.border;if(t>=i&&e<=l-r.border&&r.node&&r.contentDOM&&this.contentDOM.contains(r.contentDOM))return r.parseRange(t,e,i);t=s;for(let e=o;e>0;e--){let r=this.children[e-1];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(1)){n=rs(r.dom)+1;break}t-=r.size}if(n==-1)n=0}if(n>-1&&(l>e||o==this.children.length-1)){e=l;for(let t=o+1;t<this.children.length;t++){let r=this.children[t];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(-1)){i=rs(r.dom);break}e+=r.size}if(i==-1)i=this.contentDOM.childNodes.length;break}s=l}return{node:this.contentDOM,from:t,to:e,fromOffset:n,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:r}=this.domFromPos(t,0);if(e.nodeType!=1||r==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[r]}setSelection(t,e,r,n=false){let i=Math.min(t,e),s=Math.max(t,e);for(let o=0,l=0;o<this.children.length;o++){let u=this.children[o],a=l+u.size;if(i>l&&s<a)return u.setSelection(t-l-u.border,e-l-u.border,r,n);l=a}let o=this.domFromPos(t,t?-1:1);let l=e==t?o:this.domFromPos(e,e?-1:1);let u=r.root.getSelection();let a=r.domSelectionRange();let f=false;if((As||Ls)&&t==e){let{node:t,offset:e}=o;if(t.nodeType==3){f=!!(e&&t.nodeValue[e-1]=="\n");if(f&&e==t.nodeValue.length){for(let e=t,r;e;e=e.parentNode){if(r=e.nextSibling){if(r.nodeName=="BR")o=l={node:r.parentNode,offset:rs(r)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let r=t.childNodes[e-1];f=r&&(r.nodeName=="BR"||r.contentEditable=="false")}}if(As&&a.focusNode&&a.focusNode!=l.node&&a.focusNode.nodeType==1){let t=a.focusNode.childNodes[a.focusOffset];if(t&&t.contentEditable=="false")n=true}if(!(n||f&&Ls)&&us(o.node,o.offset,a.anchorNode,a.anchorOffset)&&us(l.node,l.offset,a.focusNode,a.focusOffset))return;let h=false;if((u.extend||t==e)&&!(f&&As)){u.collapse(o.node,o.offset);try{if(t!=e)u.extend(l.node,l.offset);h=true}catch(t){}}if(!h){if(t>e){let t=o;o=l;l=t}let r=document.createRange();r.setEnd(l.node,l.offset);r.setStart(o.node,o.offset);u.removeAllRanges();u.addRange(r)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let r=0,n=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==s?t<=s&&e>=r:t<s&&e>r){let n=r+i.border,o=s-i.border;if(t>=n&&e<=o){this.dirty=t==r||e==s?ko:vo;if(t==n&&e==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM))i.dirty=yo;else i.markDirty(t-n,e-n);return}else{i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?ko:yo}}r=s}this.dirty=ko}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=t==1?ko:vo;if(e.dirty<r)e.dirty=r}}get domAtom(){return false}get ignoreForCoords(){return false}get ignoreForSelection(){return false}isText(t){return false}}class xo extends Mo{constructor(t,e,r,n){let i,s=e.type.toDOM;if(typeof s=="function")s=s(r,(()=>{if(!i)return n;if(i.parent)return i.parent.posBeforeChild(i)}));if(!e.type.spec.raw){if(s.nodeType!=1){let t=document.createElement("span");t.appendChild(s);s=t}s.contentEditable="false";s.classList.add("ProseMirror-widget")}super(t,[],s,null);this.widget=e;this.widget=e;i=this}matchesWidget(t){return this.dirty==bo&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Oo extends Mo{constructor(t,e,r,n){super(t,[],e,null);this.textDOM=r;this.text=n}get size(){return this.text.length}localPosFromDOM(t,e){if(t!=this.textDOM)return this.posAtStart+(e?this.size:0);return this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class So extends Mo{constructor(t,e,r,n,i){super(t,[],r,n);this.mark=e;this.spec=i}static create(t,e,r,n){let i=n.nodeViews[e.type.name];let s=i&&i(e,n,r);if(!s||!s.dom)s=Tr.renderSpec(document,e.type.spec.toDOM(e,r),null,e.attrs);return new So(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){if(this.dirty&yo||this.mark.type.spec.reparseInView)return null;return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=yo&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=bo){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=bo}}slice(t,e,r){let n=So.create(this.parent,this.mark,true,r);let i=this.children,s=this.size;if(e<s)i=Wo(i,e,s,r);if(t>0)i=Wo(i,0,t,r);for(let t=0;t<i.length;t++)i[t].parent=n;n.children=i;return n}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}}class To extends Mo{constructor(t,e,r,n,i,s,o,l,u){super(t,[],i,s);this.node=e;this.outerDeco=r;this.innerDeco=n;this.nodeDOM=o}static create(t,e,r,n,i,s){let o=i.nodeViews[e.type.name],l;let u=o&&o(e,i,(()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)}),r,n);let a=u&&u.dom,f=u&&u.contentDOM;if(e.isText){if(!a)a=document.createTextNode(e.text);else if(a.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!a){let t=Tr.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:a,contentDOM:f}=t)}if(!f&&!e.isText&&a.nodeName!="BR"){if(!a.hasAttribute("contenteditable"))a.contentEditable="false";if(e.type.spec.draggable)a.draggable=true}let h=a;a=Do(a,r,e);if(u)return l=new Ro(t,e,r,n,a,f||null,h,u,i,s+1);else if(e.isText)return new Ao(t,e,r,n,a,h,i);else return new To(t,e,r,n,a,f||null,h,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let r=this.children[e];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>ce.empty}return t}matchesNode(t,e,r){return this.dirty==bo&&t.eq(this.node)&&Ho(e,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let r=this.node.inlineContent,n=e;let i=t.composing?this.localCompositionInfo(t,e):null;let s=i&&i.pos>-1?i:null;let o=i&&i.pos<0;let l=new _o(this,s&&s.node,t);Fo(this.node,this.innerDeco,((e,i,s)=>{if(e.spec.marks)l.syncToMarks(e.spec.marks,r,t);else if(e.type.side>=0&&!s)l.syncToMarks(i==this.node.childCount?ge.none:this.node.child(i).marks,r,t);l.placeWidget(e,t,n)}),((e,s,u,a)=>{l.syncToMarks(e.marks,r,t);let f;if(l.findNodeMatch(e,s,u,a));else if(o&&t.state.selection.from>n&&t.state.selection.to<n+e.nodeSize&&(f=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(e,s,u,f,t));else if(l.updateNextNode(e,s,u,t,a,n));else{l.addNode(e,s,u,t,n)}n+=e.nodeSize}));l.syncToMarks([],r,t);if(this.node.isTextblock)l.addTextblockHacks();l.destroyRest();if(l.changed||this.dirty==ko){if(s)this.protectLocalComposition(t,s);Co(this.contentDOM,this.children,t);if(Ns)qo(this.dom)}}localCompositionInfo(t,e){let{from:r,to:n}=t.state.selection;if(!(t.state.selection instanceof Xn)||r<e||n>e+this.node.content.size)return null;let i=t.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let t=i.nodeValue;let s=Ko(this.node.content,t,r-e,n-e);return s<0?null:{node:i,pos:s,text:t}}else{return{node:i,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:r,text:n}){if(this.getDesc(e))return;let i=e;for(;;i=i.parentNode){if(i.parentNode==this.contentDOM)break;while(i.previousSibling)i.parentNode.removeChild(i.previousSibling);while(i.nextSibling)i.parentNode.removeChild(i.nextSibling);if(i.pmViewDesc)i.pmViewDesc=undefined}let s=new Oo(this,i,e,n);t.input.compositionNodes.push(s);this.children=Wo(this.children,r,r+n.length,t,s)}update(t,e,r,n){if(this.dirty==yo||!t.sameMarkup(this.node))return false;this.updateInner(t,e,r,n);return true}updateInner(t,e,r,n){this.updateOuterDeco(e);this.node=t;this.innerDeco=r;if(this.contentDOM)this.updateChildren(n,this.posAtStart);this.dirty=bo}updateOuterDeco(t){if(Ho(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let r=this.dom;this.dom=Po(this.dom,this.nodeDOM,jo(this.outerDeco,this.node,e),jo(t,this.node,e));if(this.dom!=r){r.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.nodeDOM.draggable=true}}deselectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.nodeDOM.removeAttribute("draggable")}}get domAtom(){return this.node.isAtom}}function Eo(t,e,r,n,i){Do(n,e,t);let s=new To(undefined,t,e,r,n,n,n,i,0);if(s.contentDOM)s.updateChildren(i,0);return s}class Ao extends To{constructor(t,e,r,n,i,s,o){super(t,e,r,n,i,null,s,o,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,r,n){if(this.dirty==yo||this.dirty!=bo&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=bo||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(n.trackWrites==this.nodeDOM)n.trackWrites=null}this.node=t;this.dirty=bo;return true}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return true;return false}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,r){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,r){let n=this.node.cut(t,e),i=document.createTextNode(n.text);return new Ao(this.parent,n,this.outerDeco,this.innerDeco,i,i,r)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=yo}get domAtom(){return false}isText(t){return this.node.text==t}}class $o extends Mo{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==bo&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ro extends To{constructor(t,e,r,n,i,s,o,l,u,a){super(t,e,r,n,i,s,o,u,a);this.spec=l}update(t,e,r,n){if(this.dirty==yo)return false;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let i=this.spec.update(t,e,r);if(i)this.updateInner(t,e,r,n);return i}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,r,n)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,r,n){this.spec.setSelection?this.spec.setSelection(t,e,r.root):super.setSelection(t,e,r,n)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):false}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Co(t,e,r){let n=t.firstChild,i=false;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){while(l!=n){n=zo(n);i=true}n=n.nextSibling}else{i=true;t.insertBefore(l,n)}if(o instanceof So){let e=n?n.previousSibling:t.lastChild;Co(o.contentDOM,o.children,r);n=e?e.nextSibling:t.firstChild}}while(n){n=zo(n);i=true}if(i&&r.trackWrites==t)r.trackWrites=null}const Lo=function(t){if(t)this.nodeName=t};Lo.prototype=Object.create(null);const No=[new Lo];function jo(t,e,r){if(t.length==0)return No;let n=r?No[0]:new Lo,i=[n];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(!o)continue;if(o.nodeName)i.push(n=new Lo(o.nodeName));for(let t in o){let s=o[t];if(s==null)continue;if(r&&i.length==1)i.push(n=new Lo(e.isInline?"span":"div"));if(t=="class")n.class=(n.class?n.class+" ":"")+s;else if(t=="style")n.style=(n.style?n.style+";":"")+s;else if(t!="nodeName")n[t]=s}}return i}function Po(t,e,r,n){if(r==No&&n==No)return e;let i=e;for(let e=0;e<n.length;e++){let s=n[e],o=r[e];if(e){let e;if(o&&o.nodeName==s.nodeName&&i!=t&&(e=i.parentNode)&&e.nodeName.toLowerCase()==s.nodeName){i=e}else{e=document.createElement(s.nodeName);e.pmIsDeco=true;e.appendChild(i);o=No[0];i=e}}Io(i,o||No[0],s)}return i}function Io(t,e,r){for(let n in e)if(n!="class"&&n!="style"&&n!="nodeName"&&!(n in r))t.removeAttribute(n);for(let n in r)if(n!="class"&&n!="style"&&n!="nodeName"&&r[n]!=e[n])t.setAttribute(n,r[n]);if(e.class!=r.class){let n=e.class?e.class.split(" ").filter(Boolean):[];let i=r.class?r.class.split(" ").filter(Boolean):[];for(let e=0;e<n.length;e++)if(i.indexOf(n[e])==-1)t.classList.remove(n[e]);for(let e=0;e<i.length;e++)if(n.indexOf(i[e])==-1)t.classList.add(i[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=r.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,n;while(n=r.exec(e.style))t.style.removeProperty(n[1])}if(r.style)t.style.cssText+=r.style}}function Do(t,e,r){return Po(t,t,No,jo(e,r,t.nodeType!=1))}function Ho(t,e){if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!t[r].type.eq(e[r].type))return false;return true}function zo(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class _o{constructor(t,e,r){this.lock=e;this.view=r;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=Bo(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let r=t;r<e;r++)this.top.children[r].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,r){let n=0,i=this.stack.length>>1;let s=Math.min(i,t.length);while(n<s&&(n==i-1?this.top:this.stack[n+1<<1]).matchesMark(t[n])&&t[n].type.spec.spanning!==false)n++;while(n<i){this.destroyRest();this.top.dirty=bo;this.index=this.stack.pop();this.top=this.stack.pop();i--}while(i<t.length){this.stack.push(this.top,this.index+1);let n=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let r=this.top.children[e];if(r.matchesMark(t[i])&&!this.isLocked(r.dom)){n=e;break}}if(n>-1){if(n>this.index){this.changed=true;this.destroyBetween(this.index,n)}this.top=this.top.children[this.index]}else{let n=So.create(this.top,t[i],e,r);this.top.children.splice(this.index,0,n);this.top=n;this.changed=true}this.index=0;i++}}findNodeMatch(t,e,r,n){let i=-1,s;if(n>=this.preMatch.index&&(s=this.preMatch.matches[n-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,r)){i=this.top.children.indexOf(s,this.index)}else{for(let n=this.index,s=Math.min(this.top.children.length,n+5);n<s;n++){let s=this.top.children[n];if(s.matchesNode(t,e,r)&&!this.preMatch.matched.has(s)){i=n;break}}}if(i<0)return false;this.destroyBetween(this.index,i);this.index++;return true}updateNodeAt(t,e,r,n,i){let s=this.top.children[n];if(s.dirty==yo&&s.dom==s.contentDOM)s.dirty=ko;if(!s.update(t,e,r,i))return false;this.destroyBetween(this.index,n);this.index++;return true}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++){if(this.top.children[t]==e)return t}return-1}t=e}}updateNextNode(t,e,r,n,i,s){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof To){let u=this.preMatch.matched.get(l);if(u!=null&&u!=i)return false;let a=l.dom,f;let h=this.isLocked(a)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&l.dirty!=yo&&Ho(e,l.outerDeco));if(!h&&l.update(t,e,r,n)){this.destroyBetween(this.index,o);if(l.dom!=a)this.changed=true;this.index++;return true}else if(!h&&(f=this.recreateWrapper(l,t,e,r,n,s))){this.destroyBetween(this.index,o);this.top.children[this.index]=f;if(f.contentDOM){f.dirty=ko;f.updateChildren(n,s+1);f.dirty=bo}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,r,n,i,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!Ho(r,t.outerDeco)||!n.eq(t.innerDeco))return null;let o=To.create(this.top,e,r,n,i,s);if(o.contentDOM){o.children=t.children;t.children=[];for(let t of o.children)t.parent=o}t.destroy();return o}addNode(t,e,r,n,i){let s=To.create(this.top,t,e,r,n,i);if(s.contentDOM)s.updateChildren(n,i+1);this.top.children.splice(this.index++,0,s);this.changed=true}placeWidget(t,e,r){let n=this.index<this.top.children.length?this.top.children[this.index]:null;if(n&&n.matchesWidget(t)&&(t==n.widget||!n.widget.type.toDOM.parentNode)){this.index++}else{let n=new xo(this.top,t,e,r);this.top.children.splice(this.index++,0,n);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof So){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof Ao)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((Ls||Rs)&&t&&t.dom.contentEditable=="false")this.addHackNode("IMG",e);this.addHackNode("BR",this.top)}}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t)){this.index++}else{let r=document.createElement(t);if(t=="IMG"){r.className="ProseMirror-separator";r.alt=""}if(t=="BR")r.className="ProseMirror-trailingBreak";let n=new $o(this.top,[],r,null);if(e!=this.top)e.children.push(n);else e.children.splice(this.index++,0,n);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function Bo(t,e){let r=e,n=r.children.length;let i=t.childCount,s=new Map,o=[];t:while(i>0){let l;for(;;){if(n){let t=r.children[n-1];if(t instanceof So){r=t;n=t.children.length}else{l=t;n--;break}}else if(r==e){break t}else{n=r.parent.children.indexOf(r);r=r.parent}}let u=l.node;if(!u)continue;if(u!=t.child(i-1))break;--i;s.set(l,i);o.push(l)}return{index:i,matched:s,matches:o.reverse()}}function Uo(t,e){return t.type.side-e.type.side}function Fo(t,e,r,n){let i=e.locals(t),s=0;if(i.length==0){for(let r=0;r<t.childCount;r++){let o=t.child(r);n(o,i,e.forChild(s,o),r);s+=o.nodeSize}return}let o=0,l=[],u=null;for(let a=0;;){let f,h;while(o<i.length&&i[o].to==s){let t=i[o++];if(t.widget){if(!f)f=t;else(h||(h=[f])).push(t)}}if(f){if(h){h.sort(Uo);for(let t=0;t<h.length;t++)r(h[t],a,!!u)}else{r(f,a,!!u)}}let c,d;if(u){d=-1;c=u;u=null}else if(a<t.childCount){d=a;c=t.child(a++)}else{break}for(let t=0;t<l.length;t++)if(l[t].to<=s)l.splice(t--,1);while(o<i.length&&i[o].from<=s&&i[o].to>s)l.push(i[o++]);let p=s+c.nodeSize;if(c.isText){let t=p;if(o<i.length&&i[o].from<t)t=i[o].from;for(let e=0;e<l.length;e++)if(l[e].to<t)t=l[e].to;if(t<p){u=c.cut(t-s);c=c.cut(0,t-s);p=t;d=-1}}else{while(o<i.length&&i[o].to<p)o++}let m=c.isInline&&!c.isLeaf?l.filter((t=>!t.inline)):l.slice();n(c,m,e.forChild(s,c),d);s=p}}function qo(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important";window.getComputedStyle(t).listStyle;t.style.cssText=e}}function Ko(t,e,r,n){for(let i=0,s=0;i<t.childCount&&s<=n;){let o=t.child(i++),l=s;s+=o.nodeSize;if(!o.isText)continue;let u=o.text;while(i<t.childCount){let e=t.child(i++);s+=e.nodeSize;if(!e.isText)break;u+=e.text}if(s>=r){if(s>=n&&u.slice(n-e.length-l,n-l)==e)return n-e.length;let t=l<n?u.lastIndexOf(e,n-l-1):-1;if(t>=0&&t+e.length+l>=r)return l+t;if(r==n&&u.length>=n+e.length-l&&u.slice(n-l,n-l+e.length)==e)return n}}return-1}function Wo(t,e,r,n,i){let s=[];for(let o=0,l=0;o<t.length;o++){let u=t[o],a=l,f=l+=u.size;if(a>=r||f<=e){s.push(u)}else{if(a<e)s.push(u.slice(0,e-a,n));if(i){s.push(i);i=undefined}if(f>r)s.push(u.slice(r-a,u.size,n))}}return s}function Jo(t,e=null){let r=t.domSelectionRange(),n=t.state.doc;if(!r.focusNode)return null;let i=t.docView.nearestDesc(r.focusNode),s=i&&i.size==0;let o=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(o<0)return null;let l=n.resolve(o),u,a;if(gs(r)){u=o;while(i&&!i.node)i=i.parent;let t=i.node;if(i&&t.isAtom&&ti.isSelectable(t)&&i.parent&&!(t.isInline&&ps(r.focusNode,r.focusOffset,i.dom))){let t=i.posBefore;a=new ti(o==t?l:n.resolve(t))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let e=o,i=o;for(let n=0;n<r.rangeCount;n++){let s=r.getRangeAt(n);e=Math.min(e,t.docView.posFromDOM(s.startContainer,s.startOffset,1));i=Math.max(i,t.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(e<0)return null;[u,o]=i==t.state.selection.anchor?[i,e]:[e,i];l=n.resolve(o)}else{u=t.docView.posFromDOM(r.anchorNode,r.anchorOffset,1)}if(u<0)return null}let f=n.resolve(u);if(!a){let r=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;a=il(t,f,l,r)}return a}function Vo(t){return t.editable?t.hasFocus():ol(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Go(t,e=false){let r=t.state.selection;rl(t,r);if(!Vo(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Rs){let e=t.domSelectionRange(),r=t.domObserver.currentSelection;if(e.anchorNode&&r.anchorNode&&us(e.anchorNode,e.anchorOffset,r.anchorNode,r.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){el(t)}else{let{anchor:n,head:i}=r,s,o;if(Zo&&!(r instanceof Xn)){if(!r.$from.parent.inlineContent)s=Qo(t,r.from);if(!r.empty&&!r.$from.parent.inlineContent)o=Qo(t,r.to)}t.docView.setSelection(n,i,t,e);if(Zo){if(s)Yo(s);if(o)Yo(o)}if(r.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)tl(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const Zo=Ls||Rs&&Cs<63;function Qo(t,e){let{node:r,offset:n}=t.docView.domFromPos(e,0);let i=n<r.childNodes.length?r.childNodes[n]:null;let s=n?r.childNodes[n-1]:null;if(Ls&&i&&i.contentEditable=="false")return Xo(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Xo(i);else if(s)return Xo(s)}}function Xo(t){t.contentEditable="true";if(Ls&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function Yo(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function tl(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let r=t.domSelectionRange();let n=r.anchorNode,i=r.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(r.anchorNode!=n||r.anchorOffset!=i){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!Vo(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function el(t){let e=t.domSelection();if(!e)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";if(n)e.collapse(r.parentNode,rs(r)+1);else e.collapse(r,0);if(!n&&!t.state.selection.visible&&Ts&&Es<=11){r.disabled=true;r.disabled=false}}function rl(t,e){if(e instanceof ti){let r=t.docView.descAt(e.from);if(r!=t.lastSelectedViewDesc){nl(t);if(r)r.selectNode();t.lastSelectedViewDesc=r}}else{nl(t)}}function nl(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function il(t,e,r,n){return t.someProp("createSelectionBetween",(n=>n(t,e,r)))||Xn.between(e,r,n)}function sl(t){if(t.editable&&!t.hasFocus())return false;return ol(t)}function ol(t){let e=t.domSelectionRange();if(!e.anchorNode)return false;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return false}}function ll(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let r=t.domSelectionRange();return us(e.node,e.offset,r.anchorNode,r.anchorOffset)}function ul(t,e){let{$anchor:r,$head:n}=t.selection;let i=e>0?r.max(n):r.min(n);let s=!i.parent.inlineContent?i:i.depth?t.doc.resolve(e>0?i.after():i.before()):null;return s&&Vn.findFrom(s,e)}function al(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function fl(t,e,r){let n=t.state.selection;if(n instanceof Xn){if(r.indexOf("s")>-1){let{$head:r}=n,i=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText||!i.isLeaf)return false;let s=t.state.doc.resolve(r.pos+i.nodeSize*(e<0?-1:1));return al(t,new Xn(n.$anchor,s))}else if(!n.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let r=ul(t.state,e);if(r&&r instanceof ti)return al(t,r);return false}else if(!(js&&r.indexOf("m")>-1)){let r=n.$head,i=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,s;if(!i||i.isText)return false;let o=e<0?r.pos-i.nodeSize:r.pos;if(!(i.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM))return false;if(ti.isSelectable(i)){return al(t,new ti(e<0?t.state.doc.resolve(r.pos-i.nodeSize):r))}else if(Ds){return al(t,new Xn(t.state.doc.resolve(e<0?o:o+i.nodeSize)))}else{return false}}}else if(n instanceof ti&&n.node.isInline){return al(t,new Xn(e>0?n.$to:n.$from))}else{let r=ul(t.state,e);if(r)return al(t,r);return false}}function hl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function cl(t,e){let r=t.pmViewDesc;return r&&r.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function dl(t,e){return e<0?pl(t):ml(t)}function pl(t){let e=t.domSelectionRange();let r=e.focusNode,n=e.focusOffset;if(!r)return;let i,s,o=false;if(As&&r.nodeType==1&&n<hl(r)&&cl(r.childNodes[n],-1))o=true;for(;;){if(n>0){if(r.nodeType!=1){break}else{let t=r.childNodes[n-1];if(cl(t,-1)){i=r;s=--n}else if(t.nodeType==3){r=t;n=r.nodeValue.length}else break}}else if(gl(r)){break}else{let e=r.previousSibling;while(e&&cl(e,-1)){i=r.parentNode;s=rs(e);e=e.previousSibling}if(!e){r=r.parentNode;if(r==t.dom)break;n=0}else{r=e;n=hl(r)}}}if(o)vl(t,r,n);else if(i)vl(t,i,s)}function ml(t){let e=t.domSelectionRange();let r=e.focusNode,n=e.focusOffset;if(!r)return;let i=hl(r);let s,o;for(;;){if(n<i){if(r.nodeType!=1)break;let t=r.childNodes[n];if(cl(t,1)){s=r;o=++n}else break}else if(gl(r)){break}else{let e=r.nextSibling;while(e&&cl(e,1)){s=e.parentNode;o=rs(e)+1;e=e.nextSibling}if(!e){r=r.parentNode;if(r==t.dom)break;n=i=0}else{r=e;n=0;i=hl(r)}}}if(s)vl(t,s,o)}function gl(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function wl(t,e){while(t&&e==t.childNodes.length&&!ms(t)){e=rs(t)+1;t=t.parentNode}while(t&&e<t.childNodes.length){let r=t.childNodes[e];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r;e=0}}function bl(t,e){while(t&&!e&&!ms(t)){e=rs(t);t=t.parentNode}while(t&&e){let r=t.childNodes[e-1];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r;e=t.childNodes.length}}function vl(t,e,r){if(e.nodeType!=3){let t,n;if(n=wl(e,r)){e=n;r=0}else if(t=bl(e,r)){e=t;r=t.nodeValue.length}}let n=t.domSelection();if(!n)return;if(gs(n)){let t=document.createRange();t.setEnd(e,r);t.setStart(e,r);n.removeAllRanges();n.addRange(t)}else if(n.extend){n.extend(e,r)}t.domObserver.setCurSelection();let{state:i}=t;setTimeout((()=>{if(t.state==i)Go(t)}),50)}function kl(t,e){let r=t.state.doc.resolve(e);if(!(Rs||Ps)&&r.parent.inlineContent){let n=t.coordsAtPos(e);if(e>r.start()){let r=t.coordsAtPos(e-1);let i=(r.top+r.bottom)/2;if(i>n.top&&i<n.bottom&&Math.abs(r.left-n.left)>1)return r.left<n.left?"ltr":"rtl"}if(e<r.end()){let r=t.coordsAtPos(e+1);let i=(r.top+r.bottom)/2;if(i>n.top&&i<n.bottom&&Math.abs(r.left-n.left)>1)return r.left>n.left?"ltr":"rtl"}}let n=getComputedStyle(t.dom).direction;return n=="rtl"?"rtl":"ltr"}function yl(t,e,r){let n=t.state.selection;if(n instanceof Xn&&!n.empty||r.indexOf("s")>-1)return false;if(js&&r.indexOf("m")>-1)return false;let{$from:i,$to:s}=n;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=ul(t.state,e);if(r&&r instanceof ti)return al(t,r)}if(!i.parent.inlineContent){let r=e<0?i:s;let o=n instanceof ri?Vn.near(r,e):Vn.findFrom(r,e);return o?al(t,o):false}return false}function Ml(t,e){if(!(t.state.selection instanceof Xn))return true;let{$head:r,$anchor:n,empty:i}=t.state.selection;if(!r.sameParent(n))return true;if(!i)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){let n=t.state.tr;if(e<0)n.delete(r.pos-s.nodeSize,r.pos);else n.delete(r.pos,r.pos+s.nodeSize);t.dispatch(n);return true}return false}function xl(t,e,r){t.domObserver.stop();e.contentEditable=r;t.domObserver.start()}function Ol(t){if(!Ls||t.state.selection.$head.parentOffset>0)return false;let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(e&&e.nodeType==1&&r==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;xl(t,r,"true");setTimeout((()=>xl(t,r,"false")),20)}return false}function Sl(t){let e="";if(t.ctrlKey)e+="c";if(t.metaKey)e+="m";if(t.altKey)e+="a";if(t.shiftKey)e+="s";return e}function Tl(t,e){let r=e.keyCode,n=Sl(e);if(r==8||js&&r==72&&n=="c"){return Ml(t,-1)||dl(t,-1)}else if(r==46&&!e.shiftKey||js&&r==68&&n=="c"){return Ml(t,1)||dl(t,1)}else if(r==13||r==27){return true}else if(r==37||js&&r==66&&n=="c"){let e=r==37?kl(t,t.state.selection.from)=="ltr"?-1:1:-1;return fl(t,e,n)||dl(t,e)}else if(r==39||js&&r==70&&n=="c"){let e=r==39?kl(t,t.state.selection.from)=="ltr"?1:-1:1;return fl(t,e,n)||dl(t,e)}else if(r==38||js&&r==80&&n=="c"){return yl(t,-1,n)||dl(t,-1)}else if(r==40||js&&r==78&&n=="c"){return Ol(t)||yl(t,1,n)||dl(t,1)}else if(n==(js?"m":"c")&&(r==66||r==73||r==89||r==90)){return true}return false}function El(t,e){t.someProp("transformCopied",(r=>{e=r(e,t)}));let r=[],{content:n,openStart:i,openEnd:s}=e;while(i>1&&s>1&&n.childCount==1&&n.firstChild.childCount==1){i--;s--;let t=n.firstChild;r.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);n=t.content}let o=t.someProp("clipboardSerializer")||Tr.fromSchema(t.state.schema);let l=Hl(),u=l.createElement("div");u.appendChild(o.serializeFragment(n,{document:l}));let a=u.firstChild,f,h=0;while(a&&a.nodeType==1&&(f=Il[a.nodeName.toLowerCase()])){for(let t=f.length-1;t>=0;t--){let e=l.createElement(f[t]);while(u.firstChild)e.appendChild(u.firstChild);u.appendChild(e);h++}a=u.firstChild}if(a&&a.nodeType==1)a.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(r)}`);let c=t.someProp("clipboardTextSerializer",(r=>r(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:u,text:c,slice:e}}function Al(t,e,r,n,i){let s=i.parent.type.spec.code;let o,l;if(!r&&!e)return null;let u=!!e&&(n||s||!r);if(u){t.someProp("transformPastedText",(r=>{e=r(e,s||n,t)}));if(s){l=new be(ce.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0);t.someProp("transformPasted",(e=>{l=e(l,t,true)}));return l}let r=t.someProp("clipboardTextParser",(r=>r(e,i,n,t)));if(r){l=r}else{let r=i.marks();let{schema:n}=t.state,s=Tr.fromSchema(n);o=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=o.appendChild(document.createElement("p"));if(t)e.appendChild(s.serializeNode(n.text(t,r)))}))}}else{t.someProp("transformPastedHTML",(e=>{r=e(r,t)}));o=Bl(r);if(Ds)Ul(o)}let a=o&&o.querySelector("[data-pm-slice]");let f=a&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(a.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let t=+f[3];t>0;t--){let t=o.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;o=t}if(!l){let e=t.someProp("clipboardParser")||t.someProp("domParser")||cr.fromSchema(t.state.schema);l=e.parseSlice(o,{preserveWhitespace:!!(u||f),context:i,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!$l.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(f){l=Fl(Pl(l,+f[1],+f[2]),f[4])}else{l=be.maxOpen(Rl(l.content,i),true);if(l.openStart||l.openEnd){let t=0,e=0;for(let e=l.content.firstChild;t<l.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=l.content.lastChild;e<l.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}l=Pl(l,t,e)}}t.someProp("transformPasted",(e=>{l=e(l,t,u)}));return l}const $l=/^(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 Rl(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let n=e.node(r);let i=n.contentMatchAt(e.index(r));let s,o=[];t.forEach((t=>{if(!o)return;let e=i.findWrapping(t.type),r;if(!e)return o=null;if(r=o.length&&s.length&&Ll(e,s,t,o[o.length-1],0)){o[o.length-1]=r}else{if(o.length)o[o.length-1]=Nl(o[o.length-1],s.length);let r=Cl(t,e);o.push(r);i=i.matchType(r.type);s=e}}));if(o)return ce.from(o)}return t}function Cl(t,e,r=0){for(let n=e.length-1;n>=r;n--)t=e[n].create(null,ce.from(t));return t}function Ll(t,e,r,n,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Ll(t,e,r,n.lastChild,i+1);if(s)return n.copy(n.content.replaceChild(n.childCount-1,s));let o=n.contentMatchAt(n.childCount);if(o.matchType(i==t.length-1?r.type:t[i+1]))return n.copy(n.content.append(ce.from(Cl(r,t,i+1))))}}function Nl(t,e){if(e==0)return t;let r=t.content.replaceChild(t.childCount-1,Nl(t.lastChild,e-1));let n=t.contentMatchAt(t.childCount).fillBefore(ce.empty,true);return t.copy(r.append(n))}function jl(t,e,r,n,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;if(t.childCount>1)s=0;if(i<n-1)l=jl(l,e,r,n,i+1,s);if(i>=r)l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(ce.empty,true));return t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Pl(t,e,r){if(e<t.openStart)t=new be(jl(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(r<t.openEnd)t=new be(jl(t.content,1,r,t.openEnd,0,0),t.openStart,r);return t}const Il={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Dl=null;function Hl(){return Dl||(Dl=document.implementation.createHTMLDocument("title"))}let zl=null;function _l(t){let e=window.trustedTypes;if(!e)return t;if(!zl)zl=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t});return zl.createHTML(t)}function Bl(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let r=Hl().createElement("div");let n=/<([a-z][^>\s]+)/i.exec(t),i;if(i=n&&Il[n[1].toLowerCase()])t=i.map((t=>"<"+t+">")).join("")+t+i.map((t=>"</"+t+">")).reverse().join("");r.innerHTML=_l(t);if(i)for(let t=0;t<i.length;t++)r=r.querySelector(i[t])||r;return r}function Ul(t){let e=t.querySelectorAll(Rs?"span:not([class]):not([style])":"span.Apple-converted-space");for(let r=0;r<e.length;r++){let n=e[r];if(n.childNodes.length==1&&n.textContent==" "&&n.parentNode)n.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),n)}}function Fl(t,e){if(!t.size)return t;let r=t.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch(e){return t}let{content:i,openStart:s,openEnd:o}=t;for(let t=n.length-2;t>=0;t-=2){let e=r.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;i=ce.from(e.create(n[t+1],i));s++;o++}return new be(i,s,o)}const ql={};const Kl={};const Wl={touchstart:true,touchmove:true};class Jl{constructor(){this.shiftKey=false;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=false;this.compositionNode=null;this.composingTimeout=-1;this.compositionNodes=[];this.compositionEndedAt=-2e8;this.compositionID=1;this.compositionPendingChanges=0;this.domChangeCount=0;this.eventHandlers=Object.create(null);this.hideSelectionGuard=null}}function Vl(t){for(let e in ql){let r=ql[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(Yl(t,e)&&!Xl(t,e)&&(t.editable||!(e.type in Kl)))r(t,e)},Wl[e]?{passive:true}:undefined)}if(Ls)t.dom.addEventListener("input",(()=>null));Ql(t)}function Gl(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function Zl(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout);clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Ql(t){t.someProp("handleDOMEvents",(e=>{for(let r in e)if(!t.input.eventHandlers[r])t.dom.addEventListener(r,t.input.eventHandlers[r]=e=>Xl(t,e))}))}function Xl(t,e){return t.someProp("handleDOMEvents",(r=>{let n=r[e.type];return n?n(t,e)||e.defaultPrevented:false}))}function Yl(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let r=e.target;r!=t.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(e))return false;return true}function tu(t,e){if(!Xl(t,e)&&ql[e.type]&&(t.editable||!(e.type in Kl)))ql[e.type](t,e)}Kl.keydown=(t,e)=>{let r=e;t.input.shiftKey=r.keyCode==16||r.shiftKey;if(pu(t,r))return;t.input.lastKeyCode=r.keyCode;t.input.lastKeyCodeTime=Date.now();if(Is&&Rs&&r.keyCode==13)return;if(r.keyCode!=229)t.domObserver.forceFlush();if(Ns&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let e=Date.now();t.input.lastIOSEnter=e;t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{if(t.input.lastIOSEnter==e){t.someProp("handleKeyDown",(e=>e(t,ws(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,r)))||Tl(t,r)){r.preventDefault()}else{Gl(t,"key")}};Kl.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};Kl.keypress=(t,e)=>{let r=e;if(pu(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||js&&r.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,r)))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof Xn)||!n.$from.sameParent(n.$to)){let e=String.fromCharCode(r.charCode);let i=()=>t.state.tr.insertText(e).scrollIntoView();if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(r=>r(t,n.$from.pos,n.$to.pos,e,i))))t.dispatch(i());r.preventDefault()}};function eu(t){return{left:t.clientX,top:t.clientY}}function ru(t,e){let r=e.x-t.clientX,n=e.y-t.clientY;return r*r+n*n<100}function nu(t,e,r,n,i){if(n==-1)return false;let s=t.state.doc.resolve(n);for(let n=s.depth+1;n>0;n--){if(t.someProp(e,(e=>n>s.depth?e(t,r,s.nodeAfter,s.before(n),i,true):e(t,r,s.node(n),s.before(n),i,false))))return true}return false}function iu(t,e,r){if(!t.focused)t.focus();if(t.state.selection.eq(e))return;let n=t.state.tr.setSelection(e);n.setMeta("pointer",true);t.dispatch(n)}function su(t,e){if(e==-1)return false;let r=t.state.doc.resolve(e),n=r.nodeAfter;if(n&&n.isAtom&&ti.isSelectable(n)){iu(t,new ti(r));return true}return false}function ou(t,e){if(e==-1)return false;let r=t.state.selection,n,i;if(r instanceof ti)n=r.node;let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(ti.isSelectable(e)){if(n&&r.$from.depth>0&&t>=r.$from.depth&&s.before(r.$from.depth+1)==r.$from.pos)i=s.before(r.$from.depth);else i=s.before(t);break}}if(i!=null){iu(t,ti.create(t.state.doc,i));return true}else{return false}}function lu(t,e,r,n,i){return nu(t,"handleClickOn",e,r,n)||t.someProp("handleClick",(r=>r(t,e,n)))||(i?ou(t,r):su(t,r))}function uu(t,e,r,n){return nu(t,"handleDoubleClickOn",e,r,n)||t.someProp("handleDoubleClick",(r=>r(t,e,n)))}function au(t,e,r,n){return nu(t,"handleTripleClickOn",e,r,n)||t.someProp("handleTripleClick",(r=>r(t,e,n)))||fu(t,r,n)}function fu(t,e,r){if(r.button!=0)return false;let n=t.state.doc;if(e==-1){if(n.inlineContent){iu(t,Xn.create(n,0,n.content.size));return true}return false}let i=n.resolve(e);for(let e=i.depth+1;e>0;e--){let r=e>i.depth?i.nodeAfter:i.node(e);let s=i.before(e);if(r.inlineContent)iu(t,Xn.create(n,s+1,s+1+r.content.size));else if(ti.isSelectable(r))iu(t,ti.create(n,s));else continue;return true}}function hu(t){return ku(t)}const cu=js?"metaKey":"ctrlKey";ql.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let n=hu(t);let i=Date.now(),s="singleClick";if(i-t.input.lastClick.time<500&&ru(r,t.input.lastClick)&&!r[cu]&&t.input.lastClick.button==r.button){if(t.input.lastClick.type=="singleClick")s="doubleClick";else if(t.input.lastClick.type=="doubleClick")s="tripleClick"}t.input.lastClick={time:i,x:r.clientX,y:r.clientY,type:s,button:r.button};let o=t.posAtCoords(eu(r));if(!o)return;if(s=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new du(t,o,r,!!n)}else if((s=="doubleClick"?uu:au)(t,o.pos,o.inside,r)){r.preventDefault()}else{Gl(t,"pointer")}};class du{constructor(t,e,r,n){this.view=t;this.pos=e;this.event=r;this.flushed=n;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!r[cu];this.allowDefault=r.shiftKey;let i,s;if(e.inside>-1){i=t.state.doc.nodeAt(e.inside);s=e.inside}else{let r=t.state.doc.resolve(e.pos);i=r.parent;s=r.depth?r.before():0}const o=n?null:r.target;const l=o?t.docView.nearestDesc(o,true):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:u}=t.state;if(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==false||u instanceof ti&&u.from<=s&&u.to>s)this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&As&&!this.target.hasAttribute("contentEditable"))};if(this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.draggable=true;if(this.mightDrag.setUneditable)setTimeout((()=>{if(this.view.input.mouseDown==this)this.target.setAttribute("contentEditable","false")}),20);this.view.domObserver.start()}t.root.addEventListener("mouseup",this.up=this.up.bind(this));t.root.addEventListener("mousemove",this.move=this.move.bind(this));Gl(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up);this.view.root.removeEventListener("mousemove",this.move);if(this.mightDrag&&this.target){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.removeAttribute("draggable");if(this.mightDrag.setUneditable)this.target.removeAttribute("contentEditable");this.view.domObserver.start()}if(this.delayedSelectionSync)setTimeout((()=>Go(this.view)));this.view.input.mouseDown=null}up(t){this.done();if(!this.view.dom.contains(t.target))return;let e=this.pos;if(this.view.state.doc!=this.startDoc)e=this.view.posAtCoords(eu(t));this.updateAllowDefault(t);if(this.allowDefault||!e){Gl(this.view,"pointer")}else if(lu(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||Ls&&this.mightDrag&&!this.mightDrag.node.isAtom||Rs&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)){iu(this.view,Vn.near(this.view.state.doc.resolve(e.pos)));t.preventDefault()}else{Gl(this.view,"pointer")}}move(t){this.updateAllowDefault(t);Gl(this.view,"pointer");if(t.buttons==0)this.done()}updateAllowDefault(t){if(!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4))this.allowDefault=true}}ql.touchstart=t=>{t.input.lastTouch=Date.now();hu(t);Gl(t,"pointer")};ql.touchmove=t=>{t.input.lastTouch=Date.now();Gl(t,"pointer")};ql.contextmenu=t=>hu(t);function pu(t,e){if(t.composing)return true;if(Ls&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const mu=Is?5e3:-1;Kl.compositionstart=Kl.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$to;if(e.selection instanceof Xn&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||r.marks();ku(t,true);t.markCursor=null}else{ku(t,!e.selection.empty);if(As&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let e=t.domSelectionRange();for(let r=e.focusNode,n=e.focusOffset;r&&r.nodeType==1&&n!=0;){let e=n<0?r.lastChild:r.childNodes[n-1];if(!e)break;if(e.nodeType==3){let r=t.domSelection();if(r)r.collapse(e,e.nodeValue.length);break}else{r=e;n=-1}}}}t.input.composing=true}gu(t,mu)};Kl.compositionend=(t,e)=>{if(t.composing){t.input.composing=false;t.input.compositionEndedAt=e.timeStamp;t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0;t.input.compositionNode=null;if(t.input.compositionPendingChanges)Promise.resolve().then((()=>t.domObserver.flush()));t.input.compositionID++;gu(t,20)}};function gu(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>ku(t)),e)}function wu(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=vu()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function bu(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let r=cs(e.focusNode,e.focusOffset);let n=ds(e.focusNode,e.focusOffset);if(r&&n&&r!=n){let e=n.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(r==i||n==i)return i;if(!e||!e.isText(n.nodeValue)){return n}else if(t.input.compositionNode==n){let t=r.pmViewDesc;if(!(!t||!t.isText(r.nodeValue)))return n}}return r||n}function vu(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function ku(t,e=false){if(Is&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();wu(t);if(e||t.docView&&t.docView.dirty){let r=Jo(t),n=t.state.selection;if(r&&!r.eq(n))t.dispatch(t.state.tr.setSelection(r));else if((t.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent)t.dispatch(t.state.tr.deleteSelection());else t.updateState(t.state);return true}return false}function yu(t,e){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(e);r.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e);t.dom.blur();n.removeAllRanges();n.addRange(i);setTimeout((()=>{if(r.parentNode)r.parentNode.removeChild(r);t.focus()}),50)}const Mu=Ts&&Es<15||Ns&&Hs<604;ql.copy=Kl.cut=(t,e)=>{let r=e;let n=t.state.selection,i=r.type=="cut";if(n.empty)return;let s=Mu?null:r.clipboardData;let o=n.content(),{dom:l,text:u}=El(t,o);if(s){r.preventDefault();s.clearData();s.setData("text/html",l.innerHTML);s.setData("text/plain",u)}else{yu(t,l)}if(i)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function xu(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ou(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let n=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));if(!r)n.contentEditable="true";n.style.cssText="position: fixed; left: -10000px; top: 10px";n.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(n.parentNode)n.parentNode.removeChild(n);if(r)Su(t,n.value,null,i,e);else Su(t,n.textContent,n.innerHTML,i,e)}),50)}function Su(t,e,r,n,i){let s=Al(t,e,r,n,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,i,s||be.empty))))return true;if(!s)return false;let o=xu(s);let l=o?t.state.tr.replaceSelectionWith(o,n):t.state.tr.replaceSelection(s);t.dispatch(l.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function Tu(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let r=t.getData("text/uri-list");return r?r.replace(/\r?\n/g," "):""}Kl.paste=(t,e)=>{let r=e;if(t.composing&&!Is)return;let n=Mu?null:r.clipboardData;let i=t.input.shiftKey&&t.input.lastKeyCode!=45;if(n&&Su(t,Tu(n),n.getData("text/html"),i,r))r.preventDefault();else Ou(t,r)};class Eu{constructor(t,e,r){this.slice=t;this.move=e;this.node=r}}const Au=js?"altKey":"ctrlKey";function $u(t,e){let r=t.someProp("dragCopies",(t=>!t(e)));return r!=null?r:!e[Au]}ql.dragstart=(t,e)=>{let r=e;let n=t.input.mouseDown;if(n)n.done();if(!r.dataTransfer)return;let i=t.state.selection;let s=i.empty?null:t.posAtCoords(eu(r));let o;if(s&&s.pos>=i.from&&s.pos<=(i instanceof ti?i.to-1:i.to));else if(n&&n.mightDrag){o=ti.create(t.state.doc,n.mightDrag.pos)}else if(r.target&&r.target.nodeType==1){let e=t.docView.nearestDesc(r.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)o=ti.create(t.state.doc,e.posBefore)}let l=(o||t.state.selection).content();let{dom:u,text:a,slice:f}=El(t,l);if(!r.dataTransfer.files.length||!Rs||Cs>120)r.dataTransfer.clearData();r.dataTransfer.setData(Mu?"Text":"text/html",u.innerHTML);r.dataTransfer.effectAllowed="copyMove";if(!Mu)r.dataTransfer.setData("text/plain",a);t.dragging=new Eu(f,$u(t,r),o)};ql.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};Kl.dragover=Kl.dragenter=(t,e)=>e.preventDefault();Kl.drop=(t,e)=>{let r=e;let n=t.dragging;t.dragging=null;if(!r.dataTransfer)return;let i=t.posAtCoords(eu(r));if(!i)return;let s=t.state.doc.resolve(i.pos);let o=n&&n.slice;if(o){t.someProp("transformPasted",(e=>{o=e(o,t,false)}))}else{o=Al(t,Tu(r.dataTransfer),Mu?null:r.dataTransfer.getData("text/html"),false,s)}let l=!!(n&&$u(t,r));if(t.someProp("handleDrop",(e=>e(t,r,o||be.empty,l)))){r.preventDefault();return}if(!o)return;r.preventDefault();let u=o?En(t.state.doc,s.pos,o):s.pos;if(u==null)u=s.pos;let a=t.state.tr;if(l){let{node:t}=n;if(t)t.replace(a);else a.deleteSelection()}let f=a.mapping.map(u);let h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1;let c=a.doc;if(h)a.replaceRangeWith(f,f,o.content.firstChild);else a.replaceRange(f,f,o);if(a.doc.eq(c))return;let d=a.doc.resolve(f);if(h&&ti.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild)){a.setSelection(new ti(d))}else{let e=a.mapping.map(u);a.mapping.maps[a.mapping.maps.length-1].forEach(((t,r,n,i)=>e=i));a.setSelection(il(t,d,a.doc.resolve(e)))}t.focus();t.dispatch(a.setMeta("uiEvent","drop"))};ql.focus=t=>{t.input.lastFocus=Date.now();if(!t.focused){t.domObserver.stop();t.dom.classList.add("ProseMirror-focused");t.domObserver.start();t.focused=true;setTimeout((()=>{if(t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange()))Go(t)}),20)}};ql.blur=(t,e)=>{let r=e;if(t.focused){t.domObserver.stop();t.dom.classList.remove("ProseMirror-focused");t.domObserver.start();if(r.relatedTarget&&t.dom.contains(r.relatedTarget))t.domObserver.currentSelection.clear();t.focused=false}};ql.beforeinput=(t,e)=>{let r=e;if(Rs&&Is&&r.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;t.dom.blur();t.focus();if(t.someProp("handleKeyDown",(e=>e(t,ws(8,"Backspace")))))return;let{$cursor:r}=t.state.selection;if(r&&r.pos>0)t.dispatch(t.state.tr.delete(r.pos-1,r.pos).scrollIntoView())}),50)}};for(let t in Kl)ql[t]=Kl[t];function Ru(t,e){if(t==e)return true;for(let r in t)if(t[r]!==e[r])return false;for(let r in e)if(!(r in t))return false;return true}class Cu{constructor(t,e){this.toDOM=t;this.spec=e||Iu;this.side=this.spec.side||0}map(t,e,r,n){let{pos:i,deleted:s}=t.mapResult(e.from+n,this.side<0?-1:1);return s?null:new ju(i-r,i-r,this)}valid(){return true}eq(t){return this==t||t instanceof Cu&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ru(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class Lu{constructor(t,e){this.attrs=t;this.spec=e||Iu}map(t,e,r,n){let i=t.map(e.from+n,this.spec.inclusiveStart?-1:1)-r;let s=t.map(e.to+n,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new ju(i,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Lu&&Ru(this.attrs,t.attrs)&&Ru(this.spec,t.spec)}static is(t){return t.type instanceof Lu}destroy(){}}class Nu{constructor(t,e){this.attrs=t;this.spec=e||Iu}map(t,e,r,n){let i=t.mapResult(e.from+n,1);if(i.deleted)return null;let s=t.mapResult(e.to+n,-1);if(s.deleted||s.pos<=i.pos)return null;return new ju(i.pos-r,s.pos-r,this)}valid(t,e){let{index:r,offset:n}=t.content.findIndex(e.from),i;return n==e.from&&!(i=t.child(r)).isText&&n+i.nodeSize==e.to}eq(t){return this==t||t instanceof Nu&&Ru(this.attrs,t.attrs)&&Ru(this.spec,t.spec)}destroy(){}}class ju{constructor(t,e,r){this.from=t;this.to=e;this.type=r}copy(t,e){return new ju(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,r){return this.type.map(t,this,e,r)}static widget(t,e,r){return new ju(t,t,new Cu(e,r))}static inline(t,e,r,n){return new ju(t,e,new Lu(r,n))}static node(t,e,r,n){return new ju(t,e,new Nu(r,n))}get spec(){return this.type.spec}get inline(){return this.type instanceof Lu}get widget(){return this.type instanceof Cu}}const Pu=[],Iu={};class Du{constructor(t,e){this.local=t.length?t:Pu;this.children=e.length?e:Pu}static create(t,e){return e.length?Ku(e,t,0,Iu):Hu}find(t,e,r){let n=[];this.findInner(t==null?0:t,e==null?1e9:e,n,0,r);return n}findInner(t,e,r,n,i){for(let s=0;s<this.local.length;s++){let o=this.local[s];if(o.from<=e&&o.to>=t&&(!i||i(o.spec)))r.push(o.copy(o.from+n,o.to+n))}for(let s=0;s<this.children.length;s+=3){if(this.children[s]<e&&this.children[s+1]>t){let o=this.children[s]+1;this.children[s+2].findInner(t-o,e-o,r,n+o,i)}}}map(t,e,r){if(this==Hu||t.maps.length==0)return this;return this.mapInner(t,e,0,0,r||Iu)}mapInner(t,e,r,n,i){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(t,r,n);if(l&&l.type.valid(e,l))(s||(s=[])).push(l);else if(i.onRemove)i.onRemove(this.local[o].spec)}if(this.children.length)return _u(this.children,s||[],t,e,r,n,i);else return s?new Du(s.sort(Wu),Pu):Hu}add(t,e){if(!e.length)return this;if(this==Hu)return Du.create(t,e);return this.addInner(t,e,0)}addInner(t,e,r){let n,i=0;t.forEach(((t,s)=>{let o=s+r,l;if(!(l=Fu(e,t,o)))return;if(!n)n=this.children.slice();while(i<n.length&&n[i]<s)i+=3;if(n[i]==s)n[i+2]=n[i+2].addInner(t,l,o+1);else n.splice(i,0,s,s+t.nodeSize,Ku(l,t,o+1,Iu));i+=3}));let s=Bu(i?qu(e):e,-r);for(let e=0;e<s.length;e++)if(!s[e].type.valid(t,s[e]))s.splice(e--,1);return new Du(s.length?this.local.concat(s).sort(Wu):this.local,n||this.children)}remove(t){if(t.length==0||this==Hu)return this;return this.removeInner(t,0)}removeInner(t,e){let r=this.children,n=this.local;for(let n=0;n<r.length;n+=3){let i;let s=r[n]+e,o=r[n+1]+e;for(let e=0,r;e<t.length;e++)if(r=t[e]){if(r.from>s&&r.to<o){t[e]=null;(i||(i=[])).push(r)}}if(!i)continue;if(r==this.children)r=this.children.slice();let l=r[n+2].removeInner(i,s+1);if(l!=Hu){r[n+2]=l}else{r.splice(n,3);n-=3}}if(n.length)for(let r=0,i;r<t.length;r++)if(i=t[r]){for(let t=0;t<n.length;t++)if(n[t].eq(i,e)){if(n==this.local)n=this.local.slice();n.splice(t--,1)}}if(r==this.children&&n==this.local)return this;return n.length||r.length?new Du(n,r):Hu}forChild(t,e){if(this==Hu)return this;if(e.isLeaf)return Du.empty;let r,n;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)r=this.children[e+2];break}let i=t+1,s=i+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>i&&e.type instanceof Lu){let t=Math.max(i,e.from)-i,r=Math.min(s,e.to)-i;if(t<r)(n||(n=[])).push(e.copy(t,r))}}if(n){let t=new Du(n.sort(Wu),Pu);return r?new zu([t,r]):t}return r||Hu}eq(t){if(this==t)return true;if(!(t instanceof Du)||this.local.length!=t.local.length||this.children.length!=t.children.length)return false;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return false;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return false;return true}locals(t){return Ju(this.localsInner(t))}localsInner(t){if(this==Hu)return Pu;if(t.inlineContent||!this.local.some(Lu.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof Lu))e.push(this.local[t])}return e}forEachSet(t){t(this)}}Du.empty=new Du([],[]);Du.removeOverlap=Ju;const Hu=Du.empty;class zu{constructor(t){this.members=t}map(t,e){const r=this.members.map((r=>r.map(t,e,Iu)));return zu.from(r)}forChild(t,e){if(e.isLeaf)return Du.empty;let r=[];for(let n=0;n<this.members.length;n++){let i=this.members[n].forChild(t,e);if(i==Hu)continue;if(i instanceof zu)r=r.concat(i.members);else r.push(i)}return zu.from(r)}eq(t){if(!(t instanceof zu)||t.members.length!=this.members.length)return false;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return false;return true}locals(t){let e,r=true;for(let n=0;n<this.members.length;n++){let i=this.members[n].localsInner(t);if(!i.length)continue;if(!e){e=i}else{if(r){e=e.slice();r=false}for(let t=0;t<i.length;t++)e.push(i[t])}}return e?Ju(r?e:e.sort(Wu)):Pu}static from(t){switch(t.length){case 0:return Hu;case 1:return t[0];default:return new zu(t.every((t=>t instanceof Du))?t:t.reduce(((t,e)=>t.concat(e instanceof Du?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function _u(t,e,r,n,i,s,o){let l=t.slice();for(let t=0,e=s;t<r.maps.length;t++){let n=0;r.maps[t].forEach(((t,r,i,s)=>{let o=s-i-(r-t);for(let i=0;i<l.length;i+=3){let s=l[i+1];if(s<0||t>s+e-n)continue;let u=l[i]+e-n;if(r>=u){l[i+1]=t<=u?-2:-1}else if(t>=e&&o){l[i]+=o;l[i+1]+=o}}n+=o}));e=r.maps[t].map(e,-1)}let u=false;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(l[e+1]==-2){u=true;l[e+1]=-1;continue}let a=r.map(t[e]+s),f=a-i;if(f<0||f>=n.content.size){u=true;continue}let h=r.map(t[e+1]+s,-1),c=h-i;let{index:d,offset:p}=n.content.findIndex(f);let m=n.maybeChild(d);if(m&&p==f&&p+m.nodeSize==c){let n=l[e+2].mapInner(r,m,a+1,t[e]+s+1,o);if(n!=Hu){l[e]=f;l[e+1]=c;l[e+2]=n}else{l[e+1]=-2;u=true}}else{u=true}}if(u){let u=Uu(l,t,e,r,i,s,o);let a=Ku(u,n,0,o);e=a.local;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){l.splice(t,3);t-=3}for(let t=0,e=0;t<a.children.length;t+=3){let r=a.children[t];while(e<l.length&&l[e]<r)e+=3;l.splice(e,0,a.children[t],a.children[t+1],a.children[t+2])}}return new Du(e.sort(Wu),l)}function Bu(t,e){if(!e||!t.length)return t;let r=[];for(let n=0;n<t.length;n++){let i=t[n];r.push(new ju(i.from+e,i.to+e,i.type))}return r}function Uu(t,e,r,n,i,s,o){function l(t,e){for(let s=0;s<t.local.length;s++){let l=t.local[s].map(n,i,e);if(l)r.push(l);else if(o.onRemove)o.onRemove(t.local[s].spec)}for(let r=0;r<t.children.length;r+=3)l(t.children[r+2],t.children[r]+e+1)}for(let r=0;r<t.length;r+=3)if(t[r+1]==-1)l(t[r+2],e[r]+s+1);return r}function Fu(t,e,r){if(e.isLeaf)return null;let n=r+e.nodeSize,i=null;for(let e=0,s;e<t.length;e++){if((s=t[e])&&s.from>r&&s.to<n){(i||(i=[])).push(s);t[e]=null}}return i}function qu(t){let e=[];for(let r=0;r<t.length;r++)if(t[r]!=null)e.push(t[r]);return e}function Ku(t,e,r,n){let i=[],s=false;e.forEach(((e,o)=>{let l=Fu(t,e,o+r);if(l){s=true;let t=Ku(l,e,r+o+1,n);if(t!=Hu)i.push(o,o+e.nodeSize,t)}}));let o=Bu(s?qu(t):t,-r).sort(Wu);for(let t=0;t<o.length;t++)if(!o[t].type.valid(e,o[t])){if(n.onRemove)n.onRemove(o[t].spec);o.splice(t--,1)}return o.length||i.length?new Du(o,i):Hu}function Wu(t,e){return t.from-e.from||t.to-e.to}function Ju(t){let e=t;for(let r=0;r<e.length-1;r++){let n=e[r];if(n.from!=n.to)for(let i=r+1;i<e.length;i++){let s=e[i];if(s.from==n.from){if(s.to!=n.to){if(e==t)e=t.slice();e[i]=s.copy(s.from,n.to);Vu(e,i+1,s.copy(n.to,s.to))}continue}else{if(s.from<n.to){if(e==t)e=t.slice();e[r]=n.copy(n.from,s.from);Vu(e,i,n.copy(s.from,n.to))}break}}}return e}function Vu(t,e,r){while(e<t.length&&Wu(r,t[e])>0)e++;t.splice(e,0,r)}function Gu(t){let e=[];t.someProp("decorations",(r=>{let n=r(t.state);if(n&&n!=Hu)e.push(n)}));if(t.cursorWrapper)e.push(Du.create(t.state.doc,[t.cursorWrapper.deco]));return zu.from(e)}const Zu={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const Qu=Ts&&Es<=11;class Xu{constructor(){this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0}set(t){this.anchorNode=t.anchorNode;this.anchorOffset=t.anchorOffset;this.focusNode=t.focusNode;this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class Yu{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new Xu;this.onCharData=null;this.suppressingSelectionUpdates=false;this.lastChangedTextNode=null;this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);if(Ts&&Es<=11&&t.some((t=>t.type=="childList"&&t.removedNodes.length||t.type=="characterData"&&t.oldValue.length>t.target.nodeValue.length)))this.flushSoon();else this.flush()}));if(Qu){this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue});this.flushSoon()}}this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){if(this.flushingSoon<0)this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1;this.flush()}),20)}forceFlush(){if(this.flushingSoon>-1){window.clearTimeout(this.flushingSoon);this.flushingSoon=-1;this.flush()}}start(){if(this.observer){this.observer.takeRecords();this.observer.observe(this.view.dom,Zu)}if(this.onCharData)this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}if(this.onCharData)this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData);this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=true;setTimeout((()=>this.suppressingSelectionUpdates=false),50)}onSelectionChange(){if(!sl(this.view))return;if(this.suppressingSelectionUpdates)return Go(this.view);if(Ts&&Es<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&us(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return true;let e=new Set,r;for(let r=t.focusNode;r;r=ns(r))e.add(r);for(let n=t.anchorNode;n;n=ns(n))if(e.has(n)){r=n;break}let n=r&&this.view.docView.nearestDesc(r);if(n&&n.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r})){this.setCurSelection();return true}}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();if(e.length)this.queue=[];let r=t.domSelectionRange();let n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&sl(t)&&!this.ignoreSelectionChange(r);let i=-1,s=-1,o=false,l=[];if(t.editable){for(let t=0;t<e.length;t++){let r=this.registerMutation(e[t],l);if(r){i=i<0?r.from:Math.min(r.from,i);s=s<0?r.to:Math.max(r.to,s);if(r.typeOver)o=true}}}if(As&&l.length){let e=l.filter((t=>t.nodeName=="BR"));if(e.length==2){let[t,r]=e;if(t.parentNode&&t.parentNode.parentNode==r.parentNode)r.remove();else t.remove()}else{let{focusNode:r}=this.currentSelection;for(let n of e){let e=n.parentNode;if(e&&e.nodeName=="LI"&&(!r||sa(t,r)!=e))n.remove()}}}let u=null;if(i<0&&n&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&gs(r)&&(u=Jo(t))&&u.eq(Vn.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;Go(t);this.currentSelection.set(r);t.scrollToSelection()}else if(i>-1||n){if(i>-1){t.docView.markDirty(i,s);ra(t)}this.handleDOMChange(i,s,o,l);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(r))Go(t);this.currentSelection.set(r)}}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(r==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!r||r.ignoreMutation(t))return null;if(t.type=="childList"){for(let r=0;r<t.addedNodes.length;r++){let n=t.addedNodes[r];e.push(n);if(n.nodeType==3)this.lastChangedTextNode=n}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let n=t.previousSibling,i=t.nextSibling;if(Ts&&Es<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:r,nextSibling:s}=t.addedNodes[e];if(!r||Array.prototype.indexOf.call(t.addedNodes,r)<0)n=r;if(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)i=s}}let s=n&&n.parentNode==t.target?rs(n)+1:0;let o=r.localPosFromDOM(t.target,s,-1);let l=i&&i.parentNode==t.target?rs(i):t.target.childNodes.length;let u=r.localPosFromDOM(t.target,l,1);return{from:o,to:u}}else if(t.type=="attributes"){return{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}}else{this.lastChangedTextNode=t.target;return{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let ta=new WeakMap;let ea=false;function ra(t){if(ta.has(t))return;ta.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=As;if(ea)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.");ea=true}}function na(t,e){let r=e.startContainer,n=e.startOffset;let i=e.endContainer,s=e.endOffset;let o=t.domAtPos(t.state.selection.anchor);if(us(o.node,o.offset,i,s))[r,n,i,s]=[i,s,r,n];return{anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:s}}function ia(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return na(t,r)}let r;function n(t){t.preventDefault();t.stopImmediatePropagation();r=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",n,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",n,true);return r?na(t,r):null}function sa(t,e){for(let r=e.parentNode;r&&r!=t.dom;r=r.parentNode){let e=t.docView.nearestDesc(r,true);if(e&&e.node.isBlock)return r}return null}function oa(t,e,r){let{node:n,fromOffset:i,toOffset:s,from:o,to:l}=t.docView.parseRange(e,r);let u=t.domSelectionRange();let a;let f=u.anchorNode;if(f&&t.dom.contains(f.nodeType==1?f:f.parentNode)){a=[{node:f,offset:u.anchorOffset}];if(!gs(u))a.push({node:u.focusNode,offset:u.focusOffset})}if(Rs&&t.input.lastKeyCode===8){for(let t=s;t>i;t--){let e=n.childNodes[t-1],r=e.pmViewDesc;if(e.nodeName=="BR"&&!r){s=t;break}if(!r||r.size)break}}let h=t.state.doc;let c=t.someProp("domParser")||cr.fromSchema(t.state.schema);let d=h.resolve(o);let p=null,m=c.parse(n,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:i,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:a,ruleFromNode:la,context:d});if(a&&a[0].pos!=null){let t=a[0].pos,e=a[1]&&a[1].pos;if(e==null)e=t;p={anchor:t+o,head:e+o}}return{doc:m,sel:p,from:o,to:l}}function la(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(Ls&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");t.appendChild(document.createElement("li"));return{skip:t}}else if(t.parentNode.lastChild==t||Ls&&/^(tr|table)$/i.test(t.parentNode.nodeName)){return{ignore:true}}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder")){return{ignore:true}}return null}const ua=/^(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 aa(t,e,r,n,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let r=Jo(t,e);if(r&&!t.state.selection.eq(r)){if(Rs&&Is&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,ws(13,"Enter")))))return;let n=t.state.tr.setSelection(r);if(e=="pointer")n.setMeta("pointer",true);else if(e=="key")n.scrollIntoView();if(s)n.setMeta("composition",s);t.dispatch(n)}return}let o=t.state.doc.resolve(e);let l=o.sharedDepth(r);e=o.before(l+1);r=t.state.doc.resolve(r).after(l+1);let u=t.state.selection;let a=oa(t,e,r);let f=t.state.doc,h=f.slice(a.from,a.to);let c,d;if(t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime){c=t.state.selection.to;d="end"}else{c=t.state.selection.from;d="start"}t.input.lastKeyCode=null;let p=pa(h.content,a.doc.content,a.from,c,d);if(p)t.input.domChangeCount++;if((Ns&&t.input.lastIOSEnter>Date.now()-225||Is)&&i.some((t=>t.nodeType==1&&!ua.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,ws(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!p){if(n&&u instanceof Xn&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(a.sel&&a.sel.anchor!=a.sel.head)){p={start:u.from,endA:u.to,endB:u.to}}else{if(a.sel){let e=fa(t,t.state.doc,a.sel);if(e&&!e.eq(t.state.selection)){let r=t.state.tr.setSelection(e);if(s)r.setMeta("composition",s);t.dispatch(r)}}return}}if(t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof Xn){if(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=a.from){p.start=t.state.selection.from}else if(p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=a.to){p.endB+=t.state.selection.to-p.endA;p.endA=t.state.selection.to}}if(Ts&&Es<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>a.from&&a.doc.textBetween(p.start-a.from-1,p.start-a.from+1)==" "){p.start--;p.endA--;p.endB--}let m=a.doc.resolveNoCache(p.start-a.from);let g=a.doc.resolveNoCache(p.endB-a.from);let w=f.resolve(p.start);let b=m.sameParent(g)&&m.parent.inlineContent&&w.end()>=p.endA;if((Ns&&t.input.lastIOSEnter>Date.now()-225&&(!b||i.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!b&&m.pos<a.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(a.doc.textBetween(m.pos,g.pos,"","")))&&t.someProp("handleKeyDown",(e=>e(t,ws(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&ca(f,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",(e=>e(t,ws(8,"Backspace"))))){if(Is&&Rs)t.domObserver.suppressSelectionUpdates();return}if(Rs&&p.endB==p.start)t.input.lastChromeDelete=Date.now();if(Is&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&a.sel&&a.sel.anchor==a.sel.head&&a.sel.head==p.endA){p.endB-=2;g=a.doc.resolveNoCache(p.endB-a.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,ws(13,"Enter"))}))}),20)}let v=p.start,k=p.endA;let y=e=>{let r=e||t.state.tr.replace(v,k,a.doc.slice(p.start-a.from,p.endB-a.from));if(a.sel){let e=fa(t,r.doc,a.sel);if(e&&!(Rs&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==v||e.head==r.mapping.map(k)-1)||Ts&&e.empty&&e.head==v))r.setSelection(e)}if(s)r.setMeta("composition",s);return r.scrollIntoView()};let M;if(b){if(m.pos==g.pos){if(Ts&&Es<=11&&m.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>Go(t)),20)}let e=y(t.state.tr.delete(v,k));let r=f.resolve(p.start).marksAcross(f.resolve(p.endA));if(r)e.ensureMarks(r);t.dispatch(e)}else if(p.endA==p.endB&&(M=ha(m.parent.content.cut(m.parentOffset,g.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start())))){let e=y(t.state.tr);if(M.type=="add")e.addMark(v,k,M.mark);else e.removeMark(v,k,M.mark);t.dispatch(e)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,g.parentOffset);let r=()=>y(t.state.tr.insertText(e,v,k));if(!t.someProp("handleTextInput",(n=>n(t,v,k,e,r))))t.dispatch(r())}}else{t.dispatch(y())}}function fa(t,e,r){if(Math.max(r.anchor,r.head)>e.content.size)return null;return il(t,e.resolve(r.anchor),e.resolve(r.head))}function ha(t,e){let r=t.firstChild.marks,n=e.firstChild.marks;let i=r,s=n,o,l,u;for(let t=0;t<n.length;t++)i=n[t].removeFromSet(i);for(let t=0;t<r.length;t++)s=r[t].removeFromSet(s);if(i.length==1&&s.length==0){l=i[0];o="add";u=t=>t.mark(l.addToSet(t.marks))}else if(i.length==0&&s.length==1){l=s[0];o="remove";u=t=>t.mark(l.removeFromSet(t.marks))}else{return null}let a=[];for(let t=0;t<e.childCount;t++)a.push(u(e.child(t)));if(ce.from(a).eq(t))return{mark:l,type:o}}function ca(t,e,r,n,i){if(r-e<=i.pos-n.pos||da(n,true,false)<i.pos)return false;let s=t.resolve(e);if(!n.parent.isTextblock){let t=s.nodeAfter;return t!=null&&r==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return false;let o=t.resolve(da(s,true,true));if(!o.parent.isTextblock||o.pos>r||da(o,true,false)<r)return false;return n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function da(t,e,r){let n=t.depth,i=e?t.end():t.pos;while(n>0&&(e||t.indexAfter(n)==t.node(n).childCount)){n--;i++;e=false}if(r){let e=t.node(n).maybeChild(t.indexAfter(n));while(e&&!e.isLeaf){e=e.firstChild;i++}}return i}function pa(t,e,r,n,i){let s=t.findDiffStart(e,r);if(s==null)return null;let{a:o,b:l}=t.findDiffEnd(e,r+t.size,r+e.size);if(i=="end"){let t=Math.max(0,s-Math.min(o,l));n-=o+t-s}if(o<s&&t.size<e.size){let t=n<=s&&n>=o?s-n:0;s-=t;if(s&&s<e.size&&ma(e.textBetween(s-1,s+1)))s+=t?1:-1;l=s+(l-o);o=s}else if(l<s){let e=n<=s&&n>=l?s-n:0;s-=e;if(s&&s<t.size&&ma(t.textBetween(s-1,s+1)))s+=e?1:-1;o=s+(o-l);l=s}return{start:s,endA:o,endB:l}}function ma(t){if(t.length!=2)return false;let e=t.charCodeAt(0),r=t.charCodeAt(1);return e>=56320&&e<=57343&&r>=55296&&r<=56319}class ga{constructor(t,e){this._root=null;this.focused=false;this.trackWrites=null;this.mounted=false;this.markCursor=null;this.cursorWrapper=null;this.lastSelectedViewDesc=undefined;this.input=new Jl;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(xa);this.dispatch=this.dispatch.bind(this);this.dom=t&&t.mount||document.createElement("div");if(t){if(t.appendChild)t.appendChild(this.dom);else if(typeof t=="function")t(this.dom);else if(t.mount)this.mounted=true}this.editable=va(this);ba(this);this.nodeViews=ya(this);this.docView=Eo(this.state.doc,wa(this),Gu(this),this.dom,this);this.domObserver=new Yu(this,((t,e,r,n)=>aa(this,t,e,r,n)));this.domObserver.start();Vl(this);this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){if(t.handleDOMEvents!=this._props.handleDOMEvents)Ql(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(xa);this.directPlugins=t.plugins}this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let r in t)e[r]=t[r];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var r;let n=this.state,i=false,s=false;if(t.storedMarks&&this.composing){wu(this);s=true}this.state=t;let o=n.plugins!=t.plugins||this._props.plugins!=e.plugins;if(o||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=ya(this);if(Ma(t,this.nodeViews)){this.nodeViews=t;i=true}}if(o||e.handleDOMEvents!=this._props.handleDOMEvents){Ql(this)}this.editable=va(this);ba(this);let l=Gu(this),u=wa(this);let a=n.plugins!=t.plugins&&!n.doc.eq(t.doc)?"reset":t.scrollToSelection>n.scrollToSelection?"to selection":"preserve";let f=i||!this.docView.matchesNode(t.doc,u,l);if(f||!t.selection.eq(n.selection))s=true;let h=a=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Fs(this);if(s){this.domObserver.stop();let e=f&&(Ts||Rs)&&!this.composing&&!n.selection.empty&&!t.selection.empty&&ka(n.selection,t.selection);if(f){let r=Rs?this.trackWrites=this.domSelectionRange().focusNode:null;if(this.composing)this.input.compositionNode=bu(this);if(i||!this.docView.update(t.doc,u,l,this)){this.docView.updateOuterDeco(u);this.docView.destroy();this.docView=Eo(t.doc,u,l,this.dom,this)}if(r&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ll(this))){Go(this,e)}else{rl(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(n);if(((r=this.dragging)===null||r===void 0?void 0:r.node)&&!n.doc.eq(t.doc))this.updateDraggedNode(this.dragging,n);if(a=="reset"){this.dom.scrollTop=0}else if(a=="to selection"){this.scrollToSelection()}else if(h){Ks(h)}}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode));else if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof ti){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)Us(this,e.getBoundingClientRect(),t)}else{Us(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;while(t=this.pluginViews.pop())if(t.destroy)t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins;this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}}else{for(let e=0;e<this.pluginViews.length;e++){let r=this.pluginViews[e];if(r.update)r.update(this,t)}}}updateDraggedNode(t,e){let r=t.node,n=-1;if(this.state.doc.nodeAt(r.from)==r.node){n=r.from}else{let t=r.from+(this.state.doc.content.size-e.doc.content.size);let i=t>0&&this.state.doc.nodeAt(t);if(i==r.node)n=t}this.dragging=new Eu(t.slice,t.move,n<0?undefined:ti.create(this.state.doc,n))}someProp(t,e){let r=this._props&&this._props[t],n;if(r!=null&&(n=e?e(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let i=this.directPlugins[r].props[t];if(i!=null&&(n=e?e(i):i))return n}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let s=i[r].props[t];if(s!=null&&(n=e?e(s):s))return n}}hasFocus(){if(Ts){let t=this.root.activeElement;if(t==this.dom)return true;if(!t||!this.dom.contains(t))return false;while(t&&this.dom!=t&&this.dom.contains(t)){if(t.contentEditable=="false")return false;t=t.parentElement}return true}return this.root.activeElement==this.dom}focus(){this.domObserver.stop();if(this.editable)Vs(this.dom);Go(this);this.domObserver.start()}get root(){let t=this._root;if(t==null)for(let t=this.dom.parentNode;t;t=t.parentNode){if(t.nodeType==9||t.nodeType==11&&t.host){if(!t.getSelection)Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection();return this._root=t}}return t||document}updateRoot(){this._root=null}posAtCoords(t){return ro(this,t)}coordsAtPos(t,e=1){return oo(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,r=-1){let n=this.docView.posFromDOM(t,e,r);if(n==null)throw new RangeError("DOM position not inside the editor");return n}endOfTextblock(t,e){return wo(this,e||this.state,t)}pasteHTML(t,e){return Su(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return Su(this,t,null,true,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return El(this,t)}destroy(){if(!this.docView)return;Zl(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],Gu(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null;ls()}get isDestroyed(){return this.docView==null}dispatchEvent(t){return tu(this,t)}domSelectionRange(){let t=this.domSelection();if(!t)return{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0};return Ls&&this.root.nodeType===11&&bs(this.dom.ownerDocument)==this.dom&&ia(this,t)||t}domSelection(){return this.root.getSelection()}}ga.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))};function wa(t){let e=Object.create(null);e.class="ProseMirror";e.contenteditable=String(t.editable);t.someProp("attributes",(r=>{if(typeof r=="function")r=r(t.state);if(r)for(let t in r){if(t=="class")e.class+=" "+r[t];else if(t=="style")e.style=(e.style?e.style+";":"")+r[t];else if(!e[t]&&t!="contenteditable"&&t!="nodeName")e[t]=String(r[t])}}));if(!e.translate)e.translate="no";return[ju.node(0,t.state.doc.content.size,e)]}function ba(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator";e.setAttribute("mark-placeholder","true");e.setAttribute("alt","");t.cursorWrapper={dom:e,deco:ju.widget(t.state.selection.from,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function va(t){return!t.someProp("editable",(e=>e(t.state)===false))}function ka(t,e){let r=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(r)!=e.$anchor.start(r)}function ya(t){let e=Object.create(null);function r(t){for(let r in t)if(!Object.prototype.hasOwnProperty.call(e,r))e[r]=t[r]}t.someProp("nodeViews",r);t.someProp("markViews",r);return e}function Ma(t,e){let r=0,n=0;for(let n in t){if(t[n]!=e[n])return true;r++}for(let t in e)n++;return r!=n}function xa(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Oa={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"};var Sa={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};var Ta=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var Ea=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Aa=0;Aa<10;Aa++)Oa[48+Aa]=Oa[96+Aa]=String(Aa);for(var Aa=1;Aa<=24;Aa++)Oa[Aa+111]="F"+Aa;for(var Aa=65;Aa<=90;Aa++){Oa[Aa]=String.fromCharCode(Aa+32);Sa[Aa]=String.fromCharCode(Aa)}for(var $a in Oa)if(!Sa.hasOwnProperty($a))Sa[$a]=Oa[$a];function Ra(t){var e=Ta&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ea&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var r=!e&&t.key||(t.shiftKey?Sa:Oa)[t.keyCode]||t.key||"Unidentified";if(r=="Esc")r="Escape";if(r=="Del")r="Delete";if(r=="Left")r="ArrowLeft";if(r=="Up")r="ArrowUp";if(r=="Right")r="ArrowRight";if(r=="Down")r="ArrowDown";return r}const Ca=typeof navigator!="undefined"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);const La=typeof navigator!="undefined"&&/Win/.test(navigator.platform);function Na(t){let e=t.split(/-(?!$)/),r=e[e.length-1];if(r=="Space")r=" ";let n,i,s,o;for(let t=0;t<e.length-1;t++){let r=e[t];if(/^(cmd|meta|m)$/i.test(r))o=true;else if(/^a(lt)?$/i.test(r))n=true;else if(/^(c|ctrl|control)$/i.test(r))i=true;else if(/^s(hift)?$/i.test(r))s=true;else if(/^mod$/i.test(r)){if(Ca)o=true;else i=true}else throw new Error("Unrecognized modifier name: "+r)}if(n)r="Alt-"+r;if(i)r="Ctrl-"+r;if(o)r="Meta-"+r;if(s)r="Shift-"+r;return r}function ja(t){let e=Object.create(null);for(let r in t)e[Na(r)]=t[r];return e}function Pa(t,e,r=true){if(e.altKey)t="Alt-"+t;if(e.ctrlKey)t="Ctrl-"+t;if(e.metaKey)t="Meta-"+t;if(r&&e.shiftKey)t="Shift-"+t;return t}function Ia(t){return new gi({props:{handleKeyDown:Da(t)}})}function Da(t){let e=ja(t);return function(t,r){let n=Ra(r),i,s=e[Pa(n,r)];if(s&&s(t.state,t.dispatch,t))return true;if(n.length==1&&n!=" "){if(r.shiftKey){let i=e[Pa(n,r,false)];if(i&&i(t.state,t.dispatch,t))return true}if((r.altKey||r.metaKey||r.ctrlKey)&&!(La&&r.ctrlKey&&r.altKey)&&(i=Oa[r.keyCode])&&i!=n){let n=e[Pa(i,r)];if(n&&n(t.state,t.dispatch,t))return true}}return false}}var Ha=Object.defineProperty;var za=(t,e)=>{for(var r in e)Ha(t,r,{get:e[r],enumerable:true})};function _a(t){const{state:e,transaction:r}=t;let{selection:n}=r;let{doc:i}=r;let{storedMarks:s}=r;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return n},get doc(){return i},get tr(){n=r.selection;i=r.doc;s=r.storedMarks;return r}}}var Ba=class{constructor(t){this.editor=t.editor;this.rawCommands=this.editor.extensionManager.commands;this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:r}=this;const{view:n}=e;const{tr:i}=r;const s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map((([t,e])=>{const r=(...t)=>{const r=e(...t)(s);if(!i.getMeta("preventDispatch")&&!this.hasCustomState){n.dispatch(i)}return r};return[t,r]})))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=true){const{rawCommands:r,editor:n,state:i}=this;const{view:s}=n;const o=[];const l=!!t;const u=t||i.tr;const a=()=>{if(!l&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState){s.dispatch(u)}return o.every((t=>t===true))};const f={...Object.fromEntries(Object.entries(r).map((([t,r])=>{const n=(...t)=>{const n=this.buildProps(u,e);const i=r(...t)(n);o.push(i);return f};return[t,n]}))),run:a};return f}createCan(t){const{rawCommands:e,state:r}=this;const n=false;const i=t||r.tr;const s=this.buildProps(i,n);const o=Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...s,dispatch:void 0})])));return{...o,chain:()=>this.createChain(i,n)}}buildProps(t,e=true){const{rawCommands:r,editor:n,state:i}=this;const{view:s}=n;const o={tr:t,editor:n,view:s,state:_a({state:i,transaction:t}),dispatch:e?()=>void 0:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map((([t,e])=>[t,(...t)=>e(...t)(o)])))}};return o}};var Ua={};za(Ua,{blur:()=>Fa,clearContent:()=>qa,clearNodes:()=>Ka,command:()=>Wa,createParagraphNear:()=>Ja,cut:()=>Va,deleteCurrentNode:()=>Ga,deleteNode:()=>Qa,deleteRange:()=>Xa,deleteSelection:()=>Ya,enter:()=>tf,exitCode:()=>ef,extendMarkRange:()=>af,first:()=>ff,focus:()=>gf,forEach:()=>wf,insertContent:()=>bf,insertContentAt:()=>Of,joinBackward:()=>Ef,joinDown:()=>Tf,joinForward:()=>Af,joinItemBackward:()=>$f,joinItemForward:()=>Rf,joinTextblockBackward:()=>Cf,joinTextblockForward:()=>Lf,joinUp:()=>Sf,keyboardShortcut:()=>Pf,lift:()=>Df,liftEmptyBlock:()=>Hf,liftListItem:()=>zf,newlineInCode:()=>_f,resetAttributes:()=>Ff,scrollIntoView:()=>qf,selectAll:()=>Kf,selectNodeBackward:()=>Wf,selectNodeForward:()=>Jf,selectParentNode:()=>Vf,selectTextblockEnd:()=>Gf,selectTextblockStart:()=>Zf,setContent:()=>Xf,setMark:()=>Wh,setMeta:()=>Jh,setNode:()=>Vh,setNodeSelection:()=>Gh,setTextSelection:()=>Zh,sinkListItem:()=>Qh,splitBlock:()=>Yh,splitListItem:()=>tc,toggleList:()=>nc,toggleMark:()=>ic,toggleNode:()=>sc,toggleWrap:()=>oc,undoInputRule:()=>lc,unsetAllMarks:()=>uc,unsetMark:()=>ac,updateAttributes:()=>fc,wrapIn:()=>hc,wrapInList:()=>cc});var Fa=()=>({editor:t,view:e})=>{requestAnimationFrame((()=>{var r;if(!t.isDestroyed){e.dom.blur();(r=window==null?void 0:window.getSelection())==null?void 0:r.removeAllRanges()}}));return true};var qa=(t=true)=>({commands:e})=>e.setContent("",{emitUpdate:t});var Ka=()=>({state:t,tr:e,dispatch:r})=>{const{selection:n}=e;const{ranges:i}=n;if(!r){return true}i.forEach((({$from:r,$to:n})=>{t.doc.nodesBetween(r.pos,n.pos,((t,r)=>{if(t.type.isText){return}const{doc:n,mapping:i}=e;const s=n.resolve(i.map(r));const o=n.resolve(i.map(r+t.nodeSize));const l=s.blockRange(o);if(!l){return}const u=ln(l);if(t.type.isTextblock){const{defaultType:t}=s.parent.contentMatchAt(s.index());e.setNodeMarkup(l.start,t)}if(u||u===0){e.lift(l,u)}}))}));return true};var Wa=t=>e=>t(e);var Ja=()=>({state:t,dispatch:e})=>zi(t,e);var Va=(t,e)=>({editor:r,tr:n})=>{const{state:i}=r;const s=i.doc.slice(t.from,t.to);n.deleteRange(t.from,t.to);const o=n.mapping.map(e);n.insert(o,s.content);n.setSelection(new Xn(n.doc.resolve(Math.max(o-1,0))));return true};var Ga=()=>({tr:t,dispatch:e})=>{const{selection:r}=t;const n=r.$anchor.node();if(n.content.size>0){return false}const i=t.selection.$anchor;for(let r=i.depth;r>0;r-=1){const s=i.node(r);if(s.type===n.type){if(e){const e=i.before(r);const n=i.after(r);t.delete(e,n).scrollIntoView()}return true}}return false};function Za(t,e){if(typeof t==="string"){if(!e.nodes[t]){throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`)}return e.nodes[t]}return t}var Qa=t=>({tr:e,state:r,dispatch:n})=>{const i=Za(t,r.schema);const s=e.selection.$anchor;for(let t=s.depth;t>0;t-=1){const r=s.node(t);if(r.type===i){if(n){const r=s.before(t);const n=s.after(t);e.delete(r,n).scrollIntoView()}return true}}return false};var Xa=t=>({tr:e,dispatch:r})=>{const{from:n,to:i}=t;if(r){e.delete(n,i)}return true};var Ya=()=>({state:t,dispatch:e})=>ki(t,e);var tf=()=>({commands:t})=>t.keyboardShortcut("Enter");var ef=()=>({state:t,dispatch:e})=>Hi(t,e);function rf(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function nf(t,e,r={strict:true}){const n=Object.keys(e);if(!n.length){return true}return n.every((n=>{if(r.strict){return e[n]===t[n]}if(rf(e[n])){return e[n].test(t[n])}return e[n]===t[n]}))}function sf(t,e,r={}){return t.find((t=>t.type===e&&nf(Object.fromEntries(Object.keys(r).map((e=>[e,t.attrs[e]]))),r)))}function of(t,e,r={}){return!!sf(t,e,r)}function lf(t,e,r){var n;if(!t||!e){return}let i=t.parent.childAfter(t.parentOffset);if(!i.node||!i.node.marks.some((t=>t.type===e))){i=t.parent.childBefore(t.parentOffset)}if(!i.node||!i.node.marks.some((t=>t.type===e))){return}r=r||((n=i.node.marks[0])==null?void 0:n.attrs);const s=sf([...i.node.marks],e,r);if(!s){return}let o=i.index;let l=t.start()+i.offset;let u=o+1;let a=l+i.node.nodeSize;while(o>0&&of([...t.parent.child(o-1).marks],e,r)){o-=1;l-=t.parent.child(o).nodeSize}while(u<t.parent.childCount&&of([...t.parent.child(u).marks],e,r)){a+=t.parent.child(u).nodeSize;u+=1}return{from:l,to:a}}function uf(t,e){if(typeof t==="string"){if(!e.marks[t]){throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`)}return e.marks[t]}return t}var af=(t,e={})=>({tr:r,state:n,dispatch:i})=>{const s=uf(t,n.schema);const{doc:o,selection:l}=r;const{$from:u,from:a,to:f}=l;if(i){const t=lf(u,s,e);if(t&&t.from<=a&&t.to>=f){const e=Xn.create(o,t.from,t.to);r.setSelection(e)}}return true};var ff=t=>e=>{const r=typeof t==="function"?t(e):t;for(let t=0;t<r.length;t+=1){if(r[t](e)){return true}}return false};function hf(t){return t instanceof Xn}function cf(t=0,e=0,r=0){return Math.min(Math.max(t,e),r)}function df(t,e=null){if(!e){return null}const r=Vn.atStart(t);const n=Vn.atEnd(t);if(e==="start"||e===true){return r}if(e==="end"){return n}const i=r.from;const s=n.to;if(e==="all"){return Xn.create(t,cf(0,i,s),cf(t.content.size,i,s))}return Xn.create(t,cf(e,i,s),cf(e,i,s))}function pf(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function mf(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var gf=(t=null,e={})=>({editor:r,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:true,...e};const o=()=>{if(mf()||pf()){n.dom.focus()}requestAnimationFrame((()=>{if(!r.isDestroyed){n.focus();if(e==null?void 0:e.scrollIntoView){r.commands.scrollIntoView()}}}))};if(n.hasFocus()&&t===null||t===false){return true}if(s&&t===null&&!hf(r.state.selection)){o();return true}const l=df(i.doc,t)||r.state.selection;const u=r.state.selection.eq(l);if(s){if(!u){i.setSelection(l)}if(u&&i.storedMarks){i.setStoredMarks(i.storedMarks)}o()}return true};var wf=(t,e)=>r=>t.every(((t,n)=>e(t,{...r,index:n})));var bf=(t,e)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,e);var vf=t=>{const e=t.childNodes;for(let r=e.length-1;r>=0;r-=1){const n=e[r];if(n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)){t.removeChild(n)}else if(n.nodeType===1){vf(n)}}return t};function kf(t){if(typeof window==="undefined"){throw new Error("[tiptap error]: there is no window object available, so this function cannot be used")}const e=`<body>${t}</body>`;const r=(new window.DOMParser).parseFromString(e,"text/html").body;return vf(r)}function yf(t,e,r){if(t instanceof De||t instanceof ce){return t}r={slice:true,parseOptions:{},...r};const n=typeof t==="object"&&t!==null;const i=typeof t==="string";if(n){try{const n=Array.isArray(t)&&t.length>0;if(n){return ce.fromArray(t.map((t=>e.nodeFromJSON(t))))}const i=e.nodeFromJSON(t);if(r.errorOnInvalidContent){i.check()}return i}catch(n){if(r.errorOnInvalidContent){throw new Error("[tiptap error]: Invalid JSON content",{cause:n})}console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",n);return yf("",e,r)}}if(i){if(r.errorOnInvalidContent){let n=false;let i="";const s=new ur({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>{n=true;i=typeof t==="string"?t:t.outerHTML;return null}}]}})});if(r.slice){cr.fromSchema(s).parseSlice(kf(t),r.parseOptions)}else{cr.fromSchema(s).parse(kf(t),r.parseOptions)}if(r.errorOnInvalidContent&&n){throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}}const n=cr.fromSchema(e);if(r.slice){return n.parseSlice(kf(t),r.parseOptions).content}return n.parse(kf(t),r.parseOptions)}return yf("",e,r)}function Mf(t,e,r){const n=t.steps.length-1;if(n<e){return}const i=t.steps[n];if(!(i instanceof Yr||i instanceof tn)){return}const s=t.mapping.maps[n];let o=0;s.forEach(((t,e,r,n)=>{if(o===0){o=n}}));t.setSelection(Vn.near(t.doc.resolve(o),r))}var xf=t=>!("type"in t);var Of=(t,e,r)=>({tr:n,dispatch:i,editor:s})=>{var o;if(i){r={parseOptions:s.options.parseOptions,updateSelection:true,applyInputRules:false,applyPasteRules:false,...r};let i;const l=t=>{s.emit("contentError",{editor:s,error:t,disableCollaboration:()=>{if("collaboration"in s.storage&&typeof s.storage.collaboration==="object"&&s.storage.collaboration){s.storage.collaboration.isDisabled=true}}})};const u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError){try{yf(e,s.schema,{parseOptions:u,errorOnInvalidContent:true})}catch(t){l(t)}}try{i=yf(e,s.schema,{parseOptions:u,errorOnInvalidContent:(o=r.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(t){l(t);return false}let{from:a,to:f}=typeof t==="number"?{from:t,to:t}:{from:t.from,to:t.to};let h=true;let c=true;const d=xf(i)?i:[i];d.forEach((t=>{t.check();h=h?t.isText&&t.marks.length===0:false;c=c?t.isBlock:false}));if(a===f&&c){const{parent:t}=n.doc.resolve(a);const e=t.isTextblock&&!t.type.spec.code&&!t.childCount;if(e){a-=1;f+=1}}let p;if(h){if(Array.isArray(e)){p=e.map((t=>t.text||"")).join("")}else if(e instanceof ce){let t="";e.forEach((e=>{if(e.text){t+=e.text}}));p=t}else if(typeof e==="object"&&!!e&&!!e.text){p=e.text}else{p=e}n.insertText(p,a,f)}else{p=i;const t=n.doc.resolve(a);const e=t.node();const r=t.parentOffset===0;const s=e.isText||e.isTextblock;const o=e.content.size>0;if(r&&s&&o){a=Math.max(0,a-1)}n.replaceWith(a,f,p)}if(r.updateSelection){Mf(n,n.steps.length-1,-1)}if(r.applyInputRules){n.setMeta("applyInputRules",{from:a,text:p})}if(r.applyPasteRules){n.setMeta("applyPasteRules",{from:a,text:p})}}return true};var Sf=()=>({state:t,dispatch:e})=>Ni(t,e);var Tf=()=>({state:t,dispatch:e})=>ji(t,e);var Ef=()=>({state:t,dispatch:e})=>Mi(t,e);var Af=()=>({state:t,dispatch:e})=>Ri(t,e);var $f=()=>({state:t,dispatch:e,tr:r})=>{try{const n=On(t.doc,t.selection.$from.pos,-1);if(n===null||n===void 0){return false}r.join(n,2);if(e){e(r)}return true}catch{return false}};var Rf=()=>({state:t,dispatch:e,tr:r})=>{try{const n=On(t.doc,t.selection.$from.pos,1);if(n===null||n===void 0){return false}r.join(n,2);if(e){e(r)}return true}catch{return false}};var Cf=()=>({state:t,dispatch:e})=>xi(t,e);var Lf=()=>({state:t,dispatch:e})=>Oi(t,e);function Nf(){return typeof navigator!=="undefined"?/Mac/.test(navigator.platform):false}function jf(t){const e=t.split(/-(?!$)/);let r=e[e.length-1];if(r==="Space"){r=" "}let n;let i;let s;let o;for(let t=0;t<e.length-1;t+=1){const r=e[t];if(/^(cmd|meta|m)$/i.test(r)){o=true}else if(/^a(lt)?$/i.test(r)){n=true}else if(/^(c|ctrl|control)$/i.test(r)){i=true}else if(/^s(hift)?$/i.test(r)){s=true}else if(/^mod$/i.test(r)){if(mf()||Nf()){o=true}else{i=true}}else{throw new Error(`Unrecognized modifier name: ${r}`)}}if(n){r=`Alt-${r}`}if(i){r=`Ctrl-${r}`}if(o){r=`Meta-${r}`}if(s){r=`Shift-${r}`}return r}var Pf=t=>({editor:e,view:r,tr:n,dispatch:i})=>{const s=jf(t).split(/-(?!$)/);const o=s.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t)));const l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:true,cancelable:true});const u=e.captureTransaction((()=>{r.someProp("handleKeyDown",(t=>t(r,l)))}));u==null?void 0:u.steps.forEach((t=>{const e=t.map(n.mapping);if(e&&i){n.maybeStep(e)}}));return true};function If(t,e,r={}){const{from:n,to:i,empty:s}=t.selection;const o=e?Za(e,t.schema):null;const l=[];t.doc.nodesBetween(n,i,((t,e)=>{if(t.isText){return}const r=Math.max(n,e);const s=Math.min(i,e+t.nodeSize);l.push({node:t,from:r,to:s})}));const u=i-n;const a=l.filter((t=>{if(!o){return true}return o.name===t.node.type.name})).filter((t=>nf(t.node.attrs,r,{strict:false})));if(s){return!!a.length}const f=a.reduce(((t,e)=>t+e.to-e.from),0);return f>=u}var Df=(t,e={})=>({state:r,dispatch:n})=>{const i=Za(t,r.schema);const s=If(r,i,e);if(!s){return false}return Pi(r,n)};var Hf=()=>({state:t,dispatch:e})=>_i(t,e);var zf=t=>({state:e,dispatch:r})=>{const n=Za(t,e.schema);return Xi(n)(e,r)};var _f=()=>({state:t,dispatch:e})=>Ii(t,e);function Bf(t,e){if(e.nodes[t]){return"node"}if(e.marks[t]){return"mark"}return null}function Uf(t,e){const r=typeof e==="string"?[e]:e;return Object.keys(t).reduce(((e,n)=>{if(!r.includes(n)){e[n]=t[n]}return e}),{})}var Ff=(t,e)=>({tr:r,state:n,dispatch:i})=>{let s=null;let o=null;const l=Bf(typeof t==="string"?t:t.name,n.schema);if(!l){return false}if(l==="node"){s=Za(t,n.schema)}if(l==="mark"){o=uf(t,n.schema)}if(i){r.selection.ranges.forEach((t=>{n.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,n)=>{if(s&&s===t.type){r.setNodeMarkup(n,void 0,Uf(t.attrs,e))}if(o&&t.marks.length){t.marks.forEach((i=>{if(o===i.type){r.addMark(n,n+t.nodeSize,o.create(Uf(i.attrs,e)))}}))}}))}))}return true};var qf=()=>({tr:t,dispatch:e})=>{if(e){t.scrollIntoView()}return true};var Kf=()=>({tr:t,dispatch:e})=>{if(e){const e=new ri(t.doc);t.setSelection(e)}return true};var Wf=()=>({state:t,dispatch:e})=>Ei(t,e);var Jf=()=>({state:t,dispatch:e})=>Ci(t,e);var Vf=()=>({state:t,dispatch:e})=>Bi(t,e);var Gf=()=>({state:t,dispatch:e})=>Wi(t,e);var Zf=()=>({state:t,dispatch:e})=>Ki(t,e);function Qf(t,e,r={},n={}){return yf(t,e,{slice:false,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}var Xf=(t,{errorOnInvalidContent:e,emitUpdate:r=true,parseOptions:n={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:u}=s;if(n.preserveWhitespace!=="full"){const l=Qf(t,i.schema,n,{errorOnInvalidContent:e!=null?e:i.options.enableContentCheck});if(o){s.replaceWith(0,u.content.size,l).setMeta("preventUpdate",!r)}return true}if(o){s.setMeta("preventUpdate",!r)}return l.insertContentAt({from:0,to:u.content.size},t,{parseOptions:n,errorOnInvalidContent:e!=null?e:i.options.enableContentCheck})};function Yf(t,e){const r=uf(e,t.schema);const{from:n,to:i,empty:s}=t.selection;const o=[];if(s){if(t.storedMarks){o.push(...t.storedMarks)}o.push(...t.selection.$head.marks())}else{t.doc.nodesBetween(n,i,(t=>{o.push(...t.marks)}))}const l=o.find((t=>t.type.name===r.name));if(!l){return{}}return{...l.attrs}}function th(t,e){const r=new Wn(t);e.forEach((t=>{t.steps.forEach((t=>{r.step(t)}))}));return r}function eh(t){for(let e=0;e<t.edgeCount;e+=1){const{type:r}=t.edge(e);if(r.isTextblock&&!r.hasRequiredAttrs()){return r}}return null}function rh(t,e,r){const n=[];t.nodesBetween(e.from,e.to,((t,e)=>{if(r(t)){n.push({node:t,pos:e})}}));return n}function nh(t,e){for(let r=t.depth;r>0;r-=1){const n=t.node(r);if(e(n)){return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:n}}}}function ih(t){return e=>nh(e.$from,t)}function sh(t,e,r){if(t.config[e]===void 0&&t.parent){return sh(t.parent,e,r)}if(typeof t.config[e]==="function"){const n=t.config[e].bind({...r,parent:t.parent?sh(t.parent,e,r):null});return n}return t.config[e]}function oh(t){return t.map((t=>{const e={name:t.name,options:t.options,storage:t.storage};const r=sh(t,"addExtensions",e);if(r){return[t,...oh(r())]}return t})).flat(10)}function lh(t,e){const r=Tr.fromSchema(e).serializeFragment(t);const n=document.implementation.createHTMLDocument();const i=n.createElement("div");i.appendChild(r);return i.innerHTML}function uh(t){return typeof t==="function"}function ah(t,e=void 0,...r){if(uh(t)){if(e){return t.bind(e)(...r)}return t(...r)}return t}function fh(t={}){return Object.keys(t).length===0&&t.constructor===Object}function hh(t){const e=t.filter((t=>t.type==="extension"));const r=t.filter((t=>t.type==="node"));const n=t.filter((t=>t.type==="mark"));return{baseExtensions:e,nodeExtensions:r,markExtensions:n}}function ch(t){const e=[];const{nodeExtensions:r,markExtensions:n}=hh(t);const i=[...r,...n];const s={default:null,validate:void 0,rendered:true,renderHTML:null,parseHTML:null,keepOnSplit:true,isRequired:false};t.forEach((t=>{const r={name:t.name,options:t.options,storage:t.storage,extensions:i};const n=sh(t,"addGlobalAttributes",r);if(!n){return}const o=n();o.forEach((t=>{t.types.forEach((r=>{Object.entries(t.attributes).forEach((([t,n])=>{e.push({type:r,name:t,attribute:{...s,...n}})}))}))}))}));i.forEach((t=>{const r={name:t.name,options:t.options,storage:t.storage};const n=sh(t,"addAttributes",r);if(!n){return}const i=n();Object.entries(i).forEach((([r,n])=>{const i={...s,...n};if(typeof(i==null?void 0:i.default)==="function"){i.default=i.default()}if((i==null?void 0:i.isRequired)&&(i==null?void 0:i.default)===void 0){delete i.default}e.push({type:t.name,name:r,attribute:i})}))}));return e}function dh(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const r={...t};Object.entries(e).forEach((([t,e])=>{const n=r[t];if(!n){r[t]=e;return}if(t==="class"){const n=e?String(e).split(" "):[];const i=r[t]?r[t].split(" "):[];const s=n.filter((t=>!i.includes(t)));r[t]=[...i,...s].join(" ")}else if(t==="style"){const n=e?e.split(";").map((t=>t.trim())).filter(Boolean):[];const i=r[t]?r[t].split(";").map((t=>t.trim())).filter(Boolean):[];const s=new Map;i.forEach((t=>{const[e,r]=t.split(":").map((t=>t.trim()));s.set(e,r)}));n.forEach((t=>{const[e,r]=t.split(":").map((t=>t.trim()));s.set(e,r)}));r[t]=Array.from(s.entries()).map((([t,e])=>`${t}: ${e}`)).join("; ")}else{r[t]=e}}));return r}),{})}function ph(t,e){return e.filter((e=>e.type===t.type.name)).filter((t=>t.attribute.rendered)).map((e=>{if(!e.attribute.renderHTML){return{[e.name]:t.attrs[e.name]}}return e.attribute.renderHTML(t.attrs)||{}})).reduce(((t,e)=>dh(t,e)),{})}function mh(t){if(typeof t!=="string"){return t}if(t.match(/^[+-]?(?:\d*\.)?\d+$/)){return Number(t)}if(t==="true"){return true}if(t==="false"){return false}return t}function gh(t,e){if("style"in t){return t}return{...t,getAttrs:r=>{const n=t.getAttrs?t.getAttrs(r):t.attrs;if(n===false){return false}const i=e.reduce(((t,e)=>{const n=e.attribute.parseHTML?e.attribute.parseHTML(r):mh(r.getAttribute(e.name));if(n===null||n===void 0){return t}return{...t,[e.name]:n}}),{});return{...n,...i}}}}function wh(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>{if(t==="attrs"&&fh(e)){return false}return e!==null&&e!==void 0})))}function bh(t,e){var r;const n=ch(t);const{nodeExtensions:i,markExtensions:s}=hh(t);const o=(r=i.find((t=>sh(t,"topNode"))))==null?void 0:r.name;const l=Object.fromEntries(i.map((r=>{const i=n.filter((t=>t.type===r.name));const s={name:r.name,options:r.options,storage:r.storage,editor:e};const o=t.reduce(((t,e)=>{const n=sh(e,"extendNodeSchema",s);return{...t,...n?n(r):{}}}),{});const l=wh({...o,content:ah(sh(r,"content",s)),marks:ah(sh(r,"marks",s)),group:ah(sh(r,"group",s)),inline:ah(sh(r,"inline",s)),atom:ah(sh(r,"atom",s)),selectable:ah(sh(r,"selectable",s)),draggable:ah(sh(r,"draggable",s)),code:ah(sh(r,"code",s)),whitespace:ah(sh(r,"whitespace",s)),linebreakReplacement:ah(sh(r,"linebreakReplacement",s)),defining:ah(sh(r,"defining",s)),isolating:ah(sh(r,"isolating",s)),attrs:Object.fromEntries(i.map((t=>{var e,r;return[t.name,{default:(e=t==null?void 0:t.attribute)==null?void 0:e.default,validate:(r=t==null?void 0:t.attribute)==null?void 0:r.validate}]})))});const u=ah(sh(r,"parseHTML",s));if(u){l.parseDOM=u.map((t=>gh(t,i)))}const a=sh(r,"renderHTML",s);if(a){l.toDOM=t=>a({node:t,HTMLAttributes:ph(t,i)})}const f=sh(r,"renderText",s);if(f){l.toText=f}return[r.name,l]})));const u=Object.fromEntries(s.map((r=>{const i=n.filter((t=>t.type===r.name));const s={name:r.name,options:r.options,storage:r.storage,editor:e};const o=t.reduce(((t,e)=>{const n=sh(e,"extendMarkSchema",s);return{...t,...n?n(r):{}}}),{});const l=wh({...o,inclusive:ah(sh(r,"inclusive",s)),excludes:ah(sh(r,"excludes",s)),group:ah(sh(r,"group",s)),spanning:ah(sh(r,"spanning",s)),code:ah(sh(r,"code",s)),attrs:Object.fromEntries(i.map((t=>{var e,r;return[t.name,{default:(e=t==null?void 0:t.attribute)==null?void 0:e.default,validate:(r=t==null?void 0:t.attribute)==null?void 0:r.validate}]})))});const u=ah(sh(r,"parseHTML",s));if(u){l.parseDOM=u.map((t=>gh(t,i)))}const a=sh(r,"renderHTML",s);if(a){l.toDOM=t=>a({mark:t,HTMLAttributes:ph(t,i)})}return[r.name,l]})));return new ur({topNode:o,nodes:l,marks:u})}function vh(t){const e=t.filter(((e,r)=>t.indexOf(e)!==r));return Array.from(new Set(e))}function kh(t){const e=100;return t.sort(((t,r)=>{const n=sh(t,"priority")||e;const i=sh(r,"priority")||e;if(n>i){return-1}if(n<i){return 1}return 0}))}function yh(t){const e=kh(oh(t));const r=vh(e.map((t=>t.name)));if(r.length){console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`)}return e}function Mh(t,e){const r=yh(t);return bh(r,e)}function xh(t,e){const r=Mh(e);const n=kf(t);return cr.fromSchema(r).parse(n).toJSON()}function Oh(t,e,r){const{from:n,to:i}=e;const{blockSeparator:s="\n\n",textSerializers:o={}}=r||{};let l="";t.nodesBetween(n,i,((t,r,u,a)=>{var f;if(t.isBlock&&r>n){l+=s}const h=o==null?void 0:o[t.type.name];if(h){if(u){l+=h({node:t,pos:r,parent:u,index:a,range:e})}return false}if(t.isText){l+=(f=t==null?void 0:t.text)==null?void 0:f.slice(Math.max(n,r)-r,i-r)}}));return l}function Sh(t,e){const r={from:0,to:t.content.size};return Oh(t,r,e)}function Th(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}function Eh(t,e){const r=Za(e,t.schema);const{from:n,to:i}=t.selection;const s=[];t.doc.nodesBetween(n,i,(t=>{s.push(t)}));const o=s.reverse().find((t=>t.type.name===r.name));if(!o){return{}}return{...o.attrs}}function Ah(t,e){const r=Bf(typeof e==="string"?e:e.name,t.schema);if(r==="node"){return Eh(t,e)}if(r==="mark"){return Yf(t,e)}return{}}function $h(t,e=JSON.stringify){const r={};return t.filter((t=>{const n=e(t);return Object.prototype.hasOwnProperty.call(r,n)?false:r[n]=true}))}function Rh(t){const e=$h(t);return e.length===1?e:e.filter(((t,r)=>{const n=e.filter(((t,e)=>e!==r));return!n.some((e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to))}))}function Ch(t){const{mapping:e,steps:r}=t;const n=[];e.maps.forEach(((t,i)=>{const s=[];if(!t.ranges.length){const{from:t,to:e}=r[i];if(t===void 0||e===void 0){return}s.push({from:t,to:e})}else{t.forEach(((t,e)=>{s.push({from:t,to:e})}))}s.forEach((({from:t,to:r})=>{const s=e.slice(i).map(t,-1);const o=e.slice(i).map(r);const l=e.invert().map(s,-1);const u=e.invert().map(o);n.push({oldRange:{from:l,to:u},newRange:{from:s,to:o}})}))}));return Rh(n)}function Lh(t,e,r){const n=[];if(t===e){r.resolve(t).marks().forEach((e=>{const i=r.resolve(t);const s=lf(i,e.type);if(!s){return}n.push({mark:e,...s})}))}else{r.nodesBetween(t,e,((t,e)=>{if(!t||(t==null?void 0:t.nodeSize)===void 0){return}n.push(...t.marks.map((r=>({from:e,to:e+t.nodeSize,mark:r}))))}))}return n}var Nh=(t,e,r,n=20)=>{const i=t.doc.resolve(r);let s=n;let o=null;while(s>0&&o===null){const t=i.node(s);if((t==null?void 0:t.type.name)===e){o=t}else{s-=1}}return[o,s]};function jh(t,e){return e.nodes[t]||e.marks[t]||null}function Ph(t,e,r){return Object.fromEntries(Object.entries(r).filter((([r])=>{const n=t.find((t=>t.type===e&&t.name===r));if(!n){return false}return n.attribute.keepOnSplit})))}var Ih=(t,e=500)=>{let r="";const n=t.parentOffset;t.parent.nodesBetween(Math.max(0,n-e),n,((t,e,i,s)=>{var o,l;const u=((l=(o=t.type.spec).toText)==null?void 0:l.call(o,{node:t,pos:e,parent:i,index:s}))||t.textContent||"%leaf%";r+=t.isAtom&&!t.isText?u:u.slice(0,Math.max(0,n-e))}));return r};function Dh(t,e,r={}){const{empty:n,ranges:i}=t.selection;const s=e?uf(e,t.schema):null;if(n){return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>{if(!s){return true}return s.name===t.type.name})).find((t=>nf(t.attrs,r,{strict:false})))}let o=0;const l=[];i.forEach((({$from:e,$to:r})=>{const n=e.pos;const i=r.pos;t.doc.nodesBetween(n,i,((t,e)=>{if(!t.isText&&!t.marks.length){return}const r=Math.max(n,e);const s=Math.min(i,e+t.nodeSize);const u=s-r;o+=u;l.push(...t.marks.map((t=>({mark:t,from:r,to:s}))))}))}));if(o===0){return false}const u=l.filter((t=>{if(!s){return true}return s.name===t.mark.type.name})).filter((t=>nf(t.mark.attrs,r,{strict:false}))).reduce(((t,e)=>t+e.to-e.from),0);const a=l.filter((t=>{if(!s){return true}return t.mark.type!==s&&t.mark.type.excludes(s)})).reduce(((t,e)=>t+e.to-e.from),0);const f=u>0?u+a:u;return f>=o}function Hh(t,e,r={}){if(!e){return If(t,null,r)||Dh(t,null,r)}const n=Bf(e,t.schema);if(n==="node"){return If(t,e,r)}if(n==="mark"){return Dh(t,e,r)}return false}var zh=(t,e)=>{const{$from:r,$to:n,$anchor:i}=t.selection;if(e){const r=ih((t=>t.type.name===e))(t.selection);if(!r){return false}const n=t.doc.resolve(r.pos+1);if(i.pos+1===n.end()){return true}return false}if(n.parentOffset<n.parent.nodeSize-2||r.pos!==n.pos){return false}return true};var _h=t=>{const{$from:e,$to:r}=t.selection;if(e.parentOffset>0||e.pos!==r.pos){return false}return true};function Bh(t,e){if(Array.isArray(e)){return e.some((e=>{const r=typeof e==="string"?e:e.name;return r===t.name}))}return e}function Uh(t,e){const{nodeExtensions:r}=hh(e);const n=r.find((e=>e.name===t));if(!n){return false}const i={name:n.name,options:n.options,storage:n.storage};const s=ah(sh(n,"group",i));if(typeof s!=="string"){return false}return s.split(" ").includes("list")}function Fh(t,{checkChildren:e=true,ignoreWhitespace:r=false}={}){var n;if(r){if(t.type.name==="hardBreak"){return true}if(t.isText){return/^\s*$/m.test((n=t.text)!=null?n:"")}}if(t.isText){return!t.text}if(t.isAtom||t.isLeaf){return false}if(t.content.childCount===0){return true}if(e){let n=true;t.content.forEach((t=>{if(n===false){return}if(!Fh(t,{ignoreWhitespace:r,checkChildren:e})){n=false}}));return n}return false}function qh(t){return t instanceof ti}function Kh(t,e,r){var n;const{selection:i}=e;let s=null;if(hf(i)){s=i.$cursor}if(s){const e=(n=t.storedMarks)!=null?n:s.marks();const i=s.parent.type.allowsMarkType(r);return i&&(!!r.isInSet(e)||!e.some((t=>t.type.excludes(r))))}const{ranges:o}=i;return o.some((({$from:e,$to:n})=>{let i=e.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):false;t.doc.nodesBetween(e.pos,n.pos,((t,e,n)=>{if(i){return false}if(t.isInline){const e=!n||n.type.allowsMarkType(r);const s=!!r.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(r)));i=e&&s}return!i}));return i}))}var Wh=(t,e={})=>({tr:r,state:n,dispatch:i})=>{const{selection:s}=r;const{empty:o,ranges:l}=s;const u=uf(t,n.schema);if(i){if(o){const t=Yf(n,u);r.addStoredMark(u.create({...t,...e}))}else{l.forEach((t=>{const i=t.$from.pos;const s=t.$to.pos;n.doc.nodesBetween(i,s,((t,n)=>{const o=Math.max(n,i);const l=Math.min(n+t.nodeSize,s);const a=t.marks.find((t=>t.type===u));if(a){t.marks.forEach((t=>{if(u===t.type){r.addMark(o,l,u.create({...t.attrs,...e}))}}))}else{r.addMark(o,l,u.create(e))}}))}))}}return Kh(n,r,u)};var Jh=(t,e)=>({tr:r})=>{r.setMeta(t,e);return true};var Vh=(t,e={})=>({state:r,dispatch:n,chain:i})=>{const s=Za(t,r.schema);let o;if(r.selection.$anchor.sameParent(r.selection.$head)){o=r.selection.$anchor.parent.attrs}if(!s.isTextblock){console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.');return false}return i().command((({commands:t})=>{const n=Vi(s,{...o,...e})(r);if(n){return true}return t.clearNodes()})).command((({state:t})=>Vi(s,{...o,...e})(t,n))).run()};var Gh=t=>({tr:e,dispatch:r})=>{if(r){const{doc:r}=e;const n=cf(t,0,r.content.size);const i=ti.create(r,n);e.setSelection(i)}return true};var Zh=t=>({tr:e,dispatch:r})=>{if(r){const{doc:r}=e;const{from:n,to:i}=typeof t==="number"?{from:t,to:t}:t;const s=Xn.atStart(r).from;const o=Xn.atEnd(r).to;const l=cf(n,s,o);const u=cf(i,s,o);const a=Xn.create(r,l,u);e.setSelection(a)}return true};var Qh=t=>({state:e,dispatch:r})=>{const n=Za(t,e.schema);return es(n)(e,r)};function Xh(t,e){const r=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(r){const n=r.filter((t=>e==null?void 0:e.includes(t.type.name)));t.tr.ensureMarks(n)}}var Yh=({keepMarks:t=true}={})=>({tr:e,state:r,dispatch:n,editor:i})=>{const{selection:s,doc:o}=e;const{$from:l,$to:u}=s;const a=i.extensionManager.attributes;const f=Ph(a,l.node().type.name,l.node().attrs);if(s instanceof ti&&s.node.isBlock){if(!l.parentOffset||!vn(o,l.pos)){return false}if(n){if(t){Xh(r,i.extensionManager.splittableMarks)}e.split(l.pos).scrollIntoView()}return true}if(!l.parent.isBlock){return false}const h=u.parentOffset===u.parent.content.size;const c=l.depth===0?void 0:eh(l.node(-1).contentMatchAt(l.indexAfter(-1)));let d=h&&c?[{type:c,attrs:f}]:void 0;let p=vn(e.doc,e.mapping.map(l.pos),1,d);if(!d&&!p&&vn(e.doc,e.mapping.map(l.pos),1,c?[{type:c}]:void 0)){p=true;d=c?[{type:c,attrs:f}]:void 0}if(n){if(p){if(s instanceof Xn){e.deleteSelection()}e.split(e.mapping.map(l.pos),1,d);if(c&&!h&&!l.parentOffset&&l.parent.type!==c){const t=e.mapping.map(l.before());const r=e.doc.resolve(t);if(l.node(-1).canReplaceWith(r.index(),r.index()+1,c)){e.setNodeMarkup(e.mapping.map(l.before()),c)}}}if(t){Xh(r,i.extensionManager.splittableMarks)}e.scrollIntoView()}return p};var tc=(t,e={})=>({tr:r,state:n,dispatch:i,editor:s})=>{var o;const l=Za(t,n.schema);const{$from:u,$to:a}=n.selection;const f=n.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(a)){return false}const h=u.node(-1);if(h.type!==l){return false}const c=s.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==l||u.index(-2)!==u.node(-2).childCount-1){return false}if(i){let t=ce.empty;const n=u.index(-1)?1:u.index(-2)?2:3;for(let e=u.depth-n;e>=u.depth-3;e-=1){t=ce.from(u.node(e).copy(t))}const i=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3;const s={...Ph(c,u.node().type.name,u.node().attrs),...e};const a=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(s))||void 0;t=t.append(ce.from(l.createAndFill(null,a)||void 0));const f=u.before(u.depth-(n-1));r.replace(f,u.after(-i),new be(t,4-n,0));let h=-1;r.doc.nodesBetween(f,r.doc.content.size,((t,e)=>{if(h>-1){return false}if(t.isTextblock&&t.content.size===0){h=e+1}}));if(h>-1){r.setSelection(Xn.near(r.doc.resolve(h)))}r.scrollIntoView()}return true}const d=a.pos===u.end()?h.contentMatchAt(0).defaultType:null;const p={...Ph(c,h.type.name,h.attrs),...e};const m={...Ph(c,u.node().type.name,u.node().attrs),...e};r.delete(u.pos,a.pos);const g=d?[{type:l,attrs:p},{type:d,attrs:m}]:[{type:l,attrs:p}];if(!vn(r.doc,u.pos,2)){return false}if(i){const{selection:t,storedMarks:e}=n;const{splittableMarks:o}=s.extensionManager;const l=e||t.$to.parentOffset&&t.$from.marks();r.split(u.pos,2,g).scrollIntoView();if(!l||!i){return true}const a=l.filter((t=>o.includes(t.type.name)));r.ensureMarks(a)}return true};var ec=(t,e)=>{const r=ih((t=>t.type===e))(t.selection);if(!r){return true}const n=t.doc.resolve(Math.max(0,r.pos-1)).before(r.depth);if(n===void 0){return true}const i=t.doc.nodeAt(n);const s=r.node.type===(i==null?void 0:i.type)&&yn(t.doc,r.pos);if(!s){return true}t.join(r.pos);return true};var rc=(t,e)=>{const r=ih((t=>t.type===e))(t.selection);if(!r){return true}const n=t.doc.resolve(r.start).after(r.depth);if(n===void 0){return true}const i=t.doc.nodeAt(n);const s=r.node.type===(i==null?void 0:i.type)&&yn(t.doc,n);if(!s){return true}t.join(n);return true};var nc=(t,e,r,n={})=>({editor:i,tr:s,state:o,dispatch:l,chain:u,commands:a,can:f})=>{const{extensions:h,splittableMarks:c}=i.extensionManager;const d=Za(t,o.schema);const p=Za(e,o.schema);const{selection:m,storedMarks:g}=o;const{$from:w,$to:b}=m;const v=w.blockRange(b);const k=g||m.$to.parentOffset&&m.$from.marks();if(!v){return false}const y=ih((t=>Uh(t.type.name,h)))(m);if(v.depth>=1&&y&&v.depth-y.depth<=1){if(y.node.type===d){return a.liftListItem(p)}if(Uh(y.node.type.name,h)&&d.validContent(y.node.content)&&l){return u().command((()=>{s.setNodeMarkup(y.pos,d);return true})).command((()=>ec(s,d))).command((()=>rc(s,d))).run()}}if(!r||!k||!l){return u().command((()=>{const t=f().wrapInList(d,n);if(t){return true}return a.clearNodes()})).wrapInList(d,n).command((()=>ec(s,d))).command((()=>rc(s,d))).run()}return u().command((()=>{const t=f().wrapInList(d,n);const e=k.filter((t=>c.includes(t.type.name)));s.ensureMarks(e);if(t){return true}return a.clearNodes()})).wrapInList(d,n).command((()=>ec(s,d))).command((()=>rc(s,d))).run()};var ic=(t,e={},r={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=false}=r;const o=uf(t,n.schema);const l=Dh(n,o,e);if(l){return i.unsetMark(o,{extendEmptyMarkRange:s})}return i.setMark(o,e)};var sc=(t,e,r={})=>({state:n,commands:i})=>{const s=Za(t,n.schema);const o=Za(e,n.schema);const l=If(n,s,r);let u;if(n.selection.$anchor.sameParent(n.selection.$head)){u=n.selection.$anchor.parent.attrs}if(l){return i.setNode(o,u)}return i.setNode(s,{...u,...r})};var oc=(t,e={})=>({state:r,commands:n})=>{const i=Za(t,r.schema);const s=If(r,i,e);if(s){return n.lift(i)}return n.wrapIn(i,e)};var lc=()=>({state:t,dispatch:e})=>{const r=t.plugins;for(let n=0;n<r.length;n+=1){const i=r[n];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const e=t.tr;const r=s.transform;for(let t=r.steps.length-1;t>=0;t-=1){e.step(r.steps[t].invert(r.docs[t]))}if(s.text){const r=e.doc.resolve(s.from).marks();e.replaceWith(s.from,s.to,t.schema.text(s.text,r))}else{e.delete(s.from,s.to)}}return true}}return false};var uc=()=>({tr:t,dispatch:e})=>{const{selection:r}=t;const{empty:n,ranges:i}=r;if(n){return true}if(e){i.forEach((e=>{t.removeMark(e.$from.pos,e.$to.pos)}))}return true};var ac=(t,e={})=>({tr:r,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=false}=e;const{selection:l}=r;const u=uf(t,n.schema);const{$from:a,empty:f,ranges:h}=l;if(!i){return true}if(f&&o){let{from:t,to:e}=l;const n=(s=a.marks().find((t=>t.type===u)))==null?void 0:s.attrs;const i=lf(a,u,n);if(i){t=i.from;e=i.to}r.removeMark(t,e,u)}else{h.forEach((t=>{r.removeMark(t.$from.pos,t.$to.pos,u)}))}r.removeStoredMark(u);return true};var fc=(t,e={})=>({tr:r,state:n,dispatch:i})=>{let s=null;let o=null;const l=Bf(typeof t==="string"?t:t.name,n.schema);if(!l){return false}if(l==="node"){s=Za(t,n.schema)}if(l==="mark"){o=uf(t,n.schema)}if(i){r.selection.ranges.forEach((t=>{const i=t.$from.pos;const l=t.$to.pos;let u;let a;let f;let h;if(r.selection.empty){n.doc.nodesBetween(i,l,((t,e)=>{if(s&&s===t.type){f=Math.max(e,i);h=Math.min(e+t.nodeSize,l);u=e;a=t}}))}else{n.doc.nodesBetween(i,l,((t,n)=>{if(n<i&&s&&s===t.type){f=Math.max(n,i);h=Math.min(n+t.nodeSize,l);u=n;a=t}if(n>=i&&n<=l){if(s&&s===t.type){r.setNodeMarkup(n,void 0,{...t.attrs,...e})}if(o&&t.marks.length){t.marks.forEach((s=>{if(o===s.type){const u=Math.max(n,i);const a=Math.min(n+t.nodeSize,l);r.addMark(u,a,o.create({...s.attrs,...e}))}}))}}}))}if(a){if(u!==void 0){r.setNodeMarkup(u,void 0,{...a.attrs,...e})}if(o&&a.marks.length){a.marks.forEach((t=>{if(o===t.type){r.addMark(f,h,o.create({...t.attrs,...e}))}}))}}}))}return true};var hc=(t,e={})=>({state:r,dispatch:n})=>{const i=Za(t,r.schema);return Ji(i,e)(r,n)};var cc=(t,e={})=>({state:r,dispatch:n})=>{const i=Za(t,r.schema);return Gi(i,e)(r,n)};var dc=class{constructor(){this.callbacks={}}on(t,e){if(!this.callbacks[t]){this.callbacks[t]=[]}this.callbacks[t].push(e);return this}emit(t,...e){const r=this.callbacks[t];if(r){r.forEach((t=>t.apply(this,e)))}return this}off(t,e){const r=this.callbacks[t];if(r){if(e){this.callbacks[t]=r.filter((t=>t!==e))}else{delete this.callbacks[t]}}return this}once(t,e){const r=(...n)=>{this.off(t,r);e.apply(this,n)};return this.on(t,r)}removeAllListeners(){this.callbacks={}}};var pc=class{constructor(t){var e;this.find=t.find;this.handler=t.handler;this.undoable=(e=t.undoable)!=null?e:true}};var mc=(t,e)=>{if(rf(e)){return e.exec(t)}const r=e(t);if(!r){return null}const n=[r.text];n.index=r.index;n.input=t;n.data=r.data;if(r.replaceWith){if(!r.text.includes(r.replaceWith)){console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".')}n.push(r.replaceWith)}return n};function gc(t){var e;const{editor:r,from:n,to:i,text:s,rules:o,plugin:l}=t;const{view:u}=r;if(u.composing){return false}const a=u.state.doc.resolve(n);if(a.parent.type.spec.code||!!((e=a.nodeBefore||a.nodeAfter)==null?void 0:e.marks.find((t=>t.type.spec.code)))){return false}let f=false;const h=Ih(a)+s;o.forEach((t=>{if(f){return}const e=mc(h,t.find);if(!e){return}const o=u.state.tr;const a=_a({state:u.state,transaction:o});const c={from:n-(e[0].length-s.length),to:i};const{commands:d,chain:p,can:m}=new Ba({editor:r,state:a});const g=t.handler({state:a,range:c,match:e,commands:d,chain:p,can:m});if(g===null||!o.steps.length){return}if(t.undoable){o.setMeta(l,{transform:o,from:n,to:i,text:s})}u.dispatch(o);f=true}));return f}function wc(t){const{editor:e,rules:r}=t;const n=new gi({state:{init(){return null},apply(t,i,s){const o=t.getMeta(n);if(o){return o}const l=t.getMeta("applyInputRules");const u=!!l;if(u){setTimeout((()=>{let{text:t}=l;if(typeof t==="string"){t=t}else{t=lh(ce.from(t),s.schema)}const{from:i}=l;const o=i+t.length;gc({editor:e,from:i,to:o,text:t,rules:r,plugin:n})}))}return t.selectionSet||t.docChanged?null:i}},props:{handleTextInput(t,i,s,o){return gc({editor:e,from:i,to:s,text:o,rules:r,plugin:n})},handleDOMEvents:{compositionend:t=>{setTimeout((()=>{const{$cursor:i}=t.state.selection;if(i){gc({editor:e,from:i.pos,to:i.pos,text:"",rules:r,plugin:n})}}));return false}},handleKeyDown(t,i){if(i.key!=="Enter"){return false}const{$cursor:s}=t.state.selection;if(s){return gc({editor:e,from:s.pos,to:s.pos,text:"\n",rules:r,plugin:n})}return false}},isInputRules:true});return n}function bc(t){return Object.prototype.toString.call(t).slice(8,-1)}function vc(t){if(bc(t)!=="Object"){return false}return t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function kc(t,e){const r={...t};if(vc(t)&&vc(e)){Object.keys(e).forEach((n=>{if(vc(e[n])&&vc(t[n])){r[n]=kc(t[n],e[n])}else{r[n]=e[n]}}))}return r}var yc=class{constructor(t={}){this.type="extendable";this.parent=null;this.child=null;this.name="";this.config={name:this.name};this.config={...this.config,...t};this.name=this.config.name}get options(){return{...ah(sh(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ah(sh(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>kc(this.options,t)});e.name=this.name;e.parent=this.parent;return e}extend(t={}){const e=new this.constructor({...this.config,...t});e.parent=this;this.child=e;e.name="name"in t?t.name:e.parent.name;return e}};var Mc=class t extends yc{constructor(){super(...arguments);this.type="mark"}static create(e={}){const r=typeof e==="function"?e():e;return new t(r)}static handleExit({editor:t,mark:e}){const{tr:r}=t.state;const n=t.state.selection.$from;const i=n.pos===n.end();if(i){const i=n.marks();const s=!!i.find((t=>(t==null?void 0:t.type.name)===e.name));if(!s){return false}const o=i.find((t=>(t==null?void 0:t.type.name)===e.name));if(o){r.removeStoredMark(o)}r.insertText(" ",n.pos);t.view.dispatch(r);return true}return false}configure(t){return super.configure(t)}extend(t){const e=typeof t==="function"?t():t;return super.extend(e)}};function xc(t){return typeof t==="number"}var Oc=class{constructor(t){this.find=t.find;this.handler=t.handler}};var Sc=(t,e,r)=>{if(rf(e)){return[...t.matchAll(e)]}const n=e(t,r);if(!n){return[]}return n.map((e=>{const r=[e.text];r.index=e.index;r.input=t;r.data=e.data;if(e.replaceWith){if(!e.text.includes(e.replaceWith)){console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".')}r.push(e.replaceWith)}return r}))};function Tc(t){const{editor:e,state:r,from:n,to:i,rule:s,pasteEvent:o,dropEvent:l}=t;const{commands:u,chain:a,can:f}=new Ba({editor:e,state:r});const h=[];r.doc.nodesBetween(n,i,((t,e)=>{var c,d,p,m,g;if(((d=(c=t.type)==null?void 0:c.spec)==null?void 0:d.code)||!(t.isText||t.isTextblock||t.isInline)){return}const w=(g=(m=(p=t.content)==null?void 0:p.size)!=null?m:t.nodeSize)!=null?g:0;const b=Math.max(n,e);const v=Math.min(i,e+w);if(b>=v){return}const k=t.isText?t.text||"":t.textBetween(b-e,v-e,void 0,"");const y=Sc(k,s.find,o);y.forEach((t=>{if(t.index===void 0){return}const e=b+t.index+1;const n=e+t[0].length;const i={from:r.tr.mapping.map(e),to:r.tr.mapping.map(n)};const c=s.handler({state:r,range:i,match:t,commands:u,chain:a,can:f,pasteEvent:o,dropEvent:l});h.push(c)}))}));const c=h.every((t=>t!==null));return c}var Ec=null;var Ac=t=>{var e;const r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});(e=r.clipboardData)==null?void 0:e.setData("text/html",t);return r};function $c(t){const{editor:e,rules:r}=t;let n=null;let i=false;let s=false;let o=typeof ClipboardEvent!=="undefined"?new ClipboardEvent("paste"):null;let l;try{l=typeof DragEvent!=="undefined"?new DragEvent("drop"):null}catch{l=null}const u=({state:t,from:r,to:n,rule:i,pasteEvt:s})=>{const u=t.tr;const a=_a({state:t,transaction:u});const f=Tc({editor:e,state:a,from:Math.max(r-1,0),to:n.b-1,rule:i,pasteEvent:s,dropEvent:l});if(!f||!u.steps.length){return}try{l=typeof DragEvent!=="undefined"?new DragEvent("drop"):null}catch{l=null}o=typeof ClipboardEvent!=="undefined"?new ClipboardEvent("paste"):null;return u};const a=r.map((t=>new gi({view(t){const r=r=>{var i;n=((i=t.dom.parentElement)==null?void 0:i.contains(r.target))?t.dom.parentElement:null;if(n){Ec=e}};const i=()=>{if(Ec){Ec=null}};window.addEventListener("dragstart",r);window.addEventListener("dragend",i);return{destroy(){window.removeEventListener("dragstart",r);window.removeEventListener("dragend",i)}}},props:{handleDOMEvents:{drop:(t,e)=>{s=n===t.dom.parentElement;l=e;if(!s){const t=Ec;if(t==null?void 0:t.isEditable){setTimeout((()=>{const e=t.state.selection;if(e){t.commands.deleteRange({from:e.from,to:e.to})}}),10)}}return false},paste:(t,e)=>{var r;const n=(r=e.clipboardData)==null?void 0:r.getData("text/html");o=e;i=!!(n==null?void 0:n.includes("data-pm-slice"));return false}}},appendTransaction:(e,r,n)=>{const l=e[0];const a=l.getMeta("uiEvent")==="paste"&&!i;const f=l.getMeta("uiEvent")==="drop"&&!s;const h=l.getMeta("applyPasteRules");const c=!!h;if(!a&&!f&&!c){return}if(c){let{text:e}=h;if(typeof e==="string"){e=e}else{e=lh(ce.from(e),n.schema)}const{from:r}=h;const i=r+e.length;const s=Ac(e);return u({rule:t,state:n,from:r,to:{b:i},pasteEvt:s})}const d=r.doc.content.findDiffStart(n.doc.content);const p=r.doc.content.findDiffEnd(n.doc.content);if(!xc(d)||!p||d===p.b){return}return u({rule:t,state:n,from:d,to:p,pasteEvt:o})}})));return a}var Rc=class{constructor(t,e){this.splittableMarks=[];this.editor=e;this.baseExtensions=t;this.extensions=yh(t);this.schema=bh(this.extensions,e);this.setupExtensions()}get commands(){return this.extensions.reduce(((t,e)=>{const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:jh(e.name,this.schema)};const n=sh(e,"addCommands",r);if(!n){return t}return{...t,...n()}}),{})}get plugins(){const{editor:t}=this;const e=kh([...this.extensions].reverse());const r=e.flatMap((e=>{const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:jh(e.name,this.schema)};const n=[];const i=sh(e,"addKeyboardShortcuts",r);let s={};if(e.type==="mark"&&sh(e,"exitable",r)){s.ArrowRight=()=>Mc.handleExit({editor:t,mark:e})}if(i){const e=Object.fromEntries(Object.entries(i()).map((([e,r])=>[e,()=>r({editor:t})])));s={...s,...e}}const o=Ia(s);n.push(o);const l=sh(e,"addInputRules",r);if(Bh(e,t.options.enableInputRules)&&l){const e=l();if(e&&e.length){const r=wc({editor:t,rules:e});const i=Array.isArray(r)?r:[r];n.push(...i)}}const u=sh(e,"addPasteRules",r);if(Bh(e,t.options.enablePasteRules)&&u){const e=u();if(e&&e.length){const r=$c({editor:t,rules:e});n.push(...r)}}const a=sh(e,"addProseMirrorPlugins",r);if(a){const t=a();n.push(...t)}return n}));return r}get attributes(){return ch(this.extensions)}get nodeViews(){const{editor:t}=this;const{nodeExtensions:e}=hh(this.extensions);return Object.fromEntries(e.filter((t=>!!sh(t,"addNodeView"))).map((e=>{const r=this.attributes.filter((t=>t.type===e.name));const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:Za(e.name,this.schema)};const i=sh(e,"addNodeView",n);if(!i){return[]}const s=i();if(!s){return[]}const o=(n,i,o,l,u)=>{const a=ph(n,r);return s({node:n,view:i,getPos:o,decorations:l,innerDecorations:u,editor:t,extension:e,HTMLAttributes:a})};return[e.name,o]})))}get markViews(){const{editor:t}=this;const{markExtensions:e}=hh(this.extensions);return Object.fromEntries(e.filter((t=>!!sh(t,"addMarkView"))).map((e=>{const r=this.attributes.filter((t=>t.type===e.name));const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:uf(e.name,this.schema)};const i=sh(e,"addMarkView",n);if(!i){return[]}const s=(n,s,o)=>{const l=ph(n,r);return i()({mark:n,view:s,inline:o,editor:t,extension:e,HTMLAttributes:l,updateAttributes:e=>{fd(n,t,e)}})};return[e.name,s]})))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map((t=>[t.name,t.storage])));t.forEach((t=>{var e;const r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:jh(t.name,this.schema)};if(t.type==="mark"){const n=(e=ah(sh(t,"keepOnSplit",r)))!=null?e:true;if(n){this.splittableMarks.push(t.name)}}const n=sh(t,"onBeforeCreate",r);const i=sh(t,"onCreate",r);const s=sh(t,"onUpdate",r);const o=sh(t,"onSelectionUpdate",r);const l=sh(t,"onTransaction",r);const u=sh(t,"onFocus",r);const a=sh(t,"onBlur",r);const f=sh(t,"onDestroy",r);if(n){this.editor.on("beforeCreate",n)}if(i){this.editor.on("create",i)}if(s){this.editor.on("update",s)}if(o){this.editor.on("selectionUpdate",o)}if(l){this.editor.on("transaction",l)}if(u){this.editor.on("focus",u)}if(a){this.editor.on("blur",a)}if(f){this.editor.on("destroy",f)}}))}};Rc.resolve=yh;Rc.sort=kh;Rc.flatten=oh;var Cc={};za(Cc,{ClipboardTextSerializer:()=>Nc,Commands:()=>jc,Delete:()=>Pc,Drop:()=>Ic,Editable:()=>Dc,FocusEvents:()=>zc,Keymap:()=>_c,Paste:()=>Bc,Tabindex:()=>Uc,focusEventsPluginKey:()=>Hc});var Lc=class t extends yc{constructor(){super(...arguments);this.type="extension"}static create(e={}){const r=typeof e==="function"?e():e;return new t(r)}configure(t){return super.configure(t)}extend(t){const e=typeof t==="function"?t():t;return super.extend(e)}};var Nc=Lc.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new gi({key:new vi("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this;const{state:e,schema:r}=t;const{doc:n,selection:i}=e;const{ranges:s}=i;const o=Math.min(...s.map((t=>t.$from.pos)));const l=Math.max(...s.map((t=>t.$to.pos)));const u=Th(r);const a={from:o,to:l};return Oh(n,a,{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}});var jc=Lc.create({name:"commands",addCommands(){return{...Ua}}});var Pc=Lc.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var r,n,i;const s=()=>{var r,n,i,s;if((s=(i=(n=(r=this.editor.options.coreExtensionOptions)==null?void 0:r.delete)==null?void 0:n.filterTransaction)==null?void 0:i.call(n,t))!=null?s:t.getMeta("y-sync$")){return}const o=th(t.before,[t,...e]);const l=Ch(o);l.forEach((e=>{if(o.mapping.mapResult(e.oldRange.from).deletedAfter&&o.mapping.mapResult(e.oldRange.to).deletedBefore){o.before.nodesBetween(e.oldRange.from,e.oldRange.to,((r,n)=>{const i=n+r.nodeSize-2;const s=e.oldRange.from<=n&&i<=e.oldRange.to;this.editor.emit("delete",{type:"node",node:r,from:n,to:i,newFrom:o.mapping.map(n),newTo:o.mapping.map(i),deletedRange:e.oldRange,newRange:e.newRange,partial:!s,editor:this.editor,transaction:t,combinedTransform:o})}))}}));const u=o.mapping;o.steps.forEach(((e,r)=>{var n,i;if(e instanceof Zr){const s=u.slice(r).map(e.from,-1);const l=u.slice(r).map(e.to);const a=u.invert().map(s,-1);const f=u.invert().map(l);const h=(n=o.doc.nodeAt(s-1))==null?void 0:n.marks.some((t=>t.eq(e.mark)));const c=(i=o.doc.nodeAt(l))==null?void 0:i.marks.some((t=>t.eq(e.mark)));this.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:a,to:f},newRange:{from:s,to:l},partial:Boolean(c||h),editor:this.editor,transaction:t,combinedTransform:o})}}))};if((i=(n=(r=this.editor.options.coreExtensionOptions)==null?void 0:r.delete)==null?void 0:n.async)!=null?i:true){setTimeout(s,0)}else{s()}}});var Ic=Lc.create({name:"drop",addProseMirrorPlugins(){return[new gi({key:new vi("tiptapDrop"),props:{handleDrop:(t,e,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:r,moved:n})}}})]}});var Dc=Lc.create({name:"editable",addProseMirrorPlugins(){return[new gi({key:new vi("editable"),props:{editable:()=>this.editor.options.editable}})]}});var Hc=new vi("focusEvents");var zc=Lc.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new gi({key:Hc,props:{handleDOMEvents:{focus:(e,r)=>{t.isFocused=true;const n=t.state.tr.setMeta("focus",{event:r}).setMeta("addToHistory",false);e.dispatch(n);return false},blur:(e,r)=>{t.isFocused=false;const n=t.state.tr.setMeta("blur",{event:r}).setMeta("addToHistory",false);e.dispatch(n);return false}}}})]}});var _c=Lc.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:r,doc:n}=e;const{empty:i,$anchor:s}=r;const{pos:o,parent:l}=s;const u=s.parent.isTextblock&&o>0?e.doc.resolve(o-1):s;const a=u.parent.type.spec.isolating;const f=s.pos-s.parentOffset;const h=a&&u.parent.childCount===1?f===s.pos:Vn.atStart(n).from===o;if(!i||!l.type.isTextblock||l.textContent.length||!h||h&&s.parent.type.name==="paragraph"){return false}return t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()]));const e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()]));const r=()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()]));const n={Enter:r,"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()};const i={...n};const s={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};if(mf()||Nf()){return s}return i},addProseMirrorPlugins(){return[new gi({key:new vi("clearDocument"),appendTransaction:(t,e,r)=>{if(t.some((t=>t.getMeta("composition")))){return}const n=t.some((t=>t.docChanged))&&!e.doc.eq(r.doc);const i=t.some((t=>t.getMeta("preventClearDocument")));if(!n||i){return}const{empty:s,from:o,to:l}=e.selection;const u=Vn.atStart(e.doc).from;const a=Vn.atEnd(e.doc).to;const f=o===u&&l===a;if(s||!f){return}const h=Fh(r.doc);if(!h){return}const c=r.tr;const d=_a({state:r,transaction:c});const{commands:p}=new Ba({editor:this.editor,state:d});p.clearNodes();if(!c.steps.length){return}return c}})]}});var Bc=Lc.create({name:"paste",addProseMirrorPlugins(){return[new gi({key:new vi("tiptapPaste"),props:{handlePaste:(t,e,r)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:r})}}})]}});var Uc=Lc.create({name:"tabindex",addProseMirrorPlugins(){return[new gi({key:new vi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});var Fc=class t{constructor(t,e,r=false,n=null){this.currentNode=null;this.actualDepth=null;this.isBlock=r;this.resolvedPos=t;this.editor=e;this.currentNode=n}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!=null?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from;let r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}e=this.from+1;r=this.to-1}this.editor.commands.insertContentAt({from:e,to:r},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){if(this.isBlock){return this.pos}return this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){if(this.isBlock){return this.pos+this.size}return this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0){return null}const e=this.resolvedPos.start(this.resolvedPos.depth-1);const r=this.resolvedPos.doc.resolve(e);return new t(r,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));if(e.depth!==this.depth){e=this.resolvedPos.doc.resolve(this.from-3)}return new t(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));if(e.depth!==this.depth){e=this.resolvedPos.doc.resolve(this.to+3)}return new t(e,this.editor)}get children(){const e=[];this.node.content.forEach(((r,n)=>{const i=r.isBlock&&!r.isTextblock;const s=r.isAtom&&!r.isText;const o=this.pos+n+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2){return}const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth){return}const u=new t(l,this.editor,i,i?r:null);if(i){u.actualDepth=this.depth+1}e.push(new t(l,this.editor,i,i?r:null))}));return e}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let r=null;let n=this.parent;while(n&&!r){if(n.node.type.name===t){if(Object.keys(e).length>0);else{r=n}}n=n.parent}return r}querySelector(t,e={}){return this.querySelectorAll(t,e,true)[0]||null}querySelectorAll(t,e={},r=false){let n=[];if(!this.children||this.children.length===0){return n}const i=Object.keys(e);this.children.forEach((s=>{if(r&&n.length>0){return}if(s.node.type.name===t){const t=i.every((t=>e[t]===s.node.attrs[t]));if(t){n.push(s)}}if(r&&n.length>0){return}n=n.concat(s.querySelectorAll(t,e,r))}));return n}setAttribute(t){const{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t});this.editor.view.dispatch(e)}};var qc=`.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}`;function Kc(t,e,r){const n=document.querySelector(`style[data-tiptap-style${""}]`);if(n!==null){return n}const i=document.createElement("style");if(e){i.setAttribute("nonce",e)}i.setAttribute(`data-tiptap-style${""}`,"");i.innerHTML=t;document.getElementsByTagName("head")[0].appendChild(i);return i}var Wc=class extends dc{constructor(t={}){super();this.css=null;this.className="tiptap";this.editorView=null;this.isFocused=false;this.isInitialized=false;this.extensionStorage={};this.instanceId=Math.random().toString(36).slice(2,9);this.options={element:typeof document!=="undefined"?document.createElement("div"):null,content:"",injectCSS:true,injectNonce:void 0,extensions:[],autofocus:false,editable:true,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:true,enablePasteRules:true,enableCoreExtensions:true,enableContentCheck:false,emitContentError:false,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null};this.isCapturingTransaction=false;this.capturedTransaction=null;this.setOptions(t);this.createExtensionManager();this.createCommandManager();this.createSchema();this.on("beforeCreate",this.options.onBeforeCreate);this.emit("beforeCreate",{editor:this});this.on("mount",this.options.onMount);this.on("unmount",this.options.onUnmount);this.on("contentError",this.options.onContentError);this.on("create",this.options.onCreate);this.on("update",this.options.onUpdate);this.on("selectionUpdate",this.options.onSelectionUpdate);this.on("transaction",this.options.onTransaction);this.on("focus",this.options.onFocus);this.on("blur",this.options.onBlur);this.on("destroy",this.options.onDestroy);this.on("drop",(({event:t,slice:e,moved:r})=>this.options.onDrop(t,e,r)));this.on("paste",(({event:t,slice:e})=>this.options.onPaste(t,e)));this.on("delete",this.options.onDelete);const e=this.createDoc();const r=df(e,this.options.autofocus);this.editorState=pi.create({doc:e,schema:this.schema,selection:r||void 0});if(this.options.element){this.mount(this.options.element)}}mount(t){if(typeof document==="undefined"){throw new Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`)}this.createView(t);this.emit("mount",{editor:this});if(this.css&&!document.head.contains(this.css)){document.head.appendChild(this.css)}window.setTimeout((()=>{if(this.isDestroyed){return}this.commands.focus(this.options.autofocus);this.emit("create",{editor:this});this.isInitialized=true}),0)}unmount(){if(this.editorView){const t=this.editorView.dom;if(t==null?void 0:t.editor){delete t.editor}this.editorView.destroy()}this.editorView=null;this.isInitialized=false;if(this.css&&!document.querySelectorAll(`.${this.className}`).length){try{if(typeof this.css.remove==="function"){this.css.remove()}else if(this.css.parentNode){this.css.parentNode.removeChild(this.css)}}catch(t){console.warn("Failed to remove CSS element:",t)}}this.css=null;this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){if(this.options.injectCSS&&typeof document!=="undefined"){this.css=Kc(qc,this.options.injectNonce)}}setOptions(t={}){this.options={...this.options,...t};if(!this.editorView||!this.state||this.isDestroyed){return}if(this.options.editorProps){this.view.setProps(this.options.editorProps)}this.view.updateState(this.state)}setEditable(t,e=true){this.setOptions({editable:t});if(e){this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){if(this.editorView){return this.editorView}return new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:false,dragging:null,editable:true,isDestroyed:false},{get:(t,e)=>{if(this.editorView){return this.editorView[e]}if(e==="state"){return this.editorState}if(e in t){return Reflect.get(t,e)}throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){if(this.editorView){this.editorState=this.view.state}return this.editorState}registerPlugin(t,e){const r=uh(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t];const n=this.state.reconfigure({plugins:r});this.view.updateState(n);return n}unregisterPlugin(t){if(this.isDestroyed){return void 0}const e=this.state.plugins;let r=e;[].concat(t).forEach((t=>{const e=typeof t==="string"?`${t}$`:t.key;r=r.filter((t=>!t.key.startsWith(e)))}));if(e.length===r.length){return void 0}const n=this.state.reconfigure({plugins:r});this.view.updateState(n);return n}createExtensionManager(){var t,e;const r=this.options.enableCoreExtensions?[Dc,Nc.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),jc,zc,_c,Uc,Ic,Bc,Pc].filter((t=>{if(typeof this.options.enableCoreExtensions==="object"){return this.options.enableCoreExtensions[t.name]!==false}return true})):[];const n=[...r,...this.options.extensions].filter((t=>["extension","node","mark"].includes(t==null?void 0:t.type)));this.extensionManager=new Rc(n,this)}createCommandManager(){this.commandManager=new Ba({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Qf(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message)){throw e}this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{if("collaboration"in this.storage&&typeof this.storage.collaboration==="object"&&this.storage.collaboration){this.storage.collaboration.isDisabled=true}this.options.extensions=this.options.extensions.filter((t=>t.name!=="collaboration"));this.createExtensionManager()}});t=Qf(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:false})}return t}createView(t){var e;this.editorView=new ga(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r);this.prependClass();this.injectCSS();const n=this.view.dom;n.editor=this}createNodeViews(){if(this.view.isDestroyed){return}this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=true;t();this.isCapturingTransaction=false;const e=this.capturedTransaction;this.capturedTransaction=null;return e}dispatchTransaction(t){if(this.view.isDestroyed){return}if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach((t=>{var e;return(e=this.capturedTransaction)==null?void 0:e.step(t)}));return}const{state:e,transactions:r}=this.state.applyTransaction(t);const n=!this.state.selection.eq(e.selection);const i=r.includes(t);const s=this.state;this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e});if(!i){return}this.view.updateState(e);this.emit("transaction",{editor:this,transaction:t,appendedTransactions:r.slice(1)});if(n){this.emit("selectionUpdate",{editor:this,transaction:t})}const o=r.findLast((t=>t.getMeta("focus")||t.getMeta("blur")));const l=o==null?void 0:o.getMeta("focus");const u=o==null?void 0:o.getMeta("blur");if(l){this.emit("focus",{editor:this,event:l.event,transaction:o})}if(u){this.emit("blur",{editor:this,event:u.event,transaction:o})}if(t.getMeta("preventUpdate")||!r.some((t=>t.docChanged))||s.doc.eq(e.doc)){return}this.emit("update",{editor:this,transaction:t,appendedTransactions:r.slice(1)})}getAttributes(t){return Ah(this.state,t)}isActive(t,e){const r=typeof t==="string"?t:null;const n=typeof t==="string"?e:t;return Hh(this.state,r,n)}getJSON(){return this.state.doc.toJSON()}getHTML(){return lh(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:r={}}=t||{};return Sh(this.state.doc,{blockSeparator:e,textSerializers:{...Th(this.schema),...r}})}get isEmpty(){return Fh(this.state.doc)}destroy(){this.emit("destroy");this.unmount();this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:true}$node(t,e){var r;return((r=this.$doc)==null?void 0:r.querySelector(t,e))||null}$nodes(t,e){var r;return((r=this.$doc)==null?void 0:r.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new Fc(e,this)}get $doc(){return this.$pos(0)}};function Jc(t){return new pc({find:t.find,handler:({state:e,range:r,match:n})=>{const i=ah(t.getAttributes,void 0,n);if(i===false||i===null){return null}const{tr:s}=e;const o=n[n.length-1];const l=n[0];if(o){const n=l.search(/\S/);const u=r.from+l.indexOf(o);const a=u+o.length;const f=Lh(r.from,r.to,e.doc).filter((e=>{const r=e.mark.type.excluded;return r.find((r=>r===t.type&&r!==e.mark.type))})).filter((t=>t.to>u));if(f.length){return null}if(a<r.to){s.delete(a,r.to)}if(u>r.from){s.delete(r.from+n,u)}const h=r.from+n+o.length;s.addMark(r.from+n,h,t.type.create(i||{}));s.removeStoredMark(t.type)}},undoable:t.undoable})}function Vc(t){return new pc({find:t.find,handler:({state:e,range:r,match:n})=>{const i=ah(t.getAttributes,void 0,n)||{};const{tr:s}=e;const o=r.from;let l=r.to;const u=t.type.create(i);if(n[1]){const t=n[0].lastIndexOf(n[1]);let e=o+t;if(e>l){e=l}else{l=e+n[1].length}const r=n[0][n[0].length-1];s.insertText(r,o+n[0].length-1);s.replaceWith(e,l,u)}else if(n[0]){const e=t.type.isInline?o:o-1;s.insert(e,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function Gc(t){return new pc({find:t.find,handler:({state:e,range:r,match:n})=>{const i=e.doc.resolve(r.from);const s=ah(t.getAttributes,void 0,n)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type)){return null}e.tr.delete(r.from,r.to).setBlockType(r.from,r.from,t.type,s)},undoable:t.undoable})}function Zc(t){return new pc({find:t.find,handler:({state:e,range:r,match:n,chain:i})=>{const s=ah(t.getAttributes,void 0,n)||{};const o=e.tr.delete(r.from,r.to);const l=o.doc.resolve(r.from);const u=l.blockRange();const a=u&&an(u,t.type,s);if(!a){return null}o.wrap(u,a);if(t.keepMarks&&t.editor){const{selection:r,storedMarks:n}=e;const{splittableMarks:i}=t.editor.extensionManager;const s=n||r.$to.parentOffset&&r.$from.marks();if(s){const t=s.filter((t=>i.includes(t.type.name)));o.ensureMarks(t)}}if(t.keepAttributes){const e=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(e,s).run()}const f=o.doc.resolve(r.from-1).nodeBefore;if(f&&f.type===t.type&&yn(o.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,f))){o.join(r.from-1)}},undoable:t.undoable})}var Qc=t=>"touches"in t;var Xc=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"];this.minSize={height:8,width:8};this.preserveAspectRatio=false;this.classNames={container:"",wrapper:"",handle:"",resizing:""};this.initialWidth=0;this.initialHeight=0;this.aspectRatio=1;this.isResizing=false;this.activeHandle=null;this.startX=0;this.startY=0;this.startWidth=0;this.startHeight=0;this.isShiftKeyPressed=false;this.handleMouseMove=t=>{if(!this.isResizing||!this.activeHandle){return}const e=t.clientX-this.startX;const r=t.clientY-this.startY;this.handleResize(e,r)};this.handleTouchMove=t=>{if(!this.isResizing||!this.activeHandle){return}const e=t.touches[0];if(!e){return}const r=e.clientX-this.startX;const n=e.clientY-this.startY;this.handleResize(r,n)};this.handleMouseUp=()=>{if(!this.isResizing){return}const t=this.element.offsetWidth;const e=this.element.offsetHeight;this.onCommit(t,e);this.isResizing=false;this.activeHandle=null;this.container.dataset.resizeState="false";if(this.classNames.resizing){this.container.classList.remove(this.classNames.resizing)}document.removeEventListener("mousemove",this.handleMouseMove);document.removeEventListener("mouseup",this.handleMouseUp);document.removeEventListener("keydown",this.handleKeyDown);document.removeEventListener("keyup",this.handleKeyUp)};this.handleKeyDown=t=>{if(t.key==="Shift"){this.isShiftKeyPressed=true}};this.handleKeyUp=t=>{if(t.key==="Shift"){this.isShiftKeyPressed=false}};var e,r,n,i,s;this.node=t.node;this.element=t.element;this.contentElement=t.contentElement;this.getPos=t.getPos;this.onResize=t.onResize;this.onCommit=t.onCommit;this.onUpdate=t.onUpdate;if((e=t.options)==null?void 0:e.min){this.minSize={...this.minSize,...t.options.min}}if((r=t.options)==null?void 0:r.max){this.maxSize=t.options.max}if((n=t==null?void 0:t.options)==null?void 0:n.directions){this.directions=t.options.directions}if((i=t.options)==null?void 0:i.preserveAspectRatio){this.preserveAspectRatio=t.options.preserveAspectRatio}if((s=t.options)==null?void 0:s.className){this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}}this.wrapper=this.createWrapper();this.container=this.createContainer();this.applyInitialSize();this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,r){if(t.type!==this.node.type){return false}this.node=t;if(this.onUpdate){return this.onUpdate(t,e,r)}return true}destroy(){if(this.isResizing){this.container.dataset.resizeState="false";if(this.classNames.resizing){this.container.classList.remove(this.classNames.resizing)}document.removeEventListener("mousemove",this.handleMouseMove);document.removeEventListener("mouseup",this.handleMouseUp);document.removeEventListener("keydown",this.handleKeyDown);document.removeEventListener("keyup",this.handleKeyUp);this.isResizing=false;this.activeHandle=null}this.container.remove()}createContainer(){const t=document.createElement("div");t.dataset.resizeContainer="";t.dataset.node=this.node.type.name;t.style.display="flex";t.style.justifyContent="flex-start";t.style.alignItems="flex-start";if(this.classNames.container){t.className=this.classNames.container}t.appendChild(this.wrapper);return t}createWrapper(){const t=document.createElement("div");t.style.position="relative";t.style.display="block";t.dataset.resizeWrapper="";if(this.classNames.wrapper){t.className=this.classNames.wrapper}t.appendChild(this.element);return t}createHandle(t){const e=document.createElement("div");e.dataset.resizeHandle=t;e.style.position="absolute";if(this.classNames.handle){e.className=this.classNames.handle}return e}positionHandle(t,e){const r=e.includes("top");const n=e.includes("bottom");const i=e.includes("left");const s=e.includes("right");if(r){t.style.top="0"}if(n){t.style.bottom="0"}if(i){t.style.left="0"}if(s){t.style.right="0"}if(e==="top"||e==="bottom"){t.style.left="0";t.style.right="0"}if(e==="left"||e==="right"){t.style.top="0";t.style.bottom="0"}}attachHandles(){this.directions.forEach((t=>{const e=this.createHandle(t);this.positionHandle(e,t);e.addEventListener("mousedown",(e=>this.handleResizeStart(e,t)));e.addEventListener("touchstart",(e=>this.handleResizeStart(e,t)));this.wrapper.appendChild(e)}))}applyInitialSize(){const t=this.node.attrs.width;const e=this.node.attrs.height;if(t){this.element.style.width=`${t}px`;this.initialWidth=t}else{this.initialWidth=this.element.offsetWidth}if(e){this.element.style.height=`${e}px`;this.initialHeight=e}else{this.initialHeight=this.element.offsetHeight}if(this.initialWidth>0&&this.initialHeight>0){this.aspectRatio=this.initialWidth/this.initialHeight}}handleResizeStart(t,e){t.preventDefault();t.stopPropagation();this.isResizing=true;this.activeHandle=e;if(Qc(t)){this.startX=t.touches[0].clientX;this.startY=t.touches[0].clientY}else{this.startX=t.clientX;this.startY=t.clientY}this.startWidth=this.element.offsetWidth;this.startHeight=this.element.offsetHeight;if(this.startWidth>0&&this.startHeight>0){this.aspectRatio=this.startWidth/this.startHeight}this.getPos();this.container.dataset.resizeState="true";if(this.classNames.resizing){this.container.classList.add(this.classNames.resizing)}document.addEventListener("mousemove",this.handleMouseMove);document.addEventListener("touchmove",this.handleTouchMove);document.addEventListener("mouseup",this.handleMouseUp);document.addEventListener("keydown",this.handleKeyDown);document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle){return}const r=this.preserveAspectRatio||this.isShiftKeyPressed;const{width:n,height:i}=this.calculateNewDimensions(this.activeHandle,t,e);const s=this.applyConstraints(n,i,r);this.element.style.width=`${s.width}px`;this.element.style.height=`${s.height}px`;if(this.onResize){this.onResize(s.width,s.height)}}calculateNewDimensions(t,e,r){let n=this.startWidth;let i=this.startHeight;const s=t.includes("right");const o=t.includes("left");const l=t.includes("bottom");const u=t.includes("top");if(s){n=this.startWidth+e}else if(o){n=this.startWidth-e}if(l){i=this.startHeight+r}else if(u){i=this.startHeight-r}if(t==="right"||t==="left"){n=this.startWidth+(s?e:-e)}if(t==="top"||t==="bottom"){i=this.startHeight+(l?r:-r)}const a=this.preserveAspectRatio||this.isShiftKeyPressed;if(a){return this.applyAspectRatio(n,i,t)}return{width:n,height:i}}applyConstraints(t,e,r){var n,i,s,o;if(!r){let r=Math.max(this.minSize.width,t);let s=Math.max(this.minSize.height,e);if((n=this.maxSize)==null?void 0:n.width){r=Math.min(this.maxSize.width,r)}if((i=this.maxSize)==null?void 0:i.height){s=Math.min(this.maxSize.height,s)}return{width:r,height:s}}let l=t;let u=e;if(l<this.minSize.width){l=this.minSize.width;u=l/this.aspectRatio}if(u<this.minSize.height){u=this.minSize.height;l=u*this.aspectRatio}if(((s=this.maxSize)==null?void 0:s.width)&&l>this.maxSize.width){l=this.maxSize.width;u=l/this.aspectRatio}if(((o=this.maxSize)==null?void 0:o.height)&&u>this.maxSize.height){u=this.maxSize.height;l=u*this.aspectRatio}return{width:l,height:u}}applyAspectRatio(t,e,r){const n=r==="left"||r==="right";const i=r==="top"||r==="bottom";if(n){return{width:t,height:t/this.aspectRatio}}if(i){return{width:e*this.aspectRatio,height:e}}return{width:t,height:t/this.aspectRatio}}};function Yc(t,e){const{selection:r}=t;const{$from:n}=r;if(r instanceof ti){const t=n.index();const r=n.parent;return r.canReplaceWith(t,t+1,e)}let i=n.depth;while(i>=0){const t=n.index(i);const r=n.node(i);const s=r.contentMatchAt(t);if(s.matchType(e)){return true}i-=1}return false}var td={};za(td,{createAtomBlockMarkdownSpec:()=>nd,createBlockMarkdownSpec:()=>id,createInlineMarkdownSpec:()=>ld,parseAttributes:()=>ed,parseIndentedBlocks:()=>ud,renderNestedMarkdownContent:()=>ad,serializeAttributes:()=>rd});function ed(t){if(!(t==null?void 0:t.trim())){return{}}const e={};const r=[];const n=t.replace(/["']([^"']*)["']/g,(t=>{r.push(t);return`__QUOTED_${r.length-1}__`}));const i=n.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const t=i.map((t=>t.trim().slice(1)));e.class=t.join(" ")}const s=n.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);if(s){e.id=s[1]}const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;const l=Array.from(n.matchAll(o));l.forEach((([,t,n])=>{var i;const s=parseInt(((i=n.match(/__QUOTED_(\d+)__/))==null?void 0:i[1])||"0",10);const o=r[s];if(o){e[t]=o.slice(1,-1)}}));const u=n.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();if(u){const t=u.split(/\s+/).filter(Boolean);t.forEach((t=>{if(t.match(/^[a-zA-Z][\w-]*$/)){e[t]=true}}))}return e}function rd(t){if(!t||Object.keys(t).length===0){return""}const e=[];if(t.class){const r=String(t.class).split(/\s+/).filter(Boolean);r.forEach((t=>e.push(`.${t}`)))}if(t.id){e.push(`#${t.id}`)}Object.entries(t).forEach((([t,r])=>{if(t==="class"||t==="id"){return}if(r===true){e.push(t)}else if(r!==false&&r!=null){e.push(`${t}="${String(r)}"`)}}));return e.join(" ")}function nd(t){const{nodeName:e,name:r,parseAttributes:n=ed,serializeAttributes:i=rd,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t;const u=r||e;const a=t=>{if(!l){return t}const e={};l.forEach((r=>{if(r in t){e[r]=t[r]}}));return e};return{parseMarkdown:(t,r)=>{const n={...s,...t.attributes};return r.createNode(e,n,[])},markdownTokenizer:{name:e,level:"block",start(t){var e;const r=new RegExp(`^:::${u}(?:\\s|$)`,"m");const n=(e=t.match(r))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,r,i){const s=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`);const l=t.match(s);if(!l){return void 0}const a=l[1]||"";const f=n(a);const h=o.find((t=>!(t in f)));if(h){return void 0}return{type:e,raw:l[0],attributes:f}}},renderMarkdown:t=>{const e=a(t.attrs||{});const r=i(e);const n=r?` {${r}}`:"";return`:::${u}${n} :::`}}}function id(t){const{nodeName:e,name:r,getContent:n,parseAttributes:i=ed,serializeAttributes:s=rd,defaultAttributes:o={},content:l="block",allowedAttributes:u}=t;const a=r||e;const f=t=>{if(!u){return t}const e={};u.forEach((r=>{if(r in t){e[r]=t[r]}}));return e};return{parseMarkdown:(t,r)=>{let i;if(n){const e=n(t);i=typeof e==="string"?[{type:"text",text:e}]:e}else if(l==="block"){i=r.parseChildren(t.tokens||[])}else{i=r.parseInline(t.tokens||[])}const s={...o,...t.attributes};return r.createNode(e,s,i)},markdownTokenizer:{name:e,level:"block",start(t){var e;const r=new RegExp(`^:::${a}`,"m");const n=(e=t.match(r))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,r,n){var s;const o=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*\\n`);const u=t.match(o);if(!u){return void 0}const[f,h=""]=u;const c=i(h);let d=1;const p=f.length;let m="";const g=/^:::([\w-]*)(\s.*)?/gm;const w=t.slice(p);g.lastIndex=0;for(;;){const r=g.exec(w);if(r===null){break}const i=r.index;const o=r[1];if((s=r[2])==null?void 0:s.endsWith(":::")){continue}if(o){d+=1}else{d-=1;if(d===0){const s=w.slice(0,i);m=s.trim();const o=t.slice(0,p+i+r[0].length);let u=[];if(m){if(l==="block"){u=n.blockTokens(s);u.forEach((t=>{if(t.text&&(!t.tokens||t.tokens.length===0)){t.tokens=n.inlineTokens(t.text)}}));while(u.length>0){const t=u[u.length-1];if(t.type==="paragraph"&&(!t.text||t.text.trim()==="")){u.pop()}else{break}}}else{u=n.inlineTokens(m)}}return{type:e,raw:o,attributes:c,content:m,tokens:u}}}}return void 0}},renderMarkdown:(t,e)=>{const r=f(t.attrs||{});const n=s(r);const i=n?` {${n}}`:"";const o=e.renderChildren(t.content||[],"\n\n");return`:::${a}${i}\n\n${o}\n\n:::`}}}function sd(t){if(!t.trim()){return{}}const e={};const r=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let n=r.exec(t);while(n!==null){const[,i,s,o]=n;e[i]=s||o;n=r.exec(t)}return e}function od(t){return Object.entries(t).filter((([,t])=>t!==void 0&&t!==null)).map((([t,e])=>`${t}="${e}"`)).join(" ")}function ld(t){const{nodeName:e,name:r,getContent:n,parseAttributes:i=sd,serializeAttributes:s=od,defaultAttributes:o={},selfClosing:l=false,allowedAttributes:u}=t;const a=r||e;const f=t=>{if(!u){return t}const e={};u.forEach((r=>{if(r in t){e[r]=t[r]}}));return e};const h=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(t,r)=>{const i={...o,...t.attributes};if(l){return r.createNode(e,i)}const s=n?n(t):t.content||"";if(s){return r.createNode(e,i,[r.createTextNode(s)])}return r.createNode(e,i,[])},markdownTokenizer:{name:e,level:"inline",start(t){const e=l?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`);const r=t.match(e);const n=r==null?void 0:r.index;return n!==void 0?n:-1},tokenize(t,r,n){const s=l?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`);const o=t.match(s);if(!o){return void 0}let u="";let a="";if(l){const[,t]=o;a=t}else{const[,t,e]=o;a=t;u=e||""}const f=i(a.trim());return{type:e,raw:o[0],content:u.trim(),attributes:f}}},renderMarkdown:t=>{let e="";if(n){e=n(t)}else if(t.content&&t.content.length>0){e=t.content.filter((t=>t.type==="text")).map((t=>t.text)).join("")}const r=f(t.attrs||{});const i=s(r);const o=i?` ${i}`:"";if(l){return`[${a}${o}]`}return`[${a}${o}]${e}[/${a}]`}}}function ud(t,e,r){var n,i,s,o;const l=t.split("\n");const u=[];let a="";let f=0;const h=e.baseIndentSize||2;while(f<l.length){const t=l[f];const c=t.match(e.itemPattern);if(!c){if(u.length>0){break}else if(t.trim()===""){f+=1;continue}else{return void 0}}const d=e.extractItemData(c);const{indentLevel:p,mainContent:m}=d;a=`${a}${t}\n`;const g=[m];f+=1;while(f<l.length){const t=l[f];if(t.trim()===""){const e=l.slice(f+1).findIndex((t=>t.trim()!==""));if(e===-1){break}const r=l[f+1+e];const s=((i=(n=r.match(/^(\s*)/))==null?void 0:n[1])==null?void 0:i.length)||0;if(s>p){g.push(t);a=`${a}${t}\n`;f+=1;continue}else{break}}const e=((o=(s=t.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0;if(e>p){g.push(t);a=`${a}${t}\n`;f+=1}else{break}}let w;const b=g.slice(1);if(b.length>0){const t=b.map((t=>t.slice(p+h))).join("\n");if(t.trim()){if(e.customNestedParser){w=e.customNestedParser(t)}else{w=r.blockTokens(t)}}}const v=e.createToken(d,w);u.push(v)}if(u.length===0){return void 0}return{items:u,raw:a.trim()}}function ad(t,e,r,n){if(!t||!Array.isArray(t.content)){return""}const i=typeof r==="function"?r(n):r;const[s,...o]=t.content;const l=e.renderChildren([s]);const u=[`${i}${l}`];if(o&&o.length>0){o.forEach((t=>{const r=e.renderChildren([t]);if(r){const t=r.split("\n").map((t=>t?e.indent(t):"")).join("\n");u.push(t)}}))}return u.join("\n")}function fd(t,e,r={}){const{state:n}=e;const{doc:i,tr:s}=n;const o=t;i.descendants(((e,n)=>{const i=s.mapping.map(n);const l=s.mapping.map(n)+e.nodeSize;let u=null;e.marks.forEach((t=>{if(t!==o){return false}u=t}));if(!u){return}let a=false;Object.keys(r).forEach((t=>{if(r[t]!==u.attrs[t]){a=true}}));if(a){const e=t.type.create({...t.attrs,...r});s.removeMark(i,l,t.type);s.addMark(i,l,e)}}));if(s.docChanged){e.view.dispatch(s)}}var hd=class t extends yc{constructor(){super(...arguments);this.type="node"}static create(e={}){const r=typeof e==="function"?e():e;return new t(r)}configure(t){return super.configure(t)}extend(t){const e=typeof t==="function"?t():t;return super.extend(e)}};function cd(t){return new Oc({find:t.find,handler:({state:e,range:r,match:n,pasteEvent:i})=>{const s=ah(t.getAttributes,void 0,n,i);if(s===false||s===null){return null}const{tr:o}=e;const l=n[n.length-1];const u=n[0];let a=r.to;if(l){const n=u.search(/\S/);const i=r.from+u.indexOf(l);const f=i+l.length;const h=Lh(r.from,r.to,e.doc).filter((e=>{const r=e.mark.type.excluded;return r.find((r=>r===t.type&&r!==e.mark.type))})).filter((t=>t.to>i));if(h.length){return null}if(f<r.to){o.delete(f,r.to)}if(i>r.from){o.delete(r.from+n,i)}a=r.from+n+l.length;o.addMark(r.from+n,a,t.type.create(s||{}));o.removeStoredMark(t.type)}}})}function dd(){return{async:false,breaks:false,extensions:null,gfm:true,hooks:null,pedantic:false,renderer:null,silent:false,tokenizer:null,walkTokens:null}}var pd=dd();function md(t){pd=t}var gd={exec:()=>null};function wd(t,e=""){let r=typeof t=="string"?t:t.source,n={replace:(t,e)=>{let i=typeof e=="string"?e:e.source;return i=i.replace(bd.caret,"$1"),r=r.replace(t,i),n},getRegex:()=>new RegExp(r,e)};return n}var bd={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},vd=/^(?:[ \t]*(?:\n|$))+/,kd=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,yd=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Md=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,xd=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Od=/(?:[*+-]|\d{1,9}[.)])/,Sd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Td=wd(Sd).replace(/bull/g,Od).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ed=wd(Sd).replace(/bull/g,Od).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ad=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$d=/^[^\n]+/,Rd=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Cd=wd(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Rd).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ld=wd(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Od).getRegex(),Nd="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",jd=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Pd=wd("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",jd).replace("tag",Nd).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Id=wd(Ad).replace("hr",Md).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Nd).getRegex(),Dd=wd(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Id).getRegex(),Hd={blockquote:Dd,code:kd,def:Cd,fences:yd,heading:xd,hr:Md,html:Pd,lheading:Td,list:Ld,newline:vd,paragraph:Id,table:gd,text:$d},zd=wd("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Md).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Nd).getRegex(),_d={...Hd,lheading:Ed,table:zd,paragraph:wd(Ad).replace("hr",Md).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",zd).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Nd).getRegex()},Bd={...Hd,html:wd(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",jd).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:gd,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:wd(Ad).replace("hr",Md).replace("heading",` *#{1,6} *[^\n]`).replace("lheading",Td).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ud=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Fd=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,qd=/^( {2,}|\\)\n(?!\s*$)/,Kd=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Wd=/[\p{P}\p{S}]/u,Jd=/[\s\p{P}\p{S}]/u,Vd=/[^\s\p{P}\p{S}]/u,Gd=wd(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Jd).getRegex(),Zd=/(?!~)[\p{P}\p{S}]/u,Qd=/(?!~)[\s\p{P}\p{S}]/u,Xd=/(?:[^\s\p{P}\p{S}]|~)/u,Yd=/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,tp=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ep=wd(tp,"u").replace(/punct/g,Wd).getRegex(),rp=wd(tp,"u").replace(/punct/g,Zd).getRegex(),np="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ip=wd(np,"gu").replace(/notPunctSpace/g,Vd).replace(/punctSpace/g,Jd).replace(/punct/g,Wd).getRegex(),sp=wd(np,"gu").replace(/notPunctSpace/g,Xd).replace(/punctSpace/g,Qd).replace(/punct/g,Zd).getRegex(),op=wd("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Vd).replace(/punctSpace/g,Jd).replace(/punct/g,Wd).getRegex(),lp=wd(/\\(punct)/,"gu").replace(/punct/g,Wd).getRegex(),up=wd(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ap=wd(jd).replace("(?:--\x3e|$)","--\x3e").getRegex(),fp=wd("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ap).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),hp=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,cp=wd(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",hp).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),dp=wd(/^!?\[(label)\]\[(ref)\]/).replace("label",hp).replace("ref",Rd).getRegex(),pp=wd(/^!?\[(ref)\](?:\[\])?/).replace("ref",Rd).getRegex(),mp=wd("reflink|nolink(?!\\()","g").replace("reflink",dp).replace("nolink",pp).getRegex(),gp=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,wp={_backpedal:gd,anyPunctuation:lp,autolink:up,blockSkip:Yd,br:qd,code:Fd,del:gd,emStrongLDelim:ep,emStrongRDelimAst:ip,emStrongRDelimUnd:op,escape:Ud,link:cp,nolink:pp,punctuation:Gd,reflink:dp,reflinkSearch:mp,tag:fp,text:Kd,url:gd},bp={...wp,link:wd(/^!?\[(label)\]\((.*?)\)/).replace("label",hp).getRegex(),reflink:wd(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",hp).getRegex()},vp={...wp,emStrongRDelimAst:sp,emStrongLDelim:rp,url:wd(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",gp).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:wd(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",gp).getRegex()},kp={...vp,br:wd(qd).replace("{2,}","*").getRegex(),text:wd(vp.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},yp={normal:Hd,gfm:_d,pedantic:Bd},Mp={normal:wp,gfm:vp,breaks:kp,pedantic:bp};var xp={"&":"&","<":"<",">":">",'"':""","'":"'"},Op=t=>xp[t];function Sp(t,e){if(e){if(bd.escapeTest.test(t))return t.replace(bd.escapeReplace,Op)}else if(bd.escapeTestNoEncode.test(t))return t.replace(bd.escapeReplaceNoEncode,Op);return t}function Tp(t){try{t=encodeURI(t).replace(bd.percentDecode,"%")}catch{return null}return t}function Ep(t,e){let r=t.replace(bd.findPipe,((t,e,r)=>{let n=false,i=e;for(;--i>=0&&r[i]==="\\";)n=!n;return n?"|":" |"})),n=r.split(bd.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(bd.slashPipe,"|");return n}function Ap(t,e,r){let n=t.length;if(n===0)return"";let i=0;for(;i<n;){let r=t.charAt(n-i-1);if(r===e&&true)i++;else break}return t.slice(0,n-i)}function $p(t,e){if(t.indexOf(e[1])===-1)return-1;let r=0;for(let n=0;n<t.length;n++)if(t[n]==="\\")n++;else if(t[n]===e[0])r++;else if(t[n]===e[1]&&(r--,r<0))return n;return r>0?-2:-1}function Rp(t,e,r,n,i){let s=e.href,o=e.title||null,l=t[1].replace(i.other.outputLinkReplace,"$1");n.state.inLink=true;let u={type:t[0].charAt(0)==="!"?"image":"link",raw:r,href:s,title:o,text:l,tokens:n.inlineTokens(l)};return n.state.inLink=false,u}function Cp(t,e,r){let n=t.match(r.other.indentCodeCompensation);if(n===null)return e;let i=n[1];return e.split(`\n`).map((t=>{let e=t.match(r.other.beginningSpace);if(e===null)return t;let[n]=e;return n.length>=i.length?t.slice(i.length):t})).join(`\n`)}var Lp=class{options;rules;lexer;constructor(t){this.options=t||pd}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Ap(t,`\n`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let t=e[0],r=Cp(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let e=Ap(t,"#");(this.options.pedantic||!e||this.rules.other.endingSpaceChar.test(e))&&(t=e.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Ap(e[0],`\n`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let t=Ap(e[0],`\n`).split(`\n`),r="",n="",i=[];for(;t.length>0;){let e=false,s=[],o;for(o=0;o<t.length;o++)if(this.rules.other.blockquoteStart.test(t[o]))s.push(t[o]),e=true;else if(!e)s.push(t[o]);else break;t=t.slice(o);let l=s.join(`\n`),u=l.replace(this.rules.other.blockquoteSetextReplace,`\n $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}\n${l}`:l,n=n?`${n}\n${u}`:u;let a=this.lexer.state.top;if(this.lexer.state.top=true,this.lexer.blockTokens(u,i,true),this.lexer.state.top=a,t.length===0)break;let f=i.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let e=f,s=e.raw+`\n`+t.join(`\n`),o=this.blockquote(s);i[i.length-1]=o,r=r.substring(0,r.length-e.raw.length)+o.raw,n=n.substring(0,n.length-e.text.length)+o.text;break}else if(f?.type==="list"){let e=f,s=e.raw+`\n`+t.join(`\n`),o=this.list(s);i[i.length-1]=o,r=r.substring(0,r.length-f.raw.length)+o.raw,n=n.substring(0,n.length-e.raw.length)+o.raw,t=s.substring(i.at(-1).raw.length).split(`\n`);continue}}return{type:"blockquote",raw:r,tokens:i,text:n}}}list(t){let e=this.rules.block.list.exec(t);if(e){let r=e[1].trim(),n=r.length>1,i={type:"list",raw:"",ordered:n,start:n?+r.slice(0,-1):"",loose:false,items:[]};r=n?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=n?r:"[*+-]");let s=this.rules.other.listItemRegex(r),o=false;for(;t;){let r=false,n="",l="";if(!(e=s.exec(t))||this.rules.block.hr.test(t))break;n=e[0],t=t.substring(n.length);let u=e[2].split(`\n`,1)[0].replace(this.rules.other.listReplaceTabs,(t=>" ".repeat(3*t.length))),a=t.split(`\n`,1)[0],f=!u.trim(),h=0;if(this.options.pedantic?(h=2,l=u.trimStart()):f?h=e[1].length+1:(h=e[2].search(this.rules.other.nonSpaceChar),h=h>4?1:h,l=u.slice(h),h+=e[1].length),f&&this.rules.other.blankLine.test(a)&&(n+=a+`\n`,t=t.substring(a.length+1),r=true),!r){let e=this.rules.other.nextBulletRegex(h),r=this.rules.other.hrRegex(h),i=this.rules.other.fencesBeginRegex(h),s=this.rules.other.headingBeginRegex(h),o=this.rules.other.htmlBeginRegex(h);for(;t;){let c=t.split(`\n`,1)[0],d;if(a=c,this.options.pedantic?(a=a.replace(this.rules.other.listReplaceNesting," "),d=a):d=a.replace(this.rules.other.tabCharGlobal," "),i.test(a)||s.test(a)||o.test(a)||e.test(a)||r.test(a))break;if(d.search(this.rules.other.nonSpaceChar)>=h||!a.trim())l+=`\n`+d.slice(h);else{if(f||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||i.test(u)||s.test(u)||r.test(u))break;l+=`\n`+a}!f&&!a.trim()&&(f=true),n+=c+`\n`,t=t.substring(c.length+1),u=d.slice(h)}}i.loose||(o?i.loose=true:this.rules.other.doubleBlankLine.test(n)&&(o=true));let c=null,d;this.options.gfm&&(c=this.rules.other.listIsTask.exec(l),c&&(d=c[0]!=="[ ] ",l=l.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:n,task:!!c,checked:d,loose:false,text:l,tokens:[]}),i.raw+=n}let l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let t=0;t<i.items.length;t++)if(this.lexer.state.top=false,i.items[t].tokens=this.lexer.blockTokens(i.items[t].text,[]),!i.loose){let e=i.items[t].tokens.filter((t=>t.type==="space")),r=e.length>0&&e.some((t=>this.rules.other.anyLine.test(t.raw)));i.loose=r}if(i.loose)for(let t=0;t<i.items.length;t++)i.items[t].loose=true;return i}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:true,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:r,title:n}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let r=Ep(e[1]),n=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`\n`):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===n.length){for(let t of n)this.rules.other.tableAlignRight.test(t)?s.align.push("right"):this.rules.other.tableAlignCenter.test(t)?s.align.push("center"):this.rules.other.tableAlignLeft.test(t)?s.align.push("left"):s.align.push(null);for(let t=0;t<r.length;t++)s.header.push({text:r[t],tokens:this.lexer.inline(r[t]),header:true,align:s.align[t]});for(let t of i)s.rows.push(Ep(t,s.header.length).map(((t,e)=>({text:t,tokens:this.lexer.inline(t),header:false,align:s.align[e]}))));return s}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let t=e[1].charAt(e[1].length-1)===`\n`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=true:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=false),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=true:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=false),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:false,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let e=Ap(t.slice(0,-1),"\\");if((t.length-e.length)%2===0)return}else{let t=$p(e[2],"()");if(t===-2)return;if(t>-1){let r=(e[0].indexOf("!")===0?5:4)+e[1].length+t;e[2]=e[2].substring(0,t),e[0]=e[0].substring(0,r).trim(),e[3]=""}}let r=e[2],n="";if(this.options.pedantic){let t=this.rules.other.pedanticHrefTitle.exec(r);t&&(r=t[1],n=t[3])}else n=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?r=r.slice(1):r=r.slice(1,-1)),Rp(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let t=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[t.toLowerCase()];if(!n){let t=r[0].charAt(0);return{type:"text",raw:t,text:t}}return Rp(r,n,r[0],this.lexer,this.rules)}}emStrong(t,e,r=""){let n=this.rules.inline.emStrongLDelim.exec(t);if(!n||n[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(n[1]||n[2]||"")||!r||this.rules.inline.punctuation.exec(r)){let r=[...n[0]].length-1,i,s,o=r,l=0,u=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+r);(n=u.exec(e))!=null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i)continue;if(s=[...i].length,n[3]||n[4]){o+=s;continue}else if((n[5]||n[6])&&r%3&&!((r+s)%3)){l+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o+l);let e=[...n[0]][0].length,u=t.slice(0,r+n.index+e+s);if(Math.min(r,s)%2){let t=u.slice(1,-1);return{type:"em",raw:u,text:t,tokens:this.lexer.inlineTokens(t)}}let a=u.slice(2,-2);return{type:"strong",raw:u,text:a,tokens:this.lexer.inlineTokens(a)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(t),n=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return r&&n&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){let e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let t,r;return e[2]==="@"?(t=e[1],r="mailto:"+t):(t=e[1],r=t),{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let t,r;if(e[2]==="@")t=e[0],r="mailto:"+t;else{let n;do{n=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??""}while(n!==e[0]);t=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}};var Np=class t{tokens;options;state;tokenizer;inlineQueue;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||pd,this.options.tokenizer=this.options.tokenizer||new Lp,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:false,inRawBlock:false,top:true};let e={other:bd,block:yp.normal,inline:Mp.normal};this.options.pedantic?(e.block=yp.pedantic,e.inline=Mp.pedantic):this.options.gfm&&(e.block=yp.gfm,this.options.breaks?e.inline=Mp.breaks:e.inline=Mp.gfm),this.tokenizer.rules=e}static get rules(){return{block:yp,inline:Mp}}static lex(e,r){return new t(r).lex(e)}static lexInline(e,r){return new t(r).inlineTokens(e)}lex(t){t=t.replace(bd.carriageReturn,`\n`),this.blockTokens(t,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],r=false){for(this.options.pedantic&&(t=t.replace(bd.tabCharGlobal," ").replace(bd.spaceLine,""));t;){let n;if(this.options.extensions?.block?.some((r=>(n=r.call({lexer:this},t,e))?(t=t.substring(n.raw.length),e.push(n),true):false)))continue;if(n=this.tokenizer.space(t)){t=t.substring(n.raw.length);let r=e.at(-1);n.raw.length===1&&r!==void 0?r.raw+=`\n`:e.push(n);continue}if(n=this.tokenizer.code(t)){t=t.substring(n.raw.length);let r=e.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=(r.raw.endsWith(`\n`)?"":`\n`)+n.raw,r.text+=`\n`+n.text,this.inlineQueue.at(-1).src=r.text):e.push(n);continue}if(n=this.tokenizer.fences(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.heading(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.hr(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.blockquote(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.list(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.html(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.def(t)){t=t.substring(n.raw.length);let r=e.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=(r.raw.endsWith(`\n`)?"":`\n`)+n.raw,r.text+=`\n`+n.raw,this.inlineQueue.at(-1).src=r.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title},e.push(n));continue}if(n=this.tokenizer.table(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.lheading(t)){t=t.substring(n.raw.length),e.push(n);continue}let i=t;if(this.options.extensions?.startBlock){let e=1/0,r=t.slice(1),n;this.options.extensions.startBlock.forEach((t=>{n=t.call({lexer:this},r),typeof n=="number"&&n>=0&&(e=Math.min(e,n))})),e<1/0&&e>=0&&(i=t.substring(0,e+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i))){let s=e.at(-1);r&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`\n`)?"":`\n`)+n.raw,s.text+=`\n`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):e.push(n),r=i.length!==t.length,t=t.substring(n.raw.length);continue}if(n=this.tokenizer.text(t)){t=t.substring(n.raw.length);let r=e.at(-1);r?.type==="text"?(r.raw+=(r.raw.endsWith(`\n`)?"":`\n`)+n.raw,r.text+=`\n`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):e.push(n);continue}if(t){let e="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(e);break}else throw new Error(e)}}return this.state.top=true,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){let r=t,n=null;if(this.tokens.links){let t=Object.keys(this.tokens.links);if(t.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)t.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,n.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(n=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=false,s="";for(;t;){i||(s=""),i=false;let n;if(this.options.extensions?.inline?.some((r=>(n=r.call({lexer:this},t,e))?(t=t.substring(n.raw.length),e.push(n),true):false)))continue;if(n=this.tokenizer.escape(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.tag(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.link(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(n.raw.length);let r=e.at(-1);n.type==="text"&&r?.type==="text"?(r.raw+=n.raw,r.text+=n.text):e.push(n);continue}if(n=this.tokenizer.emStrong(t,r,s)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.codespan(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.br(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.del(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.autolink(t)){t=t.substring(n.raw.length),e.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(t))){t=t.substring(n.raw.length),e.push(n);continue}let o=t;if(this.options.extensions?.startInline){let e=1/0,r=t.slice(1),n;this.options.extensions.startInline.forEach((t=>{n=t.call({lexer:this},r),typeof n=="number"&&n>=0&&(e=Math.min(e,n))})),e<1/0&&e>=0&&(o=t.substring(0,e+1))}if(n=this.tokenizer.inlineText(o)){t=t.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(s=n.raw.slice(-1)),i=true;let r=e.at(-1);r?.type==="text"?(r.raw+=n.raw,r.text+=n.text):e.push(n);continue}if(t){let e="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(e);break}else throw new Error(e)}}return e}};var jp=class{options;parser;constructor(t){this.options=t||pd}space(t){return""}code({text:t,lang:e,escaped:r}){let n=(e||"").match(bd.notSpaceStart)?.[0],i=t.replace(bd.endingNewline,"")+`\n`;return n?'<pre><code class="language-'+Sp(n)+'">'+(r?i:Sp(i,true))+`</code></pre>\n`:"<pre><code>"+(r?i:Sp(i,true))+`</code></pre>\n`}blockquote({tokens:t}){return`<blockquote>\n${this.parser.parse(t)}</blockquote>\n`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>\n`}hr(t){return`<hr>\n`}list(t){let e=t.ordered,r=t.start,n="";for(let e=0;e<t.items.length;e++){let r=t.items[e];n+=this.listitem(r)}let i=e?"ol":"ul",s=e&&r!==1?' start="'+r+'"':"";return"<"+i+s+`>\n`+n+"</"+i+`>\n`}listitem(t){let e="";if(t.task){let r=this.checkbox({checked:!!t.checked});t.loose?t.tokens[0]?.type==="paragraph"?(t.tokens[0].text=r+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=r+" "+Sp(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=true)):t.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:true}):e+=r+" "}return e+=this.parser.parse(t.tokens,!!t.loose),`<li>${e}</li>\n`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>\n`}table(t){let e="",r="";for(let e=0;e<t.header.length;e++)r+=this.tablecell(t.header[e]);e+=this.tablerow({text:r});let n="";for(let e=0;e<t.rows.length;e++){let i=t.rows[e];r="";for(let t=0;t<i.length;t++)r+=this.tablecell(i[t]);n+=this.tablerow({text:r})}return n&&(n=`<tbody>${n}</tbody>`),`<table>\n<thead>\n`+e+`</thead>\n`+n+`</table>\n`}tablerow({text:t}){return`<tr>\n${t}</tr>\n`}tablecell(t){let e=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+e+`</${r}>\n`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Sp(t,true)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:r}){let n=this.parser.parseInline(r),i=Tp(t);if(i===null)return n;t=i;let s='<a href="'+t+'"';return e&&(s+=' title="'+Sp(e)+'"'),s+=">"+n+"</a>",s}image({href:t,title:e,text:r,tokens:n}){n&&(r=this.parser.parseInline(n,this.parser.textRenderer));let i=Tp(t);if(i===null)return Sp(r);t=i;let s=`<img src="${t}" alt="${r}"`;return e&&(s+=` title="${Sp(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Sp(t.text)}};var Pp=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}};var Ip=class t{options;renderer;textRenderer;constructor(t){this.options=t||pd,this.options.renderer=this.options.renderer||new jp,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Pp}static parse(e,r){return new t(r).parse(e)}static parseInline(e,r){return new t(r).parseInline(e)}parse(t,e=true){let r="";for(let n=0;n<t.length;n++){let i=t[n];if(this.options.extensions?.renderers?.[i.type]){let t=i,e=this.options.extensions.renderers[t.type].call({parser:this},t);if(e!==false||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(t.type)){r+=e||"";continue}}let s=i;switch(s.type){case"space":{r+=this.renderer.space(s);continue}case"hr":{r+=this.renderer.hr(s);continue}case"heading":{r+=this.renderer.heading(s);continue}case"code":{r+=this.renderer.code(s);continue}case"table":{r+=this.renderer.table(s);continue}case"blockquote":{r+=this.renderer.blockquote(s);continue}case"list":{r+=this.renderer.list(s);continue}case"html":{r+=this.renderer.html(s);continue}case"def":{r+=this.renderer.def(s);continue}case"paragraph":{r+=this.renderer.paragraph(s);continue}case"text":{let i=s,o=this.renderer.text(i);for(;n+1<t.length&&t[n+1].type==="text";)i=t[++n],o+=`\n`+this.renderer.text(i);e?r+=this.renderer.paragraph({type:"paragraph",raw:o,text:o,tokens:[{type:"text",raw:o,text:o,escaped:true}]}):r+=o;continue}default:{let t='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(t),"";throw new Error(t)}}}return r}parseInline(t,e=this.renderer){let r="";for(let n=0;n<t.length;n++){let i=t[n];if(this.options.extensions?.renderers?.[i.type]){let t=this.options.extensions.renderers[i.type].call({parser:this},i);if(t!==false||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=t||"";continue}}let s=i;switch(s.type){case"escape":{r+=e.text(s);break}case"html":{r+=e.html(s);break}case"link":{r+=e.link(s);break}case"image":{r+=e.image(s);break}case"strong":{r+=e.strong(s);break}case"em":{r+=e.em(s);break}case"codespan":{r+=e.codespan(s);break}case"br":{r+=e.br(s);break}case"del":{r+=e.del(s);break}case"text":{r+=e.text(s);break}default:{let t='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(t),"";throw new Error(t)}}}return r}};var Dp=class{options;block;constructor(t){this.options=t||pd}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?Np.lex:Np.lexInline}provideParser(){return this.block?Ip.parse:Ip.parseInline}};var Hp=class{defaults=dd();options=this.setOptions;parse=this.parseMarkdown(true);parseInline=this.parseMarkdown(false);Parser=Ip;Renderer=jp;TextRenderer=Pp;Lexer=Np;Tokenizer=Lp;Hooks=Dp;constructor(...t){this.use(...t)}walkTokens(t,e){let r=[];for(let n of t)switch(r=r.concat(e.call(this,n)),n.type){case"table":{let t=n;for(let n of t.header)r=r.concat(this.walkTokens(n.tokens,e));for(let n of t.rows)for(let t of n)r=r.concat(this.walkTokens(t.tokens,e));break}case"list":{let t=n;r=r.concat(this.walkTokens(t.items,e));break}default:{let t=n;this.defaults.extensions?.childTokens?.[t.type]?this.defaults.extensions.childTokens[t.type].forEach((n=>{let i=t[n].flat(1/0);r=r.concat(this.walkTokens(i,e))})):t.tokens&&(r=r.concat(this.walkTokens(t.tokens,e)))}}return r}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach((t=>{let r={...t};if(r.async=this.defaults.async||r.async||false,t.extensions&&(t.extensions.forEach((t=>{if(!t.name)throw new Error("extension name required");if("renderer"in t){let r=e.renderers[t.name];r?e.renderers[t.name]=function(...e){let n=t.renderer.apply(this,e);return n===false&&(n=r.apply(this,e)),n}:e.renderers[t.name]=t.renderer}if("tokenizer"in t){if(!t.level||t.level!=="block"&&t.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let r=e[t.level];r?r.unshift(t.tokenizer):e[t.level]=[t.tokenizer],t.start&&(t.level==="block"?e.startBlock?e.startBlock.push(t.start):e.startBlock=[t.start]:t.level==="inline"&&(e.startInline?e.startInline.push(t.start):e.startInline=[t.start]))}"childTokens"in t&&t.childTokens&&(e.childTokens[t.name]=t.childTokens)})),r.extensions=e),t.renderer){let e=this.defaults.renderer||new jp(this.defaults);for(let r in t.renderer){if(!(r in e))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let n=r,i=t.renderer[n],s=e[n];e[n]=(...t)=>{let r=i.apply(e,t);return r===false&&(r=s.apply(e,t)),r||""}}r.renderer=e}if(t.tokenizer){let e=this.defaults.tokenizer||new Lp(this.defaults);for(let r in t.tokenizer){if(!(r in e))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let n=r,i=t.tokenizer[n],s=e[n];e[n]=(...t)=>{let r=i.apply(e,t);return r===false&&(r=s.apply(e,t)),r}}r.tokenizer=e}if(t.hooks){let e=this.defaults.hooks||new Dp;for(let r in t.hooks){if(!(r in e))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let n=r,i=t.hooks[n],s=e[n];Dp.passThroughHooks.has(r)?e[n]=t=>{if(this.defaults.async&&Dp.passThroughHooksRespectAsync.has(r))return(async()=>{let r=await i.call(e,t);return s.call(e,r)})();let n=i.call(e,t);return s.call(e,n)}:e[n]=(...t)=>{if(this.defaults.async)return(async()=>{let r=await i.apply(e,t);return r===false&&(r=await s.apply(e,t)),r})();let r=i.apply(e,t);return r===false&&(r=s.apply(e,t)),r}}r.hooks=e}if(t.walkTokens){let e=this.defaults.walkTokens,n=t.walkTokens;r.walkTokens=function(t){let r=[];return r.push(n.call(this,t)),e&&(r=r.concat(e.call(this,t))),r}}this.defaults={...this.defaults,...r}})),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Np.lex(t,e??this.defaults)}parser(t,e){return Ip.parse(t,e??this.defaults)}parseMarkdown(t){return(e,r)=>{let n={...r},i={...this.defaults,...n},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===true&&n.async===false)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let r=i.hooks?await i.hooks.preprocess(e):e,n=await(i.hooks?await i.hooks.provideLexer():t?Np.lex:Np.lexInline)(r,i),s=i.hooks?await i.hooks.processAllTokens(n):n;i.walkTokens&&await Promise.all(this.walkTokens(s,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():t?Ip.parse:Ip.parseInline)(s,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let r=(i.hooks?i.hooks.provideLexer():t?Np.lex:Np.lexInline)(e,i);i.hooks&&(r=i.hooks.processAllTokens(r)),i.walkTokens&&this.walkTokens(r,i.walkTokens);let n=(i.hooks?i.hooks.provideParser():t?Ip.parse:Ip.parseInline)(r,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(t){return s(t)}}}onError(t,e){return r=>{if(r.message+=`\nPlease report this to https://github.com/markedjs/marked.`,t){let t="<p>An error occurred:</p><pre>"+Sp(r.message+"",true)+"</pre>";return e?Promise.resolve(t):t}if(e)return Promise.reject(r);throw r}}};var zp=new Hp;function _p(t,e){return zp.parse(t,e)}_p.options=_p.setOptions=function(t){return zp.setOptions(t),_p.defaults=zp.defaults,md(_p.defaults),_p};_p.getDefaults=dd;_p.defaults=pd;_p.use=function(...t){return zp.use(...t),_p.defaults=zp.defaults,md(_p.defaults),_p};_p.walkTokens=function(t,e){return zp.walkTokens(t,e)};_p.parseInline=zp.parseInline;_p.Parser=Ip;_p.parser=Ip.parse;_p.Renderer=jp;_p.TextRenderer=Pp;_p.Lexer=Np;_p.lexer=Np.lex;_p.Tokenizer=Lp;_p.Hooks=Dp;_p.parse=_p;function Bp(t,e){const r=e.split("\n");const n=r.flatMap((t=>[t,""])).map((e=>`${t}${e}`)).join("\n");return n.slice(0,n.length-1)}function Up(t,e){const r=[];Array.from(t.keys()).forEach((t=>{if(!e.has(t)){r.push(t)}}));return r.reverse()}function Fp(t,e){const r=[];Array.from(e.entries()).forEach((([e,n])=>{if(!t.has(e)){r.push({type:e,mark:n})}}));return r}function qp(t,e,r,n){const i=!r;const s=r&&r.type==="text"&&(!r.marks||r.marks.length===0);const o=r&&r.type==="text"&&r.marks&&!n(e,new Map(r.marks.map((t=>[t.type,t]))));const l=[];if(i||s||o){if(r&&r.type==="text"&&r.marks){const e=new Map(r.marks.map((t=>[t.type,t])));Array.from(t.keys()).forEach((t=>{if(!e.has(t)){l.push(t)}}))}else if(i||s){l.push(...Array.from(t.keys()))}}return l.reverse()}function Kp(t,e){let r="";Array.from(t.keys()).reverse().forEach((n=>{const i=t.get(n);const s=e(n,i);if(s){r=s+r}}));t.clear();return r}function Wp(t,e,r){let n="";Array.from(t.entries()).forEach((([t,i])=>{const s=r(t,i);if(s){n+=s}e.set(t,i)}));return n}function Jp(t,e){if(typeof t!=="string"){return"json"}return e}var Vp=class{constructor(t){this.baseExtensions=[];this.extensions=[];this.lastParseResult=null;var e,r,n,i,s;this.markedInstance=(e=t==null?void 0:t.marked)!=null?e:_p;this.lexer=new this.markedInstance.Lexer;this.indentStyle=(n=(r=t==null?void 0:t.indentation)==null?void 0:r.style)!=null?n:"space";this.indentSize=(s=(i=t==null?void 0:t.indentation)==null?void 0:i.size)!=null?s:2;this.baseExtensions=(t==null?void 0:t.extensions)||[];if((t==null?void 0:t.markedOptions)&&typeof this.markedInstance.setOptions==="function"){this.markedInstance.setOptions(t.markedOptions)}this.registry=new Map;this.nodeTypeRegistry=new Map;if(t==null?void 0:t.extensions){this.baseExtensions=t.extensions;const e=oh(t.extensions);e.forEach((t=>this.registerExtension(t,false)))}this.lexer=new this.markedInstance.Lexer}get instance(){return this.markedInstance}get indentCharacter(){return this.indentStyle==="space"?" ":"\t"}get indentString(){return this.indentCharacter.repeat(this.indentSize)}hasMarked(){return!!this.markedInstance}registerExtension(t,e=true){var r,n;this.extensions.push(t);const i=t.name;const s=sh(t,"markdownTokenName")||i;const o=sh(t,"parseMarkdown");const l=sh(t,"renderMarkdown");const u=sh(t,"markdownTokenizer");const a=(r=sh(t,"markdownOptions"))!=null?r:null;const f=(n=a==null?void 0:a.indentsContent)!=null?n:false;const h={tokenName:s,nodeName:i,parseMarkdown:o,renderMarkdown:l,isIndenting:f,tokenizer:u};if(s&&o){const t=this.registry.get(s)||[];t.push(h);this.registry.set(s,t)}if(l){const t=this.nodeTypeRegistry.get(i)||[];t.push(h);this.nodeTypeRegistry.set(i,t)}if(u&&this.hasMarked()){this.registerTokenizer(u);if(e){this.lexer=new this.markedInstance.Lexer}}}registerTokenizer(t){if(!this.hasMarked()){return}const{name:e,start:r,level:n="inline",tokenize:i}=t;const s=t=>this.lexer.inlineTokens(t);const o=t=>this.lexer.blockTokens(t);const l={inlineTokens:s,blockTokens:o};let u;if(!r){u=t=>{const e=i(t,[],l);if(e&&e.raw){const r=t.indexOf(e.raw);return r}return-1}}else{u=typeof r==="function"?r:t=>t.indexOf(r)}const a={name:e,level:n,start:u,tokenizer:(t,r)=>{const n=i(t,r,l);if(n&&n.type){return{...n,type:n.type||e,raw:n.raw||"",tokens:n.tokens||[]}}return void 0},childTokens:[]};this.markedInstance.use({extensions:[a]})}getHandlersForToken(t){try{return this.registry.get(t)||[]}catch{return[]}}getHandlerForToken(t){const e=this.getHandlersForToken(t);if(e.length>0){return e[0]}const r=this.getHandlersForNodeType(t);return r.length>0?r[0]:void 0}getHandlersForNodeType(t){try{return this.nodeTypeRegistry.get(t)||[]}catch{return[]}}serialize(t){if(!t){return""}if(Array.isArray(t)){return this.renderNodes(t,t)}return this.renderNodes(t,t)}parse(t){if(!this.hasMarked()){throw new Error("No marked instance available for parsing")}const e=this.markedInstance.lexer(t);const r=this.parseTokens(e);return{type:"doc",content:r}}parseTokens(t){return t.map((t=>this.parseToken(t))).filter((t=>t!==null)).flatMap((t=>Array.isArray(t)?t:[t]))}parseToken(t){if(!t.type){return null}const e=this.getHandlersForToken(t.type);const r=this.createParseHelpers();const n=e.find((e=>{if(!e.parseMarkdown){return false}const n=e.parseMarkdown(t,r);const i=this.normalizeParseResult(n);if(i&&(!Array.isArray(i)||i.length>0)){this.lastParseResult=i;return true}return false}));if(n&&this.lastParseResult){const t=this.lastParseResult;this.lastParseResult=null;return t}return this.parseFallbackToken(t)}createParseHelpers(){return{parseInline:t=>this.parseInlineTokens(t),parseChildren:t=>this.parseTokens(t),createTextNode:(t,e)=>{const r={type:"text",text:t,marks:e||void 0};return r},createNode:(t,e,r)=>{const n={type:t,attrs:e||void 0,content:r||void 0};if(!e||Object.keys(e).length===0){delete n.attrs}return n},applyMark:(t,e,r)=>({mark:t,content:e,attrs:r&&Object.keys(r).length>0?r:void 0})}}parseInlineTokens(t){const e=[];t.forEach((t=>{if(t.type==="text"){e.push({type:"text",text:t.text||""})}else if(t.type){const r=this.getHandlerForToken(t.type);if(r&&r.parseMarkdown){const n=this.createParseHelpers();const i=r.parseMarkdown(t,n);if(this.isMarkResult(i)){const t=this.applyMarkToContent(i.mark,i.content,i.attrs);e.push(...t)}else{const t=this.normalizeParseResult(i);if(Array.isArray(t)){e.push(...t)}else if(t){e.push(t)}}}else if(t.tokens){e.push(...this.parseInlineTokens(t.tokens))}}}));return e}applyMarkToContent(t,e,r){return e.map((e=>{if(e.type==="text"){const n=e.marks||[];const i=r?{type:t,attrs:r}:{type:t};return{...e,marks:[...n,i]}}return{...e,content:e.content?this.applyMarkToContent(t,e.content,r):void 0}}))}isMarkResult(t){return t&&typeof t==="object"&&"mark"in t}normalizeParseResult(t){if(!t){return null}if(this.isMarkResult(t)){return t.content}return t}parseFallbackToken(t){switch(t.type){case"paragraph":return{type:"paragraph",content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"heading":return{type:"heading",attrs:{level:t.depth||1},content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"text":return{type:"text",text:t.text||""};case"html":return this.parseHTMLToken(t);case"space":return null;default:if(t.tokens){return this.parseTokens(t.tokens)}return null}}parseHTMLToken(t){const e=t.text||t.raw||"";if(!e.trim()){return null}try{const r=xh(e,this.baseExtensions);if(r.type==="doc"&&r.content){if(t.block){return r.content}if(r.content.length===1&&r.content[0].type==="paragraph"&&r.content[0].content){return r.content[0].content}return r.content}return r}catch(t){throw new Error(`Failed to parse HTML in markdown: ${t}`)}}renderNodeToMarkdown(t,e,r=0,n=0){var i;if(t.type==="text"){return t.text||""}if(!t.type){return""}const s=this.getHandlerForToken(t.type);if(!s){return""}const o={renderChildren:(e,i)=>{const o=s.isIndenting?n+1:n;if(!Array.isArray(e)&&e.content){return this.renderNodes(e.content,t,i||"",r,o)}return this.renderNodes(e,t,i||"",r,o)},indent:t=>this.indentString+t,wrapInBlock:Bp};const l={index:r,level:n,parentType:e==null?void 0:e.type,meta:{}};const u=((i=s.renderMarkdown)==null?void 0:i.call(s,t,o,l))||"";return u}renderNodes(t,e,r="",n=0,i=0){if(!Array.isArray(t)){if(!t.type){return""}return this.renderNodeToMarkdown(t,e,n,i)}return this.renderNodesWithMarkBoundaries(t,e,r,i)}renderNodesWithMarkBoundaries(t,e,r="",n=0){const i=[];const s=new Map;t.forEach(((r,o)=>{const l=o<t.length-1?t[o+1]:null;if(!r.type){return}if(r.type==="text"){let t=r.text||"";const e=new Map((r.marks||[]).map((t=>[t.type,t])));const n=Up(s,e);const o=Fp(s,e);n.forEach((e=>{const r=s.get(e);const n=this.getMarkClosing(e,r);if(n){t+=n}s.delete(e)}));o.forEach((({type:e,mark:r})=>{const n=this.getMarkOpening(e,r);if(n){t=n+t}s.set(e,r)}));const u=qp(s,e,l,this.markSetsEqual.bind(this));u.forEach((e=>{const r=s.get(e);const n=this.getMarkClosing(e,r);if(n){t+=n}s.delete(e)}));i.push(t)}else{const t=new Map(s);const l=Kp(s,this.getMarkClosing.bind(this));const u=this.renderNodeToMarkdown(r,e,o,n);const a=Wp(t,s,this.getMarkOpening.bind(this));i.push(l+u+a)}}));return i.join(r)}getMarkOpening(t,e){const r=this.getHandlersForNodeType(t);const n=r.length>0?r[0]:void 0;if(!n||!n.renderMarkdown){return""}const i="__TIPTAP_MARKDOWN_PLACEHOLDER__";const s={type:t,attrs:e.attrs||{},content:[{type:"text",text:i}]};try{const t=n.renderMarkdown(s,{renderChildren:()=>i,indent:t=>t,wrapInBlock:(t,e)=>t+e},{index:0,level:0,parentType:"text",meta:{}});const e=t.indexOf(i);return e>=0?t.substring(0,e):""}catch(e){throw new Error(`Failed to get mark opening for ${t}: ${e}`)}}getMarkClosing(t,e){const r=this.getHandlersForNodeType(t);const n=r.length>0?r[0]:void 0;if(!n||!n.renderMarkdown){return""}const i="__TIPTAP_MARKDOWN_PLACEHOLDER__";const s={type:t,attrs:e.attrs||{},content:[{type:"text",text:i}]};try{const t=n.renderMarkdown(s,{renderChildren:()=>i,indent:t=>t,wrapInBlock:(t,e)=>t+e},{index:0,level:0,parentType:"text",meta:{}});const e=t.indexOf(i);const r=e+i.length;return e>=0?t.substring(r):""}catch(e){throw new Error(`Failed to get mark closing for ${t}: ${e}`)}}markSetsEqual(t,e){if(t.size!==e.size){return false}return Array.from(t.keys()).every((t=>e.has(t)))}};var Gp=Vp;var Zp=Lc.create({name:"markdown",addOptions(){return{indentation:{style:"space",size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(t,e)=>{if(!(e==null?void 0:e.contentType)){return Ua.setContent(t,e)}const r=Jp(t,e==null?void 0:e.contentType);if(r!=="markdown"||!this.editor.markdown){return Ua.setContent(t,e)}const n=this.editor.markdown.parse(t);return Ua.setContent(n,e)},insertContent:(t,e)=>{if(!(e==null?void 0:e.contentType)){return Ua.insertContent(t,e)}const r=Jp(t,e==null?void 0:e.contentType);if(r!=="markdown"||!this.editor.markdown){return Ua.insertContent(t,e)}const n=this.editor.markdown.parse(t);return Ua.insertContent(n,e)},insertContentAt:(t,e,r)=>{if(!(r==null?void 0:r.contentType)){return Ua.insertContentAt(t,e,r)}const n=Jp(e,r==null?void 0:r.contentType);if(n!=="markdown"||!this.editor.markdown){return Ua.insertContentAt(t,e,r)}const i=this.editor.markdown.parse(e);return Ua.insertContentAt(t,i,r)}}},addStorage(){return{manager:new Gp({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate(){if(this.editor.markdown){console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");return}this.storage.manager=new Gp({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions});this.editor.markdown=this.storage.manager;this.editor.getMarkdown=()=>this.storage.manager.serialize(this.editor.getJSON());if(!this.editor.options.contentType){return}const t=Jp(this.editor.options.content,this.editor.options.contentType);if(t!=="markdown"){return}if(!this.editor.markdown){throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.')}if(this.editor.options.content===void 0||typeof this.editor.options.content!=="string"){throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.')}const e=this.editor.markdown.parse(this.editor.options.content);this.editor.options.content=e}});var Qp=(t,e)=>{if(t==="slot"){return 0}if(t instanceof Function){return t(e)}const{children:r,...n}=e!=null?e:{};if(t==="svg"){throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead")}return[t,n,r]};var Xp=/^\s*>\s$/;var Yp=hd.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:true,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Qp("blockquote",{...dh(this.options.HTMLAttributes,t),children:Qp("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content){return""}const r=[];t.content.forEach((t=>{const n=e.renderChildren(t);const i=n.split("\n").map((t=>`> ${t}`)).join("\n");r.push(i)}));const n=r.flatMap((t=>[t,"> "]));return n.slice(0,-1).join("\n")},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Zc({find:Xp,type:this.type})]}});var tm=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/;var em=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g;var rm=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/;var nm=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g;var im=Mc.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Qp("strong",{...dh(this.options.HTMLAttributes,t),children:Qp("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Jc({find:tm,type:this.type}),Jc({find:rm,type:this.type})]},addPasteRules(){return[cd({find:em,type:this.type}),cd({find:nm,type:this.type})]}});var sm=/(^|[^`])`([^`]+)`(?!`)$/;var om=/(^|[^`])`([^`]+)`(?!`)/g;var lm=Mc.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:true,exitable:true,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",dh(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>{if(!t.content){return""}return`\`${e.renderChildren(t.content)}\``},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Jc({find:sm,type:this.type})]},addPasteRules(){return[cd({find:om,type:this.type})]}});var um=4;var am=/^```([a-z]+)?[\s\n]$/;var fm=/^~~~([a-z]+)?[\s\n]$/;var hm=hd.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:true,exitOnArrowDown:true,defaultLanguage:null,enableTabIndentation:false,tabSize:um,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:true,defining:true,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:r}=this.options;if(!r){return null}const n=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]];const i=n.filter((t=>t.startsWith(r))).map((t=>t.replace(r,"")));const s=i[0];if(!s){return null}return s},rendered:false}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",dh(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var r;if(((r=t.raw)==null?void 0:r.startsWith("```"))===false&&t.codeBlockStyle!=="indented"){return[]}return e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var r;let n="";const i=((r=t.attrs)==null?void 0:r.language)||"";if(!t.content){n=`\`\`\`${i}\n\n\`\`\``}else{const r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"];n=r.join("\n")}return n},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection;const r=e.pos===1;if(!t||e.parent.type.name!==this.name){return false}if(r||!e.parent.textContent.length){return this.editor.commands.clearNodes()}return false},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation){return false}const r=(e=this.options.tabSize)!=null?e:um;const{state:n}=t;const{selection:i}=n;const{$from:s,empty:o}=i;if(s.parent.type!==this.type){return false}const l=" ".repeat(r);if(o){return t.commands.insertContent(l)}return t.commands.command((({tr:t})=>{const{from:e,to:r}=i;const s=n.doc.textBetween(e,r,"\n","\n");const o=s.split("\n");const u=o.map((t=>l+t)).join("\n");t.replaceWith(e,r,n.schema.text(u));return true}))},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation){return false}const r=(e=this.options.tabSize)!=null?e:um;const{state:n}=t;const{selection:i}=n;const{$from:s,empty:o}=i;if(s.parent.type!==this.type){return false}if(o){return t.commands.command((({tr:t})=>{var e;const{pos:i}=s;const o=s.start();const l=s.end();const u=n.doc.textBetween(o,l,"\n","\n");const a=u.split("\n");let f=0;let h=0;const c=i-o;for(let t=0;t<a.length;t+=1){if(h+a[t].length>=c){f=t;break}h+=a[t].length+1}const d=a[f];const p=((e=d.match(/^ */))==null?void 0:e[0])||"";const m=Math.min(p.length,r);if(m===0){return true}let g=o;for(let t=0;t<f;t+=1){g+=a[t].length+1}t.delete(g,g+m);const w=i-g;if(w<=m){t.setSelection(Xn.create(t.doc,g))}return true}))}return t.commands.command((({tr:t})=>{const{from:e,to:s}=i;const o=n.doc.textBetween(e,s,"\n","\n");const l=o.split("\n");const u=l.map((t=>{var e;const n=((e=t.match(/^ */))==null?void 0:e[0])||"";const i=Math.min(n.length,r);return t.slice(i)})).join("\n");t.replaceWith(e,s,n.schema.text(u));return true}))},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter){return false}const{state:e}=t;const{selection:r}=e;const{$from:n,empty:i}=r;if(!i||n.parent.type!==this.type){return false}const s=n.parentOffset===n.parent.nodeSize-2;const o=n.parent.textContent.endsWith("\n\n");if(!s||!o){return false}return t.chain().command((({tr:t})=>{t.delete(n.pos-2,n.pos);return true})).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown){return false}const{state:e}=t;const{selection:r,doc:n}=e;const{$from:i,empty:s}=r;if(!s||i.parent.type!==this.type){return false}const o=i.parentOffset===i.parent.nodeSize-2;if(!o){return false}const l=i.after();if(l===void 0){return false}const u=n.nodeAt(l);if(u){return t.commands.command((({tr:t})=>{t.setSelection(Vn.near(n.resolve(l)));return true}))}return t.commands.exitCode()}}},addInputRules(){return[Gc({find:am,type:this.type,getAttributes:t=>({language:t[1]})}),Gc({find:fm,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new gi({key:new vi("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData){return false}if(this.editor.isActive(this.type.name)){return false}const r=e.clipboardData.getData("text/plain");const n=e.clipboardData.getData("vscode-editor-data");const i=n?JSON.parse(n):void 0;const s=i==null?void 0:i.mode;if(!r||!s){return false}const{tr:o,schema:l}=t.state;const u=l.text(r.replace(/\r\n?/g,"\n"));o.replaceSelectionWith(this.type.create({language:s},u));if(o.selection.$from.parent.type!==this.type){o.setSelection(Xn.near(o.doc.resolve(Math.max(0,o.selection.from-2))))}o.setMeta("paste",true);t.dispatch(o);return true}}})]}});var cm=hd.create({name:"doc",topNode:true,content:"block+",renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n\n")}});var dm=hd.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:true,HTMLAttributes:{}}},inline:true,group:"inline",selectable:false,linebreakReplacement:true,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",dh(this.options.HTMLAttributes,t)]},renderText(){return"\n"},renderMarkdown:(t,e)=>e.indent(`\n`),parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:r,editor:n})=>t.first([()=>t.exitCode(),()=>t.command((()=>{const{selection:t,storedMarks:i}=r;if(t.$from.parent.type.spec.isolating){return false}const{keepMarks:s}=this.options;const{splittableMarks:o}=n.extensionManager;const l=i||t.$to.parentOffset&&t.$from.marks();return e().insertContent({type:this.name}).command((({tr:t,dispatch:e})=>{if(e&&l&&s){const e=l.filter((t=>o.includes(t.type.name)));t.ensureMarks(e)}return true})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var pm=hd.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:true,addAttributes(){return{level:{default:1,rendered:false}}},parseHTML(){return this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}})))},renderHTML({node:t,HTMLAttributes:e}){const r=this.options.levels.includes(t.attrs.level);const n=r?t.attrs.level:this.options.levels[0];return[`h${n}`,dh(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var r;const n=((r=t.attrs)==null?void 0:r.level)?parseInt(t.attrs.level,10):1;const i="#".repeat(n);if(!t.content){return""}return`${i} ${e.renderChildren(t.content)}`},addCommands(){return{setHeading:t=>({commands:e})=>{if(!this.options.levels.includes(t.level)){return false}return e.setNode(this.name,t)},toggleHeading:t=>({commands:e})=>{if(!this.options.levels.includes(t.level)){return false}return e.toggleNode(this.name,"paragraph",t)}}},addKeyboardShortcuts(){return this.options.levels.reduce(((t,e)=>({...t,...{[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}})),{})},addInputRules(){return this.options.levels.map((t=>Gc({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}})))}});var mm=hd.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",dh(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Yc(e,e.schema.nodes[this.name])){return false}const{selection:r}=e;const{$to:n}=r;const i=t();if(qh(r)){i.insertContentAt(n.pos,{type:this.name})}else{i.insertContent({type:this.name})}return i.command((({state:t,tr:e,dispatch:r})=>{if(r){const{$to:r}=e.selection;const n=r.end();if(r.nodeAfter){if(r.nodeAfter.isTextblock){e.setSelection(Xn.create(e.doc,r.pos+1))}else if(r.nodeAfter.isBlock){e.setSelection(ti.create(e.doc,r.pos))}else{e.setSelection(Xn.create(e.doc,r.pos))}}else{const i=t.schema.nodes[this.options.nextNodeType]||r.parent.type.contentMatch.defaultType;const s=i==null?void 0:i.create();if(s){e.insert(n,s);e.setSelection(Xn.create(e.doc,n+1))}}e.scrollIntoView()}return true})).run()}}},addInputRules(){return[Vc({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var gm=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/;var wm=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g;var bm=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/;var vm=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g;var km=Mc.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",dh(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Jc({find:gm,type:this.type}),Jc({find:bm,type:this.type})]},addPasteRules(){return[cd({find:wm,type:this.type}),cd({find:vm,type:this.type})]}});const ym="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";const Mm="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2";const xm="numeric";const Om="ascii";const Sm="alpha";const Tm="asciinumeric";const Em="alphanumeric";const Am="domain";const $m="emoji";const Rm="scheme";const Cm="slashscheme";const Lm="whitespace";function Nm(t,e){if(!(t in e)){e[t]=[]}return e[t]}function jm(t,e,r){if(e[xm]){e[Tm]=true;e[Em]=true}if(e[Om]){e[Tm]=true;e[Sm]=true}if(e[Tm]){e[Em]=true}if(e[Sm]){e[Em]=true}if(e[Em]){e[Am]=true}if(e[$m]){e[Am]=true}for(const n in e){const e=Nm(n,r);if(e.indexOf(t)<0){e.push(t)}}}function Pm(t,e){const r={};for(const n in e){if(e[n].indexOf(t)>=0){r[n]=true}}return r}function Im(t=null){this.j={};this.jr=[];this.jd=null;this.t=t}Im.groups={};Im.prototype={accepts(){return!!this.t},go(t){const e=this;const r=e.j[t];if(r){return r}for(let r=0;r<e.jr.length;r++){const n=e.jr[r][0];const i=e.jr[r][1];if(i&&n.test(t)){return i}}return e.jd},has(t,e=false){return e?t in this.j:!!this.go(t)},ta(t,e,r,n){for(let i=0;i<t.length;i++){this.tt(t[i],e,r,n)}},tr(t,e,r,n){n=n||Im.groups;let i;if(e&&e.j){i=e}else{i=new Im(e);if(r&&n){jm(e,r,n)}}this.jr.push([t,i]);return i},ts(t,e,r,n){let i=this;const s=t.length;if(!s){return i}for(let e=0;e<s-1;e++){i=i.tt(t[e])}return i.tt(t[s-1],e,r,n)},tt(t,e,r,n){n=n||Im.groups;const i=this;if(e&&e.j){i.j[t]=e;return e}const s=e;let o,l=i.go(t);if(l){o=new Im;Object.assign(o.j,l.j);o.jr.push.apply(o.jr,l.jr);o.jd=l.jd;o.t=l.t}else{o=new Im}if(s){if(n){if(o.t&&typeof o.t==="string"){const t=Object.assign(Pm(o.t,n),r);jm(s,t,n)}else if(r){jm(s,r,n)}}o.t=s}i.j[t]=o;return o}};const Dm=(t,e,r,n,i)=>t.ta(e,r,n,i);const Hm=(t,e,r,n,i)=>t.tr(e,r,n,i);const zm=(t,e,r,n,i)=>t.ts(e,r,n,i);const _m=(t,e,r,n,i)=>t.tt(e,r,n,i);const Bm="WORD";const Um="UWORD";const Fm="ASCIINUMERICAL";const qm="ALPHANUMERICAL";const Km="LOCALHOST";const Wm="TLD";const Jm="UTLD";const Vm="SCHEME";const Gm="SLASH_SCHEME";const Zm="NUM";const Qm="WS";const Xm="NL";const Ym="OPENBRACE";const tg="CLOSEBRACE";const eg="OPENBRACKET";const rg="CLOSEBRACKET";const ng="OPENPAREN";const ig="CLOSEPAREN";const sg="OPENANGLEBRACKET";const og="CLOSEANGLEBRACKET";const lg="FULLWIDTHLEFTPAREN";const ug="FULLWIDTHRIGHTPAREN";const ag="LEFTCORNERBRACKET";const fg="RIGHTCORNERBRACKET";const hg="LEFTWHITECORNERBRACKET";const cg="RIGHTWHITECORNERBRACKET";const dg="FULLWIDTHLESSTHAN";const pg="FULLWIDTHGREATERTHAN";const mg="AMPERSAND";const gg="APOSTROPHE";const wg="ASTERISK";const bg="AT";const vg="BACKSLASH";const kg="BACKTICK";const yg="CARET";const Mg="COLON";const xg="COMMA";const Og="DOLLAR";const Sg="DOT";const Tg="EQUALS";const Eg="EXCLAMATION";const Ag="HYPHEN";const $g="PERCENT";const Rg="PIPE";const Cg="PLUS";const Lg="POUND";const Ng="QUERY";const jg="QUOTE";const Pg="FULLWIDTHMIDDLEDOT";const Ig="SEMI";const Dg="SLASH";const Hg="TILDE";const zg="UNDERSCORE";const _g="EMOJI";const Bg="SYM";var Ug=Object.freeze({__proto__:null,ALPHANUMERICAL:qm,AMPERSAND:mg,APOSTROPHE:gg,ASCIINUMERICAL:Fm,ASTERISK:wg,AT:bg,BACKSLASH:vg,BACKTICK:kg,CARET:yg,CLOSEANGLEBRACKET:og,CLOSEBRACE:tg,CLOSEBRACKET:rg,CLOSEPAREN:ig,COLON:Mg,COMMA:xg,DOLLAR:Og,DOT:Sg,EMOJI:_g,EQUALS:Tg,EXCLAMATION:Eg,FULLWIDTHGREATERTHAN:pg,FULLWIDTHLEFTPAREN:lg,FULLWIDTHLESSTHAN:dg,FULLWIDTHMIDDLEDOT:Pg,FULLWIDTHRIGHTPAREN:ug,HYPHEN:Ag,LEFTCORNERBRACKET:ag,LEFTWHITECORNERBRACKET:hg,LOCALHOST:Km,NL:Xm,NUM:Zm,OPENANGLEBRACKET:sg,OPENBRACE:Ym,OPENBRACKET:eg,OPENPAREN:ng,PERCENT:$g,PIPE:Rg,PLUS:Cg,POUND:Lg,QUERY:Ng,QUOTE:jg,RIGHTCORNERBRACKET:fg,RIGHTWHITECORNERBRACKET:cg,SCHEME:Vm,SEMI:Ig,SLASH:Dg,SLASH_SCHEME:Gm,SYM:Bg,TILDE:Hg,TLD:Wm,UNDERSCORE:zg,UTLD:Jm,UWORD:Um,WORD:Bm,WS:Qm});const Fg=/[a-z]/;const qg=/\p{L}/u;const Kg=/\p{Emoji}/u;const Wg=/\d/;const Jg=/\s/;const Vg="\r";const Gg="\n";const Zg="️";const Qg="";const Xg="";let Yg=null,tw=null;function ew(t=[]){const e={};Im.groups=e;const r=new Im;if(Yg==null){Yg=sw(ym)}if(tw==null){tw=sw(Mm)}_m(r,"'",gg);_m(r,"{",Ym);_m(r,"}",tg);_m(r,"[",eg);_m(r,"]",rg);_m(r,"(",ng);_m(r,")",ig);_m(r,"<",sg);_m(r,">",og);_m(r,"(",lg);_m(r,")",ug);_m(r,"「",ag);_m(r,"」",fg);_m(r,"『",hg);_m(r,"』",cg);_m(r,"<",dg);_m(r,">",pg);_m(r,"&",mg);_m(r,"*",wg);_m(r,"@",bg);_m(r,"`",kg);_m(r,"^",yg);_m(r,":",Mg);_m(r,",",xg);_m(r,"$",Og);_m(r,".",Sg);_m(r,"=",Tg);_m(r,"!",Eg);_m(r,"-",Ag);_m(r,"%",$g);_m(r,"|",Rg);_m(r,"+",Cg);_m(r,"#",Lg);_m(r,"?",Ng);_m(r,'"',jg);_m(r,"/",Dg);_m(r,";",Ig);_m(r,"~",Hg);_m(r,"_",zg);_m(r,"\\",vg);_m(r,"・",Pg);const n=Hm(r,Wg,Zm,{[xm]:true});Hm(n,Wg,n);const i=Hm(n,Fg,Fm,{[Tm]:true});const s=Hm(n,qg,qm,{[Em]:true});const o=Hm(r,Fg,Bm,{[Om]:true});Hm(o,Wg,i);Hm(o,Fg,o);Hm(i,Wg,i);Hm(i,Fg,i);const l=Hm(r,qg,Um,{[Sm]:true});Hm(l,Fg);Hm(l,Wg,s);Hm(l,qg,l);Hm(s,Wg,s);Hm(s,Fg);Hm(s,qg,s);const u=_m(r,Gg,Xm,{[Lm]:true});const a=_m(r,Vg,Qm,{[Lm]:true});const f=Hm(r,Jg,Qm,{[Lm]:true});_m(r,Xg,f);_m(a,Gg,u);_m(a,Xg,f);Hm(a,Jg,f);_m(f,Vg);_m(f,Gg);Hm(f,Jg,f);_m(f,Xg,f);const h=Hm(r,Kg,_g,{[$m]:true});_m(h,"#");Hm(h,Kg,h);_m(h,Zg,h);const c=_m(h,Qg);_m(c,"#");Hm(c,Kg,h);const d=[[Fg,o],[Wg,i]];const p=[[Fg,null],[qg,l],[Wg,s]];for(let t=0;t<Yg.length;t++){iw(r,Yg[t],Wm,Bm,d)}for(let t=0;t<tw.length;t++){iw(r,tw[t],Jm,Um,p)}jm(Wm,{tld:true,ascii:true},e);jm(Jm,{utld:true,alpha:true},e);iw(r,"file",Vm,Bm,d);iw(r,"mailto",Vm,Bm,d);iw(r,"http",Gm,Bm,d);iw(r,"https",Gm,Bm,d);iw(r,"ftp",Gm,Bm,d);iw(r,"ftps",Gm,Bm,d);jm(Vm,{scheme:true,ascii:true},e);jm(Gm,{slashscheme:true,ascii:true},e);t=t.sort(((t,e)=>t[0]>e[0]?1:-1));for(let e=0;e<t.length;e++){const n=t[e][0];const i=t[e][1];const s=i?{[Rm]:true}:{[Cm]:true};if(n.indexOf("-")>=0){s[Am]=true}else if(!Fg.test(n)){s[xm]=true}else if(Wg.test(n)){s[Tm]=true}else{s[Om]=true}zm(r,n,n,s)}zm(r,"localhost",Km,{ascii:true});r.jd=new Im(Bg);return{start:r,tokens:Object.assign({groups:e},Ug)}}function rw(t,e){const r=nw(e.replace(/[A-Z]/g,(t=>t.toLowerCase())));const n=r.length;const i=[];let s=0;let o=0;while(o<n){let l=t;let u=null;let a=0;let f=null;let h=-1;let c=-1;while(o<n&&(u=l.go(r[o]))){l=u;if(l.accepts()){h=0;c=0;f=l}else if(h>=0){h+=r[o].length;c++}a+=r[o].length;s+=r[o].length;o++}s-=h;o-=c;a-=h;i.push({t:f.t,v:e.slice(s-a,s),s:s-a,e:s})}return i}function nw(t){const e=[];const r=t.length;let n=0;while(n<r){let i=t.charCodeAt(n);let s;let o=i<55296||i>56319||n+1===r||(s=t.charCodeAt(n+1))<56320||s>57343?t[n]:t.slice(n,n+2);e.push(o);n+=o.length}return e}function iw(t,e,r,n,i){let s;const o=e.length;for(let r=0;r<o-1;r++){const o=e[r];if(t.j[o]){s=t.j[o]}else{s=new Im(n);s.jr=i.slice();t.j[o]=s}t=s}s=new Im(r);s.jr=i.slice();t.j[e[o-1]]=s;return s}function sw(t){const e=[];const r=[];let n=0;let i="0123456789";while(n<t.length){let s=0;while(i.indexOf(t[n+s])>=0){s++}if(s>0){e.push(r.join(""));for(let e=parseInt(t.substring(n,n+s),10);e>0;e--){r.pop()}n+=s}else{r.push(t[n]);n++}}return e}const ow={defaultProtocol:"http",events:null,format:uw,formatHref:uw,nl2br:false,tagName:"a",target:null,rel:null,validate:true,truncate:Infinity,className:null,attributes:null,ignoreTags:[],render:null};function lw(t,e=null){let r=Object.assign({},ow);if(t){r=Object.assign(r,t instanceof lw?t.o:t)}const n=r.ignoreTags;const i=[];for(let t=0;t<n.length;t++){i.push(n[t].toUpperCase())}this.o=r;if(e){this.defaultRender=e}this.ignoreTags=i}lw.prototype={o:ow,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,r){const n=e!=null;let i=this.o[t];if(!i){return i}if(typeof i==="object"){i=r.t in i?i[r.t]:ow[t];if(typeof i==="function"&&n){i=i(e,r)}}else if(typeof i==="function"&&n){i=i(e,r.t,r)}return i},getObj(t,e,r){let n=this.o[t];if(typeof n==="function"&&e!=null){n=n(e,r.t,r)}return n},render(t){const e=t.render(this);const r=this.get("render",null,t)||this.defaultRender;return r(e,t.t,t)}};function uw(t){return t}function aw(t,e){this.t="token";this.v=t;this.tk=e}aw.prototype={isLink:false,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString();const r=t.get("truncate",e,this);const n=t.get("format",e,this);return r&&n.length>r?n.substring(0,r)+"…":n},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=ow.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this;const r=this.toHref(t.get("defaultProtocol"));const n=t.get("formatHref",r,this);const i=t.get("tagName",r,e);const s=this.toFormattedString(t);const o={};const l=t.get("className",r,e);const u=t.get("target",r,e);const a=t.get("rel",r,e);const f=t.getObj("attributes",r,e);const h=t.getObj("events",r,e);o.href=n;if(l){o.class=l}if(u){o.target=u}if(a){o.rel=a}if(f){Object.assign(o,f)}return{tagName:i,attributes:o,content:s,eventListeners:h}}};function fw(t,e){class r extends aw{constructor(e,r){super(e,r);this.t=t}}for(const t in e){r.prototype[t]=e[t]}r.t=t;return r}const hw=fw("email",{isLink:true,toHref(){return"mailto:"+this.toString()}});const cw=fw("text");const dw=fw("nl");const pw=fw("url",{isLink:true,toHref(t=ow.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Km&&t[1].t===Mg}});const mw=t=>new Im(t);function gw({groups:t}){const e=t.domain.concat([mg,wg,bg,vg,kg,yg,Og,Tg,Ag,Zm,$g,Rg,Cg,Lg,Dg,Bg,Hg,zg]);const r=[gg,Mg,xg,Sg,Eg,$g,Ng,jg,Ig,sg,og,Ym,tg,rg,eg,ng,ig,lg,ug,ag,fg,hg,cg,dg,pg];const n=[mg,gg,wg,vg,kg,yg,Og,Tg,Ag,Ym,tg,$g,Rg,Cg,Lg,Ng,Dg,Bg,Hg,zg];const i=mw();const s=_m(i,Hg);Dm(s,n,s);Dm(s,t.domain,s);const o=mw(),l=mw(),u=mw();Dm(i,t.domain,o);Dm(i,t.scheme,l);Dm(i,t.slashscheme,u);Dm(o,n,s);Dm(o,t.domain,o);const a=_m(o,bg);_m(s,bg,a);_m(l,bg,a);_m(u,bg,a);const f=_m(s,Sg);Dm(f,n,s);Dm(f,t.domain,s);const h=mw();Dm(a,t.domain,h);Dm(h,t.domain,h);const c=_m(h,Sg);Dm(c,t.domain,h);const d=mw(hw);Dm(c,t.tld,d);Dm(c,t.utld,d);_m(a,Km,d);const p=_m(h,Ag);_m(p,Ag,p);Dm(p,t.domain,h);Dm(d,t.domain,h);_m(d,Sg,c);_m(d,Ag,p);const m=_m(d,Mg);Dm(m,t.numeric,hw);const g=_m(o,Ag);const w=_m(o,Sg);_m(g,Ag,g);Dm(g,t.domain,o);Dm(w,n,s);Dm(w,t.domain,o);const b=mw(pw);Dm(w,t.tld,b);Dm(w,t.utld,b);Dm(b,t.domain,o);Dm(b,n,s);_m(b,Sg,w);_m(b,Ag,g);_m(b,bg,a);const v=_m(b,Mg);const k=mw(pw);Dm(v,t.numeric,k);const y=mw(pw);const M=mw();Dm(y,e,y);Dm(y,r,M);Dm(M,e,y);Dm(M,r,M);_m(b,Dg,y);_m(k,Dg,y);const x=_m(l,Mg);const O=_m(u,Mg);const S=_m(O,Dg);const T=_m(S,Dg);Dm(l,t.domain,o);_m(l,Sg,w);_m(l,Ag,g);Dm(u,t.domain,o);_m(u,Sg,w);_m(u,Ag,g);Dm(x,t.domain,y);_m(x,Dg,y);_m(x,Ng,y);Dm(T,t.domain,y);Dm(T,e,y);_m(T,Dg,y);const E=[[Ym,tg],[eg,rg],[ng,ig],[sg,og],[lg,ug],[ag,fg],[hg,cg],[dg,pg]];for(let t=0;t<E.length;t++){const[n,i]=E[t];const s=_m(y,n);_m(M,n,s);_m(s,i,y);const o=mw(pw);Dm(s,e,o);const l=mw();Dm(s,r);Dm(o,e,o);Dm(o,r,l);Dm(l,e,o);Dm(l,r,l);_m(o,i,y);_m(l,i,y)}_m(i,Km,b);_m(i,Xm,dw);return{start:i,tokens:Ug}}function ww(t,e,r){let n=r.length;let i=0;let s=[];let o=[];while(i<n){let l=t;let u=null;let a=null;let f=0;let h=null;let c=-1;while(i<n&&!(u=l.go(r[i].t))){o.push(r[i++])}while(i<n&&(a=u||l.go(r[i].t))){u=null;l=a;if(l.accepts()){c=0;h=l}else if(c>=0){c++}i++;f++}if(c<0){i-=f;if(i<n){o.push(r[i]);i++}}else{if(o.length>0){s.push(bw(cw,e,o));o=[]}i-=c;f-=c;const t=h.t;const n=r.slice(i-f,i);s.push(bw(t,e,n))}}if(o.length>0){s.push(bw(cw,e,o))}return s}function bw(t,e,r){const n=r[0].s;const i=r[r.length-1].e;const s=e.slice(n,i);return new t(s,r)}const vw=typeof console!=="undefined"&&console&&console.warn||(()=>{});const kw="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.";const yw={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:false};function Mw(){Im.groups={};yw.scanner=null;yw.parser=null;yw.tokenQueue=[];yw.pluginQueue=[];yw.customSchemes=[];yw.initialized=false;return yw}function xw(t,e=false){if(yw.initialized){vw(`linkifyjs: already initialized - will not register custom scheme "${t}" ${kw}`)}if(!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t)){throw new Error(`linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat`)}yw.customSchemes.push([t,e])}function Ow(){yw.scanner=ew(yw.customSchemes);for(let t=0;t<yw.tokenQueue.length;t++){yw.tokenQueue[t][1]({scanner:yw.scanner})}yw.parser=gw(yw.scanner.tokens);for(let t=0;t<yw.pluginQueue.length;t++){yw.pluginQueue[t][1]({scanner:yw.scanner,parser:yw.parser})}yw.initialized=true;return yw}function Sw(t){if(!yw.initialized){Ow()}return ww(yw.parser.start,t,rw(yw.scanner.start,t))}Sw.scan=rw;function Tw(t,e=null,r=null){if(e&&typeof e==="object"){if(r){throw Error(`linkifyjs: Invalid link type ${e}; must be a string`)}r=e;e=null}const n=new lw(r);const i=Sw(t);const s=[];for(let t=0;t<i.length;t++){const r=i[t];if(r.isLink&&(!e||r.t===e)&&n.check(r)){s.push(r.toFormattedObject(n))}}return s}var Ew="[\0- -\u2029 ]";var Aw=new RegExp(Ew);var $w=new RegExp(`${Ew}$`);var Rw=new RegExp(Ew,"g");function Cw(t){if(t.length===1){return t[0].isLink}if(t.length===3&&t[1].isLink){return["()","[]"].includes(t[0].value+t[2].value)}return false}function Lw(t){return new gi({key:new vi("autolink"),appendTransaction:(e,r,n)=>{const i=e.some((t=>t.docChanged))&&!r.doc.eq(n.doc);const s=e.some((t=>t.getMeta("preventAutolink")));if(!i||s){return}const{tr:o}=n;const l=th(r.doc,[...e]);const u=Ch(l);u.forEach((({newRange:e})=>{const r=rh(n.doc,e,(t=>t.isTextblock));let i;let s;if(r.length>1){i=r[0];s=n.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0," ")}else if(r.length){const t=n.doc.textBetween(e.from,e.to," "," ");if(!$w.test(t)){return}i=r[0];s=n.doc.textBetween(i.pos,e.to,void 0," ")}if(i&&s){const e=s.split(Aw).filter(Boolean);if(e.length<=0){return false}const r=e[e.length-1];const l=i.pos+s.lastIndexOf(r);if(!r){return false}const u=Sw(r).map((e=>e.toObject(t.defaultProtocol)));if(!Cw(u)){return false}u.filter((t=>t.isLink)).map((t=>({...t,from:l+t.start+1,to:l+t.end+1}))).filter((t=>{if(!n.schema.marks.code){return true}return!n.doc.rangeHasMark(t.from,t.to,n.schema.marks.code)})).filter((e=>t.validate(e.value))).filter((e=>t.shouldAutoLink(e.value))).forEach((e=>{if(Lh(e.from,e.to,n.doc).some((e=>e.mark.type===t.type))){return}o.addMark(e.from,e.to,t.type.create({href:e.href}))}))}}));if(!o.steps.length){return}return o}})}function Nw(t){return new gi({key:new vi("handleClickLink"),props:{handleClick:(e,r,n)=>{var i,s;if(n.button!==0){return false}if(!e.editable){return false}let o=null;if(n.target instanceof HTMLAnchorElement){o=n.target}else{let t=n.target;const e=[];while(t.nodeName!=="DIV"){e.push(t);t=t.parentNode}o=e.find((t=>t.nodeName==="A"))}if(!o){return false}const l=Ah(e.state,t.type.name);const u=(i=o==null?void 0:o.href)!=null?i:l.href;const a=(s=o==null?void 0:o.target)!=null?s:l.target;if(t.enableClickSelection){t.editor.commands.extendMarkRange(t.type.name)}if(o&&u){window.open(u,a);return true}return false}}})}function jw(t){return new gi({key:new vi("handlePasteLink"),props:{handlePaste:(e,r,n)=>{const{shouldAutoLink:i}=t;const{state:s}=e;const{selection:o}=s;const{empty:l}=o;if(l){return false}let u="";n.content.forEach((t=>{u+=t.textContent}));const a=Tw(u,{defaultProtocol:t.defaultProtocol}).find((t=>t.isLink&&t.value===u));if(!u||!a||i!==void 0&&!i(a.href)){return false}return t.editor.commands.setMark(t.type,{href:a.href})}}})}function Pw(t,e){const r=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];if(e){e.forEach((t=>{const e=typeof t==="string"?t:t.scheme;if(e){r.push(e)}}))}return!t||t.replace(Rw,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Iw=Mc.create({name:"link",priority:1e3,keepOnSplit:false,exitable:true,onCreate(){if(this.options.validate&&!this.options.shouldAutoLink){this.options.shouldAutoLink=this.options.validate;console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")}this.options.protocols.forEach((t=>{if(typeof t==="string"){xw(t);return}xw(t.scheme,t.optionalSlashes)}))},onDestroy(){Mw()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:true,enableClickSelection:false,linkOnPaste:true,autolink:true,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Pw(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");if(!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Pw(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return false}return null}}]},renderHTML({HTMLAttributes:t}){if(!this.options.isAllowedUri(t.href,{defaultValidate:t=>!!Pw(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return["a",dh(this.options.HTMLAttributes,{...t,href:""}),0]}return["a",dh(this.options.HTMLAttributes,t),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var r;const n=((r=t.attrs)==null?void 0:r.href)||"";const i=e.renderChildren(t);return`[${i}](${n})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:r}=t;if(!this.options.isAllowedUri(r,{defaultValidate:t=>!!Pw(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return false}return e().setMark(this.name,t).setMeta("preventAutolink",true).run()},toggleLink:t=>({chain:e})=>{const{href:r}=t||{};if(r&&!this.options.isAllowedUri(r,{defaultValidate:t=>!!Pw(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return false}return e().toggleMark(this.name,t,{extendEmptyMarkRange:true}).setMeta("preventAutolink",true).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:true}).setMeta("preventAutolink",true).run()}},addPasteRules(){return[cd({find:t=>{const e=[];if(t){const{protocols:r,defaultProtocol:n}=this.options;const i=Tw(t).filter((t=>t.isLink&&this.options.isAllowedUri(t.value,{defaultValidate:t=>!!Pw(t,r),protocols:r,defaultProtocol:n})));if(i.length){i.forEach((t=>{if(!this.options.shouldAutoLink(t.value)){return}e.push({text:t.value,data:{href:t.href},index:t.start})}))}}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[];const{protocols:e,defaultProtocol:r}=this.options;if(this.options.autolink){t.push(Lw({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:t=>this.options.isAllowedUri(t,{defaultValidate:t=>!!Pw(t,e),protocols:e,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink}))}if(this.options.openOnClick===true){t.push(Nw({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection}))}if(this.options.linkOnPaste){t.push(jw({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink}))}return t}});var Dw=Iw;var Hw=Object.defineProperty;var zw=(t,e)=>{for(var r in e)Hw(t,r,{get:e[r],enumerable:true})};var _w="listItem";var Bw="textStyle";var Uw=/^\s*([-+*])\s$/;var Fw=hd.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:false,keepAttributes:false}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",dh(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||t.ordered){return[]}return{type:"bulletList",content:t.items?e.parseChildren(t.items):[]}},renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n")},markdownOptions:{indentsContent:true},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>{if(this.options.keepAttributes){return e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(_w,this.editor.getAttributes(Bw)).run()}return t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Zc({find:Uw,type:this.type});if(this.options.keepMarks||this.options.keepAttributes){t=Zc({find:Uw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Bw),editor:this.editor})}return[t]}});var qw=hd.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:true,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",dh(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item"){return[]}let r=[];if(t.tokens&&t.tokens.length>0){const n=t.tokens.some((t=>t.type==="paragraph"));if(n){r=e.parseChildren(t.tokens)}else{const n=t.tokens[0];if(n&&n.type==="text"&&n.tokens&&n.tokens.length>0){const i=e.parseInline(n.tokens);r=[{type:"paragraph",content:i}];if(t.tokens.length>1){const n=t.tokens.slice(1);const i=e.parseChildren(n);r.push(...i)}}else{r=e.parseChildren(t.tokens)}}}if(r.length===0){r=[{type:"paragraph",content:[]}]}return{type:"listItem",content:r}},renderMarkdown:(t,e,r)=>ad(t,e,(t=>{if(t.parentType==="bulletList"){return"- "}if(t.parentType==="orderedList"){return`${t.index+1}. `}return"- "}),r),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});var Kw={};zw(Kw,{findListItemPos:()=>Ww,getNextListDepth:()=>Jw,handleBackspace:()=>Qw,handleDelete:()=>tb,hasListBefore:()=>Vw,hasListItemAfter:()=>eb,hasListItemBefore:()=>Gw,listItemHasSubList:()=>Zw,nextListIsDeeper:()=>Xw,nextListIsHigher:()=>Yw});var Ww=(t,e)=>{const{$from:r}=e.selection;const n=Za(t,e.schema);let i=null;let s=r.depth;let o=r.pos;let l=null;while(s>0&&l===null){i=r.node(s);if(i.type===n){l=s}else{s-=1;o-=1}}if(l===null){return null}return{$pos:e.doc.resolve(o),depth:l}};var Jw=(t,e)=>{const r=Ww(t,e);if(!r){return false}const[,n]=Nh(e,t,r.$pos.pos+4);return n};var Vw=(t,e,r)=>{const{$anchor:n}=t.selection;const i=Math.max(0,n.pos-2);const s=t.doc.resolve(i).node();if(!s||!r.includes(s.type.name)){return false}return true};var Gw=(t,e)=>{var r;const{$anchor:n}=e.selection;const i=e.doc.resolve(n.pos-2);if(i.index()===0){return false}if(((r=i.nodeBefore)==null?void 0:r.type.name)!==t){return false}return true};var Zw=(t,e,r)=>{if(!r){return false}const n=Za(t,e.schema);let i=false;r.descendants((t=>{if(t.type===n){i=true}}));return i};var Qw=(t,e,r)=>{if(t.commands.undoInputRule()){return true}if(t.state.selection.from!==t.state.selection.to){return false}if(!If(t.state,e)&&Vw(t.state,e,r)){const{$anchor:r}=t.state.selection;const n=t.state.doc.resolve(r.before()-1);const i=[];n.node().descendants(((t,r)=>{if(t.type.name===e){i.push({node:t,pos:r})}}));const s=i.at(-1);if(!s){return false}const o=t.state.doc.resolve(n.start()+s.pos+1);return t.chain().cut({from:r.start()-1,to:r.end()+1},o.end()).joinForward().run()}if(!If(t.state,e)){return false}if(!_h(t.state)){return false}const n=Ww(e,t.state);if(!n){return false}const i=t.state.doc.resolve(n.$pos.pos-2);const s=i.node(n.depth);const o=Zw(e,t.state,s);if(Gw(e,t.state)&&!o){return t.commands.joinItemBackward()}return t.chain().liftListItem(e).run()};var Xw=(t,e)=>{const r=Jw(t,e);const n=Ww(t,e);if(!n||!r){return false}if(r>n.depth){return true}return false};var Yw=(t,e)=>{const r=Jw(t,e);const n=Ww(t,e);if(!n||!r){return false}if(r<n.depth){return true}return false};var tb=(t,e)=>{if(!If(t.state,e)){return false}if(!zh(t.state,e)){return false}const{selection:r}=t.state;const{$from:n,$to:i}=r;if(!r.empty&&n.sameParent(i)){return false}if(Xw(e,t.state)){return t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run()}if(Yw(e,t.state)){return t.chain().joinForward().joinBackward().run()}return t.commands.joinItemForward()};var eb=(t,e)=>{var r;const{$anchor:n}=e.selection;const i=e.doc.resolve(n.pos-n.parentOffset-2);if(i.index()===i.parent.childCount-1){return false}if(((r=i.nodeAfter)==null?void 0:r.type.name)!==t){return false}return true};var rb=Lc.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:r})=>{if(t.state.schema.nodes[r]===void 0){return}if(tb(t,r)){e=true}}));return e},"Mod-Delete":({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:r})=>{if(t.state.schema.nodes[r]===void 0){return}if(tb(t,r)){e=true}}));return e},Backspace:({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:r,wrapperNames:n})=>{if(t.state.schema.nodes[r]===void 0){return}if(Qw(t,r,n)){e=true}}));return e},"Mod-Backspace":({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:r,wrapperNames:n})=>{if(t.state.schema.nodes[r]===void 0){return}if(Qw(t,r,n)){e=true}}));return e}}}});var nb=/^(\s*)(\d+)\.\s+(.*)$/;var ib=/^\s/;function sb(t){const e=[];let r=0;let n=0;while(r<t.length){const i=t[r];const s=i.match(nb);if(!s){break}const[,o,l,u]=s;const a=o.length;let f=u;let h=r+1;const c=[i];while(h<t.length){const e=t[h];const r=e.match(nb);if(r){break}if(e.trim()===""){c.push(e);f+="\n";h+=1}else if(e.match(ib)){c.push(e);f+=`\n${e.slice(a+2)}`;h+=1}else{break}}e.push({indent:a,number:parseInt(l,10),content:f.trim(),raw:c.join("\n")});n=h;r=h}return[e,n]}function ob(t,e,r){var n;const i=[];let s=0;while(s<t.length){const o=t[s];if(o.indent===e){const l=o.content.split("\n");const u=((n=l[0])==null?void 0:n.trim())||"";const a=[];if(u){a.push({type:"paragraph",raw:u,tokens:r.inlineTokens(u)})}const f=l.slice(1).join("\n").trim();if(f){const t=r.blockTokens(f);a.push(...t)}let h=s+1;const c=[];while(h<t.length&&t[h].indent>e){c.push(t[h]);h+=1}if(c.length>0){const t=Math.min(...c.map((t=>t.indent)));const e=ob(c,t,r);a.push({type:"list",ordered:true,start:c[0].number,items:e,raw:c.map((t=>t.raw)).join("\n")})}i.push({type:"list_item",raw:o.raw,tokens:a});s=h}else{s+=1}}return i}function lb(t,e){return t.map((t=>{if(t.type!=="list_item"){return e.parseChildren([t])[0]}const r=[];if(t.tokens&&t.tokens.length>0){t.tokens.forEach((t=>{if(t.type==="paragraph"||t.type==="list"||t.type==="blockquote"||t.type==="code"){r.push(...e.parseChildren([t]))}else if(t.type==="text"&&t.tokens){const n=e.parseChildren([t]);r.push({type:"paragraph",content:n})}else{const n=e.parseChildren([t]);if(n.length>0){r.push(...n)}}}))}return{type:"listItem",content:r}}))}var ub="listItem";var ab="textStyle";var fb=/^(\d+)\.\s$/;var hb=hd.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:false,keepAttributes:false}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...r}=t;return e===1?["ol",dh(this.options.HTMLAttributes,r),0]:["ol",dh(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered){return[]}const r=t.start||1;const n=t.items?lb(t.items,e):[];if(r!==1){return{type:"orderedList",attrs:{start:r},content:n}}return{type:"orderedList",content:n}},renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n")},markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/);const r=e==null?void 0:e.index;return r!==void 0?r:-1},tokenize:(t,e,r)=>{var n;const i=t.split("\n");const[s,o]=sb(i);if(s.length===0){return void 0}const l=ob(s,0,r);if(l.length===0){return void 0}const u=((n=s[0])==null?void 0:n.number)||1;return{type:"list",ordered:true,start:u,items:l,raw:i.slice(0,o).join("\n")}}},markdownOptions:{indentsContent:true},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>{if(this.options.keepAttributes){return e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ub,this.editor.getAttributes(ab)).run()}return t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Zc({find:fb,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});if(this.options.keepMarks||this.options.keepAttributes){t=Zc({find:fb,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(ab)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})}return[t]}});var cb=/^\s*(\[([( |x])?\])\s$/;var db=hd.create({name:"taskItem",addOptions(){return{nested:false,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:true,addAttributes(){return{checked:{default:false,keepOnSplit:false,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",dh(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const r=[];if(t.tokens&&t.tokens.length>0){r.push(e.createNode("paragraph",{},e.parseInline(t.tokens)))}else if(t.text){r.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})]))}else{r.push(e.createNode("paragraph",{},[]))}if(t.nestedTokens&&t.nestedTokens.length>0){const n=e.parseChildren(t.nestedTokens);r.push(...n)}return e.createNode("taskItem",{checked:t.checked||false},r)},renderMarkdown:(t,e)=>{var r;const n=((r=t.attrs)==null?void 0:r.checked)?"x":" ";const i=`- [${n}] `;return ad(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};if(!this.options.nested){return t}return{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}},addNodeView(){return({node:t,HTMLAttributes:e,getPos:r,editor:n})=>{const i=document.createElement("li");const s=document.createElement("label");const o=document.createElement("span");const l=document.createElement("input");const u=document.createElement("div");const a=t=>{var e,r;l.ariaLabel=((r=(e=this.options.a11y)==null?void 0:e.checkboxLabel)==null?void 0:r.call(e,t,l.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};a(t);s.contentEditable="false";l.type="checkbox";l.addEventListener("mousedown",(t=>t.preventDefault()));l.addEventListener("change",(e=>{if(!n.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:i}=e.target;if(n.isEditable&&typeof r==="function"){n.chain().focus(void 0,{scrollIntoView:false}).command((({tr:t})=>{const e=r();if(typeof e!=="number"){return false}const n=t.doc.nodeAt(e);t.setNodeMarkup(e,void 0,{...n==null?void 0:n.attrs,checked:i});return true})).run()}if(!n.isEditable&&this.options.onReadOnlyChecked){if(!this.options.onReadOnlyChecked(t,i)){l.checked=!l.checked}}}));Object.entries(this.options.HTMLAttributes).forEach((([t,e])=>{i.setAttribute(t,e)}));i.dataset.checked=t.attrs.checked;l.checked=t.attrs.checked;s.append(l,o);i.append(s,u);Object.entries(e).forEach((([t,e])=>{i.setAttribute(t,e)}));return{dom:i,contentDOM:u,update:t=>{if(t.type!==this.type){return false}i.dataset.checked=t.attrs.checked;l.checked=t.attrs.checked;a(t);return true}}}},addInputRules(){return[Zc({find:cb,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}});var pb=hd.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",dh(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n")},markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const r=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return r!==void 0?r:-1},tokenize(t,e,r){const n=t=>{const e=ud(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:t[3].toLowerCase()==="x"}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:r.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:n},r);if(e){return[{type:"taskList",raw:e.raw,items:e.items}]}return r.blockTokens(t)};const i=ud(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:t[3].toLowerCase()==="x"}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:r.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:n},r);if(!i){return void 0}return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:true},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Lc.create({name:"listKit",addExtensions(){const t=[];if(this.options.bulletList!==false){t.push(Fw.configure(this.options.bulletList))}if(this.options.listItem!==false){t.push(qw.configure(this.options.listItem))}if(this.options.listKeymap!==false){t.push(rb.configure(this.options.listKeymap))}if(this.options.orderedList!==false){t.push(hb.configure(this.options.orderedList))}if(this.options.taskItem!==false){t.push(db.configure(this.options.taskItem))}if(this.options.taskList!==false){t.push(pb.configure(this.options.taskList))}return t}});var mb=hd.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",dh(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const r=t.tokens||[];if(r.length===1&&r[0].type==="image"){return e.parseChildren([r[0]])}return e.createNode("paragraph",void 0,e.parseInline(r))},renderMarkdown:(t,e)=>{if(!t||!Array.isArray(t.content)){return""}return e.renderChildren(t.content)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var gb=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/;var wb=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g;var bb=Mc.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:false,getAttrs:t=>t.includes("line-through")?{}:false}]},renderHTML({HTMLAttributes:t}){return["s",dh(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Jc({find:gb,type:this.type})]},addPasteRules(){return[cd({find:wb,type:this.type})]}});var vb=hd.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""});var kb=Mc.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:false,getAttrs:t=>t.includes("underline")?{}:false}]},renderHTML({HTMLAttributes:t}){return["u",dh(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,r){const n=/^(\+\+)([\s\S]+?)(\+\+)/;const i=n.exec(t);if(!i){return void 0}const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:r.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function yb(t={}){return new gi({view(e){return new Mb(e,t)}})}class Mb{constructor(t,e){var r;this.editorView=t;this.cursorPos=null;this.element=null;this.timeout=-1;this.width=(r=e.width)!==null&&r!==void 0?r:1;this.color=e.color===false?undefined:e.color||"black";this.class=e.class;this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let r=t=>{this[e](t)};t.dom.addEventListener(e,r);return{name:e,handler:r}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc){if(this.cursorPos>t.state.doc.content.size)this.setCursor(null);else this.updateOverlay()}}setCursor(t){if(t==this.cursorPos)return;this.cursorPos=t;if(t==null){this.element.parentNode.removeChild(this.element);this.element=null}else{this.updateOverlay()}}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos);let e=!t.parent.inlineContent,r;let n=this.editorView.dom,i=n.getBoundingClientRect();let s=i.width/n.offsetWidth,o=i.height/n.offsetHeight;if(e){let e=t.nodeBefore,n=t.nodeAfter;if(e||n){let t=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(t){let i=t.getBoundingClientRect();let s=e?i.bottom:i.top;if(e&&n)s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;let l=this.width/2*o;r={left:i.left,right:i.right,top:s-l,bottom:s+l}}}}if(!r){let t=this.editorView.coordsAtPos(this.cursorPos);let e=this.width/2*s;r={left:t.left-e,right:t.left+e,top:t.top,bottom:t.bottom}}let l=this.editorView.dom.offsetParent;if(!this.element){this.element=l.appendChild(document.createElement("div"));if(this.class)this.element.className=this.class;this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;";if(this.color){this.element.style.backgroundColor=this.color}}this.element.classList.toggle("prosemirror-dropcursor-block",e);this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let u,a;if(!l||l==document.body&&getComputedStyle(l).position=="static"){u=-pageXOffset;a=-pageYOffset}else{let t=l.getBoundingClientRect();let e=t.width/l.offsetWidth,r=t.height/l.offsetHeight;u=t.left-l.scrollLeft*e;a=t.top-l.scrollTop*r}this.element.style.left=(r.left-u)/s+"px";this.element.style.top=(r.top-a)/o+"px";this.element.style.width=(r.right-r.left)/s+"px";this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(t){clearTimeout(this.timeout);this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});let r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside);let n=r&&r.type.spec.disableDropCursor;let i=typeof n=="function"?n(this.editorView,e,t):n;if(e&&!i){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=En(this.editorView.state.doc,t,this.editorView.dragging.slice);if(e!=null)t=e}this.setCursor(t);this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){if(!this.editorView.dom.contains(t.relatedTarget))this.setCursor(null)}}class xb extends Vn{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return xb.valid(r)?new xb(r):Vn.near(r)}content(){return be.empty}eq(t){return t instanceof xb&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new xb(t.resolve(e.pos))}getBookmark(){return new Ob(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!Sb(t)||!Tb(t))return false;let r=e.type.spec.allowGapCursor;if(r!=null)return r;let n=e.contentMatchAt(t.index()).defaultType;return n&&n.isTextblock}static findGapCursorFrom(t,e,r=false){t:for(;;){if(!r&&xb.valid(t))return t;let n=t.pos,i=null;for(let r=t.depth;;r--){let s=t.node(r);if(e>0?t.indexAfter(r)<s.childCount:t.index(r)>0){i=s.child(e>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0){return null}n+=e;let o=t.doc.resolve(n);if(xb.valid(o))return o}for(;;){let s=e>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!ti.isSelectable(i)){t=t.doc.resolve(n+i.nodeSize*e);r=false;continue t}break}i=s;n+=e;let o=t.doc.resolve(n);if(xb.valid(o))return o}return null}}}xb.prototype.visible=false;xb.findFrom=xb.findGapCursorFrom;Vn.jsonID("gapcursor",xb);class Ob{constructor(t){this.pos=t}map(t){return new Ob(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return xb.valid(e)?new xb(e):Vn.near(e)}}function Sb(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),n=t.node(e);if(r==0){if(n.type.spec.isolating)return true;continue}for(let t=n.child(r-1);;t=t.lastChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function Tb(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),n=t.node(e);if(r==n.childCount){if(n.type.spec.isolating)return true;continue}for(let t=n.child(r);;t=t.firstChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function Eb(){return new gi({props:{decorations:Lb,createSelectionBetween(t,e,r){return e.pos==r.pos&&xb.valid(r)?new xb(r):null},handleClick:Rb,handleKeyDown:Ab,handleDOMEvents:{beforeinput:Cb}}})}const Ab=Da({ArrowLeft:$b("horiz",-1),ArrowRight:$b("horiz",1),ArrowUp:$b("vert",-1),ArrowDown:$b("vert",1)});function $b(t,e){const r=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(t,n,i){let s=t.selection;let o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Xn){if(!i.endOfTextblock(r)||o.depth==0)return false;l=false;o=t.doc.resolve(e>0?o.after():o.before())}let u=xb.findGapCursorFrom(o,e,l);if(!u)return false;if(n)n(t.tr.setSelection(new xb(u)));return true}}function Rb(t,e,r){if(!t||!t.editable)return false;let n=t.state.doc.resolve(e);if(!xb.valid(n))return false;let i=t.posAtCoords({left:r.clientX,top:r.clientY});if(i&&i.inside>-1&&ti.isSelectable(t.state.doc.nodeAt(i.inside)))return false;t.dispatch(t.state.tr.setSelection(new xb(n)));return true}function Cb(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof xb))return false;let{$from:r}=t.state.selection;let n=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!n)return false;let i=ce.empty;for(let t=n.length-1;t>=0;t--)i=ce.from(n[t].createAndFill(null,i));let s=t.state.tr.replace(r.pos,r.pos,new be(i,0,0));s.setSelection(Xn.near(s.doc.resolve(r.pos+1)));t.dispatch(s);return false}function Lb(t){if(!(t.selection instanceof xb))return null;let e=document.createElement("div");e.className="ProseMirror-gapcursor";return Du.create(t.doc,[ju.widget(t.selection.head,e,{key:"gapcursor"})])}var Nb=200;var jb=function t(){};jb.prototype.append=function t(e){if(!e.length){return this}e=jb.from(e);return!this.length&&e||e.length<Nb&&this.leafAppend(e)||this.length<Nb&&e.leafPrepend(this)||this.appendInner(e)};jb.prototype.prepend=function t(e){if(!e.length){return this}return jb.from(e).append(this)};jb.prototype.appendInner=function t(e){return new Ib(this,e)};jb.prototype.slice=function t(e,r){if(e===void 0)e=0;if(r===void 0)r=this.length;if(e>=r){return jb.empty}return this.sliceInner(Math.max(0,e),Math.min(this.length,r))};jb.prototype.get=function t(e){if(e<0||e>=this.length){return undefined}return this.getInner(e)};jb.prototype.forEach=function t(e,r,n){if(r===void 0)r=0;if(n===void 0)n=this.length;if(r<=n){this.forEachInner(e,r,n,0)}else{this.forEachInvertedInner(e,r,n,0)}};jb.prototype.map=function t(e,r,n){if(r===void 0)r=0;if(n===void 0)n=this.length;var i=[];this.forEach((function(t,r){return i.push(e(t,r))}),r,n);return i};jb.from=function t(e){if(e instanceof jb){return e}return e&&e.length?new Pb(e):jb.empty};var Pb=function(t){function e(e){t.call(this);this.values=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;var r={length:{configurable:true},depth:{configurable:true}};e.prototype.flatten=function t(){return this.values};e.prototype.sliceInner=function t(r,n){if(r==0&&n==this.length){return this}return new e(this.values.slice(r,n))};e.prototype.getInner=function t(e){return this.values[e]};e.prototype.forEachInner=function t(e,r,n,i){for(var s=r;s<n;s++){if(e(this.values[s],i+s)===false){return false}}};e.prototype.forEachInvertedInner=function t(e,r,n,i){for(var s=r-1;s>=n;s--){if(e(this.values[s],i+s)===false){return false}}};e.prototype.leafAppend=function t(r){if(this.length+r.length<=Nb){return new e(this.values.concat(r.flatten()))}};e.prototype.leafPrepend=function t(r){if(this.length+r.length<=Nb){return new e(r.flatten().concat(this.values))}};r.length.get=function(){return this.values.length};r.depth.get=function(){return 0};Object.defineProperties(e.prototype,r);return e}(jb);jb.empty=new Pb([]);var Ib=function(t){function e(e,r){t.call(this);this.left=e;this.right=r;this.length=e.length+r.length;this.depth=Math.max(e.depth,r.depth)+1}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.flatten=function t(){return this.left.flatten().concat(this.right.flatten())};e.prototype.getInner=function t(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)};e.prototype.forEachInner=function t(e,r,n,i){var s=this.left.length;if(r<s&&this.left.forEachInner(e,r,Math.min(n,s),i)===false){return false}if(n>s&&this.right.forEachInner(e,Math.max(r-s,0),Math.min(this.length,n)-s,i+s)===false){return false}};e.prototype.forEachInvertedInner=function t(e,r,n,i){var s=this.left.length;if(r>s&&this.right.forEachInvertedInner(e,r-s,Math.max(n,s)-s,i+s)===false){return false}if(n<s&&this.left.forEachInvertedInner(e,Math.min(r,s),n,i)===false){return false}};e.prototype.sliceInner=function t(e,r){if(e==0&&r==this.length){return this}var n=this.left.length;if(r<=n){return this.left.slice(e,r)}if(e>=n){return this.right.slice(e-n,r-n)}return this.left.slice(e,n).append(this.right.slice(0,r-n))};e.prototype.leafAppend=function t(r){var n=this.right.leafAppend(r);if(n){return new e(this.left,n)}};e.prototype.leafPrepend=function t(r){var n=this.left.leafPrepend(r);if(n){return new e(n,this.right)}};e.prototype.appendInner=function t(r){if(this.left.depth>=Math.max(this.right.depth,r.depth)+1){return new e(this.left,new e(this.right,r))}return new e(this,r)};return e}(jb);const Db=500;class Hb{constructor(t,e){this.items=t;this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--){let t=this.items.get(r-1);if(t.selection){--r;break}}let n,i;if(e){n=this.remapping(r,this.items.length);i=n.maps.length}let s=t.tr;let o,l;let u=[],a=[];this.items.forEach(((t,e)=>{if(!t.step){if(!n){n=this.remapping(r,e+1);i=n.maps.length}i--;a.push(t);return}if(n){a.push(new _b(t.map));let e=t.step.map(n.slice(i)),r;if(e&&s.maybeStep(e).doc){r=s.mapping.maps[s.mapping.maps.length-1];u.push(new _b(r,undefined,undefined,u.length+a.length))}i--;if(r)n.appendMap(r,i)}else{s.maybeStep(t.step)}if(t.selection){o=n?t.selection.map(n.slice(i)):t.selection;l=new Hb(this.items.slice(0,r).append(a.reverse().concat(u)),this.eventCount-1);return false}}),this.items.length,0);return{remaining:l,transform:s,selection:o}}addTransform(t,e,r,n){let i=[],s=this.eventCount;let o=this.items,l=!n&&o.length?o.get(o.length-1):null;for(let r=0;r<t.steps.length;r++){let u=t.steps[r].invert(t.docs[r]);let a=new _b(t.mapping.maps[r],u,e),f;if(f=l&&l.merge(a)){a=f;if(r)i.pop();else o=o.slice(0,o.length-1)}i.push(a);if(e){s++;e=undefined}if(!n)l=a}let u=s-r.depth;if(u>Ub){o=zb(o,u);s-=u}return new Hb(o.append(i),s)}remapping(t,e){let r=new qr;this.items.forEach(((e,n)=>{let i=e.mirrorOffset!=null&&n-e.mirrorOffset>=t?r.maps.length-e.mirrorOffset:undefined;r.appendMap(e.map,i)}),t,e);return r}addMaps(t){if(this.eventCount==0)return this;return new Hb(this.items.append(t.map((t=>new _b(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],n=Math.max(0,this.items.length-e);let i=t.mapping;let s=t.steps.length;let o=this.eventCount;this.items.forEach((t=>{if(t.selection)o--}),n);let l=e;this.items.forEach((e=>{let n=i.getMirror(--l);if(n==null)return;s=Math.min(s,n);let u=i.maps[n];if(e.step){let s=t.steps[n].invert(t.docs[n]);let a=e.selection&&e.selection.map(i.slice(l+1,n));if(a)o++;r.push(new _b(u,s,a))}else{r.push(new _b(u))}}),n);let u=[];for(let t=e;t<s;t++)u.push(new _b(i.maps[t]));let a=this.items.slice(0,n).append(u).append(r);let f=new Hb(a,o);if(f.emptyItemCount()>Db)f=f.compress(this.items.length-r.length);return f}emptyItemCount(){let t=0;this.items.forEach((e=>{if(!e.step)t++}));return t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length;let n=[],i=0;this.items.forEach(((s,o)=>{if(o>=t){n.push(s);if(s.selection)i++}else if(s.step){let t=s.step.map(e.slice(r)),o=t&&t.getMap();r--;if(o)e.appendMap(o,r);if(t){let l=s.selection&&s.selection.map(e.slice(r));if(l)i++;let u=new _b(o.invert(),t,l),a,f=n.length-1;if(a=n.length&&n[f].merge(u))n[f]=a;else n.push(u)}}else if(s.map){r--}}),this.items.length,0);return new Hb(jb.from(n.reverse()),i)}}Hb.empty=new Hb(jb.empty,0);function zb(t,e){let r;t.forEach(((t,n)=>{if(t.selection&&e--==0){r=n;return false}}));return t.slice(r)}class _b{constructor(t,e,r,n){this.map=t;this.step=e;this.selection=r;this.mirrorOffset=n}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new _b(e.getMap().invert(),e,this.selection)}}}class Bb{constructor(t,e,r,n,i){this.done=t;this.undone=e;this.prevRanges=r;this.prevTime=n;this.prevComposition=i}}const Ub=20;function Fb(t,e,r,n){let i=r.getMeta(Qb),s;if(i)return i.historyState;if(r.getMeta(Xb))t=new Bb(t.done,t.undone,null,0,-1);let o=r.getMeta("appendedTransaction");if(r.steps.length==0){return t}else if(o&&o.getMeta(Qb)){if(o.getMeta(Qb).redo)return new Bb(t.done.addTransform(r,undefined,n,Zb(e)),t.undone,Kb(r.mapping.maps),t.prevTime,t.prevComposition);else return new Bb(t.done,t.undone.addTransform(r,undefined,n,Zb(e)),null,t.prevTime,t.prevComposition)}else if(r.getMeta("addToHistory")!==false&&!(o&&o.getMeta("addToHistory")===false)){let i=r.getMeta("composition");let s=t.prevTime==0||!o&&t.prevComposition!=i&&(t.prevTime<(r.time||0)-n.newGroupDelay||!qb(r,t.prevRanges));let l=o?Wb(t.prevRanges,r.mapping):Kb(r.mapping.maps);return new Bb(t.done.addTransform(r,s?e.selection.getBookmark():undefined,n,Zb(e)),Hb.empty,l,r.time,i==null?t.prevComposition:i)}else if(s=r.getMeta("rebased")){return new Bb(t.done.rebased(r,s),t.undone.rebased(r,s),Wb(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}else{return new Bb(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),Wb(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}}function qb(t,e){if(!e)return false;if(!t.docChanged)return true;let r=false;t.mapping.maps[0].forEach(((t,n)=>{for(let i=0;i<e.length;i+=2)if(t<=e[i+1]&&n>=e[i])r=true}));return r}function Kb(t){let e=[];for(let r=t.length-1;r>=0&&e.length==0;r--)t[r].forEach(((t,r,n,i)=>e.push(n,i)));return e}function Wb(t,e){if(!t)return null;let r=[];for(let n=0;n<t.length;n+=2){let i=e.map(t[n],1),s=e.map(t[n+1],-1);if(i<=s)r.push(i,s)}return r}function Jb(t,e,r){let n=Zb(e);let i=Qb.get(e).spec.config;let s=(r?t.undone:t.done).popEvent(e,n);if(!s)return null;let o=s.selection.resolve(s.transform.doc);let l=(r?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,n);let u=new Bb(r?l:s.remaining,r?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Qb,{redo:r,historyState:u})}let Vb=false,Gb=null;function Zb(t){let e=t.plugins;if(Gb!=e){Vb=false;Gb=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Vb=true;break}}return Vb}const Qb=new vi("history");const Xb=new vi("closeHistory");function Yb(t={}){t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500};return new gi({key:Qb,state:{init(){return new Bb(Hb.empty,Hb.empty,null,0,-1)},apply(e,r,n){return Fb(r,n,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(t,e){let r=e.inputType;let n=r=="historyUndo"?ev:r=="historyRedo"?rv:null;if(!n)return false;e.preventDefault();return n(t.state,t.dispatch)}}}})}function tv(t,e){return(r,n)=>{let i=Qb.getState(r);if(!i||(t?i.undone:i.done).eventCount==0)return false;if(n){let s=Jb(i,r,t);if(s)n(e?s.scrollIntoView():s)}return true}}const ev=tv(false,true);const rv=tv(true,true);Lc.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter((t=>t!=="")).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;const r=(t==null?void 0:t.mode)||this.options.mode;if(r==="textSize"){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize};this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;const r=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(r)}},addProseMirrorPlugins(){let t=false;return[new gi({key:new vi("characterCount"),appendTransaction:(e,r,n)=>{if(t){return}const i=this.options.limit;if(i===null||i===void 0||i===0){t=true;return}const s=this.storage.characters({node:n.doc});if(s>i){const e=s-i;const r=0;const o=e;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const l=n.tr.deleteRange(r,o);t=true;return l}t=true},filterTransaction:(t,e)=>{const r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0){return true}const n=this.storage.characters({node:e.doc});const i=this.storage.characters({node:t.doc});if(i<=r){return true}if(n>r&&i>r&&i<=n){return true}if(n>r&&i>r&&i>n){return false}const s=t.getMeta("paste");if(!s){return false}const o=t.selection.$head.pos;const l=i-r;const u=o-l;const a=o;t.deleteRange(u,a);const f=this.storage.characters({node:t.doc});if(f>r){return false}return true}})]}});var nv=Lc.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[yb(this.options)]}});Lc.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new gi({key:new vi("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:r,isFocused:n}=this.editor;const{anchor:i}=e;const s=[];if(!r||!n){return Du.create(t,[])}let o=0;if(this.options.mode==="deepest"){t.descendants(((t,e)=>{if(t.isText){return}const r=i>=e&&i<=e+t.nodeSize-1;if(!r){return false}o+=1}))}let l=0;t.descendants(((t,e)=>{if(t.isText){return false}const r=i>=e&&i<=e+t.nodeSize-1;if(!r){return false}l+=1;const n=this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1;if(n){return this.options.mode==="deepest"}s.push(ju.node(e,e+t.nodeSize,{class:this.options.className}))}));return Du.create(t,s)}}})]}});var iv=Lc.create({name:"gapCursor",addProseMirrorPlugins(){return[Eb()]},extendNodeSchema(t){var e;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ah(sh(t,"allowGapCursor",r)))!=null?e:null}}});Lc.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:true,showOnlyCurrent:true,includeChildren:false}},addProseMirrorPlugins(){return[new gi({key:new vi("placeholder"),props:{decorations:({doc:t,selection:e})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable;const{anchor:n}=e;const i=[];if(!r){return null}const s=this.editor.isEmpty;t.descendants(((t,e)=>{const r=n>=e&&n<=e+t.nodeSize;const o=!t.isLeaf&&Fh(t);if((r||!this.options.showOnlyCurrent)&&o){const n=[this.options.emptyNodeClass];if(s){n.push(this.options.emptyEditorClass)}const o=ju.node(e,e+t.nodeSize,{class:n.join(" "),"data-placeholder":typeof this.options.placeholder==="function"?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:r}):this.options.placeholder});i.push(o)}return this.options.includeChildren}));return Du.create(t,i)}}})]}});Lc.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new gi({key:new vi("selection"),props:{decorations(r){if(r.selection.empty||t.isFocused||!t.isEditable||qh(r.selection)||t.view.dragging){return null}return Du.create(r.doc,[ju.inline(r.selection.from,r.selection.to,{class:e.className})])}}})]}});function sv({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var ov=Lc.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new vi(this.name);const r=((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||this.options.node||"paragraph";const n=Object.entries(this.editor.schema.nodes).map((([,t])=>t)).filter((t=>(this.options.notAfter||[]).concat(r).includes(t.name)));return[new gi({key:e,appendTransaction:(t,n,i)=>{const{doc:s,tr:o,schema:l}=i;const u=e.getState(i);const a=s.content.size;const f=l.nodes[r];if(!u){return}return o.insert(a,f.create())},state:{init:(t,e)=>{const r=e.tr.doc.lastChild;return!sv({node:r,types:n})},apply:(t,e)=>{if(!t.docChanged){return e}const r=t.doc.lastChild;return!sv({node:r,types:n})}}})]}});var lv=Lc.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ev(t,e),redo:()=>({state:t,dispatch:e})=>rv(t,e)}},addProseMirrorPlugins(){return[Yb(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});var uv=Lc.create({name:"starterKit",addExtensions(){var t,e,r,n;const i=[];if(this.options.bold!==false){i.push(im.configure(this.options.bold))}if(this.options.blockquote!==false){i.push(Yp.configure(this.options.blockquote))}if(this.options.bulletList!==false){i.push(Fw.configure(this.options.bulletList))}if(this.options.code!==false){i.push(lm.configure(this.options.code))}if(this.options.codeBlock!==false){i.push(hm.configure(this.options.codeBlock))}if(this.options.document!==false){i.push(cm.configure(this.options.document))}if(this.options.dropcursor!==false){i.push(nv.configure(this.options.dropcursor))}if(this.options.gapcursor!==false){i.push(iv.configure(this.options.gapcursor))}if(this.options.hardBreak!==false){i.push(dm.configure(this.options.hardBreak))}if(this.options.heading!==false){i.push(pm.configure(this.options.heading))}if(this.options.undoRedo!==false){i.push(lv.configure(this.options.undoRedo))}if(this.options.horizontalRule!==false){i.push(mm.configure(this.options.horizontalRule))}if(this.options.italic!==false){i.push(km.configure(this.options.italic))}if(this.options.listItem!==false){i.push(qw.configure(this.options.listItem))}if(this.options.listKeymap!==false){i.push(rb.configure((t=this.options)==null?void 0:t.listKeymap))}if(this.options.link!==false){i.push(Iw.configure((e=this.options)==null?void 0:e.link))}if(this.options.orderedList!==false){i.push(hb.configure(this.options.orderedList))}if(this.options.paragraph!==false){i.push(mb.configure(this.options.paragraph))}if(this.options.strike!==false){i.push(bb.configure(this.options.strike))}if(this.options.text!==false){i.push(vb.configure(this.options.text))}if(this.options.underline!==false){i.push(kb.configure((r=this.options)==null?void 0:r.underline))}if(this.options.trailingNode!==false){i.push(ov.configure((n=this.options)==null?void 0:n.trailingNode))}return i}});var av=uv;var fv=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;var hv=hd.create({name:"image",addOptions(){return{inline:false,allowBase64:false,HTMLAttributes:{},resize:false}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:true,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",dh(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,r,n,i,s,o;const l=(r=(e=t.attrs)==null?void 0:e.src)!=null?r:"";const u=(i=(n=t.attrs)==null?void 0:n.alt)!=null?i:"";const a=(o=(s=t.attrs)==null?void 0:s.title)!=null?o:"";return a?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document==="undefined"||!this.editor.isEditable){return null}const{directions:t,minWidth:e,minHeight:r,alwaysPreserveAspectRatio:n}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach((([t,e])=>{if(e!=null){switch(t){case"width":case"height":break;default:l.setAttribute(t,e);break}}}));l.src=o.src;const u=new Xc({element:l,node:i,getPos:s,onResize:(t,e)=>{l.style.width=`${t}px`;l.style.height=`${e}px`},onCommit:(t,e)=>{const r=s();if(r===void 0){return}this.editor.chain().setNodeSelection(r).updateAttributes(this.name,{width:t,height:e}).run()},onUpdate:(t,e,r)=>{if(t.type!==i.type){return false}return true},options:{directions:t,min:{width:e,height:r},preserveAspectRatio:n===true}});const a=u.dom;a.style.visibility="hidden";a.style.pointerEvents="none";l.onload=()=>{a.style.visibility="";a.style.pointerEvents=""};return u}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Vc({find:fv,type:this.type,getAttributes:t=>{const[,,e,r,n]=t;return{src:r,alt:e,title:n}}})]}});var cv=hv;const dv=new Set(["http:","https:"]);const pv=t=>({HTMLAttributes:e})=>{const r=document.createElement("pos-image");const n=new URL(e.src,t);if(dv.has(n.protocol)){r.setAttribute("src",n.toString())}let i=["alt","title"];for(const t of i){if(e[t]){r.setAttribute(t,e[t])}}return{dom:r,ignoreMutation:()=>true}};const mv=t=>cv.extend({addNodeView(){return pv(t)}});const gv=new Set(["http:","https:","mailto:","tel:"]);const wv=t=>({HTMLAttributes:e})=>{const r=document.createElement("pos-rich-link");const n=new URL(e.href,t);if(gv.has(n.protocol)){r.setAttribute("uri",n.toString())}return{dom:r,contentDOM:r,ignoreMutation:()=>true}};const bv=t=>Dw.extend({addMarkView(){return wv(t)}});var vv={};var kv={};var yv;function Mv(){if(yv)return kv;yv=1;Object.defineProperty(kv,"__esModule",{value:true});kv.partition=void 0;var t=i();var e=n();function r(r,n){return function(i){return[e.filter(r,n)(i),e.filter(t.not(r,n))(i)]}}kv.partition=r;return kv}var xv={};var Ov;function Sv(){if(Ov)return xv;Ov=1;var t=xv&&xv.__read||function(t,e){var r=typeof Symbol==="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{while((e===void 0||e-- >0)&&!(i=n.next()).done)s.push(i.value)}catch(t){o={error:t}}finally{try{if(i&&!i.done&&(r=n["return"]))r.call(n)}finally{if(o)throw o.error}}return s};var e=xv&&xv.__spreadArray||function(t,e){for(var r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];return t};Object.defineProperty(xv,"__esModule",{value:true});xv.race=void 0;var r=o();var n=s();function i(){var i=[];for(var s=0;s<arguments.length;s++){i[s]=arguments[s]}return n.raceWith.apply(void 0,e([],t(r.argsOrArgArray(i))))}xv.race=i;return xv}var Tv;function Ev(){if(Tv)return vv;Tv=1;(function(t){Object.defineProperty(t,"__esModule",{value:true});t.mergeAll=t.merge=t.max=t.materialize=t.mapTo=t.map=t.last=t.isEmpty=t.ignoreElements=t.groupBy=t.first=t.findIndex=t.find=t.finalize=t.filter=t.expand=t.exhaustMap=t.exhaustAll=t.exhaust=t.every=t.endWith=t.elementAt=t.distinctUntilKeyChanged=t.distinctUntilChanged=t.distinct=t.dematerialize=t.delayWhen=t.delay=t.defaultIfEmpty=t.debounceTime=t.debounce=t.count=t.connect=t.concatWith=t.concatMapTo=t.concatMap=t.concatAll=t.concat=t.combineLatestWith=t.combineLatest=t.combineLatestAll=t.combineAll=t.catchError=t.bufferWhen=t.bufferToggle=t.bufferTime=t.bufferCount=t.buffer=t.auditTime=t.audit=void 0;t.timeInterval=t.throwIfEmpty=t.throttleTime=t.throttle=t.tap=t.takeWhile=t.takeUntil=t.takeLast=t.take=t.switchScan=t.switchMapTo=t.switchMap=t.switchAll=t.subscribeOn=t.startWith=t.skipWhile=t.skipUntil=t.skipLast=t.skip=t.single=t.shareReplay=t.share=t.sequenceEqual=t.scan=t.sampleTime=t.sample=t.refCount=t.retryWhen=t.retry=t.repeatWhen=t.repeat=t.reduce=t.raceWith=t.race=t.publishReplay=t.publishLast=t.publishBehavior=t.publish=t.pluck=t.partition=t.pairwise=t.onErrorResumeNext=t.observeOn=t.multicast=t.min=t.mergeWith=t.mergeScan=t.mergeMapTo=t.mergeMap=t.flatMap=void 0;t.zipWith=t.zipAll=t.zip=t.withLatestFrom=t.windowWhen=t.windowToggle=t.windowTime=t.windowCount=t.window=t.toArray=t.timestamp=t.timeoutWith=t.timeout=void 0;var e=l();Object.defineProperty(t,"audit",{enumerable:true,get:function(){return e.audit}});var r=u();Object.defineProperty(t,"auditTime",{enumerable:true,get:function(){return r.auditTime}});var i=a();Object.defineProperty(t,"buffer",{enumerable:true,get:function(){return i.buffer}});var o=f();Object.defineProperty(t,"bufferCount",{enumerable:true,get:function(){return o.bufferCount}});var ue=h();Object.defineProperty(t,"bufferTime",{enumerable:true,get:function(){return ue.bufferTime}});var ae=c();Object.defineProperty(t,"bufferToggle",{enumerable:true,get:function(){return ae.bufferToggle}});var fe=d();Object.defineProperty(t,"bufferWhen",{enumerable:true,get:function(){return fe.bufferWhen}});var he=p();Object.defineProperty(t,"catchError",{enumerable:true,get:function(){return he.catchError}});var ce=m();Object.defineProperty(t,"combineAll",{enumerable:true,get:function(){return ce.combineAll}});var de=g();Object.defineProperty(t,"combineLatestAll",{enumerable:true,get:function(){return de.combineLatestAll}});var pe=w();Object.defineProperty(t,"combineLatest",{enumerable:true,get:function(){return pe.combineLatest}});var me=b();Object.defineProperty(t,"combineLatestWith",{enumerable:true,get:function(){return me.combineLatestWith}});var ge=v();Object.defineProperty(t,"concat",{enumerable:true,get:function(){return ge.concat}});var we=k();Object.defineProperty(t,"concatAll",{enumerable:true,get:function(){return we.concatAll}});var be=y();Object.defineProperty(t,"concatMap",{enumerable:true,get:function(){return be.concatMap}});var ve=M();Object.defineProperty(t,"concatMapTo",{enumerable:true,get:function(){return ve.concatMapTo}});var ke=x();Object.defineProperty(t,"concatWith",{enumerable:true,get:function(){return ke.concatWith}});var ye=O();Object.defineProperty(t,"connect",{enumerable:true,get:function(){return ye.connect}});var Me=S();Object.defineProperty(t,"count",{enumerable:true,get:function(){return Me.count}});var xe=T();Object.defineProperty(t,"debounce",{enumerable:true,get:function(){return xe.debounce}});var Oe=E();Object.defineProperty(t,"debounceTime",{enumerable:true,get:function(){return Oe.debounceTime}});var Se=A();Object.defineProperty(t,"defaultIfEmpty",{enumerable:true,get:function(){return Se.defaultIfEmpty}});var Te=$();Object.defineProperty(t,"delay",{enumerable:true,get:function(){return Te.delay}});var Ee=R();Object.defineProperty(t,"delayWhen",{enumerable:true,get:function(){return Ee.delayWhen}});var Ae=C();Object.defineProperty(t,"dematerialize",{enumerable:true,get:function(){return Ae.dematerialize}});var $e=L();Object.defineProperty(t,"distinct",{enumerable:true,get:function(){return $e.distinct}});var Re=N();Object.defineProperty(t,"distinctUntilChanged",{enumerable:true,get:function(){return Re.distinctUntilChanged}});var Ce=j();Object.defineProperty(t,"distinctUntilKeyChanged",{enumerable:true,get:function(){return Ce.distinctUntilKeyChanged}});var Le=P();Object.defineProperty(t,"elementAt",{enumerable:true,get:function(){return Le.elementAt}});var Ne=I();Object.defineProperty(t,"endWith",{enumerable:true,get:function(){return Ne.endWith}});var je=D();Object.defineProperty(t,"every",{enumerable:true,get:function(){return je.every}});var Pe=H();Object.defineProperty(t,"exhaust",{enumerable:true,get:function(){return Pe.exhaust}});var Ie=z();Object.defineProperty(t,"exhaustAll",{enumerable:true,get:function(){return Ie.exhaustAll}});var De=_();Object.defineProperty(t,"exhaustMap",{enumerable:true,get:function(){return De.exhaustMap}});var He=B();Object.defineProperty(t,"expand",{enumerable:true,get:function(){return He.expand}});var ze=n();Object.defineProperty(t,"filter",{enumerable:true,get:function(){return ze.filter}});var _e=U();Object.defineProperty(t,"finalize",{enumerable:true,get:function(){return _e.finalize}});var Be=F();Object.defineProperty(t,"find",{enumerable:true,get:function(){return Be.find}});var Ue=q();Object.defineProperty(t,"findIndex",{enumerable:true,get:function(){return Ue.findIndex}});var Fe=K();Object.defineProperty(t,"first",{enumerable:true,get:function(){return Fe.first}});var qe=W();Object.defineProperty(t,"groupBy",{enumerable:true,get:function(){return qe.groupBy}});var Ke=J();Object.defineProperty(t,"ignoreElements",{enumerable:true,get:function(){return Ke.ignoreElements}});var We=V();Object.defineProperty(t,"isEmpty",{enumerable:true,get:function(){return We.isEmpty}});var Je=G();Object.defineProperty(t,"last",{enumerable:true,get:function(){return Je.last}});var Ve=Z();Object.defineProperty(t,"map",{enumerable:true,get:function(){return Ve.map}});var Ge=Q();Object.defineProperty(t,"mapTo",{enumerable:true,get:function(){return Ge.mapTo}});var Ze=X();Object.defineProperty(t,"materialize",{enumerable:true,get:function(){return Ze.materialize}});var Qe=Y();Object.defineProperty(t,"max",{enumerable:true,get:function(){return Qe.max}});var Xe=tt();Object.defineProperty(t,"merge",{enumerable:true,get:function(){return Xe.merge}});var Ye=et();Object.defineProperty(t,"mergeAll",{enumerable:true,get:function(){return Ye.mergeAll}});var tr=rt();Object.defineProperty(t,"flatMap",{enumerable:true,get:function(){return tr.flatMap}});var er=nt();Object.defineProperty(t,"mergeMap",{enumerable:true,get:function(){return er.mergeMap}});var rr=it();Object.defineProperty(t,"mergeMapTo",{enumerable:true,get:function(){return rr.mergeMapTo}});var nr=st();Object.defineProperty(t,"mergeScan",{enumerable:true,get:function(){return nr.mergeScan}});var ir=ot();Object.defineProperty(t,"mergeWith",{enumerable:true,get:function(){return ir.mergeWith}});var sr=lt();Object.defineProperty(t,"min",{enumerable:true,get:function(){return sr.min}});var or=ut();Object.defineProperty(t,"multicast",{enumerable:true,get:function(){return or.multicast}});var lr=at();Object.defineProperty(t,"observeOn",{enumerable:true,get:function(){return lr.observeOn}});var ur=ft();Object.defineProperty(t,"onErrorResumeNext",{enumerable:true,get:function(){return ur.onErrorResumeNext}});var ar=ht();Object.defineProperty(t,"pairwise",{enumerable:true,get:function(){return ar.pairwise}});var fr=Mv();Object.defineProperty(t,"partition",{enumerable:true,get:function(){return fr.partition}});var hr=ct();Object.defineProperty(t,"pluck",{enumerable:true,get:function(){return hr.pluck}});var cr=dt();Object.defineProperty(t,"publish",{enumerable:true,get:function(){return cr.publish}});var dr=pt();Object.defineProperty(t,"publishBehavior",{enumerable:true,get:function(){return dr.publishBehavior}});var pr=mt();Object.defineProperty(t,"publishLast",{enumerable:true,get:function(){return pr.publishLast}});var mr=gt();Object.defineProperty(t,"publishReplay",{enumerable:true,get:function(){return mr.publishReplay}});var gr=Sv();Object.defineProperty(t,"race",{enumerable:true,get:function(){return gr.race}});var wr=s();Object.defineProperty(t,"raceWith",{enumerable:true,get:function(){return wr.raceWith}});var br=wt();Object.defineProperty(t,"reduce",{enumerable:true,get:function(){return br.reduce}});var vr=bt();Object.defineProperty(t,"repeat",{enumerable:true,get:function(){return vr.repeat}});var kr=vt();Object.defineProperty(t,"repeatWhen",{enumerable:true,get:function(){return kr.repeatWhen}});var yr=kt();Object.defineProperty(t,"retry",{enumerable:true,get:function(){return yr.retry}});var Mr=yt();Object.defineProperty(t,"retryWhen",{enumerable:true,get:function(){return Mr.retryWhen}});var xr=Mt();Object.defineProperty(t,"refCount",{enumerable:true,get:function(){return xr.refCount}});var Or=xt();Object.defineProperty(t,"sample",{enumerable:true,get:function(){return Or.sample}});var Sr=Ot();Object.defineProperty(t,"sampleTime",{enumerable:true,get:function(){return Sr.sampleTime}});var Tr=St();Object.defineProperty(t,"scan",{enumerable:true,get:function(){return Tr.scan}});var Er=Tt();Object.defineProperty(t,"sequenceEqual",{enumerable:true,get:function(){return Er.sequenceEqual}});var Ar=Et();Object.defineProperty(t,"share",{enumerable:true,get:function(){return Ar.share}});var $r=At();Object.defineProperty(t,"shareReplay",{enumerable:true,get:function(){return $r.shareReplay}});var Rr=$t();Object.defineProperty(t,"single",{enumerable:true,get:function(){return Rr.single}});var Cr=Rt();Object.defineProperty(t,"skip",{enumerable:true,get:function(){return Cr.skip}});var Lr=Ct();Object.defineProperty(t,"skipLast",{enumerable:true,get:function(){return Lr.skipLast}});var Nr=Lt();Object.defineProperty(t,"skipUntil",{enumerable:true,get:function(){return Nr.skipUntil}});var jr=Nt();Object.defineProperty(t,"skipWhile",{enumerable:true,get:function(){return jr.skipWhile}});var Pr=jt();Object.defineProperty(t,"startWith",{enumerable:true,get:function(){return Pr.startWith}});var Ir=Pt();Object.defineProperty(t,"subscribeOn",{enumerable:true,get:function(){return Ir.subscribeOn}});var Dr=It();Object.defineProperty(t,"switchAll",{enumerable:true,get:function(){return Dr.switchAll}});var Hr=Dt();Object.defineProperty(t,"switchMap",{enumerable:true,get:function(){return Hr.switchMap}});var zr=Ht();Object.defineProperty(t,"switchMapTo",{enumerable:true,get:function(){return zr.switchMapTo}});var _r=zt();Object.defineProperty(t,"switchScan",{enumerable:true,get:function(){return _r.switchScan}});var Br=_t();Object.defineProperty(t,"take",{enumerable:true,get:function(){return Br.take}});var Ur=Bt();Object.defineProperty(t,"takeLast",{enumerable:true,get:function(){return Ur.takeLast}});var Fr=Ut();Object.defineProperty(t,"takeUntil",{enumerable:true,get:function(){return Fr.takeUntil}});var qr=Ft();Object.defineProperty(t,"takeWhile",{enumerable:true,get:function(){return qr.takeWhile}});var Kr=qt();Object.defineProperty(t,"tap",{enumerable:true,get:function(){return Kr.tap}});var Wr=Kt();Object.defineProperty(t,"throttle",{enumerable:true,get:function(){return Wr.throttle}});var Jr=Wt();Object.defineProperty(t,"throttleTime",{enumerable:true,get:function(){return Jr.throttleTime}});var Vr=Jt();Object.defineProperty(t,"throwIfEmpty",{enumerable:true,get:function(){return Vr.throwIfEmpty}});var Gr=Vt();Object.defineProperty(t,"timeInterval",{enumerable:true,get:function(){return Gr.timeInterval}});var Zr=Gt();Object.defineProperty(t,"timeout",{enumerable:true,get:function(){return Zr.timeout}});var Qr=Zt();Object.defineProperty(t,"timeoutWith",{enumerable:true,get:function(){return Qr.timeoutWith}});var Xr=Qt();Object.defineProperty(t,"timestamp",{enumerable:true,get:function(){return Xr.timestamp}});var Yr=Xt();Object.defineProperty(t,"toArray",{enumerable:true,get:function(){return Yr.toArray}});var tn=Yt();Object.defineProperty(t,"window",{enumerable:true,get:function(){return tn.window}});var en=te();Object.defineProperty(t,"windowCount",{enumerable:true,get:function(){return en.windowCount}});var rn=ee();Object.defineProperty(t,"windowTime",{enumerable:true,get:function(){return rn.windowTime}});var nn=re();Object.defineProperty(t,"windowToggle",{enumerable:true,get:function(){return nn.windowToggle}});var sn=ne();Object.defineProperty(t,"windowWhen",{enumerable:true,get:function(){return sn.windowWhen}});var on=ie();Object.defineProperty(t,"withLatestFrom",{enumerable:true,get:function(){return on.withLatestFrom}});var ln=se();Object.defineProperty(t,"zip",{enumerable:true,get:function(){return ln.zip}});var un=oe();Object.defineProperty(t,"zipAll",{enumerable:true,get:function(){return un.zipAll}});var an=le();Object.defineProperty(t,"zipWith",{enumerable:true,get:function(){return an.zipWith}})})(vv);return vv}var Av=Ev();class $v{constructor(t,e,r){this.modifications=new ue.Subject;this.editor=new Wc({element:t,extensions:[Zp,av.configure({link:false}),mv(r),bv(r)],content:e,contentType:"markdown",editable:false});this.editor.on("update",(()=>{this.modifications.next({content:this.editor.getMarkdown()})}))}onUpdate(t){this.editor.on("update",t)}isEditable(){return this.editor.isEditable}startEditing(){this.editor.setEditable(true,false);this.editor.commands.focus()}stopEditing(){this.editor.setEditable(false,false)}getContent(){return this.editor.getMarkdown()}observeChanges(t=1e3){return this.modifications.pipe(Av.debounceTime(t))}}const Rv=":host {\n article {\n padding: 0;\n &:focus-within {\n outline: var(--pos-input-focus-outline);\n }\n\n .tiptap {\n border: none;\n outline: none;\n }\n\n line-height: 1.5;\n pos-image {\n --max-width: 100%;\n }\n\n header {\n position: sticky;\n background-color: var(--pos-background-color);\n border-bottom: var(--size-px) solid var(--pos-border-color);\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n overflow: hidden;\n z-index: var(--layer-1);\n top: 0;\n padding: var(--size-1);\n flex-direction: row;\n justify-content: flex-end;\n button {\n background: var(--pos-primary-color);\n color: var(--pos-primary-text-color);\n outline: none;\n border: none;\n border-radius: var(--radius-xs);\n display: inline-flex;\n gap: var(--size-1);\n justify-content: center;\n align-items: center;\n height: var(--size-8);\n flex-shrink: 1;\n\n &:focus {\n outline: var(--pos-input-focus-outline);\n }\n\n &:hover {\n filter: brightness(110%);\n box-shadow: var(--shadow-md);\n }\n }\n .status {\n display: flex;\n align-content: center;\n align-items: center;\n gap: var(--size-1);\n font-size: var(--scale-00);\n\n &.pending {\n animation: pending-fade 1s ease forwards;\n }\n\n &.success {\n animation: success-flash 2s ease forwards;\n }\n\n &.error {\n animation: error-flash 2s ease infinite;\n }\n\n &.saving {\n animation: saving-flash 2s ease infinite;\n }\n }\n }\n\n .content {\n padding: var(--size-4);\n\n pre {\n code {\n display: block;\n padding: var(--size-4);\n overflow-x: auto;\n background-color: var(--color-black);\n font-family: monospace;\n color: var(--color-white);\n line-height: 1.6;\n border-radius: var(--radius-lg);\n }\n }\n\n blockquote {\n border-left: var(--size-1) solid var(--pos-primary-color);\n margin-left: var(--size-4);\n padding-left: var(--size-4);\n }\n }\n }\n}\n\n@keyframes pending-fade {\n 0% {\n opacity: 0;\n color: var(--pos-subtle-text-color);\n }\n 100% {\n opacity: 1;\n color: var(--pos-primary-color);\n }\n}\n\n@keyframes success-flash {\n 0% {\n opacity: 0;\n color: var(--pos-subtle-text-color);\n }\n 50% {\n opacity: 1;\n color: var(--color-green-500);\n }\n 100% {\n opacity: 1;\n color: var(--pos-subtle-text-color);\n }\n}\n\n@keyframes error-flash {\n 0% {\n opacity: 0;\n }\n 50% {\n opacity: 1;\n color: var(--color-red-500);\n }\n 100% {\n opacity: 0;\n }\n}\n\n@keyframes saving-flash {\n 0% {\n opacity: 0;\n }\n 50% {\n opacity: 1;\n color: var(--pos-primary-color);\n }\n 100% {\n opacity: 0;\n }\n}\n";const Cv="article {\n padding: var(--size-2);\n display: flex;\n flex-direction: column;\n gap: var(--size-2);\n outline: var(--pos-border-solid);\n border-radius: var(--radius-sm);\n box-shadow: var(--shadow-md);\n background-color: var(--pos-card-background);\n\n header {\n display: flex;\n flex-direction: column;\n gap: var(--size-2);\n h1 {\n margin: 0;\n }\n }\n}\n";const Lv=class{constructor(r){t(this,r);this.documentModified=e(this,"pod-os:document-modified");this.saveStatus="idle";this.editable=false;this.isModified=false;this.isEditing=false;this.disconnected$=new ue.Subject}async componentWillLoad(){this.markdown=await this.file.blob().text()}componentDidLoad(){this.editor=new $v(this.editorEl,this.markdown,this.file.url);this.editor.onUpdate((()=>{this.isModified=true}));this.editor.observeChanges().pipe(ue.takeUntil(this.disconnected$),ue.map((t=>t.content)),ue.tap((t=>{this.isModified=false;this.documentModified.emit({file:this.file,newContent:t})}))).subscribe()}disconnectedCallback(){this.disconnected$.next();this.disconnected$.unsubscribe()}async startEditing(){this.editor.startEditing();this.isEditing=true}async stopEditing(){this.editor.stopEditing();this.isEditing=false}render(){return r("article",{key:"a45dd6888d84875c9dea5f488f2d76688e2626fc"},this.editable?r("header",null,this.isEditing?this.getStatus():null,this.isEditing?r("button",{onClick:()=>this.stopEditing()},r("sl-icon",{name:"eye"}),"View"):r("button",{onClick:()=>this.startEditing()},r("sl-icon",{name:"pencil-square"}),"Edit")):null,r("div",{key:"60057933d8bf808e76915b88b2eecd7f70834be6",class:"content",ref:t=>this.editorEl=t}))}getStatus(){if(this.isModified){return r(Nv,{status:"pending",message:"pending changes",icon:"clock-history"})}if(this.saveStatus==="failed"){return r(Nv,{status:"error",message:"saving failed",icon:"x-octagon"})}if(this.saveStatus==="saving"){return r(Nv,{status:"saving",message:"saving changes",icon:"cloud-upload"})}return r(Nv,{status:"success",message:"all saved",icon:"check2-circle"})}};function Nv({status:t,icon:e,message:n}){return r("span",{class:{status:true,[t]:true},role:"status","aria-live":"polite","aria-labelledby":"status-message"},r("sl-icon",{name:e,"aria-hidden":"true"}),r("span",{id:"status-message"},n))}Lv.style=Rv+Cv;export{Lv as pos_markdown_document};
|
|
2
|
-
//# sourceMappingURL=p-300ef87f.entry.js.map
|